puzhibing
2023-08-16 d5b3e5a413bcfccba294793ee093722f31b2448a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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>