Merge branch 'wq1' of SH-Arbitrate/Mediation-Backend into dev

This commit was merged in pull request #153.
This commit is contained in:
2024-04-29 16:38:41 +08:00
committed by Gitea
6 changed files with 13 additions and 30 deletions
@@ -2,12 +2,10 @@ package com.ruoyi;
import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.boot.SpringApplication;
@@ -59,13 +57,6 @@ public class RuoYiApplication
redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId());
}
}
// 初始化部门redis
SysDeptMapper deptMapper = SpringUtils.getBean(SysDeptMapper.class);
List<SysDept> depts = deptMapper.selectDeptList(new SysDept());
if(CollectionUtil.isNotEmpty(depts)){
for (SysDept dept : depts) {
redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId());
}
}
}
}
@@ -64,8 +64,5 @@ public class CacheConstants
* 角色 redis key
*/
public static final String ROLE_KEY = "role_key:";
/**
* 部门 redis key
*/
public static final String DEPT_KEY = "dept_key:";
}
@@ -2,7 +2,6 @@ package com.ruoyi.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
@@ -231,7 +230,6 @@ public class SysDeptServiceImpl implements ISysDeptService
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
}
int i = deptMapper.insertDept(dept);
redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId());
return i;
}
@@ -260,8 +258,6 @@ public class SysDeptServiceImpl implements ISysDeptService
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
// 修改缓存
redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId());
return result;
}
@@ -311,11 +307,7 @@ public class SysDeptServiceImpl implements ISysDeptService
if(CollectionUtil.isNotEmpty(caseList)){
throw new ServiceException("该部门有关联案件,不允许删除");
}
SysDept sysDept = deptMapper.selectDeptById(deptId);
if(sysDept!=null) {
// 删除缓存
redisCache.deleteObject(CacheConstants.DEPT_KEY + sysDept.getDeptName());
}
return deptMapper.deleteDeptById(deptId);
}
@@ -253,8 +253,7 @@ public class SysUserServiceImpl implements ISysUserService {
user.setCreateBy("admin");
user.setCreateTime(DateUtils.getNowDate());
int rows = userMapper.insertUser(user);
// redis缓存
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
// 新增用户部门关联
if(CollectionUtil.isNotEmpty(user.getDeptIds())) {
// 先删除用户与部门关联
@@ -272,6 +271,8 @@ public class SysUserServiceImpl implements ISysUserService {
insertUserPost(user);
// 新增用户与角色管理
insertUserRole(user);
// redis缓存
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
return AjaxResult.success("新建用户成功");
}
@@ -322,6 +323,7 @@ public class SysUserServiceImpl implements ISysUserService {
insertUserPost(user);
userMapper.updateUser(user);
// redis缓存
user=userMapper.selectUserById(userId);
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
return AjaxResult.success("更新用户成功");
}
@@ -349,7 +351,7 @@ public class SysUserServiceImpl implements ISysUserService {
public int updateUserStatus(SysUser user) {
int i = userMapper.updateUser(user);
// redis缓存
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
// redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
return i;
}
@@ -363,6 +365,7 @@ public class SysUserServiceImpl implements ISysUserService {
public int updateUserProfile(SysUser user) {
int i = userMapper.updateUser(user);
// redis缓存
user=userMapper.selectUserById(user.getUserId());
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
return i;
}
@@ -388,8 +391,6 @@ public class SysUserServiceImpl implements ISysUserService {
@Override
public int resetPwd(SysUser user) {
int i = userMapper.updateUser(user);
// redis缓存
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
return i;
}
@@ -554,6 +555,7 @@ public class SysUserServiceImpl implements ISysUserService {
user.setUpdateBy(operName);
userMapper.updateUser(user);
// redis缓存
user=userMapper.selectUserById(user.getUserId());
redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
@@ -160,6 +160,7 @@ public class WeChatUserServiceImpl implements WeChatUserService {
sysUser.setPassword(SecurityUtils.encryptPassword(ientityAuthentication.getPassWord()));
sysUserMapper.updateUser(sysUser);
// redis缓存
sysUser=sysUserMapper.selectUserById(sysUser.getUserId());
redisCache.setCacheObject(CacheConstants.USER_KEY+sysUser.getUserId(),sysUser);
ientityAuthentication.setUserId(sysUser.getUserId());
int count=0;
@@ -223,14 +223,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
throw new ServiceException("该角色为绑定案件流程");
throw new ServiceException("该角色未绑定案件流程");
}
Example flowExample = new Example(MsCaseFlow.class);
flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
if (CollectionUtil.isEmpty(caseFlows)) {
throw new ServiceException("该角色为绑定案件流程");
throw new ServiceException("该角色未绑定案件流程");
}
List<Integer> caseFlowIds = caseFlows.stream().map(MsCaseFlow::getId).collect(Collectors.toList());
// 流程名称分组