| | |
| | | package com.lf.server.service.all; |
| | | |
| | | import com.lf.server.entity.all.*; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.entity.sys.MenuEntity; |
| | | import com.lf.server.mapper.all.PermsMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | public class PermsService implements PermsMapper { |
| | | @Autowired |
| | | @Resource |
| | | PermsMapper permsMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | RedisService redisService; |
| | | |
| | | @Override |
| | | public List<ResAuthEntity> selectRes(String uid) { |
| | | if (StringHelper.isEmpty(uid)) { |
| | | return null; |
| | | } |
| | | |
| | | String key = RedisCacheKey.permsResKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | |
| | | |
| | | @Override |
| | | public List<MenusAuthEntity> selectMenus(String uid) { |
| | | if (StringHelper.isEmpty(uid)) { |
| | | return null; |
| | | } |
| | | |
| | | String key = RedisCacheKey.permsMenusKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | |
| | | |
| | | @Override |
| | | public List<String> selectPerms(String uid) { |
| | | if (StringHelper.isEmpty(uid)) { |
| | | return null; |
| | | } |
| | | |
| | | String key = RedisCacheKey.permsPermsKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | |
| | | |
| | | @Override |
| | | public List<PermsAuthEntity> selectPermsEntity(String uid) { |
| | | if (StringHelper.isEmpty(uid)) { |
| | | return null; |
| | | } |
| | | |
| | | String key = RedisCacheKey.permsPermsEntityKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | public void clearResCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsResKey("")); |
| | | @Override |
| | | public List<Integer> selectRoles(String uid) { |
| | | return permsMapper.selectRoles(uid); |
| | | } |
| | | |
| | | @Override |
| | | public List<MenuEntity> selectMenuRecursive(int id, String uid) { |
| | | return permsMapper.selectMenuRecursive(id, uid); |
| | | } |
| | | |
| | | /** |
| | | * 清除授权缓存 |
| | | */ |
| | | public void clearPermsCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsMenusKey("")); |
| | | redisService.clearKeys(RedisCacheKey.permsPermsKey("")); |
| | | redisService.clearKeys(RedisCacheKey.permsPermsEntityKey("")); |
| | | redisService.clearKeys(RedisCacheKey.permsRootKey()); |
| | | } |
| | | |
| | | /** |
| | | * 清除所有缓存 |
| | | */ |
| | | public void clearAllCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsRootKey()); |
| | | redisService.clearAll(); |
| | | } |
| | | } |