This commit is contained in:
2023-05-18 17:29:02 +08:00
parent 9be00db5e4
commit e41797c750
28 changed files with 413 additions and 105 deletions

View File

@ -24,7 +24,7 @@
</select>
<select id="existUsed" resultType="string">
SELECT nickname from sys_user where dept_id = #{deptId} and is_delete = '0' limit 1
SELECT nickname from sys_user where dept_id = #{deptId} limit 1
</select>
</mapper>

View File

@ -23,11 +23,11 @@
<result property="nickname" column="nickname"/>
<result property="email" column="email"/>
<result property="phone" column="phone"/>
<result property="sex" column="sex"/>
<result property="gender" column="gender"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
<collection property="posts" javaType="java.util.List" resultMap="PostResult"/>
<collection property="roles" ofType="string" resultMap="RoleResult"/>
<collection property="posts" ofType="string" resultMap="PostResult"/>
</resultMap>
<resultMap id="RoleResult" type="string">
@ -43,28 +43,29 @@
FROM sys_user u
left join sys_dept t2
on u.dept_id = t2.dept_id
where u.is_delete = #{param.isDelete}
<if test="param.username != null and param.username != ''">
AND u.username like concat('%', #{param.username}, '%')
</if>
<if test="param.nickname != null and param.nickname != ''">
AND u.nickname like concat('%', #{param.nickname}, '%')
</if>
<if test="param.status != null and param.status != ''">
AND u.status = #{param.status}
</if>
<if test="param.deptId != null and param.deptId != ''">
AND u.dept_id = #{param.deptId}
</if>
<if test="param.phone != null and param.phone != ''">
AND u.phone like concat('%', #{param.phone}, '%')
</if>
<if test="param.beginTime != null and param.beginTime != ''">
AND u.create_time &gt;= #{param.beginTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND u.create_time &lt;= #{param.endTime}
</if>
<where>
<if test="param.username != null and param.username != ''">
AND u.username like concat('%', #{param.username}, '%')
</if>
<if test="param.nickname != null and param.nickname != ''">
AND u.nickname like concat('%', #{param.nickname}, '%')
</if>
<if test="param.status != null and param.status != ''">
AND u.status = #{param.status}
</if>
<if test="param.deptId != null and param.deptId != ''">
AND u.dept_id = #{param.deptId}
</if>
<if test="param.phone != null and param.phone != ''">
AND u.phone like concat('%', #{param.phone}, '%')
</if>
<if test="param.beginTime != null and param.beginTime != ''">
AND u.create_time &gt;= #{param.beginTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND u.create_time &lt;= #{param.endTime}
</if>
</where>
</sql>
<select id="selectVoPageList" resultMap="SysUserVoResult">
@ -79,28 +80,29 @@
left join sys_role t4 on t4.role_id = t3.role_id
left join sys_user_post t5 on t5.user_id = t1.user_id
left join sys_post t6 on t6.post_id = t5.post_id
where t1.is_delete = #{param.isDelete}
<if test="param.username != null and param.username != ''">
AND t1.username like concat('%', #{param.username}, '%')
</if>
<if test="param.nickname != null and param.nickname != ''">
AND t1.nickname like concat('%', #{param.nickname}, '%')
</if>
<if test="param.status != null and param.status != ''">
AND t1.status = #{param.status}
</if>
<if test="param.deptId != null and param.deptId != ''">
AND t1.dept_id = #{param.deptId}
</if>
<if test="param.phone != null and param.phone != ''">
AND t1.phone like concat('%', #{param.phone}, '%')
</if>
<if test="param.beginTime != null and param.beginTime != ''">
AND t1.create_time &gt;= #{param.beginTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND t1.create_time &lt;= #{param.endTime}
</if>
<where>
<if test="param.username != null and param.username != ''">
AND t1.username like concat('%', #{param.username}, '%')
</if>
<if test="param.nickname != null and param.nickname != ''">
AND t1.nickname like concat('%', #{param.nickname}, '%')
</if>
<if test="param.status != null and param.status != ''">
AND t1.status = #{param.status}
</if>
<if test="param.deptId != null and param.deptId != ''">
AND t1.dept_id = #{param.deptId}
</if>
<if test="param.phone != null and param.phone != ''">
AND t1.phone like concat('%', #{param.phone}, '%')
</if>
<if test="param.beginTime != null and param.beginTime != ''">
AND t1.create_time &gt;= #{param.beginTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND t1.create_time &lt;= #{param.endTime}
</if>
</where>
</select>
<select id="selectAllocatedList" resultMap="SysUserVoResult">
@ -112,7 +114,7 @@
on t1.user_id = t3.user_id
left join sys_role t4
on t4.role_id = t3.role_id
where t1.is_delete = #{param.isDelete} and t4.role_id = #{param.roleId}
where t4.role_id = #{param.roleId}
<if test="param.username != null and param.username != ''">
AND t1.username like concat('%', #{param.username}, '%')
</if>
@ -127,7 +129,7 @@
left join sys_dept t2 on t1.dept_id = t2.dept_id
left join sys_user_role t3 on t1.user_id = t3.user_id
left join sys_role t4 on t4.role_id = t3.role_id
where t1.is_delete = #{param.isDelete} and (t4.role_id != #{param.roleId} or t4.role_id IS NULL)
where (t4.role_id != #{param.roleId} or t4.role_id IS NULL)
and t1.user_id not in (select t1.user_id from sys_user t1 inner join sys_user_role t3 on t1.user_id = t3.user_id and
t3.role_id = #{param.roleId})
<if test="param.username != null and param.username != ''">
@ -142,27 +144,21 @@
<include refid="selectUserVo"/>
</select>
<select id="checkUsernameUnique" resultType="int">
select count(*) from sys_user where username = #{username} and is_delete = #{isDelete}
select count(*) from sys_user where username = #{username}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
<select id="checkPhoneUnique" resultType="int">
select count(*) from sys_user where phone = #{phone} and is_delete = #{isDelete}
select count(*) from sys_user where phone = #{phone}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
<select id="checkEmailUnique" resultType="int">
select count(*) from sys_user where email = #{email} and is_delete = #{isDelete}
select count(*) from sys_user where email = #{email}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
<update id="updateUserDeleteStatus">
update sys_user set is_delete = #{status} where user_id in
<foreach collection="list" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
</mapper>

View File

@ -19,4 +19,10 @@
</foreach>
</select>
<delete id="deleteByUserIds">
delete from sys_user_post where user_id in
<foreach collection="list" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>

View File

@ -19,4 +19,11 @@
#{userId}
</foreach>
</delete>
<delete id="deleteByUserIds">
delete from sys_user_role where user_id in
<foreach collection="list" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>