ZQN
2024-06-27 ea5615a5081d675700544e3c834939c18dae543e
project-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -64,17 +64,20 @@
          left join sys_role r on r.role_id = ur.role_id
    </sql>
    <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
   <select id="selectUserListCommon" parameterType="SysUser" resultMap="SysUserResult">
      select u.user_id, u.dept_id, u.nick_name, u.user_name,u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
             u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,d.dept_name, d.leader
      u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,d.dept_name, d.leader
      from sys_user u
      left join sys_dept d on u.dept_id = d.dept_id
      where u.del_flag = '0'
      where u.del_flag = '0' and u.user_name!='admin' and u.user_type!='02'
      <if test="userId != null and userId != 0">
         AND u.user_id = #{userId}
      </if>
      <if test="userName != null and userName != ''">
         AND u.user_name like concat('%', #{userName}, '%')
      </if>
      <if test="nickName != null and nickName != ''">
         AND u.nick_name like concat('%', #{nickName}, '%')
      </if>
      <if test="status != null and status != ''">
         AND u.status = #{status}
@@ -92,7 +95,43 @@
         AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
      </if>
      <!-- 数据范围过滤 -->
      <if test="params != null and params.dataScope != null">
      <if test="params != null and params.dataScope != null and params.dataScope != ''">
         AND ${params.dataScope}
      </if>
   </select>
    <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
      select u.user_id, u.dept_id, u.nick_name, u.user_name,u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
             u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,d.dept_name, d.leader
      from sys_user u
      left join sys_dept d on u.dept_id = d.dept_id
      where u.del_flag = '0' and u.user_name!='admin'
      <if test="userId != null and userId != 0">
         AND u.user_id = #{userId}
      </if>
      <if test="userName != null and userName != ''">
         AND u.user_name like concat('%', #{userName}, '%')
      </if>
      <if test="nickName != null and nickName != ''">
         AND u.nick_name like concat('%', #{nickName}, '%')
      </if>
      <if test="status != null and status != ''">
         AND u.status = #{status}
      </if>
      <if test="phonenumber != null and phonenumber != ''">
         AND u.phonenumber like concat('%', #{phonenumber}, '%')
      </if>
      <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
         AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
      </if>
      <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
         AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
      </if>
      <if test="deptId != null and deptId != 0">
         AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
      </if>
      <!-- 数据范围过滤 -->
      <if test="params != null and params.dataScope != null and params.dataScope != ''">
         AND ${params.dataScope}
      </if>
   </select>
@@ -111,7 +150,7 @@
         AND u.phonenumber like concat('%', #{phonenumber}, '%')
      </if>
      <!-- 数据范围过滤 -->
      <if test="params != null and params.dataScope != null">
      <if test="params != null and params.dataScope != null and params.dataScope != ''">
         AND ${params.dataScope}
      </if>
   </select>
@@ -131,7 +170,7 @@
         AND u.phonenumber like concat('%', #{phonenumber}, '%')
      </if>
      <!-- 数据范围过滤 -->
      <if test="params != null and params.dataScope != null">
      <if test="params != null and params.dataScope != null and params.dataScope != ''">
         AND ${params.dataScope}
      </if>
   </select>
@@ -229,6 +268,10 @@
       update sys_user set password = #{password}, recommend_user = #{recommendUser} where user_name = #{userName}
   </update>
   <update id="resetPhone" parameterType="SysUser">
      update sys_user set phonenumber = #{phone}, user_name = #{phone} where user_id = #{userId}
   </update>
   <delete id="deleteUserById" parameterType="Long">
       update sys_user set del_flag = '1' where user_id = #{userId}
    </delete>
@@ -245,11 +288,13 @@
      select u.phonenumber
         from sys_user u
         join sys_user_role ur on u.user_id = ur.user_id
         join sys_role r on r.role_id=ur.role_id
         join sys_role r on r.role_id = ur.role_id
         join sys_user_dept ud on u.user_id = ud.user_id
      where
        u.user_type != '02'
        and u.status='0'
        and r.role_key = #{roleKey}
        and u.dept_id = #{deptId}
        and ud.dept_id = #{deptId}
   </select>
</mapper>