| | |
| | | package com.whyc.task; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.pojo.PageParam; |
| | | import com.whyc.service.PageParamService; |
| | | import com.whyc.service.UserService; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletContext; |
| | |
| | | * 账号登录失败时间超过24小时,移除 |
| | | * TODO 尚未测试 |
| | | */ |
| | | @Component |
| | | public class AccountLockStrategyTask extends TimerTask { |
| | | |
| | | @Autowired |
| | | private ServletContext servletContext; |
| | | |
| | | @Resource |
| | |
| | | @Resource |
| | | private PageParamService pageParamService; |
| | | |
| | | public AccountLockStrategyTask(ServletContext servletContext) { |
| | | this.servletContext = servletContext; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | //临时账号检测是否过期,如果过期,更改状态为注销 |
| | | userService.updateExpiredAccount(); |
| | | |
| | | //查询账号解锁策略 |
| | | PageParam accountUnLock = (PageParam) ((List)pageParamService.findByCategoryId(9).getData()).get(1); |
| | | PageParam accountUnLock = (PageParam) ((PageInfo)pageParamService.findByCategoryId(9).getData()).getList().get(1); |
| | | if(accountUnLock.getStatus()==2){ //自动解锁策略 |
| | | //查询账号锁定时间,超过20分钟解锁 |
| | | userService.unLock(); |
| | | } |
| | | |
| | | //登录失败时间超过24小时记录,内存中application移除 |
| | | //servletContext = ActionUtil.getApplication(); |
| | | Enumeration<String> attributeNames = servletContext.getAttributeNames(); |
| | | //24小时前的时间戳 |
| | | long oneDayBefore = System.currentTimeMillis()-24*60*60*1000; |