UserMapper.xml
6.67 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
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
145
146
147
148
149
150
151
152
153
154
155
<?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.bootdo.system.dao.UserDao">
<select id="get" resultType="com.bootdo.system.domain.UserDO">
select `user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district` from sys_user where user_id = #{value}
</select>
<select id="list" resultType="com.bootdo.system.domain.UserDO">
select `user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district` from sys_user
<where>
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
<if test="username != null and username != ''"> and username = #{username} </if>
<if test="name != null and name != ''"> and name = #{name} </if>
<if test="password != null and password != ''"> and password = #{password} </if>
<if test="deptId != null and deptId != ''"> and dept_id = #{deptId} </if>
<if test="email != null and email != ''"> and email = #{email} </if>
<if test="mobile != null and mobile != ''"> and mobile = #{mobile} </if>
<if test="status != null and status != ''"> and status = #{status} </if>
<if test="userIdCreate != null and userIdCreate != ''"> and user_id_create = #{userIdCreate} </if>
<if test="gmtCreate != null and gmtCreate != ''"> and gmt_create = #{gmtCreate} </if>
<if test="gmtModified != null and gmtModified != ''"> and gmt_modified = #{gmtModified} </if>
<if test="sex != null and sex != ''"> and sex = #{sex} </if>
<if test="birth != null and birth != ''"> and birth = #{birth} </if>
<if test="picId != null and picId != ''"> and pic_id = #{picId} </if>
<if test="liveAddress != null and liveAddress != ''"> and live_address = #{liveAddress} </if>
<if test="hobby != null and hobby != ''"> and hobby = #{hobby} </if>
<if test="province != null and province != ''"> and province = #{province} </if>
<if test="city != null and city != ''"> and city = #{city} </if>
<if test="district != null and district != ''"> and district = #{district} </if>
</where>
<choose>
<when test="sort != null and sort.trim() != ''">
order by ${sort} ${order}
</when>
<otherwise>
order by user_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="count" resultType="int">
select count(*) from sys_user
<where>
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
<if test="username != null and username != ''"> and username = #{username} </if>
<if test="name != null and name != ''"> and name = #{name} </if>
<if test="password != null and password != ''"> and password = #{password} </if>
<if test="deptId != null and deptId != ''"> and dept_id = #{deptId} </if>
<if test="email != null and email != ''"> and email = #{email} </if>
<if test="mobile != null and mobile != ''"> and mobile = #{mobile} </if>
<if test="status != null and status != ''"> and status = #{status} </if>
<if test="userIdCreate != null and userIdCreate != ''"> and user_id_create = #{userIdCreate} </if>
<if test="gmtCreate != null and gmtCreate != ''"> and gmt_create = #{gmtCreate} </if>
<if test="gmtModified != null and gmtModified != ''"> and gmt_modified = #{gmtModified} </if>
<if test="sex != null and sex != ''"> and sex = #{sex} </if>
<if test="birth != null and birth != ''"> and birth = #{birth} </if>
<if test="picId != null and picId != ''"> and pic_id = #{picId} </if>
<if test="liveAddress != null and liveAddress != ''"> and live_address = #{liveAddress} </if>
<if test="hobby != null and hobby != ''"> and hobby = #{hobby} </if>
<if test="province != null and province != ''"> and province = #{province} </if>
<if test="city != null and city != ''"> and city = #{city} </if>
<if test="district != null and district != ''"> and district = #{district} </if>
</where>
</select>
<insert id="save" parameterType="com.bootdo.system.domain.UserDO" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user
(
`username`,
`name`,
`password`,
`dept_id`,
`email`,
`mobile`,
`status`,
`user_id_create`,
`gmt_create`,
`gmt_modified`,
`sex`,
`birth`,
`pic_id`,
`live_address`,
`hobby`,
`province`,
`city`,
`district`
)
values
(
#{username},
#{name},
#{password},
#{deptId},
#{email},
#{mobile},
#{status},
#{userIdCreate},
#{gmtCreate},
#{gmtModified},
#{sex},
#{birth},
#{picId},
#{liveAddress},
#{hobby},
#{province},
#{city},
#{district}
)
</insert>
<update id="update" parameterType="com.bootdo.system.domain.UserDO">
update sys_user
<set>
<if test="username != null">`username` = #{username}, </if>
<if test="name != null">`name` = #{name}, </if>
<if test="password != null">`password` = #{password}, </if>
<if test="deptId != null">`dept_id` = #{deptId}, </if>
<if test="email != null">`email` = #{email}, </if>
<if test="mobile != null">`mobile` = #{mobile}, </if>
<if test="status != null">`status` = #{status}, </if>
<if test="userIdCreate != null">`user_id_create` = #{userIdCreate}, </if>
<if test="gmtCreate != null">`gmt_create` = #{gmtCreate}, </if>
<if test="gmtModified != null">`gmt_modified` = #{gmtModified}, </if>
<if test="sex != null">`sex` = #{sex}, </if>
<if test="birth != null">`birth` = #{birth}, </if>
<if test="picId != null">`pic_id` = #{picId}, </if>
<if test="liveAddress != null">`live_address` = #{liveAddress}, </if>
<if test="hobby != null">`hobby` = #{hobby}, </if>
<if test="province != null">`province` = #{province}, </if>
<if test="city != null">`city` = #{city}, </if>
<if test="district != null">`district` = #{district}</if>
</set>
where user_id = #{userId}
</update>
<delete id="remove">
delete from sys_user where user_id = #{value}
</delete>
<delete id="batchRemove">
delete from sys_user where user_id in
<foreach item="userId" collection="array" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<select id="listAllDept" resultType="long">
select DISTINCT dept_id from sys_user
</select>
</mapper>