| | |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.mapper.sys.TokenMapper; |
| | | import com.lf.server.service.all.PermsService; |
| | | import com.lf.server.service.all.RedisService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Service |
| | | public class TokenService implements TokenMapper { |
| | | @Autowired |
| | | public RedisService redisService; |
| | | |
| | | @Autowired |
| | | TokenMapper tokenMapper; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | LoginService loginService; |
| | | |
| | | @Autowired |
| | | public RedisService redisService; |
| | | |
| | | @Autowired |
| | | public PermsService permsService; |
| | | |
| | | @Override |
| | | public Integer selectCount(String name, Integer type) { |
| | |
| | | |
| | | // redis |
| | | Object obj = redisService.get(tokenKey); |
| | | if (obj != null && obj instanceof TokenEntity) { |
| | | if (obj instanceof TokenEntity) { |
| | | return (TokenEntity) obj; |
| | | } |
| | | |
| | |
| | | |
| | | // redis |
| | | Object obj = redisService.get(userKey); |
| | | if (obj != null && obj instanceof UserEntity) { |
| | | if (obj instanceof UserEntity) { |
| | | return (UserEntity) obj; |
| | | } |
| | | |
| | |
| | | |
| | | int count = objCount == null ? 1 : (int) objCount + 1; |
| | | redisService.put(key, count, SettingData.PWD_ERR_TIME, TimeUnit.MINUTES); |
| | | |
| | | // 记录日志 |
| | | HttpServletRequest req = WebHelper.getRequest(); |
| | | LoginEntity le = loginService.getNewLogin(ue.getId(), 1, 1, 0, req); |
| | | le.setDescr("密码不正确"); |
| | | loginService.insertLogin(le); |
| | | |
| | | if (count >= SettingData.PWD_ERR_COUNT) { |
| | | String token = WebHelper.getToken(req); |
| | | HttpServletResponse res = WebHelper.getResponse(); |
| | | logout(token, req, res); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | Object objCount = redisService.get(key); |
| | | |
| | | return objCount != null && (int) objCount >= SettingData.PWD_ERR_COUNT; |
| | | } |
| | | |
| | | public void logoffToken(String token) { |
| | | // |
| | | } |
| | | } |