| | |
| | | |
| | | import com.terra.common.entity.all.RedisCacheKey; |
| | | import com.terra.common.entity.all.SettingData; |
| | | import com.terra.common.entity.all.StaticData; |
| | | import com.terra.common.entity.lf.TokenPo; |
| | | import com.terra.common.entity.lf.UserPo; |
| | | import com.terra.common.helper.StringHelper; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | |
| | | @Component |
| | | public class CommonService { |
| | | @Resource |
| | | RedisService redisService; |
| | | CommonMapper mapper; |
| | | |
| | | |
| | | @Resource |
| | | CommonMapper mapper; |
| | | RedisService redisService; |
| | | |
| | | public UserPo getCurrentUser(HttpServletRequest req) { |
| | | String token = WebHelper.getToken(req); |
| | |
| | | |
| | | return po; |
| | | } |
| | | |
| | | /** |
| | | * 用户ID是/否禁用 |
| | | */ |
| | | public boolean isUidDisable(UserPo ue) { |
| | | String key = RedisCacheKey.signPwdError(ue.getUid()); |
| | | Object objCount = redisService.get(key); |
| | | |
| | | return null != objCount && (int) objCount >= SettingData.PWD_ERR_COUNT; |
| | | } |
| | | |
| | | public List<String> selectIpList(Integer type) { |
| | | String key = RedisCacheKey.blacklistKey(type.toString()); |
| | | |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<String>) obj; |
| | | } |
| | | |
| | | List<String> list = mapper.selectIpList(type); |
| | | if (list != null && !list.isEmpty()) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public List<String> selectPerms(String uid) { |
| | | String key = RedisCacheKey.permsPermsKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<String>) obj; |
| | | } |
| | | |
| | | List<String> list = mapper.selectPerms(uid); |
| | | if (list != null && !list.isEmpty()) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | } |