!646 ApiAccessLog、ApiErrorLog、JobLog 3 个日志的 定时 物理清理
Merge pull request !646 from lanxindx/feature/mall_productplp
commit
00c2153fd3
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.framework.quartz.core.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.quartz.core.service.JobLogFrameworkService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author: j-sentinel
|
||||
* @Date: 2023/9/30 20:40
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class JobLogJobHandler implements JobHandler {
|
||||
|
||||
private LogJobProperties logJobProperties;
|
||||
|
||||
public JobLogJobHandler(LogJobProperties logJobProperties) {
|
||||
this.logJobProperties = logJobProperties;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private JobLogFrameworkService jobLogFrameworkService;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
Integer integer = jobLogFrameworkService.timingJobCleanLog(logJobProperties.getJobCleanRetainDay());
|
||||
log.info("定时执行清理定时任务日志数量({})个",integer);
|
||||
return String.format("定时执行清理定时任务日志数量 %s 个", integer);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.framework.quartz.core.job;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @Author: j-sentinel
|
||||
* @Date: 2023/9/30 16:17
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "yudao.clean-job")
|
||||
public class LogJobProperties {
|
||||
|
||||
private int accessRetainDay = 7;
|
||||
|
||||
private int errorRetainDay = 8;
|
||||
|
||||
private int jobCleanRetainDay = 7;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.framework.apilog.core.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author: j-sentinel
|
||||
* @Date: 2023/9/30 16:13
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ApiAccessLogJobHandler implements JobHandler {
|
||||
|
||||
private LogJobProperties logJobProperties;
|
||||
|
||||
public ApiAccessLogJobHandler(LogJobProperties logJobProperties) {
|
||||
this.logJobProperties = logJobProperties;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ApiAccessLogFrameworkService apiAccessLogFrameworkService;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
apiAccessLogFrameworkService.jobCleanAccessLog(logJobProperties.getAccessRetainDay());
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.framework.apilog.core.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author: j-sentinel
|
||||
* @Date: 2023/9/30 16:13
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ApiErrorLogJobHandler implements JobHandler {
|
||||
|
||||
private LogJobProperties logJobProperties;
|
||||
|
||||
public ApiErrorLogJobHandler(LogJobProperties logJobProperties) {
|
||||
this.logJobProperties = logJobProperties;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ApiErrorLogFrameworkService apiErrorLogFrameworkService;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
apiErrorLogFrameworkService.jobCleanErrorLog(logJobProperties.getErrorRetainDay());
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue