mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: define JobLogConfig
This commit is contained in:
parent
3842acf952
commit
a4a41c4ab7
@ -0,0 +1,45 @@
|
||||
package tech.powerjob.common.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 任务日志配置
|
||||
*
|
||||
* @author yhz
|
||||
* @since 2022/9/16
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class JobLogConfig {
|
||||
/**
|
||||
* log type {@link LogType}
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* log level {@link tech.powerjob.common.enums.LogLevel}
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LogType {
|
||||
ONLINE(1),
|
||||
LOCAL(2);
|
||||
private final Integer v;
|
||||
|
||||
public LogType of(Integer type) {
|
||||
for (LogType logType : values()) {
|
||||
if (logType.v.equals(type)) {
|
||||
return logType;
|
||||
}
|
||||
}
|
||||
return ONLINE;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import tech.powerjob.common.enums.ExecuteType;
|
||||
import tech.powerjob.common.enums.ProcessorType;
|
||||
import tech.powerjob.common.enums.TimeExpressionType;
|
||||
import tech.powerjob.common.model.AlarmConfig;
|
||||
import tech.powerjob.common.model.JobLogConfig;
|
||||
import tech.powerjob.common.model.LifeCycle;
|
||||
import tech.powerjob.common.utils.CommonUtils;
|
||||
import lombok.Data;
|
||||
@ -139,6 +140,16 @@ public class SaveJobInfoRequest {
|
||||
*/
|
||||
private AlarmConfig alarmConfig;
|
||||
|
||||
/**
|
||||
* 任务归类,开放给接入方自由定制
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* 日志配置,包括日志级别、日志方式等配置信息
|
||||
*/
|
||||
private JobLogConfig logConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Check non-null properties.
|
||||
|
@ -50,4 +50,6 @@ public class JobInfoQuery extends PowerQuery {
|
||||
private Date gmtModifiedGt;
|
||||
|
||||
private Integer dispatchStrategyEq;
|
||||
|
||||
private String tagEq;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package tech.powerjob.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
import tech.powerjob.common.model.AlarmConfig;
|
||||
import tech.powerjob.common.model.JobLogConfig;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -125,4 +126,15 @@ public class JobInfoDTO {
|
||||
private String lifecycle;
|
||||
|
||||
private AlarmConfig alarmConfig;
|
||||
|
||||
/**
|
||||
* 任务归类,开放给接入方自由定制
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* 日志配置,包括日志级别、日志方式等配置信息
|
||||
*/
|
||||
private JobLogConfig logConfig;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package tech.powerjob.server.core.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
@ -107,6 +108,10 @@ public class JobService {
|
||||
}
|
||||
jobInfoDO.setAlarmConfig(JSON.toJSONString(request.getAlarmConfig()));
|
||||
}
|
||||
// 日志配置
|
||||
if (request.getLogConfig() != null) {
|
||||
jobInfoDO.setLogConfig(JSONObject.toJSONString(request.getLogConfig()));
|
||||
}
|
||||
JobInfoDO res = jobInfoRepository.saveAndFlush(jobInfoDO);
|
||||
return res.getId();
|
||||
}
|
||||
|
@ -145,4 +145,13 @@ public class JobInfoDO {
|
||||
*/
|
||||
private String alarmConfig;
|
||||
|
||||
/**
|
||||
* 任务归类,开放给接入方自由定制
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* 日志配置,包括日志级别、日志方式等配置信息
|
||||
*/
|
||||
private String logConfig;
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package tech.powerjob.server.web.response;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import tech.powerjob.common.enums.ExecuteType;
|
||||
import tech.powerjob.common.enums.ProcessorType;
|
||||
import tech.powerjob.common.enums.TimeExpressionType;
|
||||
import tech.powerjob.common.model.AlarmConfig;
|
||||
import tech.powerjob.common.model.JobLogConfig;
|
||||
import tech.powerjob.common.model.LifeCycle;
|
||||
import tech.powerjob.common.utils.CommonUtils;
|
||||
import tech.powerjob.server.common.SJ;
|
||||
@ -144,6 +146,16 @@ public class JobInfoVO {
|
||||
|
||||
private AlarmConfig alarmConfig;
|
||||
|
||||
/**
|
||||
* 任务归类,开放给接入方自由定制
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* 日志配置,包括日志级别、日志方式等配置信息
|
||||
*/
|
||||
private JobLogConfig logConfig;
|
||||
|
||||
public static JobInfoVO from(JobInfoDO jobInfoDO) {
|
||||
JobInfoVO jobInfoVO = new JobInfoVO();
|
||||
BeanUtils.copyProperties(jobInfoDO, jobInfoVO);
|
||||
@ -173,6 +185,10 @@ public class JobInfoVO {
|
||||
jobInfoVO.setLifeCycle(LifeCycle.parse(jobInfoDO.getLifecycle()));
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(jobInfoDO.getLogConfig())) {
|
||||
jobInfoVO.setLogConfig(JSONObject.parseObject(jobInfoDO.getLogConfig(), JobLogConfig.class));
|
||||
}
|
||||
|
||||
return jobInfoVO;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user