mirror of https://github.com/elunez/eladmin
complete other CacheKey name
parent
5303e47842
commit
e7deb482d1
|
@ -33,6 +33,7 @@ public interface CacheKey {
|
||||||
/**
|
/**
|
||||||
* 菜单
|
* 菜单
|
||||||
*/
|
*/
|
||||||
|
String MENU_ID = "menu::id:";
|
||||||
String MENU_USER = "menu::user:";
|
String MENU_USER = "menu::user:";
|
||||||
/**
|
/**
|
||||||
* 角色授权
|
* 角色授权
|
||||||
|
@ -42,4 +43,12 @@ public interface CacheKey {
|
||||||
* 角色信息
|
* 角色信息
|
||||||
*/
|
*/
|
||||||
String ROLE_ID = "role::id:";
|
String ROLE_ID = "role::id:";
|
||||||
|
/**
|
||||||
|
* 部门
|
||||||
|
*/
|
||||||
|
String DEPT_ID = "dept::id:";
|
||||||
|
/**
|
||||||
|
* 数据字典
|
||||||
|
*/
|
||||||
|
String DICT_NAME = "dict::name:";
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class DeptServiceImpl implements DeptService {
|
||||||
public void delCaches(Long id){
|
public void delCaches(Long id){
|
||||||
List<User> users = userRepository.findByDeptRoleId(id);
|
List<User> users = userRepository.findByDeptRoleId(id);
|
||||||
// 删除数据权限
|
// 删除数据权限
|
||||||
redisUtils.delByKeys("data::user:",users.stream().map(User::getId).collect(Collectors.toSet()));
|
redisUtils.delByKeys(CacheKey.DATA_USER, users.stream().map(User::getId).collect(Collectors.toSet()));
|
||||||
redisUtils.del("dept::id:" + id);
|
redisUtils.del(CacheKey.DEPT_ID + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,10 +20,7 @@ import me.zhengjie.modules.system.domain.Dict;
|
||||||
import me.zhengjie.modules.system.domain.DictDetail;
|
import me.zhengjie.modules.system.domain.DictDetail;
|
||||||
import me.zhengjie.modules.system.repository.DictRepository;
|
import me.zhengjie.modules.system.repository.DictRepository;
|
||||||
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
|
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.*;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
|
||||||
import me.zhengjie.utils.RedisUtils;
|
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
|
||||||
import me.zhengjie.modules.system.repository.DictDetailRepository;
|
import me.zhengjie.modules.system.repository.DictDetailRepository;
|
||||||
import me.zhengjie.modules.system.service.DictDetailService;
|
import me.zhengjie.modules.system.service.DictDetailService;
|
||||||
import me.zhengjie.modules.system.service.dto.DictDetailDto;
|
import me.zhengjie.modules.system.service.dto.DictDetailDto;
|
||||||
|
@ -93,6 +90,6 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||||
|
|
||||||
public void delCaches(DictDetail dictDetail){
|
public void delCaches(DictDetail dictDetail){
|
||||||
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
||||||
redisUtils.del("dict::name:" + dict.getName());
|
redisUtils.del(CacheKey.DICT_NAME + dict.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -115,6 +115,6 @@ public class DictServiceImpl implements DictService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delCaches(Dict dict){
|
public void delCaches(Dict dict){
|
||||||
redisUtils.del("dict::name:" + dict.getName());
|
redisUtils.del(CacheKey.DICT_NAME + dict.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -344,12 +344,12 @@ public class MenuServiceImpl implements MenuService {
|
||||||
*/
|
*/
|
||||||
public void delCaches(Long id){
|
public void delCaches(Long id){
|
||||||
List<User> users = userRepository.findByMenuId(id);
|
List<User> users = userRepository.findByMenuId(id);
|
||||||
redisUtils.del("menu::id:" +id);
|
redisUtils.del(CacheKey.MENU_ID + id);
|
||||||
redisUtils.delByKeys("menu::user:",users.stream().map(User::getId).collect(Collectors.toSet()));
|
redisUtils.delByKeys(CacheKey.MENU_USER, users.stream().map(User::getId).collect(Collectors.toSet()));
|
||||||
// 清除 Role 缓存
|
// 清除 Role 缓存
|
||||||
List<Role> roles = roleService.findInMenuId(new ArrayList<Long>(){{
|
List<Role> roles = roleService.findInMenuId(new ArrayList<Long>(){{
|
||||||
add(id);
|
add(id);
|
||||||
}});
|
}});
|
||||||
redisUtils.delByKeys("role::id:",roles.stream().map(Role::getId).collect(Collectors.toSet()));
|
redisUtils.delByKeys(CacheKey.ROLE_ID, roles.stream().map(Role::getId).collect(Collectors.toSet()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue