SpringBoot注册登录(一):User表的设计点击打开链接
SpringBoot注册登录(二):注册---验证码kaptcha的实现点击打开链接
SpringBoot注册登录(三):注册--验证账号密码是否符合格式及后台完成注册功能点击打开链接
SpringBoot注册登录(四):登录功能--密码错误三次,需要等待2分钟才能登录,固定时间内不能登录点击打开链接
SpringBoot(六):拦截器--只允许进入登录注册页面,没登录不允许查看其它页面点击打开链接
SpringBoot--mybatis--ajax--模态框--log:注册、登录、拦截器、文件系统源代码点击打开链接
一、Controller内容
package com.fxy.task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import com.fxy.bean.User;
import com.fxy.service.UserService;
@Component
@Controller
public class ScheduledTest {
@Autowired
private UserService userService;
private static final Logger logger = LoggerFactory.getLogger(ScheduledTest.class);
// 每天早八点到晚八点,间隔5分钟执行任务
@Scheduled(cron="0 0/5 8-20 * * ?")
public void executeUploadTask() {
// 间隔5分钟,执行工单上传任务
Thread current = Thread.currentThread();
logger.info("ScheduledTest.executeUploadTask 定时任务:"+current.getId() + ",name:"+current.getName());
//每隔5分钟清空一次miss_number、allow_time
int intUpdateUser = userService.updateUserMissTimeAllowTime();
logger.info("intUpdateUser:"+intUpdateUser);
}
}
二、SQL语句
清空时间的时候注意:date类型设为null,经常出现各种问题,所以不要使用mybatis逆向工程生成的sql接口,要自己写sql。
可以先在mySQL里面新建查询语句看看能不能执行,再写到eclipse
<!-- 每隔5分钟清空一次miss_number、allow_time -->
<update id="updateUserMissTimeAllowTime">
update user
set
allow_time = null,
miss_number = 0
</update>