删除1周前无用的im task数据

This commit is contained in:
yanglin 2024-05-09 14:25:06 +08:00
parent eccef94911
commit 834f986196
2 changed files with 5 additions and 8 deletions

View File

@ -83,8 +83,8 @@ public class PrivateController {
}
@PostMapping("/private/message/expungeTask")
public Object expungeTask() {
int count = expungeImTaskJob.runWithDefault();
public Object expungeTask(@RequestBody(required = false) ExpungeImTaskJob.Param param) {
int count = expungeImTaskJob.expunge(param);
return CommonResponse.success(count);
}
}

View File

@ -29,7 +29,7 @@ public class ExpungeImTaskJob extends IJobHandler {
log.info("start - run job with param={}", paramStr);
try {
Param param = JSONObjectUtil.parseObject(paramStr, Param.class);
executeImpl(param);
expunge(param);
log.info("end - run job with param={}", param);
return ReturnT.SUCCESS;
} catch (Exception e) {
@ -38,11 +38,8 @@ public class ExpungeImTaskJob extends IJobHandler {
}
}
public int runWithDefault() {
return executeImpl(new Param());
}
private int executeImpl(Param param) {
public int expunge(Param nullableParam) {
Param param = nullableParam == null ? new Param() : nullableParam;
Date until = DateTime.now().minusDays(param.daysAgo).toDate();
int count = messageTaskMapper.expunge(until);
log.info("deleted count={}", count);