UsrUserMapper.xml
3.35 KB
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
73
74
75
76
<?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">
<!-- REQ-USR-003 T3:查询用户跨表分页 SQL(LEFT JOIN + 动态单条件)。
map-underscore-to-camel-case=false,故用显式 resultMap 映射列别名到 UserVO 字段;
不 SELECT u.sPassword 与租户列;值用 #{} 预编译占位,列 token 由 Service 白名单产出。 -->
<mapper namespace="com.xly.erp.modules.usr.mapper.UsrUserMapper">
<resultMap id="userVOMap" type="com.xly.erp.modules.usr.vo.UserVO">
<id property="id" column="id"/>
<result property="sUserName" column="sUserName"/>
<result property="employeeName" column="employeeName"/>
<result property="sUserNo" column="sUserNo"/>
<result property="department" column="department"/>
<result property="sUserType" column="sUserType"/>
<result property="sLanguage" column="sLanguage"/>
<result property="iIsVoid" column="iIsVoid"/>
<result property="tLastLoginDate" column="tLastLoginDate"/>
<result property="sCreator" column="sCreator"/>
<result property="tCreateDate" column="tCreateDate"/>
</resultMap>
<select id="selectUserPage" resultMap="userVOMap">
SELECT
u.iIncrement AS id,
u.sUserName AS sUserName,
e.sEmployeeName AS employeeName,
u.sUserNo AS sUserNo,
e.sDepartment AS department,
u.sUserType AS sUserType,
u.sLanguage AS sLanguage,
u.iIsVoid AS iIsVoid,
u.tLastLoginDate AS tLastLoginDate,
u.sCreator AS sCreator,
u.tCreateDate AS tCreateDate
FROM usr_user u
LEFT JOIN usr_employee e ON u.iEmployeeId = e.iIncrement
<where>
<if test="cond != null and cond.text">
<choose>
<when test="cond.textEquals">
${cond.column} = #{cond.textValue}
</when>
<when test="cond.textNotContains">
${cond.column} NOT LIKE CONCAT('%', #{cond.textValue}, '%') ESCAPE '\\'
</when>
<otherwise>
${cond.column} LIKE CONCAT('%', #{cond.textValue}, '%') ESCAPE '\\'
</otherwise>
</choose>
</if>
<if test="cond != null and cond.bool">
<choose>
<when test="cond.boolNegated">
${cond.column} <> #{cond.boolValue}
</when>
<otherwise>
${cond.column} = #{cond.boolValue}
</otherwise>
</choose>
</if>
<if test="cond != null and cond.date">
<choose>
<when test="cond.dateNegated">
(${cond.column} < #{cond.dateStart} OR ${cond.column} >= #{cond.dateEnd})
</when>
<otherwise>
${cond.column} >= #{cond.dateStart} AND ${cond.column} < #{cond.dateEnd}
</otherwise>
</choose>
</if>
</where>
ORDER BY u.iIncrement
</select>
</mapper>