|
@@ -2,6 +2,162 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper">
|
|
|
<select id="selectPage1" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
|
|
+ SELECT
|
|
|
+ a.*,
|
|
|
+ COALESCE(ua.is_graduate, 1) AS is_graduate,
|
|
|
+ CASE
|
|
|
+ WHEN a.photo_url IS NOT NULL 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 -- 自连接获取 supervisor 的信息
|
|
|
+ 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>
|
|
|
+ <if test="reqVO.grade != null and reqVO.grade != ''">
|
|
|
+ AND a.grade LIKE CONCAT('%', #{reqVO.grade}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.supervisorId != null">
|
|
|
+ AND a.supervisor_id = #{reqVO.supervisorId}
|
|
|
+ </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>
|
|
|
+ <if test="roleIds != null and roleIds.contains(113L)">
|
|
|
+ AND a.supervisor_id = #{loginId}
|
|
|
+ AND a.user_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="roleIds != null and roleIds.contains(114L)">
|
|
|
+ AND a.user_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="roleIds != null and roleIds.contains(1L)">
|
|
|
+ AND a.dept_id IN (1, 2)
|
|
|
+ </if>
|
|
|
+ <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>
|
|
|
+ GROUP BY
|
|
|
+ a.id
|
|
|
+ ORDER BY
|
|
|
+ a.id DESC
|
|
|
+ LIMIT #{offset}, #{reqVO.pageSize}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectPage1Count" 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}, '%')
|
|
|
+ </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>
|
|
|
+ <if test="reqVO.grade != null and reqVO.grade != ''">
|
|
|
+ AND a.grade LIKE CONCAT('%', #{reqVO.grade}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.supervisorId != null">
|
|
|
+ AND a.supervisor_id = #{reqVO.supervisorId}
|
|
|
+ </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>
|
|
|
+ <if test="roleIds != null and roleIds.contains(113L)">
|
|
|
+ AND a.supervisor_id = #{loginId}
|
|
|
+ AND a.user_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="roleIds != null and roleIds.contains(114L)">
|
|
|
+ AND a.user_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="roleIds != null and roleIds.contains(1L)">
|
|
|
+ AND a.dept_id IN (1, 2)
|
|
|
+ </if>
|
|
|
+ <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>
|
|
|
+ GROUP BY a.id
|
|
|
+ ) AS subquery;
|
|
|
</select>
|
|
|
</mapper>
|