zhanghua
2023-09-08 7ef4892f9f24f941aca37e6b3991b808a0aca619
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
<?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.ycl.mapper.equipment.HandheldTerminalMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.equipment.HandheldTerminal">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="user" property="user" jdbcType="VARCHAR"/>
        <result column="phone" property="phone" jdbcType="VARCHAR"/>
        <result column="depart_id" property="departId" jdbcType="INTEGER"/>
        <result column="state" property="state" jdbcType="INTEGER"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        ,name,code,user,phone,depart_id,state,create_time
    </sql>
 
    <resultMap id="VoMap" type="com.ycl.vo.equipment.HandheldTerminalVo">
        <result column="depart_name" property="departName" jdbcType="VARCHAR"/>
        <result column="p_depart_name" property="pDepartName" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="search" resultMap="VoMap">
        SELECT ht.*,IF(p.depart_name is null ,'',d.depart_name) depart_name,IFNULL(p.depart_name,d.depart_name)
        p_depart_name
        FROM ums_equipment_handheld_terminal ht
        LEFT JOIN ums_depart d on ht.depart_id = d.id
        LEFT JOIN ums_depart p on d.parent_id = p.id
        <where>
            <if test="state!=null">
                ht.state = #{state}
            </if>
        </where>
        order by ht.id desc
    </select>
 
</mapper>