first commit
This commit is contained in:
38
orion-ops-api/orion-ops-mapping/pom.xml
Normal file
38
orion-ops-api/orion-ops-mapping/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>cn.orionsec.ops</groupId>
|
||||
<artifactId>orion-ops-api</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>orion-ops-mapping</name>
|
||||
<artifactId>orion-ops-mapping</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<dependencies>
|
||||
<!-- dao -->
|
||||
<dependency>
|
||||
<groupId>cn.orionsec.ops</groupId>
|
||||
<artifactId>orion-ops-dao</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- model -->
|
||||
<dependency>
|
||||
<groupId>cn.orionsec.ops</groupId>
|
||||
<artifactId>orion-ops-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- data -->
|
||||
<dependency>
|
||||
<groupId>cn.orionsec.ops</groupId>
|
||||
<artifactId>orion-ops-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
package cn.orionsec.ops;
|
||||
|
||||
import cn.orionsec.kit.lang.support.Attempt;
|
||||
import cn.orionsec.kit.lang.utils.reflect.PackageScanner;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MappingConversionProvider implements InitializingBean {
|
||||
|
||||
private final String CONVERSION_PACKAGE = this.getClass().getPackage().getName() + ".mapping.*";
|
||||
|
||||
private static final String EXPORTER_PACKAGE = "cn.orionsec.ops.entity.exporter";
|
||||
|
||||
private static final String IMPORTER_PACKAGE = "cn.orionsec.ops.entity.importer";
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
new PackageScanner(CONVERSION_PACKAGE, EXPORTER_PACKAGE, IMPORTER_PACKAGE)
|
||||
.with(MappingConversionProvider.class)
|
||||
.with(DataModuleConversionProvider.class)
|
||||
.scan()
|
||||
.getClasses()
|
||||
.forEach(Attempt.rethrows(s -> {
|
||||
log.info("register type conversion {}", s.getName());
|
||||
Class.forName(s.getName());
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.alarm;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.AlarmGroupDO;
|
||||
import cn.orionsec.ops.entity.domain.AlarmGroupUserDO;
|
||||
import cn.orionsec.ops.entity.vo.alarm.AlarmGroupUserVO;
|
||||
import cn.orionsec.ops.entity.vo.alarm.AlarmGroupVO;
|
||||
|
||||
|
||||
public class AlarmGroupConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(AlarmGroupDO.class, AlarmGroupVO.class, p -> {
|
||||
AlarmGroupVO vo = new AlarmGroupVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getGroupName());
|
||||
vo.setDescription(p.getGroupDescription());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(AlarmGroupUserDO.class, AlarmGroupUserVO.class, p -> {
|
||||
AlarmGroupUserVO vo = new AlarmGroupUserVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setUserId(p.getUserId());
|
||||
vo.setUsername(p.getUsername());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationActionDO;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationActionLogDO;
|
||||
import cn.orionsec.ops.entity.vo.app.*;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class ApplicationActionConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationActionDO.class, ApplicationActionVO.class, p -> {
|
||||
ApplicationActionVO vo = new ApplicationActionVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getActionName());
|
||||
vo.setType(p.getActionType());
|
||||
vo.setCommand(p.getActionCommand());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationActionLogDO.class, ApplicationActionLogVO.class, p -> {
|
||||
ApplicationActionLogVO vo = new ApplicationActionLogVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setRelId(p.getRelId());
|
||||
vo.setActionId(p.getActionId());
|
||||
vo.setActionName(p.getActionName());
|
||||
vo.setActionType(p.getActionType());
|
||||
vo.setActionCommand(p.getActionCommand());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
vo.setExitCode(p.getExitCode());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationActionLogDO.class, ApplicationActionStatusVO.class, p -> {
|
||||
ApplicationActionStatusVO vo = new ApplicationActionStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
Date startTime = p.getStartTime(), endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
vo.setExitCode(p.getExitCode());
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationActionLogDO.class, ApplicationActionLogStatisticsVO.class, p -> {
|
||||
ApplicationActionLogStatisticsVO vo = new ApplicationActionLogStatisticsVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
if (startTime != null && endTime != null) {
|
||||
long used = endTime.getTime() - startTime.getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationActionDO.class, ApplicationActionStatisticsVO.class, p -> {
|
||||
ApplicationActionStatisticsVO vo = new ApplicationActionStatisticsVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getActionName());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.constant.app.BuildStatus;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationBuildDO;
|
||||
import cn.orionsec.ops.entity.dto.ApplicationBuildStatisticsDTO;
|
||||
import cn.orionsec.ops.entity.vo.app.*;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class ApplicationBuildConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildDO.class, ApplicationBuildReleaseListVO.class, p -> {
|
||||
ApplicationBuildReleaseListVO vo = new ApplicationBuildReleaseListVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setSeq(p.getBuildSeq());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildDO.class, ApplicationBuildStatisticsRecordVO.class, p -> {
|
||||
ApplicationBuildStatisticsRecordVO vo = new ApplicationBuildStatisticsRecordVO();
|
||||
vo.setBuildId(p.getId());
|
||||
vo.setSeq(p.getBuildSeq());
|
||||
vo.setBuildDate(p.getBuildStartTime());
|
||||
vo.setStatus(p.getBuildStatus());
|
||||
// 设置构建用时
|
||||
if (BuildStatus.FINISH.getStatus().equals(p.getBuildStatus())
|
||||
&& p.getBuildStartTime() != null
|
||||
&& p.getBuildEndTime() != null) {
|
||||
long used = p.getBuildEndTime().getTime() - p.getBuildStartTime().getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildDO.class, ApplicationBuildStatusVO.class, p -> {
|
||||
ApplicationBuildStatusVO vo = new ApplicationBuildStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getBuildStatus());
|
||||
Date startTime = p.getBuildStartTime(), endTime = p.getBuildEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildDO.class, ApplicationBuildVO.class, p -> {
|
||||
ApplicationBuildVO vo = new ApplicationBuildVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setAppName(p.getAppName());
|
||||
vo.setAppTag(p.getAppTag());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setProfileName(p.getProfileName());
|
||||
vo.setProfileTag(p.getProfileTag());
|
||||
vo.setSeq(p.getBuildSeq());
|
||||
vo.setRepoId(p.getRepoId());
|
||||
vo.setBranchName(p.getBranchName());
|
||||
vo.setCommitId(p.getCommitId());
|
||||
vo.setStatus(p.getBuildStatus());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateUserId(p.getCreateUserId());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
Date startTime = p.getBuildStartTime();
|
||||
Date endTime = p.getBuildEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildStatisticsDTO.class, ApplicationBuildStatisticsChartVO.class, p -> {
|
||||
ApplicationBuildStatisticsChartVO vo = new ApplicationBuildStatisticsChartVO();
|
||||
vo.setDate(Dates.format(p.getDate(), Dates.YMD));
|
||||
vo.setBuildCount(p.getBuildCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationBuildStatisticsDTO.class, ApplicationBuildStatisticsMetricsVO.class, p -> {
|
||||
ApplicationBuildStatisticsMetricsVO vo = new ApplicationBuildStatisticsMetricsVO();
|
||||
vo.setBuildCount(p.getBuildCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
vo.setAvgUsed(p.getAvgUsed());
|
||||
vo.setAvgUsedInterval(Utils.interval(p.getAvgUsed()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationInfoDO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationDetailVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationInfoVO;
|
||||
|
||||
|
||||
public class ApplicationConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationInfoDO.class, ApplicationInfoVO.class, p -> {
|
||||
ApplicationInfoVO vo = new ApplicationInfoVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getAppName());
|
||||
vo.setTag(p.getAppTag());
|
||||
vo.setSort(p.getAppSort());
|
||||
vo.setRepoId(p.getRepoId());
|
||||
vo.setDescription(p.getDescription());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationInfoDO.class, ApplicationDetailVO.class, p -> {
|
||||
ApplicationDetailVO vo = new ApplicationDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getAppName());
|
||||
vo.setTag(p.getAppTag());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setRepoId(p.getRepoId());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.constant.Const;
|
||||
import cn.orionsec.ops.constant.app.ApplicationEnvAttr;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationEnvDO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationEnvVO;
|
||||
|
||||
public class ApplicationEnvConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationEnvDO.class, ApplicationEnvVO.class, p -> {
|
||||
ApplicationEnvVO vo = new ApplicationEnvVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setKey(p.getAttrKey());
|
||||
vo.setValue(p.getAttrValue());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
Integer forbidDelete = ApplicationEnvAttr.of(p.getAttrKey()) == null ? Const.FORBID_DELETE_CAN : Const.FORBID_DELETE_NOT;
|
||||
vo.setForbidDelete(forbidDelete);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationMachineDO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationMachineVO;
|
||||
|
||||
public class ApplicationMachineConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationMachineDO.class, ApplicationMachineVO.class, p -> {
|
||||
ApplicationMachineVO vo = new ApplicationMachineVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setReleaseId(p.getReleaseId());
|
||||
vo.setBuildId(p.getBuildId());
|
||||
vo.setBuildSeq(p.getBuildSeq());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationPipelineDO;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationPipelineDetailDO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationPipelineDetailVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationPipelineStatisticsDetailVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationPipelineVO;
|
||||
|
||||
public class ApplicationPipelineConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineDO.class, ApplicationPipelineVO.class, p -> {
|
||||
ApplicationPipelineVO vo = new ApplicationPipelineVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getPipelineName());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineDetailDO.class, ApplicationPipelineDetailVO.class, p -> {
|
||||
ApplicationPipelineDetailVO vo = new ApplicationPipelineDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setPipelineId(p.getPipelineId());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setStageType(p.getStageType());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineDetailDO.class, ApplicationPipelineStatisticsDetailVO.class, p -> {
|
||||
ApplicationPipelineStatisticsDetailVO vo = new ApplicationPipelineStatisticsDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setStageType(p.getStageType());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.Converts;
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.constant.app.PipelineStatus;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationPipelineTaskDO;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationPipelineTaskDetailDO;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationPipelineTaskLogDO;
|
||||
import cn.orionsec.ops.entity.dto.ApplicationPipelineTaskStatisticsDTO;
|
||||
import cn.orionsec.ops.entity.dto.app.ApplicationPipelineStageConfigDTO;
|
||||
import cn.orionsec.ops.entity.request.app.ApplicationPipelineTaskDetailRequest;
|
||||
import cn.orionsec.ops.entity.vo.app.*;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ApplicationPipelineTaskConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDetailRequest.class, ApplicationPipelineStageConfigDTO.class, p -> {
|
||||
ApplicationPipelineStageConfigDTO dto = new ApplicationPipelineStageConfigDTO();
|
||||
dto.setBranchName(p.getBranchName());
|
||||
dto.setCommitId(p.getCommitId());
|
||||
dto.setBuildId(p.getBuildId());
|
||||
dto.setTitle(p.getTitle());
|
||||
dto.setDescription(p.getDescription());
|
||||
dto.setMachineIdList(p.getMachineIdList());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDO.class, ApplicationPipelineTaskStatisticsTaskVO.class, p -> {
|
||||
ApplicationPipelineTaskStatisticsTaskVO vo = new ApplicationPipelineTaskStatisticsTaskVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTitle(p.getExecTitle());
|
||||
vo.setExecDate(p.getExecStartTime());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
// 设置构建用时
|
||||
if (PipelineStatus.FINISH.getStatus().equals(p.getExecStatus())
|
||||
&& p.getExecStartTime() != null
|
||||
&& p.getExecEndTime() != null) {
|
||||
long used = p.getExecEndTime().getTime() - p.getExecStartTime().getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDO.class, ApplicationPipelineTaskVO.class, p -> {
|
||||
ApplicationPipelineTaskVO vo = new ApplicationPipelineTaskVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setPipelineId(p.getPipelineId());
|
||||
vo.setPipelineName(p.getPipelineName());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setProfileName(p.getProfileName());
|
||||
vo.setProfileTag(p.getProfileTag());
|
||||
vo.setTitle(p.getExecTitle());
|
||||
vo.setDescription(p.getExecDescription());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
vo.setTimedExec(p.getTimedExec());
|
||||
vo.setTimedExecTime(p.getTimedExecTime());
|
||||
vo.setCreateUserId(p.getCreateUserId());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setAuditUserId(p.getAuditUserId());
|
||||
vo.setAuditUserName(p.getAuditUserName());
|
||||
vo.setAuditTime(p.getAuditTime());
|
||||
Optional.ofNullable(p.getAuditTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setAuditTimeAgo);
|
||||
vo.setAuditReason(p.getAuditReason());
|
||||
vo.setExecUserId(p.getCreateUserId());
|
||||
vo.setExecUserName(p.getCreateUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
Optional.ofNullable(p.getCreateTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setCreateTimeAgo);
|
||||
Date startTime = p.getExecStartTime();
|
||||
Date endTime = p.getExecEndTime();
|
||||
vo.setExecStartTime(startTime);
|
||||
vo.setExecEndTime(endTime);
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setExecStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setExecEndTimeAgo);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDO.class, ApplicationPipelineTaskListVO.class, p -> {
|
||||
ApplicationPipelineTaskListVO vo = new ApplicationPipelineTaskListVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setPipelineId(p.getPipelineId());
|
||||
vo.setPipelineName(p.getPipelineName());
|
||||
vo.setTitle(p.getExecTitle());
|
||||
vo.setDescription(p.getExecDescription());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
vo.setTimedExec(p.getTimedExec());
|
||||
vo.setTimedExecTime(p.getTimedExecTime());
|
||||
vo.setCreateUserId(p.getCreateUserId());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setExecUserId(p.getExecUserId());
|
||||
vo.setExecUserName(p.getExecUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
Date startTime = p.getExecStartTime();
|
||||
Date endTime = p.getExecEndTime();
|
||||
vo.setExecStartTime(startTime);
|
||||
vo.setExecEndTime(endTime);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDetailDO.class, ApplicationPipelineTaskDetailVO.class, p -> {
|
||||
ApplicationPipelineTaskDetailVO vo = new ApplicationPipelineTaskDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTaskId(p.getTaskId());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setRelId(p.getRelId());
|
||||
vo.setAppName(p.getAppName());
|
||||
vo.setAppTag(p.getAppTag());
|
||||
vo.setStageType(p.getStageType());
|
||||
ApplicationPipelineStageConfigDTO config = JSON.parseObject(p.getStageConfig(), ApplicationPipelineStageConfigDTO.class);
|
||||
vo.setConfig(Converts.to(config, ApplicationPipelineStageConfigVO.class));
|
||||
vo.setStatus(p.getExecStatus());
|
||||
Date startTime = p.getExecStartTime();
|
||||
Date endTime = p.getExecEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
Optional.ofNullable(startTime).map(Dates::ago).ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime).map(Dates::ago).ifPresent(vo::setEndTimeAgo);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDetailDO.class, ApplicationPipelineTaskDetailStatusVO.class, p -> {
|
||||
ApplicationPipelineTaskDetailStatusVO vo = new ApplicationPipelineTaskDetailStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTaskId(p.getTaskId());
|
||||
vo.setRelId(p.getRelId());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
Date startTime = p.getExecStartTime();
|
||||
Date endTime = p.getExecEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
Optional.ofNullable(startTime).map(Dates::ago).ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime).map(Dates::ago).ifPresent(vo::setEndTimeAgo);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineStageConfigDTO.class, ApplicationPipelineStageConfigVO.class, p -> {
|
||||
ApplicationPipelineStageConfigVO dto = new ApplicationPipelineStageConfigVO();
|
||||
dto.setBranchName(p.getBranchName());
|
||||
dto.setCommitId(p.getCommitId());
|
||||
dto.setBuildId(p.getBuildId());
|
||||
dto.setMachineIdList(p.getMachineIdList());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineStageConfigDTO.class, ApplicationPipelineTaskDetailRequest.class, p -> {
|
||||
ApplicationPipelineTaskDetailRequest req = new ApplicationPipelineTaskDetailRequest();
|
||||
req.setBranchName(p.getBranchName());
|
||||
req.setCommitId(p.getCommitId());
|
||||
req.setBuildId(p.getBuildId());
|
||||
req.setTitle(p.getTitle());
|
||||
req.setDescription(p.getDescription());
|
||||
req.setMachineIdList(p.getMachineIdList());
|
||||
return req;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskStatisticsDTO.class, ApplicationPipelineTaskStatisticsChartVO.class, p -> {
|
||||
ApplicationPipelineTaskStatisticsChartVO vo = new ApplicationPipelineTaskStatisticsChartVO();
|
||||
vo.setDate(Dates.format(p.getDate(), Dates.YMD));
|
||||
vo.setExecCount(p.getExecCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskStatisticsDTO.class, ApplicationPipelineTaskStatisticsMetricsVO.class, p -> {
|
||||
ApplicationPipelineTaskStatisticsMetricsVO vo = new ApplicationPipelineTaskStatisticsMetricsVO();
|
||||
vo.setExecCount(p.getExecCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
vo.setAvgUsed(p.getAvgUsed());
|
||||
vo.setAvgUsedInterval(Utils.interval(p.getAvgUsed()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDO.class, ApplicationPipelineTaskStatusVO.class, p -> {
|
||||
ApplicationPipelineTaskStatusVO vo = new ApplicationPipelineTaskStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
Date startTime = p.getExecStartTime(), endTime = p.getExecEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskDetailDO.class, ApplicationPipelineTaskStatisticsDetailVO.class, p -> {
|
||||
ApplicationPipelineTaskStatisticsDetailVO vo = new ApplicationPipelineTaskStatisticsDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setRelId(p.getRelId());
|
||||
vo.setStageType(p.getStageType());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
Date startTime = p.getExecStartTime();
|
||||
Date endTime = p.getExecEndTime();
|
||||
if (startTime != null && endTime != null) {
|
||||
long used = endTime.getTime() - startTime.getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationPipelineTaskLogDO.class, ApplicationPipelineTaskLogVO.class, p -> {
|
||||
ApplicationPipelineTaskLogVO vo = new ApplicationPipelineTaskLogVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTaskId(p.getTaskId());
|
||||
vo.setTaskDetailId(p.getTaskDetailId());
|
||||
vo.setStatus(p.getLogStatus());
|
||||
vo.setType(p.getStageType());
|
||||
vo.setLog(p.getLogInfo());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationProfileDO;
|
||||
import cn.orionsec.ops.entity.dto.app.ApplicationProfileDTO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationProfileFastVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationProfileVO;
|
||||
|
||||
public class ApplicationProfileConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationProfileDO.class, ApplicationProfileVO.class, p -> {
|
||||
ApplicationProfileVO vo = new ApplicationProfileVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getProfileName());
|
||||
vo.setTag(p.getProfileTag());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setReleaseAudit(p.getReleaseAudit());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationProfileDO.class, ApplicationProfileDTO.class, p -> {
|
||||
ApplicationProfileDTO dto = new ApplicationProfileDTO();
|
||||
dto.setId(p.getId());
|
||||
dto.setProfileName(p.getProfileName());
|
||||
dto.setProfileTag(p.getProfileTag());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationProfileDTO.class, ApplicationProfileFastVO.class, p -> {
|
||||
ApplicationProfileFastVO vo = new ApplicationProfileFastVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getProfileName());
|
||||
vo.setTag(p.getProfileTag());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.constant.app.ReleaseStatus;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationReleaseDO;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationReleaseMachineDO;
|
||||
import cn.orionsec.ops.entity.dto.ApplicationReleaseStatisticsDTO;
|
||||
import cn.orionsec.ops.entity.vo.app.*;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ApplicationReleaseConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseDO.class, ApplicationReleaseDetailVO.class, p -> {
|
||||
ApplicationReleaseDetailVO vo = new ApplicationReleaseDetailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTitle(p.getReleaseTitle());
|
||||
vo.setDescription(p.getReleaseDescription());
|
||||
vo.setBuildId(p.getBuildId());
|
||||
vo.setBuildSeq(p.getBuildSeq());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setAppName(p.getAppName());
|
||||
vo.setAppTag(p.getAppTag());
|
||||
vo.setProfileId(p.getProfileId());
|
||||
vo.setProfileName(p.getProfileName());
|
||||
vo.setProfileTag(p.getProfileTag());
|
||||
vo.setType(p.getReleaseType());
|
||||
vo.setStatus(p.getReleaseStatus());
|
||||
vo.setSerializer(p.getReleaseSerialize());
|
||||
vo.setExceptionHandler(p.getExceptionHandler());
|
||||
vo.setTimedRelease(p.getTimedRelease());
|
||||
vo.setTimedReleaseTime(p.getTimedReleaseTime());
|
||||
vo.setCreateUserId(p.getCreateUserId());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setAuditUserId(p.getAuditUserId());
|
||||
vo.setAuditUserName(p.getAuditUserName());
|
||||
vo.setAuditTime(p.getAuditTime());
|
||||
vo.setAuditReason(p.getAuditReason());
|
||||
vo.setStartTime(p.getReleaseStartTime());
|
||||
vo.setEndTime(p.getReleaseEndTime());
|
||||
vo.setReleaseUserName(p.getReleaseUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
Date startTime = p.getReleaseStartTime();
|
||||
Date endTime = p.getReleaseEndTime();
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
Optional.ofNullable(p.getTimedReleaseTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setTimedReleaseTimeAgo);
|
||||
Optional.ofNullable(p.getAuditTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setAuditTimeAgo);
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setEndTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseDO.class, ApplicationReleaseListVO.class, p -> {
|
||||
ApplicationReleaseListVO vo = new ApplicationReleaseListVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTitle(p.getReleaseTitle());
|
||||
vo.setDescription(p.getReleaseDescription());
|
||||
vo.setBuildId(p.getBuildId());
|
||||
vo.setBuildSeq(p.getBuildSeq());
|
||||
vo.setAppId(p.getAppId());
|
||||
vo.setAppName(p.getAppName());
|
||||
vo.setAppTag(p.getAppTag());
|
||||
vo.setType(p.getReleaseType());
|
||||
vo.setStatus(p.getReleaseStatus());
|
||||
vo.setSerializer(p.getReleaseSerialize());
|
||||
vo.setExceptionHandler(p.getExceptionHandler());
|
||||
vo.setTimedRelease(p.getTimedRelease());
|
||||
vo.setTimedReleaseTime(p.getTimedReleaseTime());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setAuditUserName(p.getAuditUserName());
|
||||
vo.setAuditReason(p.getAuditReason());
|
||||
vo.setAuditTime(p.getAuditTime());
|
||||
Date startTime = p.getReleaseStartTime();
|
||||
vo.setReleaseUserName(p.getReleaseUserName());
|
||||
vo.setReleaseTime(startTime);
|
||||
Date endTime = p.getReleaseEndTime();
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseMachineDO.class, ApplicationReleaseMachineVO.class, p -> {
|
||||
ApplicationReleaseMachineVO vo = new ApplicationReleaseMachineVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setReleaseId(p.getReleaseId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineTag(p.getMachineTag());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseMachineDO.class, ApplicationReleaseMachineStatusVO.class, p -> {
|
||||
ApplicationReleaseMachineStatusVO vo = new ApplicationReleaseMachineStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
Date startTime = p.getStartTime(), endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseStatisticsDTO.class, ApplicationReleaseStatisticsChartVO.class, p -> {
|
||||
ApplicationReleaseStatisticsChartVO vo = new ApplicationReleaseStatisticsChartVO();
|
||||
vo.setDate(Dates.format(p.getDate(), Dates.YMD));
|
||||
vo.setReleaseCount(p.getReleaseCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseMachineDO.class, ApplicationReleaseStatisticsMachineVO.class, p -> {
|
||||
ApplicationReleaseStatisticsMachineVO vo = new ApplicationReleaseStatisticsMachineVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setStatus(p.getRunStatus());
|
||||
// 设置构建用时
|
||||
if (p.getStartTime() != null && p.getEndTime() != null) {
|
||||
long used = p.getEndTime().getTime() - p.getStartTime().getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseStatisticsDTO.class, ApplicationReleaseStatisticsMetricsVO.class, p -> {
|
||||
ApplicationReleaseStatisticsMetricsVO vo = new ApplicationReleaseStatisticsMetricsVO();
|
||||
vo.setReleaseCount(p.getReleaseCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
vo.setAvgUsed(p.getAvgUsed());
|
||||
vo.setAvgUsedInterval(Utils.interval(p.getAvgUsed()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseDO.class, ApplicationReleaseStatisticsRecordVO.class, p -> {
|
||||
ApplicationReleaseStatisticsRecordVO vo = new ApplicationReleaseStatisticsRecordVO();
|
||||
vo.setReleaseId(p.getId());
|
||||
vo.setReleaseTitle(p.getReleaseTitle());
|
||||
vo.setReleaseDate(p.getReleaseStartTime());
|
||||
vo.setStatus(p.getReleaseStatus());
|
||||
// 设置构建用时
|
||||
if (ReleaseStatus.FINISH.getStatus().equals(p.getReleaseStatus())
|
||||
&& p.getReleaseStartTime() != null
|
||||
&& p.getReleaseEndTime() != null) {
|
||||
long used = p.getReleaseEndTime().getTime() - p.getReleaseStartTime().getTime();
|
||||
vo.setUsed(used);
|
||||
vo.setUsedInterval(Utils.interval(used));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationReleaseDO.class, ApplicationReleaseStatusVO.class, p -> {
|
||||
ApplicationReleaseStatusVO vo = new ApplicationReleaseStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getReleaseStatus());
|
||||
Date startTime = p.getReleaseStartTime(), endTime = p.getReleaseEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setStartTimeAgo(Optional.ofNullable(startTime).map(Dates::ago).orElse(null));
|
||||
vo.setEndTime(endTime);
|
||||
vo.setEndTimeAgo(Optional.ofNullable(endTime).map(Dates::ago).orElse(null));
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.app;
|
||||
|
||||
import cn.orionsec.kit.ext.vcs.git.info.BranchInfo;
|
||||
import cn.orionsec.kit.ext.vcs.git.info.LogInfo;
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.ApplicationRepositoryDO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationRepositoryBranchVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationRepositoryCommitVO;
|
||||
import cn.orionsec.ops.entity.vo.app.ApplicationRepositoryVO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ApplicationRepositoryConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(ApplicationRepositoryDO.class, ApplicationRepositoryVO.class, p -> {
|
||||
ApplicationRepositoryVO vo = new ApplicationRepositoryVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getRepoName());
|
||||
vo.setDescription(p.getRepoDescription());
|
||||
vo.setType(p.getRepoType());
|
||||
vo.setUrl(p.getRepoUrl());
|
||||
vo.setUsername(p.getRepoUsername());
|
||||
vo.setStatus(p.getRepoStatus());
|
||||
vo.setAuthType(p.getRepoAuthType());
|
||||
vo.setTokenType(p.getRepoTokenType());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(BranchInfo.class, ApplicationRepositoryBranchVO.class, p -> {
|
||||
ApplicationRepositoryBranchVO vo = new ApplicationRepositoryBranchVO();
|
||||
vo.setName(p.toString());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(LogInfo.class, ApplicationRepositoryCommitVO.class, p -> {
|
||||
ApplicationRepositoryCommitVO vo = new ApplicationRepositoryCommitVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMessage(p.getMessage());
|
||||
vo.setName(p.getName());
|
||||
Date time = p.getTime();
|
||||
vo.setTime(time);
|
||||
Optional.ofNullable(time).map(Dates::ago).ifPresent(vo::setTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.exec;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.CommandExecDO;
|
||||
import cn.orionsec.ops.entity.vo.exec.CommandExecStatusVO;
|
||||
import cn.orionsec.ops.entity.vo.exec.CommandExecVO;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandExecConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(CommandExecDO.class, CommandExecStatusVO.class, p -> {
|
||||
CommandExecStatusVO vo = new CommandExecStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setExitCode(p.getExitCode());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
if (p.getStartDate() != null && p.getEndDate() != null) {
|
||||
vo.setUsed(p.getEndDate().getTime() - p.getStartDate().getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(CommandExecDO.class, CommandExecVO.class, p -> {
|
||||
CommandExecVO vo = new CommandExecVO();
|
||||
Date startDate = p.getStartDate();
|
||||
Date endDate = p.getEndDate();
|
||||
Date createTime = p.getCreateTime();
|
||||
vo.setId(p.getId());
|
||||
vo.setUserId(p.getUserId());
|
||||
vo.setUsername(p.getUserName());
|
||||
vo.setType(p.getExecType());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setMachineTag(p.getMachineTag());
|
||||
vo.setExitCode(p.getExitCode());
|
||||
vo.setCommand(p.getExecCommand());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setStartDate(startDate);
|
||||
vo.setEndDate(endDate);
|
||||
vo.setCreateTime(createTime);
|
||||
Optional.ofNullable(startDate).map(Dates::ago).ifPresent(vo::setStartDateAgo);
|
||||
Optional.ofNullable(endDate).map(Dates::ago).ifPresent(vo::setEndDateAgo);
|
||||
Optional.ofNullable(createTime).map(Dates::ago).ifPresent(vo::setCreateTimeAgo);
|
||||
if (startDate != null && endDate != null) {
|
||||
vo.setUsed(endDate.getTime() - startDate.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.file;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.FileTailListDO;
|
||||
import cn.orionsec.ops.entity.dto.file.FileTailDTO;
|
||||
import cn.orionsec.ops.entity.vo.tail.FileTailVO;
|
||||
|
||||
public class FileTailConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(FileTailVO.class, FileTailDTO.class, p -> {
|
||||
FileTailDTO dto = new FileTailDTO();
|
||||
dto.setMachineId(p.getMachineId());
|
||||
dto.setFilePath(p.getPath());
|
||||
dto.setOffset(p.getOffset());
|
||||
dto.setCharset(p.getCharset());
|
||||
dto.setCommand(p.getCommand());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(FileTailListDO.class, FileTailVO.class, p -> {
|
||||
FileTailVO vo = new FileTailVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getAliasName());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setPath(p.getFilePath());
|
||||
vo.setFileName(Files1.getFileName(p.getFilePath()));
|
||||
vo.setOffset(p.getFileOffset());
|
||||
vo.setCharset(p.getFileCharset());
|
||||
vo.setCommand(p.getTailCommand());
|
||||
vo.setTailMode(p.getTailMode());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
vo.setUpdateTimeAgo(Dates.ago(p.getUpdateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.file;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.ops.entity.domain.FileTransferLogDO;
|
||||
import cn.orionsec.ops.entity.vo.sftp.FileTransferLogVO;
|
||||
|
||||
public class FileTransferLogConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(FileTransferLogDO.class, FileTransferLogVO.class, p -> {
|
||||
FileTransferLogVO vo = new FileTransferLogVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setFileToken(p.getFileToken());
|
||||
vo.setType(p.getTransferType());
|
||||
vo.setRemoteFile(p.getRemoteFile());
|
||||
vo.setCurrent(Files1.getSize(p.getCurrentSize()));
|
||||
vo.setSize(Files1.getSize(p.getFileSize()));
|
||||
vo.setProgress(p.getNowProgress());
|
||||
vo.setStatus(p.getTransferStatus());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.history;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.HistoryValueSnapshotDO;
|
||||
import cn.orionsec.ops.entity.vo.history.HistoryValueVO;
|
||||
|
||||
public class HistoryValueConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(HistoryValueSnapshotDO.class, HistoryValueVO.class, p -> {
|
||||
HistoryValueVO vo = new HistoryValueVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setType(p.getOperatorType());
|
||||
vo.setBeforeValue(p.getBeforeValue());
|
||||
vo.setAfterValue(p.getAfterValue());
|
||||
vo.setUpdateUserId(p.getUpdateUserId());
|
||||
vo.setUpdateUserName(p.getUpdateUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.home;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.dto.statistic.StatisticsCountDTO;
|
||||
import cn.orionsec.ops.entity.vo.home.HomeStatisticsCountVO;
|
||||
|
||||
public class StatisticsConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(StatisticsCountDTO.class, HomeStatisticsCountVO.class, p -> {
|
||||
HomeStatisticsCountVO vo = new HomeStatisticsCountVO();
|
||||
vo.setMachineCount(p.getMachineCount());
|
||||
vo.setProfileCount(p.getProfileCount());
|
||||
vo.setAppCount(p.getAppCount());
|
||||
vo.setPipelineCount(p.getPipelineCount());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.MachineAlarmConfigDO;
|
||||
import cn.orionsec.ops.entity.domain.MachineAlarmHistoryDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineAlarmConfigVO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineAlarmHistoryVO;
|
||||
|
||||
public class MachineAlarmConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineAlarmConfigDO.class, MachineAlarmConfigVO.class, p -> {
|
||||
MachineAlarmConfigVO vo = new MachineAlarmConfigVO();
|
||||
vo.setType(p.getAlarmType());
|
||||
vo.setAlarmThreshold(p.getAlarmThreshold());
|
||||
vo.setTriggerThreshold(p.getTriggerThreshold());
|
||||
vo.setNotifySilence(p.getNotifySilence());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineAlarmHistoryDO.class, MachineAlarmHistoryVO.class, p -> {
|
||||
MachineAlarmHistoryVO vo = new MachineAlarmHistoryVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setType(p.getAlarmType());
|
||||
vo.setAlarmValue(p.getAlarmValue());
|
||||
vo.setAlarmTime(p.getAlarmTime());
|
||||
vo.setAlarmTimeAgo(Dates.ago(p.getAlarmTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.MachineInfoDO;
|
||||
import cn.orionsec.ops.entity.request.machine.MachineInfoRequest;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineInfoVO;
|
||||
|
||||
public class MachineConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineInfoDO.class, MachineInfoVO.class, p -> {
|
||||
MachineInfoVO vo = new MachineInfoVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setProxyId(p.getProxyId());
|
||||
vo.setKeyId(p.getKeyId());
|
||||
vo.setHost(p.getMachineHost());
|
||||
vo.setSshPort(p.getSshPort());
|
||||
vo.setName(p.getMachineName());
|
||||
vo.setTag(p.getMachineTag());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setUsername(p.getUsername());
|
||||
vo.setAuthType(p.getAuthType());
|
||||
vo.setStatus(p.getMachineStatus());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineInfoRequest.class, MachineInfoDO.class, p -> {
|
||||
MachineInfoDO d = new MachineInfoDO();
|
||||
d.setId(p.getId());
|
||||
d.setProxyId(p.getProxyId());
|
||||
d.setKeyId(p.getKeyId());
|
||||
d.setMachineHost(p.getHost());
|
||||
d.setSshPort(p.getSshPort());
|
||||
d.setMachineName(p.getName());
|
||||
d.setMachineTag(p.getTag());
|
||||
d.setDescription(p.getDescription());
|
||||
d.setUsername(p.getUsername());
|
||||
d.setAuthType(p.getAuthType());
|
||||
d.setMachineStatus(p.getStatus());
|
||||
return d;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.constant.Const;
|
||||
import cn.orionsec.ops.constant.machine.MachineEnvAttr;
|
||||
import cn.orionsec.ops.entity.domain.MachineEnvDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineEnvVO;
|
||||
|
||||
public class MachineEnvConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineEnvDO.class, MachineEnvVO.class, p -> {
|
||||
MachineEnvVO vo = new MachineEnvVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setKey(p.getAttrKey());
|
||||
vo.setValue(p.getAttrValue());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
Integer forbidDelete = MachineEnvAttr.of(p.getAttrKey()) == null ? Const.FORBID_DELETE_CAN : Const.FORBID_DELETE_NOT;
|
||||
vo.setForbidDelete(forbidDelete);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.MachineGroupDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineGroupTreeVO;
|
||||
|
||||
public class MachineGroupConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineGroupDO.class, MachineGroupTreeVO.class, p -> {
|
||||
MachineGroupTreeVO vo = new MachineGroupTreeVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setParentId(p.getParentId());
|
||||
vo.setTitle(p.getGroupName());
|
||||
vo.setSort(p.getSort());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.constant.monitor.MonitorConst;
|
||||
import cn.orionsec.ops.entity.domain.MachineMonitorDO;
|
||||
import cn.orionsec.ops.entity.dto.MachineMonitorDTO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineMonitorVO;
|
||||
|
||||
public class MachineMonitorConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineMonitorDO.class, MachineMonitorVO.class, p -> {
|
||||
MachineMonitorVO vo = new MachineMonitorVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setStatus(p.getMonitorStatus());
|
||||
vo.setUrl(p.getMonitorUrl());
|
||||
vo.setAccessToken(p.getAccessToken());
|
||||
vo.setCurrentVersion(p.getAgentVersion());
|
||||
vo.setLatestVersion(MonitorConst.LATEST_VERSION);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineMonitorDTO.class, MachineMonitorVO.class, p -> {
|
||||
MachineMonitorVO vo = new MachineMonitorVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setStatus(p.getMonitorStatus());
|
||||
vo.setUrl(p.getMonitorUrl());
|
||||
vo.setAccessToken(p.getAccessToken());
|
||||
vo.setCurrentVersion(p.getAgentVersion());
|
||||
vo.setLatestVersion(MonitorConst.LATEST_VERSION);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.MachineProxyDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineProxyVO;
|
||||
|
||||
public class MachineProxyConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineProxyDO.class, MachineProxyVO.class, p -> {
|
||||
MachineProxyVO vo = new MachineProxyVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setHost(p.getProxyHost());
|
||||
vo.setPort(p.getProxyPort());
|
||||
vo.setUsername(p.getProxyUsername());
|
||||
vo.setType(p.getProxyType());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.MachineSecretKeyDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineSecretKeyVO;
|
||||
|
||||
public class MachineSecretKeyConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineSecretKeyDO.class, MachineSecretKeyVO.class, p -> {
|
||||
MachineSecretKeyVO vo = new MachineSecretKeyVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getKeyName());
|
||||
vo.setPath(p.getSecretKeyPath());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.machine;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.config.TerminalConnectConfig;
|
||||
import cn.orionsec.ops.entity.domain.MachineTerminalDO;
|
||||
import cn.orionsec.ops.entity.domain.MachineTerminalLogDO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineTerminalLogVO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineTerminalManagerVO;
|
||||
import cn.orionsec.ops.entity.vo.machine.MachineTerminalVO;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MachineTerminalConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineTerminalDO.class, MachineTerminalVO.class, p -> {
|
||||
MachineTerminalVO vo = new MachineTerminalVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setTerminalType(p.getTerminalType());
|
||||
vo.setBackgroundColor(p.getBackgroundColor());
|
||||
vo.setFontColor(p.getFontColor());
|
||||
vo.setFontSize(p.getFontSize());
|
||||
vo.setFontFamily(p.getFontFamily());
|
||||
vo.setEnableWebLink(p.getEnableWebLink());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(TerminalConnectConfig.class, MachineTerminalManagerVO.class, p -> {
|
||||
MachineTerminalManagerVO vo = new MachineTerminalManagerVO();
|
||||
vo.setUserId(p.getUserId());
|
||||
vo.setUserName(p.getUsername());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setMachineTag(p.getMachineTag());
|
||||
vo.setLogId(p.getLogId());
|
||||
vo.setConnectedTime(p.getConnectedTime());
|
||||
Optional.ofNullable(p.getConnectedTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setConnectedTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineTerminalLogDO.class, MachineTerminalLogVO.class, p -> {
|
||||
MachineTerminalLogVO vo = new MachineTerminalLogVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setUserId(p.getUserId());
|
||||
vo.setUsername(p.getUsername());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineTag(p.getMachineTag());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setAccessToken(p.getAccessToken());
|
||||
vo.setConnectedTime(p.getConnectedTime());
|
||||
vo.setDisconnectedTime(p.getDisconnectedTime());
|
||||
Optional.ofNullable(p.getConnectedTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setConnectedTimeAgo);
|
||||
Optional.ofNullable(p.getDisconnectedTime())
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setDisconnectedTimeAgo);
|
||||
vo.setCloseCode(p.getCloseCode());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.message;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.WebSideMessageDO;
|
||||
import cn.orionsec.ops.entity.vo.message.WebSideMessageVO;
|
||||
|
||||
public class WebSideMessageConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(WebSideMessageDO.class, WebSideMessageVO.class, p -> {
|
||||
WebSideMessageVO vo = new WebSideMessageVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setClassify(p.getMessageClassify());
|
||||
vo.setType(p.getMessageType());
|
||||
vo.setStatus(p.getReadStatus());
|
||||
vo.setToUserId(p.getToUserId());
|
||||
vo.setToUserName(p.getToUserName());
|
||||
vo.setMessage(p.getSendMessage());
|
||||
vo.setRelId(p.getRelId());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.scheduler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.cron.Cron;
|
||||
import cn.orionsec.kit.lang.utils.time.cron.CronSupport;
|
||||
import cn.orionsec.ops.entity.domain.SchedulerTaskDO;
|
||||
import cn.orionsec.ops.entity.vo.scheduler.SchedulerTaskVO;
|
||||
|
||||
public class SchedulerTaskConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskDO.class, SchedulerTaskVO.class, p -> {
|
||||
SchedulerTaskVO vo = new SchedulerTaskVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getTaskName());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCommand(p.getTaskCommand());
|
||||
vo.setExpression(p.getExpression());
|
||||
vo.setEnableStatus(p.getEnableStatus());
|
||||
vo.setLatelyStatus(p.getLatelyStatus());
|
||||
vo.setSerializeType(p.getSerializeType());
|
||||
vo.setExceptionHandler(p.getExceptionHandler());
|
||||
vo.setLatelyScheduleTime(p.getLatelyScheduleTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
try {
|
||||
vo.setNextTime(CronSupport.getNextTime(new Cron(p.getExpression()), 5));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.scheduler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.SchedulerTaskMachineRecordDO;
|
||||
import cn.orionsec.ops.entity.domain.SchedulerTaskRecordDO;
|
||||
import cn.orionsec.ops.entity.dto.SchedulerTaskRecordStatisticsDTO;
|
||||
import cn.orionsec.ops.entity.vo.scheduler.*;
|
||||
import cn.orionsec.ops.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SchedulerTaskRecordConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskRecordDO.class, SchedulerTaskRecordVO.class, p -> {
|
||||
SchedulerTaskRecordVO vo = new SchedulerTaskRecordVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setTaskId(p.getTaskId());
|
||||
vo.setTaskName(p.getTaskName());
|
||||
vo.setStatus(p.getTaskStatus());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setEndTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskRecordDO.class, SchedulerTaskRecordStatusVO.class, p -> {
|
||||
SchedulerTaskRecordStatusVO vo = new SchedulerTaskRecordStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setStatus(p.getTaskStatus());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setEndTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskRecordStatisticsDTO.class, SchedulerTaskRecordStatisticsChartVO.class, p -> {
|
||||
SchedulerTaskRecordStatisticsChartVO vo = new SchedulerTaskRecordStatisticsChartVO();
|
||||
vo.setDate(Dates.format(p.getDate(), Dates.YMD));
|
||||
vo.setScheduledCount(p.getScheduledCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskRecordStatisticsDTO.class, SchedulerTaskRecordStatisticsVO.class, p -> {
|
||||
SchedulerTaskRecordStatisticsVO vo = new SchedulerTaskRecordStatisticsVO();
|
||||
vo.setScheduledCount(p.getScheduledCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
vo.setAvgUsed(p.getAvgUsed());
|
||||
vo.setAvgUsedInterval(Utils.interval(p.getAvgUsed()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskMachineRecordDO.class, SchedulerTaskMachineRecordVO.class, p -> {
|
||||
SchedulerTaskMachineRecordVO vo = new SchedulerTaskMachineRecordVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setRecordId(p.getRecordId());
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setMachineHost(p.getMachineHost());
|
||||
vo.setMachineTag(p.getMachineTag());
|
||||
vo.setCommand(p.getExecCommand());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
vo.setExitCode(p.getExitCode());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setEndTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskMachineRecordDO.class, SchedulerTaskMachineRecordStatusVO.class, p -> {
|
||||
SchedulerTaskMachineRecordStatusVO vo = new SchedulerTaskMachineRecordStatusVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setRecordId(p.getRecordId());
|
||||
vo.setStatus(p.getExecStatus());
|
||||
vo.setExitCode(p.getExitCode());
|
||||
Date startTime = p.getStartTime();
|
||||
Date endTime = p.getEndTime();
|
||||
vo.setStartTime(startTime);
|
||||
vo.setEndTime(endTime);
|
||||
if (startTime != null && endTime != null) {
|
||||
vo.setUsed(endTime.getTime() - startTime.getTime());
|
||||
vo.setKeepTime(Utils.interval(vo.getUsed()));
|
||||
}
|
||||
Optional.ofNullable(startTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setStartTimeAgo);
|
||||
Optional.ofNullable(endTime)
|
||||
.map(Dates::ago)
|
||||
.ifPresent(vo::setEndTimeAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SchedulerTaskRecordStatisticsDTO.class, SchedulerTaskMachineRecordStatisticsVO.class, p -> {
|
||||
SchedulerTaskMachineRecordStatisticsVO vo = new SchedulerTaskMachineRecordStatisticsVO();
|
||||
vo.setMachineId(p.getMachineId());
|
||||
vo.setMachineName(p.getMachineName());
|
||||
vo.setScheduledCount(p.getScheduledCount());
|
||||
vo.setSuccessCount(p.getSuccessCount());
|
||||
vo.setFailureCount(p.getFailureCount());
|
||||
vo.setAvgUsed(p.getAvgUsed());
|
||||
vo.setAvgUsedInterval(Utils.interval(p.getAvgUsed()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.sftp;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.io.FileType;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpFile;
|
||||
import cn.orionsec.ops.constant.Const;
|
||||
import cn.orionsec.ops.entity.dto.sftp.SftpUploadInfoDTO;
|
||||
import cn.orionsec.ops.entity.request.sftp.FileUploadRequest;
|
||||
import cn.orionsec.ops.entity.vo.sftp.FileDetailVO;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class SftpConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SftpFile.class, FileDetailVO.class, s -> {
|
||||
FileDetailVO vo = new FileDetailVO();
|
||||
vo.setName(s.getName());
|
||||
vo.setPath(s.getPath());
|
||||
vo.setSize(Files1.getSize(s.getSize()));
|
||||
vo.setSizeByte(s.getSize());
|
||||
vo.setPermission(s.getPermission());
|
||||
vo.setUid(s.getUid());
|
||||
vo.setGid(s.getGid());
|
||||
vo.setAttr(s.getPermissionString());
|
||||
vo.setModifyTime(s.getModifyTime());
|
||||
Boolean isDir = Optional.ofNullable(FileType.of(vo.getAttr()))
|
||||
.map(FileType.DIRECTORY::equals)
|
||||
.orElse(false);
|
||||
vo.setIsDir(isDir);
|
||||
vo.setIsSafe(!Const.UNSAFE_FS_DIR.contains(s.getPath()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(FileUploadRequest.class, SftpUploadInfoDTO.class, p -> {
|
||||
SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
|
||||
dto.setRemotePath(p.getRemotePath());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.system;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.dto.system.SystemSpaceAnalysisDTO;
|
||||
import cn.orionsec.ops.entity.vo.system.SystemAnalysisVO;
|
||||
|
||||
public class SystemAnalysisConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SystemSpaceAnalysisDTO.class, SystemAnalysisVO.class, p -> {
|
||||
SystemAnalysisVO vo = new SystemAnalysisVO();
|
||||
vo.setTempFileCount(p.getTempFileCount());
|
||||
vo.setTempFileSize(p.getTempFileSize());
|
||||
vo.setLogFileCount(p.getLogFileCount());
|
||||
vo.setLogFileSize(p.getLogFileSize());
|
||||
vo.setSwapFileCount(p.getSwapFileCount());
|
||||
vo.setSwapFileSize(p.getSwapFileSize());
|
||||
vo.setDistVersionCount(p.getDistVersionCount());
|
||||
vo.setDistFileSize(p.getDistFileSize());
|
||||
vo.setRepoVersionCount(p.getRepoVersionCount());
|
||||
vo.setRepoVersionFileSize(p.getRepoVersionFileSize());
|
||||
vo.setScreenFileCount(p.getScreenFileCount());
|
||||
vo.setScreenFileSize(p.getScreenFileSize());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.system;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.constant.Const;
|
||||
import cn.orionsec.ops.constant.system.SystemEnvAttr;
|
||||
import cn.orionsec.ops.entity.domain.SystemEnvDO;
|
||||
import cn.orionsec.ops.entity.vo.system.SystemEnvVO;
|
||||
|
||||
public class SystemEnvConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(SystemEnvDO.class, SystemEnvVO.class, p -> {
|
||||
SystemEnvVO vo = new SystemEnvVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setKey(p.getAttrKey());
|
||||
vo.setValue(p.getAttrValue());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
Integer forbidDelete = SystemEnvAttr.of(p.getAttrKey()) == null ? Const.FORBID_DELETE_CAN : Const.FORBID_DELETE_NOT;
|
||||
vo.setForbidDelete(forbidDelete);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.template;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.CommandTemplateDO;
|
||||
import cn.orionsec.ops.entity.vo.template.CommandTemplateVO;
|
||||
|
||||
public class CommandTemplateConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(CommandTemplateDO.class, CommandTemplateVO.class, p -> {
|
||||
CommandTemplateVO vo = new CommandTemplateVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getTemplateName());
|
||||
vo.setValue(p.getTemplateValue());
|
||||
vo.setDescription(p.getDescription());
|
||||
vo.setCreateUserId(p.getCreateUserId());
|
||||
vo.setCreateUserName(p.getCreateUserName());
|
||||
vo.setUpdateUserId(p.getUpdateUserId());
|
||||
vo.setUpdateUserName(p.getUpdateUserName());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setUpdateTime(p.getUpdateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
vo.setUpdateTimeAgo(Dates.ago(p.getUpdateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.upload;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.MachineInfoDO;
|
||||
import cn.orionsec.ops.entity.dto.sftp.SftpUploadInfoDTO;
|
||||
import cn.orionsec.ops.entity.request.upload.BatchUploadRequest;
|
||||
import cn.orionsec.ops.entity.vo.upload.BatchUploadCheckFileVO;
|
||||
import cn.orionsec.ops.entity.vo.upload.BatchUploadCheckMachineVO;
|
||||
|
||||
public class BatchUploadConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(BatchUploadRequest.class, SftpUploadInfoDTO.class, p -> {
|
||||
SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
|
||||
dto.setRemotePath(p.getRemotePath());
|
||||
dto.setMachineIdList(p.getMachineIds());
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineInfoDO.class, BatchUploadCheckFileVO.class, p -> {
|
||||
BatchUploadCheckFileVO vo = new BatchUploadCheckFileVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getMachineName());
|
||||
vo.setHost(p.getMachineHost());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(MachineInfoDO.class, BatchUploadCheckMachineVO.class, p -> {
|
||||
BatchUploadCheckMachineVO vo = new BatchUploadCheckMachineVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getMachineName());
|
||||
vo.setHost(p.getMachineHost());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.user;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.UserEventLogDO;
|
||||
import cn.orionsec.ops.entity.vo.user.UserEventLogVO;
|
||||
|
||||
public class UserEventLogConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(UserEventLogDO.class, UserEventLogVO.class, p -> {
|
||||
UserEventLogVO vo = new UserEventLogVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setUserId(p.getUserId());
|
||||
vo.setUsername(p.getUsername());
|
||||
vo.setClassify(p.getEventClassify());
|
||||
vo.setType(p.getEventType());
|
||||
vo.setLog(p.getLogInfo());
|
||||
vo.setParams(p.getParamsJson());
|
||||
vo.setResult(p.getExecResult());
|
||||
vo.setCreateTime(p.getCreateTime());
|
||||
vo.setCreateTimeAgo(Dates.ago(p.getCreateTime()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.user;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.ops.entity.domain.UserInfoDO;
|
||||
import cn.orionsec.ops.entity.dto.user.UserDTO;
|
||||
import cn.orionsec.ops.entity.vo.user.UserInfoVO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
public class UserInfoConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(UserInfoDO.class, UserInfoVO.class, d -> {
|
||||
UserInfoVO vo = new UserInfoVO();
|
||||
vo.setId(d.getId());
|
||||
vo.setUsername(d.getUsername());
|
||||
vo.setNickname(d.getNickname());
|
||||
vo.setRole(d.getRoleType());
|
||||
vo.setStatus(d.getUserStatus());
|
||||
vo.setLocked(d.getLockStatus());
|
||||
vo.setPhone(d.getContactPhone());
|
||||
vo.setEmail(d.getContactEmail());
|
||||
Date lastLoginTime = d.getLastLoginTime();
|
||||
vo.setLastLoginTime(lastLoginTime);
|
||||
Optional.ofNullable(lastLoginTime).map(Dates::ago).ifPresent(vo::setLastLoginAgo);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(UserDTO.class, UserInfoVO.class, d -> {
|
||||
UserInfoVO vo = new UserInfoVO();
|
||||
vo.setId(d.getId());
|
||||
vo.setUsername(d.getUsername());
|
||||
vo.setNickname(d.getNickname());
|
||||
vo.setRole(d.getRoleType());
|
||||
vo.setStatus(d.getUserStatus());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
package cn.orionsec.ops.mapping.webhook;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.convert.TypeStore;
|
||||
import cn.orionsec.ops.entity.domain.WebhookConfigDO;
|
||||
import cn.orionsec.ops.entity.vo.webhook.WebhookConfigVO;
|
||||
|
||||
public class WebhookConfigConversion {
|
||||
|
||||
static {
|
||||
TypeStore.STORE.register(WebhookConfigDO.class, WebhookConfigVO.class, p -> {
|
||||
WebhookConfigVO vo = new WebhookConfigVO();
|
||||
vo.setId(p.getId());
|
||||
vo.setName(p.getWebhookName());
|
||||
vo.setUrl(p.getWebhookUrl());
|
||||
vo.setType(p.getWebhookType());
|
||||
vo.setConfig(p.getWebhookConfig());
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user