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
<?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.mapper.WorkUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkUser">
<id column="id" property="id" />
<result column="oa_user_id" property="oaUserId" />
<result column="dept_id" property="deptId" />
<result column="name" property="name" />
<result column="login_name" property="loginName" />
<result column="password" property="password" />
<result column="phone" property="phone" />
<result column="email" property="email" />
<result column="role" property="role" />
<result column="type" property="type" />
<result column="status" property="status" />
<result column="wx_id" property="wxId" />
<result column="level" property="level" />
<result column="create_time" property="createTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
<sql id="table">
work_user
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
name, oa_user_id, login_name, phone, dept_id, email, role ,type,status,wx_id,level,create_time,modify_time
</sql>
<sql id="values">
#{name},#{oaUserId},#{loginName},#{phone},#{deptId},#{email},#{role},#{type},#{status},#{wxId},#{level},now(),now()
</sql>
<sql id="updateCondition">
<if test="name != null">name = #{name},</if>
<if test="oaUserId != null">oa_user_id = #{oaUserId},</if>
<if test="loginName != null">login_name = #{loginName},</if>
<if test="password != null">password = #{password},</if>
<if test="phone != null">phone =#{phone},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="email != null">email = #{email},</if>
<if test="role != null">role = #{role},</if>
<if test="type != null">type =#{type},</if>
<if test="status != null">status = #{status},</if>
<if test="wxId != null">wx_id =#{wxId},</if>
<if test="level != null">level = #{level},</if>
modify_time =now()
</sql>
<sql id="criteria">
<if test="id != null">and id = #{id}</if>
<if test="oaUserId != null">and oa_user_id = #{oaUserId}</if>
<if test="name != null">and name = #{name}</if>
<if test="loginName != null">and login_name = #{loginName}</if>
<if test="password != null">and password = #{password}</if>
<if test="phone != null">and phone =#{phone}</if>
<if test="deptId != null">and dept_id = #{deptId}</if>
<if test="email != null">and email = #{email}</if>
<if test="role != null">and role = #{role}</if>
<if test="type != null">and type =#{type}</if>
<if test="status != null">and status = #{status}</if>
<if test="wxId != null">and wx_id =#{wxId},</if>
<if test="level != null">and level = #{level}</if>
<if test="createTime != null">and create_time >= #{createTime}</if>
<if test="modifyTime != null">and #{modifyTime} >= modify_time</if>
</sql>
<select id="getUserInfo" resultMap="BaseResultMap" parameterType="map" >
select <include refid="cols_all"/>
from <include refid="table"/>
<where>
<include refid="criteria"/>
</where>
</select>
<select id="getUserById" resultMap="BaseResultMap" parameterType="integer" >
select <include refid="cols_all"/>
from <include refid="table"/>
where id = #{userId}
</select>
<select id="getStatisticsTableDtos" resultType="cn.wisenergy.model.dto.StatisticsTableDto">
select u.id AS user_id, u.name AS user_name, d.dept_name
from work_user u join work_dept d on u.dept_id=d.id
where u.id in
<foreach collection="list" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</select>
<update id="updateUserInfo" parameterType="cn.wisenergy.model.app.WorkUser">
update <include refid="table"/>
set <include refid="updateCondition"/>
where id = #{id}
</update>
</mapper>