SpringBoot注册登录(五):登录功能--Scheduling Tasks定时作业,用于某个时间段允许/不允许用户登录

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值