| | |
| | | package com.terra.system.service.all; |
| | | |
| | | import com.terra.common.entity.all.StaticData; |
| | | import com.terra.system.entity.all.*; |
| | | import com.terra.system.entity.sys.MenuEntity; |
| | | import com.terra.system.entity.sys.ResEntity; |
| | | import com.terra.system.mapper.all.PermsMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | RedisService redisService; |
| | | |
| | | @Override |
| | | public List<ResAuthEntity> selectRes(String uid) { |
| | | public List<ResEntity> selectRes(String uid) { |
| | | return selectResByUid(uid, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectAllRes() { |
| | | return selectResByUid(StaticData.ADMIN, true); |
| | | } |
| | | |
| | | private List<ResEntity> selectResByUid(String uid, boolean isAll) { |
| | | String key = RedisCacheKey.permsResKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<ResAuthEntity>) obj; |
| | | return (List<ResEntity>) obj; |
| | | } |
| | | |
| | | List<ResAuthEntity> list = permsMapper.selectRes(uid); |
| | | List<ResEntity> list = isAll ? permsMapper.selectAllRes() : permsMapper.selectRes(uid); |
| | | if (list != null && list.size() > 0) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | |
| | | } |
| | | |
| | | List<MenusAuthEntity> list = permsMapper.selectMenus(uid); |
| | | if (list != null && list.size() > 0) { |
| | | if (list != null && !list.isEmpty()) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | List<String> list = permsMapper.selectPerms(uid); |
| | | if (list != null && list.size() > 0) { |
| | | if (list != null && !list.isEmpty()) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | List<PermsAuthEntity> list = permsMapper.selectPermsEntity(uid); |
| | | if (list != null && list.size() > 0) { |
| | | if (list != null && !list.isEmpty()) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |