123
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.job;
|
||||
|
||||
import com.ruoyi.cai.service.DynamicService;
|
||||
import com.ruoyi.cai.service.UserChatRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@@ -8,14 +9,17 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ClearJob {
|
||||
public class Clear2HoursJob {
|
||||
|
||||
@Autowired
|
||||
private DynamicService dynamicService;
|
||||
@Autowired
|
||||
private UserChatRecordService userChatRecordService;
|
||||
|
||||
|
||||
@Scheduled(cron = "0 1 0 * * ? ")
|
||||
public void persistentDb() {
|
||||
// 每隔小时执行一次
|
||||
// @Scheduled(cron = "0 0 0/2 * * ? *")
|
||||
public void clearRun() {
|
||||
try {
|
||||
log.info("定时删除动态== 开始");
|
||||
dynamicService.clearDynamic(12);
|
||||
@@ -24,9 +28,11 @@ public class ClearJob {
|
||||
log.error("定时删除动态== 异常",e);
|
||||
}
|
||||
try {
|
||||
|
||||
log.info("定时删除聊天记录== 开始");
|
||||
userChatRecordService.clearChatRecord(24);
|
||||
log.info("定时删除聊天记录== 结束");
|
||||
}catch (Exception e){
|
||||
|
||||
log.error("定时删除聊天记录== 异常",e);
|
||||
}
|
||||
|
||||
}
|
||||
31
ruoyi-cai/src/main/java/com/ruoyi/cai/job/ClearDaysJob.java
Normal file
31
ruoyi-cai/src/main/java/com/ruoyi/cai/job/ClearDaysJob.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.ruoyi.cai.job;
|
||||
|
||||
import com.ruoyi.cai.service.DynamicService;
|
||||
import com.ruoyi.cai.service.SmsVerifyService;
|
||||
import com.ruoyi.cai.service.UserChatRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ClearDaysJob {
|
||||
|
||||
@Autowired
|
||||
private SmsVerifyService smsVerifyService;
|
||||
|
||||
|
||||
// 凌晨8点执行
|
||||
@Scheduled(cron = "0 0 8 * * ? ")
|
||||
public void clearRun() {
|
||||
try {
|
||||
log.info("定时删除短信记录== 开始");
|
||||
smsVerifyService.clearSmsVerify(7);
|
||||
log.info("定时删除短信记录== 结束");
|
||||
}catch (Exception e){
|
||||
log.error("定时删除短信记录== 异常",e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user