UserRoleMapper.xml
4.02 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
<?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.meishu.mapper.UserRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.meishu.model.UserRoleDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="user_id" property="userId" />
<result column="user_name" property="userName" />
<result column="gender" property="gender" />
<result column="birthday" property="birthday" />
<result column="email" property="email" />
<result column="img_url" property="imgUrl" />
<result column="user_status" property="userStatus" />
<result column="register_method" property="registerMethod" />
<result column="role_type" property="roleType" />
<result column="session" property="session" />
<result column="classes_id" property="classesId" />
<result column="phone" property="phone" />
<result column="password" property="password" />
<result column="id_card" property="idCard" />
<result column="open_id" property="openId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
create_date,
update_date,
id, user_id, user_name, gender, birthday, email, img_url, user_status, register_method, role_type, session, classes_id, phone, password, id_card, open_id
</sql>
<select id="queryStudents" resultType="com.meishu.vo.userrole.QueryStudentsVO">
SELECT
t.id,
t.user_name,
t.study_code,
t.phone,
t.id_card,
t3.grade,
t.`session`,
t.gender,
t.email,
t3.class_name,
t.user_status
FROM
user_role t
LEFT JOIN classes_user_mapping t2 ON t.id = t2.user_id
LEFT JOIN classes_dict t3 ON t2.classes_id = t3.id
WHERE
1=1 and t.delete_date is null and t2.delete_date is null
<if test="userName != null and userName !=''">
and t.user_name like concat('%',#{userName} ,'%')
</if>
<if test="grade != null and userName !=''">
and t3.grade = #{grade}
</if>
<if test="session != null and session != ''">
and t.session = #{session}
</if>
<if test="userStatus != null and userStatus !=''">
and t.user_status = #{userStatus}
</if>
</select>
<select id="exportStudents" resultType="com.meishu.vo.userrole.QueryStudentsVO">
SELECT
t.user_name,
t.study_code,
t.phone,
t.id_card,
t3.grade,
t.`session`,
t.gender,
t.email,
t3.class_name,
t.user_status
FROM
user_role t
LEFT JOIN classes_user_mapping t2 ON t.id = t2.user_id
LEFT JOIN classes_dict t3 ON t2.classes_id = t3.id
WHERE
t2.`status` = 1
<if test="userName != null and userName !=''">
and t.user_name like concat('%',#{userName} ,'%')
</if>
<if test="grade != null and userName !=''">
and t3.grade = #{grade}
</if>
<if test="session != null and session != ''">
and t.session = #{session}
</if>
<if test="userStatus != null and userStatus !=''">
and t.user_status = #{userStatus}
</if>
</select>
<select id="findOpenIdByClassId" parameterType="integer" resultType="com.meishu.model.UserRoleDO">
SELECT
t2.user_name,
t2.open_id
FROM
classes_user_mapping t
LEFT JOIN user_role t2 ON t.user_id = t2.id
WHERE
t.classes_id = #{id}
and open_id is not NULL
</select>
</mapper>