2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-26 d57d96ce51231734aa0b4979abeea17271660c1e
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?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.sandu.ximon.dao.mapper.LightMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Light">
        <id property="lightId" column="light_id" jdbcType="BIGINT"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
        <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
        <result property="power1" column="power1" jdbcType="INTEGER"/>
        <result property="power2" column="power2" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <resultMap id="listLight" type="com.sandu.ximon.dao.bo.LightBo" extends="BaseResultMap">
        <result property="poleId" column="pole_id" jdbcType="BIGINT"/>
        <result property="poleCode" column="pole_code" jdbcType="VARCHAR"/>
        <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
        <result property="taskName" column="task_name" jdbcType="VARCHAR"/>
    </resultMap>
 
 
    <select id="listLight" resultMap="listLight">
        SELECT
        t1.*,
        t2.id AS pole_id,
        t2.pole_code,
        t2.pole_name,
        t4.task_name
        FROM
        light t1
        LEFT JOIN pole t2 USING ( device_code )
        LEFT JOIN light_task_pole_relation t3 ON t3.pole_id = t2.id
        LEFT JOIN light_task t4 ON t3.task_id = t4.task_id
        <where>
            <if test="clientId != null">
                AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
            </if>
            <if test="keyword != null and keyword != ''">
                AND (
                t1.device_code LIKE CONCAT('%', #{keyword},'%')
                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
                )
            </if>
        </where>
    </select>
    <select id="listCode" resultType="java.lang.String">
        SELECT
        t1.device_code
        FROM
        light t1
        LEFT JOIN pole t2 ON t1.device_code = t2.device_code
        <where>
            <if test="userId != null">
                AND (t2.user_id = #{userId} OR t2.client_id = #{userId})
            </if>
            <if test="keyword != null and keyword != ''">
                AND (
                t1.device_code LIKE CONCAT('%', #{keyword},'%')
                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
                )
            </if>
            <if test="deviceCode != null and deviceCode!= ''">
                AND t2.device_code = #{deviceCode}
            </if>
        </where>
    </select>
</mapper>