dept/role/user的where中补充del_flag='0'条件,防止查询或更新时数据问题。
This commit is contained in:
parent
7414bc492e
commit
32199c42f2
@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
from sys_dept d
|
from sys_dept d
|
||||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||||
where rd.role_id = #{roleId}
|
where rd.role_id = #{roleId}
|
||||||
|
and d.del_flag = '0'
|
||||||
<if test="deptCheckStrictly">
|
<if test="deptCheckStrictly">
|
||||||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
||||||
</if>
|
</if>
|
||||||
@ -60,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
||||||
<include refid="selectDeptVo"/>
|
<include refid="selectDeptVo"/>
|
||||||
where dept_id = #{deptId}
|
where d.dept_id = #{deptId} and d.del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
||||||
@ -73,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
|
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
|
||||||
select * from sys_dept where find_in_set(#{deptId}, ancestors)
|
select * from sys_dept where find_in_set(#{deptId}, ancestors) and del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
||||||
@ -82,10 +83,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
||||||
<include refid="selectDeptVo"/>
|
<include refid="selectDeptVo"/>
|
||||||
where dept_name=#{deptName} and parent_id = #{parentId} limit 1
|
where d.dept_name=#{deptName} and d.parent_id = #{parentId} and d.del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertDept" parameterType="SysDept">
|
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
||||||
insert into sys_dept(
|
insert into sys_dept(
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||||
@ -127,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where dept_id = #{deptId}
|
where dept_id = #{deptId} and del_flag = '0'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||||
@ -141,6 +142,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
separator="," open="(" close=")">
|
separator="," open="(" close=")">
|
||||||
#{item.deptId}
|
#{item.deptId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
and del_flag = '0'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||||
@ -148,10 +150,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||||
#{deptId}
|
#{deptId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
and del_flag = '0'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteDeptById" parameterType="Long">
|
<delete id="deleteDeptById" parameterType="Long">
|
||||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
update sys_dept set del_flag = '2' where dept_id = #{deptId} and del_flag = '0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -70,12 +70,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
from sys_role r
|
from sys_role r
|
||||||
left join sys_user_role ur on ur.role_id = r.role_id
|
left join sys_user_role ur on ur.role_id = r.role_id
|
||||||
left join sys_user u on u.user_id = ur.user_id
|
left join sys_user u on u.user_id = ur.user_id
|
||||||
where u.user_id = #{userId}
|
where u.user_id = #{userId} and r.del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
|
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
where r.role_id = #{roleId}
|
where r.role_id = #{roleId} and r.del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
|
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
|
||||||
@ -85,12 +85,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
|
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
where r.role_name=#{roleName} limit 1
|
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
|
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
where r.role_key=#{roleKey} limit 1
|
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||||
@ -135,18 +135,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where role_id = #{roleId}
|
where role_id = #{roleId} and del_flag = '0'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteRoleById" parameterType="Long">
|
<delete id="deleteRoleById" parameterType="Long">
|
||||||
update sys_role set del_flag = '2' where role_id = #{roleId}
|
update sys_role set del_flag = '2' where role_id = #{roleId} and del_flag = '0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteRoleByIds" parameterType="Long">
|
<delete id="deleteRoleByIds" parameterType="Long">
|
||||||
update sys_role set del_flag = '2' where role_id in
|
update sys_role set del_flag = '2' where role_id in
|
||||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||||
#{roleId}
|
#{roleId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
and del_flag = '0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -122,24 +122,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||||
<include refid="selectUserVo"/>
|
<include refid="selectUserVo"/>
|
||||||
where u.user_name = #{userName}
|
where u.user_name = #{userName} and u.del_flag ='0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
<include refid="selectUserVo"/>
|
<include refid="selectUserVo"/>
|
||||||
where u.user_id = #{userId}
|
where u.user_id = #{userId} and u.del_flag ='0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkUserNameUnique" parameterType="String" resultType="int">
|
<select id="checkUserNameUnique" parameterType="String" resultType="int">
|
||||||
select count(1) from sys_user where user_name = #{userName} limit 1
|
select count(1) from sys_user where user_name = #{userName} and del_flag ='0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} limit 1
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag ='0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, email from sys_user where email = #{email} limit 1
|
select user_id, email from sys_user where email = #{email} and del_flag ='0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
@ -193,6 +193,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
|
and del_flag ='0'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateUserStatus" parameterType="SysUser">
|
<update id="updateUserStatus" parameterType="SysUser">
|
||||||
@ -208,14 +209,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteUserById" parameterType="Long">
|
<delete id="deleteUserById" parameterType="Long">
|
||||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
update sys_user set del_flag = '2' where user_id = #{userId} and del_flag ='0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteUserByIds" parameterType="Long">
|
<delete id="deleteUserByIds" parameterType="Long">
|
||||||
update sys_user set del_flag = '2' where user_id in
|
update sys_user set del_flag = '2' where user_id in
|
||||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||||
#{userId}
|
#{userId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
and del_flag ='0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user