| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.time.Instant; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 |
| | | */ |
| | |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | |
| | | List<SysRole> sysRoles = roleService.selectListByDelFlag(2); |
| | | if(CollectionUtils.isEmpty(sysRoles)){ |
| | | return; |
| | | } |
| | | for (SysRole sysRole : sysRoles) { |
| | | if(sysRole.getRemoveDays()>0){ |
| | | sysRole.setRemoveDays(sysRole.getRemoveDays()-1); |
| | | roleService.updateRole(sysRole); |
| | | }else { |
| | | roleService.deleteRoleById(sysRole.getRoleId()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 每天的凌晨执行的任务 |
| | | */ |