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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?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="cn.wisenergy.chnmuseum.party.mapper.TUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TUser">
<id column="id" property="id"/>
<result column="user_name" property="userName"/>
<result column="password_hash" property="passwordHash"/>
<result column="password_salt" property="passwordSalt"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="org_id" property="orgId"/>
<result column="permanent" property="permanent"/>
<result column="effective_date" property="effectiveDate"/>
<result column="exired_date" property="exiredDate"/>
<result column="status" property="status"/>
<result column="phone" property="phone"/>
<result column="email" property="email"/>
<result column="we_chat" property="weChat"/>
<result column="telephone" property="telephone"/>
<result column="is_deleted" property="isDeleted"/>
<result column="real_name" property="realName"/>
<result column="type" property="type"/>
<result column="audit_status" property="auditStatus"/>
<result column="area_id" property="areaId"/>
<result column="password" property="password"/>
<result column="org_name" property="orgName"/>
<result column="area_name" property="areaName"/>
<result column="org_code" property="orgCode"/>
<collection fetchType="eager" property="roleList" ofType="java.lang.String"
select="selectRoles" column="user_name">
<result column="rid"/>
</collection>
</resultMap>
<!-- <resultMap id="roleMap" type="java.lang.String">-->
<!-- <result column="id"/>-->
<!-- </resultMap>-->
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
u.id, u.user_name, u.password_hash, u.password_salt, u.create_time, u.update_time, u.org_id, u.permanent, u.effective_date, u.exired_date, u.status, u.phone, u.email, u.we_chat, u.telephone, u.is_deleted, u.real_name,u.type,u.audit_status,u.area_id
</sql>
<select id="selectByUsername" resultMap="BaseResultMap">
select u.*,o.name org_name,a.full_name area_name,o.code org_code
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where binary u.user_name =#{userName}
</select>
<select id="getById" resultMap="BaseResultMap">
select u.id, u.user_name,u.create_time, u.update_time, u.org_id, u.permanent, u.effective_date, u.exired_date, u.status, u.phone, u.email, u.we_chat, u.telephone, u.is_deleted, u.real_name,u.type,u.audit_status,u.area_id
,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where u.id =#{id}
</select>
<select id="getList" resultMap="BaseResultMap">
select u.id, u.user_name,u.create_time, u.update_time, u.org_id, u.permanent, u.effective_date, u.exired_date, u.status, u.phone, u.email, u.we_chat, u.telephone, u.is_deleted, u.real_name,u.type,u.audit_status,u.area_id
,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where 1 = 1
<if test=" user.userName != null and user.userName != '' ">
and u.user_name LIKE concat('%', #{user.userName}, '%')
</if>
<if test=" user.status != null and user.status != '' ">
and u.status = #{user.status}
</if>
<if test=" user.auditStatus != null and user.auditStatus != '' ">
and u.audit_status LIKE "TBC%"
</if>
<if test=" user.type != null and user.type != '' ">
and u.type = #{user.type}
</if>
<if test=" user.orgId != null and user.orgId != '' ">
and u.org_id = #{user.orgId}
</if>
<if test=" user.orgCode != null and user.orgCode != '' ">
and o.code LIKE concat(#{user.orgCode}, '%')
</if>
<if test=" user.areaId != null and user.areaId != '' ">
and u.area_id = #{user.areaId}
</if>
<if test=" user.areaName != null and user.areaName != '' ">
and u.area_id LIKE concat(#{user.areaName}, '%')
</if>
and u.is_deleted = false
order by u.create_time desc
</select>
<select id="getUserList" resultMap="BaseResultMap">
select u.id, u.user_name, u.create_time, u.update_time, u.org_id, u.permanent, u.effective_date, u.exired_date, u.status, u.phone, u.email, u.we_chat, u.telephone, u.is_deleted, u.real_name,u.type,u.audit_status,u.area_id
,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where 1 = 1
<if test=" user.userName != null and user.userName != '' ">
and u.user_name LIKE concat('%', #{user.userName}, '%')
</if>
<if test=" user.status != null and user.status != '' ">
and u.status = #{user.status}
</if>
<if test=" user.auditStatus != null and user.auditStatus != '' ">
and u.audit_status LIKE "TBC%"
</if>
<if test=" user.type != null and user.type != '' ">
and u.type = #{user.type}
</if>
<if test=" user.orgId != null and user.orgId != '' ">
and u.org_id = #{user.orgId}
</if>
<if test="user.orgCode != null and user.orgCode != '' ">
and o.code LIKE concat(#{user.orgCode}, '%')
</if>
<if test=" user.areaId != null and user.areaId != '' ">
and u.area_id = #{user.areaId}
</if>
and u.is_deleted = false
order by u.create_time desc
</select>
<select id="selectRoles" resultType="java.lang.String">
select r.id rid
from t_user u
left join t_organ o on o.id = u.org_id
left join t_user_role_link l on l.user_id = u.id
left join t_role r on l.role_id = r.id
where 1=1
<if test=" userName != null and userName != '' ">
and u.user_name =#{userName}
</if>
</select>
</mapper>