删除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") @PostMapping("/private/message/expungeTask")
public Object expungeTask() { public Object expungeTask(@RequestBody(required = false) ExpungeImTaskJob.Param param) {
int count = expungeImTaskJob.runWithDefault(); int count = expungeImTaskJob.expunge(param);
return CommonResponse.success(count); return CommonResponse.success(count);
} }
} }

View File

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