package com.template.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.template.api.UnlockingControllerAPI; import com.template.model.pojo.Unlocking; import com.template.services.UnlockingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.Date; import java.util.List; /** *

* 前端控制器 *

* * @author ceshi * @since 2023-12-01 */ @RestController public class UnlockingController implements UnlockingControllerAPI { @Autowired UnlockingService unlockingService; @Autowired PasswordIssController passwordIssController; // 定时删除过期用户 // @Scheduled(cron = "0 2 * * * ? ") @Scheduled(cron = "0 0/3 * * * ?") public void deleteUnlocking() { // 先查询已过期的自定义的锁 LambdaQueryWrapper wrapperUC = new LambdaQueryWrapper<>(); wrapperUC.le(Unlocking::getEndTime, new Date()); List list = unlockingService.list(wrapperUC); if (list.size() > 0) { ArrayList idUCs = new ArrayList<>(); for (Unlocking unlockingCustom : list) { String luid = unlockingCustom.getLuid(); String lockUserId = unlockingCustom.getLockUserId(); passwordIssController.deleteLockUser(luid, lockUserId); idUCs.add(unlockingCustom.getId()); } unlockingService.removeByIds(idUCs); } } }