|
@@ -216,6 +216,215 @@
|
|
|
) AS subquery;
|
|
|
</select>
|
|
|
|
|
|
+ <select id="selectPageForDept" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
|
|
+ SELECT
|
|
|
+ a.*,
|
|
|
+ COALESCE(
|
|
|
+ (SELECT MIN(ua.is_graduate) FROM system_user_achievement ua WHERE ua.user_id = a.id),
|
|
|
+ 1
|
|
|
+ ) AS is_graduate,
|
|
|
+ CASE
|
|
|
+ WHEN a.photo_url IS NOT NULL AND TRIM(a.photo_url) != '' THEN 1
|
|
|
+ ELSE 0
|
|
|
+ END AS photoIsExist,
|
|
|
+
|
|
|
+ COALESCE(system_dept.name, "测绘学院") AS deptName,
|
|
|
+ supervisor_user.nickname as supervisor,
|
|
|
+ supervisor_user.mobile as supervisorMobile
|
|
|
+ FROM
|
|
|
+ system_users a
|
|
|
+ LEFT JOIN
|
|
|
+ system_user_achievement ua ON ua.user_id = a.id
|
|
|
+ LEFT JOIN
|
|
|
+ system_users supervisor_user
|
|
|
+ ON supervisor_user.id = a.supervisor_id
|
|
|
+ AND supervisor_user.deleted = 0
|
|
|
+ LEFT JOIN
|
|
|
+ system_dept system_dept ON system_dept.id = a.dept_id
|
|
|
+ WHERE
|
|
|
+ 1=1
|
|
|
+ <if test="reqVO.username != null and reqVO.username != ''">
|
|
|
+ AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.email != null and reqVO.email != ''">
|
|
|
+ AND a.email LIKE CONCAT('%', #{reqVO.email}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.mobile != null and reqVO.mobile != ''">
|
|
|
+ AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.userNumber != null and reqVO.userNumber != ''">
|
|
|
+ AND a.user_number LIKE CONCAT('%', #{reqVO.userNumber}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.nickname != null and reqVO.nickname != ''">
|
|
|
+ AND a.nickname LIKE CONCAT('%', #{reqVO.nickname}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.userType != null">
|
|
|
+ AND a.user_type = #{reqVO.userType}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <bind name="gradePrefix" value="reqVO.grade != null and reqVO.grade.length() >= 4 ? reqVO.grade.substring(0, 4) : ''"/>
|
|
|
+ <if test="gradePrefix != ''">
|
|
|
+ AND a.grade LIKE CONCAT('%', #{gradePrefix}, '%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.supervisorId != null">
|
|
|
+ AND a.supervisor_id = #{reqVO.supervisorId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.major != null">
|
|
|
+ AND a.major = #{reqVO.major}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.masterType != null">
|
|
|
+ AND a.masterType = #{reqVO.masterType}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.status != null">
|
|
|
+ AND a.status = #{reqVO.status}
|
|
|
+ </if>
|
|
|
+ <if test="deptIds != null and !deptIds.isEmpty()">
|
|
|
+ AND a.dept_id IN
|
|
|
+ <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
|
|
+ #{deptId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="type == 0">
|
|
|
+ AND a.user_type = 1
|
|
|
+ </when>
|
|
|
+ <when test="type == 1">
|
|
|
+ AND a.user_type = 1
|
|
|
+ AND (
|
|
|
+ ( a.dept_id != 0
|
|
|
+ AND a.dept_id = #{deptId}
|
|
|
+ AND a.dept_id IS NOT NULL
|
|
|
+ AND a.dept_id != ''
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test="reqVO.isGraduate != null">
|
|
|
+ <if test="reqVO.isGraduate == 1">
|
|
|
+ AND a.id NOT IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = 0)
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.isGraduate == 0">
|
|
|
+ AND a.id IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = #{reqVO.isGraduate})
|
|
|
+ AND ua.is_graduate = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.photoIsExist != null">
|
|
|
+ <if test="reqVO.photoIsExist == 0">
|
|
|
+ AND a.photo_url IS NULL
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.photoIsExist == 1">
|
|
|
+ AND a.photo_url IS NOT NULL AND a.photo_url != ''
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ AND a.deleted = 0
|
|
|
+ GROUP BY
|
|
|
+ a.id
|
|
|
+ ORDER BY
|
|
|
+ a.id DESC
|
|
|
+ <if test="offset != -1">
|
|
|
+ LIMIT #{offset}, #{reqVO.pageSize}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectPageDeptCount" resultType="Long">
|
|
|
+ SELECT COUNT(*) AS total_count
|
|
|
+ FROM (
|
|
|
+ SELECT a.id
|
|
|
+ FROM system_users a
|
|
|
+ LEFT JOIN system_user_achievement ua ON ua.user_id = a.id
|
|
|
+ WHERE 1=1
|
|
|
+ <if test="reqVO.username != null and reqVO.username != ''">
|
|
|
+ AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.email != null and reqVO.email != ''">
|
|
|
+ AND a.email LIKE CONCAT('%', #{reqVO.email}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.mobile != null and reqVO.mobile != ''">
|
|
|
+ AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
|
|
|
+ AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
|
|
|
+ AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.userNumber != null and reqVO.userNumber != ''">
|
|
|
+ AND a.user_number LIKE CONCAT('%', #{reqVO.userNumber}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.nickname != null and reqVO.nickname != ''">
|
|
|
+ AND a.nickname LIKE CONCAT('%', #{reqVO.nickname}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.userType != null">
|
|
|
+ AND a.user_type = #{reqVO.userType}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <bind name="gradePrefix" value="reqVO.grade != null and reqVO.grade.length() >= 4 ? reqVO.grade.substring(0, 4) : ''"/>
|
|
|
+ <if test="gradePrefix != ''">
|
|
|
+ AND a.grade LIKE CONCAT('%', #{gradePrefix}, '%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.supervisorId != null">
|
|
|
+ AND a.supervisor_id = #{reqVO.supervisorId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.major != null">
|
|
|
+ AND a.major = #{reqVO.major}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.masterType != null">
|
|
|
+ AND a.masterType = #{reqVO.masterType}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="reqVO.status != null">
|
|
|
+ AND a.status = #{reqVO.status}
|
|
|
+ </if>
|
|
|
+ <if test="deptIds != null and !deptIds.isEmpty()">
|
|
|
+ AND a.dept_id IN
|
|
|
+ <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
|
|
+ #{deptId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="type == 0">
|
|
|
+ AND a.user_type = 1
|
|
|
+ </when>
|
|
|
+ <when test="type == 1">
|
|
|
+ AND a.user_type = 1
|
|
|
+ AND (
|
|
|
+ ( a.dept_id != 0
|
|
|
+ AND a.dept_id = #{deptId}
|
|
|
+ AND a.dept_id IS NOT NULL
|
|
|
+ AND a.dept_id != ''
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test="reqVO.isGraduate != null">
|
|
|
+ <if test="reqVO.isGraduate == 1">
|
|
|
+ AND a.id NOT IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = 0)
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.isGraduate == 0">
|
|
|
+ AND a.id IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = #{reqVO.isGraduate})
|
|
|
+ AND ua.is_graduate = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.photoIsExist != null">
|
|
|
+ <if test="reqVO.photoIsExist == 0">
|
|
|
+ AND a.photo_url IS NULL
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.photoIsExist == 1">
|
|
|
+ AND a.photo_url IS NOT NULL AND a.photo_url != ''
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ AND a.deleted = 0
|
|
|
+ GROUP BY a.id
|
|
|
+ ) AS subquery;
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<select id="selectList1" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
|
|
SELECT
|
|
|
a.*,
|