<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.stylefeng.guns.modular.system.dao.DriverOnlineMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.DriverOnline">
|
<id column="id" property="id" />
|
<result column="driverId" property="driverId" />
|
<result column="device" property="device" />
|
<result column="version" property="version"/>
|
<result column="insertTime" property="insertTime" />
|
<result column="lastTime" property="lastTime"/>
|
</resultMap>
|
|
|
|
<select id="queryOnlineDriver" resultType="map">
|
select
|
b.id as id,
|
b.headImgUrl as headImgUrl,
|
b.`name` as `name`,
|
b.phone as phone,
|
if(a.device = 1, '手机端', '车载端') as device,
|
a.version as version,
|
DATE_FORMAT(a.lastTime, '%Y-%m-%d %H:%i:%s') as insertTime
|
from t_driver_online a
|
left join t_driver b on (a.driverId = b.id)
|
where UNIX_TIMESTAMP(a.lastTime) > (UNIX_TIMESTAMP(now()) - 30)
|
<if test="null != name and '' != name">
|
and b.`name` like CONCAT('%', #{name}, '%')
|
</if>
|
<if test="null != phone and '' != phone">
|
and b.phone like CONCAT('%', #{phone}, '%')
|
</if>
|
order by a.insertTime desc
|
<if test="null != offset and null != limit">
|
limit #{offset}, #{limit}
|
</if>
|
</select>
|
|
|
<select id="queryOnlineDriverCount" resultType="int">
|
select
|
COUNT(a.id)
|
from t_driver_online a
|
left join t_driver b on (a.driverId = b.id)
|
where UNIX_TIMESTAMP(a.lastTime) > (UNIX_TIMESTAMP(now()) - 30)
|
<if test="null != name and '' != name">
|
and b.`name` like CONCAT('%', #{name}, '%')
|
</if>
|
<if test="null != phone and '' != phone">
|
and b.phone like CONCAT('%', #{phone}, '%')
|
</if>
|
</select>
|
</mapper>
|