mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 优化 数据权限查询增加缓存
This commit is contained in:
@ -5,12 +5,14 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRoleDept;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.system.mapper.SysRoleDeptMapper;
|
||||
import org.dromara.system.service.ISysDataScopeService;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,6 +38,7 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
* @param roleId 角色Id
|
||||
* @return 部门Id组
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_ROLE_CUSTOM, key = "#roleId")
|
||||
@Override
|
||||
public String getRoleCustom(Long roleId) {
|
||||
if (ObjectUtil.isNull(roleId)) {
|
||||
@ -57,6 +60,7 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
* @param deptId 部门Id
|
||||
* @return 部门Id组
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId")
|
||||
@Override
|
||||
public String getDeptAndChild(Long deptId) {
|
||||
if (ObjectUtil.isNull(deptId)) {
|
||||
|
@ -27,6 +27,7 @@ import org.dromara.system.mapper.SysUserMapper;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -250,6 +251,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
* @param bo 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true)
|
||||
@Override
|
||||
public int insertDept(SysDeptBo bo) {
|
||||
SysDept info = baseMapper.selectById(bo.getParentId());
|
||||
@ -268,7 +270,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
* @param bo 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId")
|
||||
@Caching(evict = {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId"),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true)
|
||||
})
|
||||
@Override
|
||||
public int updateDept(SysDeptBo bo) {
|
||||
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
|
||||
@ -341,7 +346,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@Caching(evict = {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId"),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId")
|
||||
})
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId) {
|
||||
return baseMapper.deleteById(deptId);
|
||||
|
@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
@ -33,6 +34,7 @@ import org.dromara.system.mapper.SysRoleMapper;
|
||||
import org.dromara.system.mapper.SysRoleMenuMapper;
|
||||
import org.dromara.system.mapper.SysUserRoleMapper;
|
||||
import org.dromara.system.service.ISysRoleService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -328,6 +330,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
* @param bo 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_ROLE_CUSTOM, key = "#bo.roleId")
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int authDataScope(SysRoleBo bo) {
|
||||
@ -404,6 +407,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_ROLE_CUSTOM, allEntries = true)
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleByIds(Long[] roleIds) {
|
||||
|
Reference in New Issue
Block a user