1.新增查询部门及区市未配置审核人员列表接口

2.角色用户关联表新增修改时间,修改人及删除标志字段
3.修改用户数据变更时角色信息修改逻辑,关联数据由物理删除变为逻辑删除
4.调整其他设计用户角色关联表查询sql,增加删除标志条件
This commit is contained in:
dinggang 2022-11-25 14:30:52 +08:00
parent 02d01ad170
commit 0d3d6f61ec
13 changed files with 185 additions and 8 deletions

View File

@ -0,0 +1,5 @@
ALTER TABLE sys_role_user
ADD COLUMN `del_flag` INT NOT NULL DEFAULT 0 COMMENT '删除标志0正常1删除',
ADD COLUMN `updater` BIGINT NULL COMMENT '修改人',
ADD COLUMN `update_date` datetime(0) NULL COMMENT '修改时间';

View File

@ -196,4 +196,27 @@ public class SysUserController {
}
}
@GetMapping("/getApproverUnconfiguredDepartment")
@ApiOperation("查询未配置部门审核人部门列表")
@LogOperation("查询未配置部门审核人部门列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "当前页码从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "int")
})
public Result getApproverUnconfiguredDepartment(@ApiIgnore @RequestParam Map<String, Object> params) {
return new Result().ok(sysUserService.getApproverUnconfiguredDepartment(params));
}
@GetMapping("/getApproverUnconfiguredRegion")
@ApiOperation("查询未配置区市审核人区市列表")
@LogOperation("查询未配置区市审核人区市列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "当前页码从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "int")
})
public Result getApproverUnconfiguredRegion(@ApiIgnore @RequestParam Map<String, Object> params) {
return new Result().ok(sysUserService.getApproverUnconfiguredRegion(params));
}
}

View File

@ -3,6 +3,7 @@ package io.renren.modules.sys.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.sys.entity.SysRoleUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -26,7 +27,7 @@ public interface SysRoleUserDao extends BaseDao<SysRoleUserEntity> {
*
* @param userIds 用户ids
*/
void deleteByUserIds(Long[] userIds);
void deleteByUserIds(@Param("userIds") Long[] userIds, @Param("updater") Long updater);
/**
* 角色ID列表

View File

@ -5,6 +5,7 @@ import io.renren.modules.sys.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@ -48,4 +49,8 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
SysUserEntity getUserByName(@Param("username") String username);
String getDeptNameByUserId(@Param("id") String id);
List<Map> getApproverUnconfiguredDepartment(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize);
List<Map> getApproverUnconfiguredRegion(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize);
}

View File

@ -47,4 +47,13 @@ public class SysRoleDTO implements Serializable {
@ApiModelProperty(value = "部门ID列表")
private List<Long> deptIdList;
@ApiModelProperty(value = "删除标志")
private Integer delFlag;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "修改人")
private Long updater;
}

View File

@ -1,10 +1,15 @@
package io.renren.modules.sys.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.renren.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 角色用户关系
*
@ -25,4 +30,12 @@ public class SysRoleUserEntity extends BaseEntity {
*/
private Long userId;
private Integer delFlag;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
}

View File

@ -62,4 +62,7 @@ public interface SysUserService extends BaseService<SysUserEntity> {
int backSysUser();
Object getApproverUnconfiguredDepartment(Map<String, Object> params);
Object getApproverUnconfiguredRegion(Map<String, Object> params);
}

View File

@ -2,10 +2,12 @@ package io.renren.modules.sys.service.impl;
import cn.hutool.core.collection.CollUtil;
import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dao.SysRoleUserDao;
import io.renren.modules.sys.entity.SysRoleUserEntity;
import io.renren.modules.sys.service.SysRoleUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -18,6 +20,7 @@ import java.util.List;
public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService {
@Override
@Transactional
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
//先删除角色用户关系
deleteByUserIds(new Long[]{userId});
@ -45,7 +48,9 @@ public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysR
@Override
public void deleteByUserIds(Long[] userIds) {
baseDao.deleteByUserIds(userIds);
Long updater = SecurityUser.getUserId();
baseDao.deleteByUserIds(userIds, updater);
}
@Override

View File

@ -1,5 +1,6 @@
package io.renren.modules.sys.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -26,6 +27,8 @@ import io.renren.modules.sys.enums.JhDeptsEnum;
import io.renren.modules.sys.enums.SuperAdminEnum;
import io.renren.modules.sys.service.*;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ObjectUtils;
import org.h2.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -37,7 +40,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
/**
* 系统用户
*/
@ -520,4 +522,34 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return result;
}
}
@Override
public Object getApproverUnconfiguredDepartment(Map<String, Object> params) {
int pageNum = 1;
int pageSize = 10;
if (params.get("pageNum") != null && StringUtils.isNumber(params.get("pageNum").toString())) {
pageNum = Integer.parseInt(params.get("pageNum").toString());
}
if (params.get("pageSize") != null && StringUtils.isNumber(params.get("pageSize").toString())) {
pageSize = Integer.parseInt(params.get("pageSize").toString());
}
ArrayList<Object> resultList = new ArrayList<>();
resultList.addAll(sysUserDao.getApproverUnconfiguredDepartment(pageNum, pageSize));
return resultList;
}
@Override
public Object getApproverUnconfiguredRegion(Map<String, Object> params) {
int pageNum = 1;
int pageSize = 10;
if (params.get("pageNum") != null && StringUtils.isNumber(params.get("pageNum").toString())) {
pageNum = Integer.parseInt(params.get("pageNum").toString());
}
if (params.get("pageSize") != null && StringUtils.isNumber(params.get("pageSize").toString())) {
pageSize = Integer.parseInt(params.get("pageSize").toString());
}
ArrayList<Object> resultList = new ArrayList<>();
resultList.addAll(sysUserDao.getApproverUnconfiguredRegion(pageNum, pageSize));
return resultList;
}
}

View File

@ -39,6 +39,7 @@
left join sys_role_menu t2 on t1.role_id = t2.role_id
left join sys_menu t3 on t2.menu_id = t3.id
where t1.user_id = #{userId}
AND t1.del_flag = 0
<if test="type != null">
and t3.type = #{type}
</if>
@ -48,7 +49,7 @@
<select id="getUserPermissionsList" resultType="string">
select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id
left join sys_menu t3 on t2.menu_id = t3.id
where t1.user_id = #{userId} order by t3.sort asc
where t1.user_id = #{userId} AND t1.del_flag = 0 order by t3.sort
</select>
<select id="getPermissionsList" resultType="string">

View File

@ -9,7 +9,7 @@
<select id="getDataScopeList" resultType="long">
select t2.dept_id from sys_role_user t1, sys_role_data_scope t2
where t1.user_id = #{value} and t1.role_id = t2.role_id
where t1.user_id = #{value} and t1.role_id = t2.role_id AND t1.del_flag = 0
</select>
<delete id="deleteByRoleIds">

View File

@ -9,6 +9,7 @@
#{roleId}
</foreach>
</delete>
<!--
<delete id="deleteByUserIds">
delete from sys_role_user where user_id in
@ -17,12 +18,21 @@
</foreach>
</delete>
-->
<update id="deleteByUserIds">
UPDATE sys_role_user SET del_flag = 0, update_date = NOW(), updater = #{updater}
where user_id in
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
<select id="getRoleIdList" resultType="long">
select role_id from sys_role_user where user_id = #{value}
select role_id from sys_role_user where user_id = #{value} AND del_flag = 0
</select>
<select id="getUserIdsByRoleId" resultType="java.lang.Long">
select user_id from sys_role_user where role_id = #{roleId}
select user_id from sys_role_user where role_id = #{roleId} AND del_flag = 0
</select>
</mapper>

View File

@ -33,7 +33,7 @@
</if>
<if test="role_id != null">
AND EXISTS(SELECT 1 FROM sys_role_user WHERE sys_role_user.user_id = t1.id AND sys_role_user.role_id =
#{role_id})
#{role_id}) AND sys_role_user.del_flag = 0
</if>
</select>
@ -71,6 +71,7 @@
AND t1.role_id = #{roleId}
AND t2.dept_id = #{deptId}
AND t2.status = 1
AND t1.del_flag = 0
ORDER BY
update_date DESC
LIMIT 1
@ -102,4 +103,73 @@
SELECT name FROM sys_dept LEFT JOIN sys_user ON sys_user.dept_id = sys_dept.id WHERE sys_user.id = #{id}
</select>
<select id="getApproverUnconfiguredDepartment" resultType="java.util.Map">
SELECT
id,
name,
(CASE type
WHEN 1 THEN
'省'
WHEN 2 THEN
'市'
WHEN 3 THEN
'区'
ELSE
' '
END) AS "type",
sort
FROM
sys_dept sd
WHERE
id NOT IN (
SELECT
sd.id
FROM
sys_user su,
sys_dept sd,
sys_role sr,
sys_role_user sru
WHERE
su.dept_id = sd.id
AND su.id = sru.user_id
AND sru.role_id = sr.id
AND sru.del_flag = 0
AND sr.`name` = '部门审批人'
)
AND sd.type != 4
ORDER BY sd.type, sort
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="getApproverUnconfiguredRegion" resultType="java.util.Map">
SELECT
id,
NAME,
sort
FROM
sys_region srg
WHERE
id NOT IN (
SELECT
srg.id
FROM
sys_user su,
sys_dept sd,
sys_region srg,
sys_role sr,
sys_role_user sru
WHERE
su.dept_id = sd.id
AND su.id = sru.user_id
AND sru.role_id = sr.id
AND sd.district = srg.id
AND sru.del_falg = 0
AND sr.`name` = '区审批人'
)
AND srg.tree_level = 3
AND 9 >= srg.sort
ORDER BY srg.sort
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper>