🔨 批量执行日志.
This commit is contained in:
@@ -45,9 +45,9 @@ public class CodeGenerators {
|
||||
// .color("blue", "gray", "red", "green", "white")
|
||||
// .valueUseFields()
|
||||
// .build(),
|
||||
Template.create("exec_log", "执行日志", "exec")
|
||||
Template.create("exec_host_log", "批量执行主机日志", "exec")
|
||||
.disableUnitTest()
|
||||
.vue("exec", "exec-log")
|
||||
.vue("exec", "exec-log-exec")
|
||||
.enableDrawerForm()
|
||||
.build(),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
### 批量执行
|
||||
POST {{baseUrl}}/asset/exec/start
|
||||
Authorization: {{token}}
|
||||
|
||||
###
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orion.ops.module.asset.controller;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.asset.define.operator.ExecOperatorType;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecRequest;
|
||||
import com.orion.ops.module.asset.service.ExecService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 批量执行
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/3/11 11:44
|
||||
*/
|
||||
@Tag(name = "asset - 批量执行服务")
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@RestController
|
||||
@RequestMapping("/asset/exec")
|
||||
@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"})
|
||||
public class ExecController {
|
||||
|
||||
@Resource
|
||||
private ExecService execService;
|
||||
|
||||
@OperatorLog(ExecOperatorType.START)
|
||||
@PostMapping("/start")
|
||||
@Operation(summary = "批量执行")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec:start')")
|
||||
public void startExecCommand(@RequestBody ExecRequest request) {
|
||||
execService.startExecCommand(request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
### 分页查询批量执行主机日志
|
||||
POST {{baseUrl}}/asset/exec-host-log/query
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"page": 1,
|
||||
"limit": 10,
|
||||
"id": "",
|
||||
"logId": "",
|
||||
"hostId": "",
|
||||
"hostName": "",
|
||||
"status": "",
|
||||
"command": "",
|
||||
"parameter": "",
|
||||
"exitStatus": "",
|
||||
"logPath": "",
|
||||
"startTime": "",
|
||||
"finishTime": ""
|
||||
}
|
||||
|
||||
|
||||
### 删除批量执行主机日志
|
||||
DELETE {{baseUrl}}/asset/exec-host-log/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 批量删除批量执行主机日志
|
||||
DELETE {{baseUrl}}/asset/exec-host-log/batch-delete?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
###
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.orion.ops.module.asset.controller;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.asset.define.operator.ExecHostLogOperatorType;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecHostLogQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||
import com.orion.ops.module.asset.service.ExecHostLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 api
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Tag(name = "asset - 批量执行主机日志服务")
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@RestController
|
||||
@RequestMapping("/asset/exec-host-log")
|
||||
@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"})
|
||||
public class ExecHostLogController {
|
||||
|
||||
@Resource
|
||||
private ExecHostLogService execHostLogService;
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "查询全部批量执行主机日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-host-log:query')")
|
||||
public List<ExecHostLogVO> getExecHostLogList(@Validated @RequestBody ExecHostLogQueryRequest request) {
|
||||
return execHostLogService.getExecHostLogList(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecHostLogOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除批量执行主机日志")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-host-log:delete')")
|
||||
public Integer deleteExecHostLog(@RequestParam("id") Long id) {
|
||||
return execHostLogService.deleteExecHostLogById(id);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecHostLogOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除批量执行主机日志")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-host-log:delete')")
|
||||
public Integer batchDeleteExecHostLog(@RequestParam("idList") List<Long> idList) {
|
||||
return execHostLogService.deleteExecHostLogByIdList(idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,67 +1,9 @@
|
||||
### 创建执行日志
|
||||
POST {{baseUrl}}/asset/exec-log/create
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"userId": "",
|
||||
"source": "",
|
||||
"sourceId": "",
|
||||
"desc": "",
|
||||
"command": "",
|
||||
"status": "",
|
||||
"startTime": "",
|
||||
"finishTime": ""
|
||||
}
|
||||
|
||||
|
||||
### 更新执行日志
|
||||
PUT {{baseUrl}}/asset/exec-log/update
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"id": "",
|
||||
"userId": "",
|
||||
"source": "",
|
||||
"sourceId": "",
|
||||
"desc": "",
|
||||
"command": "",
|
||||
"status": "",
|
||||
"startTime": "",
|
||||
"finishTime": ""
|
||||
}
|
||||
|
||||
|
||||
### 查询执行日志
|
||||
### 查询批量执行日志
|
||||
GET {{baseUrl}}/asset/exec-log/get?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 批量查询执行日志
|
||||
GET {{baseUrl}}/asset/exec-log/batch-get?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 查询全部执行日志
|
||||
POST {{baseUrl}}/asset/exec-log/list
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"id": "",
|
||||
"userId": "",
|
||||
"source": "",
|
||||
"sourceId": "",
|
||||
"desc": "",
|
||||
"command": "",
|
||||
"status": "",
|
||||
"startTime": "",
|
||||
"finishTime": ""
|
||||
}
|
||||
|
||||
|
||||
### 分页查询执行日志
|
||||
### 分页查询批量执行日志
|
||||
POST {{baseUrl}}/asset/exec-log/query
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
@@ -75,18 +17,16 @@ Authorization: {{token}}
|
||||
"sourceId": "",
|
||||
"desc": "",
|
||||
"command": "",
|
||||
"status": "",
|
||||
"startTime": "",
|
||||
"finishTime": ""
|
||||
"status": ""
|
||||
}
|
||||
|
||||
|
||||
### 删除执行日志
|
||||
### 删除批量执行日志
|
||||
DELETE {{baseUrl}}/asset/exec-log/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 批量删除执行日志
|
||||
### 批量删除批量执行日志
|
||||
DELETE {{baseUrl}}/asset/exec-log/batch-delete?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.orion.ops.framework.common.validator.group.Page;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.asset.define.operator.ExecLogOperatorType;
|
||||
import com.orion.ops.module.asset.define.operator.ExecOperatorType;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecLogVO;
|
||||
import com.orion.ops.module.asset.service.ExecLogService;
|
||||
@@ -22,13 +22,13 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行日志 api
|
||||
* 批量执行日志 api
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 11:31
|
||||
*/
|
||||
@Tag(name = "asset - 执行日志服务")
|
||||
@Tag(name = "asset - 批量执行日志服务")
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@@ -42,7 +42,7 @@ public class ExecLogController {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "查询执行日志")
|
||||
@Operation(summary = "查询批量执行日志")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
||||
public ExecLogVO getExecLog(@RequestParam("id") Long id) {
|
||||
@@ -51,24 +51,24 @@ public class ExecLogController {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/query")
|
||||
@Operation(summary = "分页查询执行日志")
|
||||
@Operation(summary = "分页查询批量执行日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
||||
public DataGrid<ExecLogVO> getExecLogPage(@Validated(Page.class) @RequestBody ExecLogQueryRequest request) {
|
||||
return execLogService.getExecLogPage(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecLogOperatorType.DELETE)
|
||||
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除执行日志")
|
||||
@Operation(summary = "删除批量执行日志")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
||||
public Integer deleteExecLog(@RequestParam("id") Long id) {
|
||||
return execLogService.deleteExecLogById(id);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecLogOperatorType.DELETE)
|
||||
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除执行日志")
|
||||
@Operation(summary = "批量删除批量执行日志")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
||||
public Integer batchDeleteExecLog(@RequestParam("idList") List<Long> idList) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.orion.ops.module.asset.convert;
|
||||
|
||||
import com.orion.ops.module.asset.entity.domain.ExecHostLogDO;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecHostLogQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExecHostLogConvert {
|
||||
|
||||
ExecHostLogConvert MAPPER = Mappers.getMapper(ExecHostLogConvert.class);
|
||||
|
||||
ExecHostLogDO to(ExecHostLogQueryRequest request);
|
||||
|
||||
ExecHostLogVO to(ExecHostLogDO domain);
|
||||
|
||||
List<ExecHostLogVO> to(List<ExecHostLogDO> list);
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.mapstruct.factory.Mappers;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行日志 内部对象转换器
|
||||
* 批量执行日志 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.orion.ops.module.asset.dao;
|
||||
|
||||
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.ops.module.asset.entity.domain.ExecHostLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 Mapper 接口
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExecHostLogDAO extends IMapper<ExecHostLogDO> {
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import com.orion.ops.module.asset.entity.domain.ExecLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 执行日志 Mapper 接口
|
||||
* 批量执行日志 Mapper 接口
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orion.ops.module.asset.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.Module;
|
||||
import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Module("asset:exec-host-log")
|
||||
public class ExecHostLogOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "exec-host-log:create";
|
||||
|
||||
public static final String UPDATE = "exec-host-log:update";
|
||||
|
||||
public static final String DELETE = "exec-host-log:delete";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建批量执行主机日志"),
|
||||
new OperatorType(M, UPDATE, "更新批量执行主机日志"),
|
||||
new OperatorType(H, DELETE, "删除批量执行主机日志"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,23 +5,27 @@ import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperato
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.H;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.M;
|
||||
|
||||
/**
|
||||
* 执行日志 操作日志类型
|
||||
* 批量执行 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 11:31
|
||||
*/
|
||||
@Module("asset:exec-log")
|
||||
public class ExecLogOperatorType extends InitializingOperatorTypes {
|
||||
@Module("asset:exec")
|
||||
public class ExecOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String DELETE = "exec-log:delete";
|
||||
public static final String START = "exec:start";
|
||||
|
||||
public static final String DELETE_LOG = "exec:delete-log";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(H, DELETE, "删除执行日志"),
|
||||
new OperatorType(M, START, "批量执行主机命令"),
|
||||
new OperatorType(H, DELETE_LOG, "删除批量执行日志"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.orion.ops.module.asset.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "exec_host_log", autoResultMap = true)
|
||||
@Schema(name = "ExecHostLogDO", description = "批量执行主机日志 实体对象")
|
||||
public class ExecHostLogDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "执行日志id")
|
||||
@TableField("log_id")
|
||||
private Long logId;
|
||||
|
||||
@Schema(description = "主机id")
|
||||
@TableField("host_id")
|
||||
private Long hostId;
|
||||
|
||||
@Schema(description = "主机名称")
|
||||
@TableField("host_name")
|
||||
private String hostName;
|
||||
|
||||
@Schema(description = "执行状态")
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
@TableField("command")
|
||||
private String command;
|
||||
|
||||
@Schema(description = "执行参数")
|
||||
@TableField("parameter")
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "退出码")
|
||||
@TableField("exit_status")
|
||||
private Integer exitStatus;
|
||||
|
||||
@Schema(description = "日志路径")
|
||||
@TableField("log_path")
|
||||
private String logPath;
|
||||
|
||||
@Schema(description = "执行开始时间")
|
||||
@TableField("start_time")
|
||||
private Date startTime;
|
||||
|
||||
@Schema(description = "执行结束时间")
|
||||
@TableField("finish_time")
|
||||
private Date finishTime;
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import lombok.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 执行日志 实体对象
|
||||
* 批量执行日志 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
@@ -23,7 +23,7 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "exec_log", autoResultMap = true)
|
||||
@Schema(name = "ExecLogDO", description = "执行日志 实体对象")
|
||||
@Schema(name = "ExecLogDO", description = "批量执行日志 实体对象")
|
||||
public class ExecLogDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.orion.ops.module.asset.entity.request.exec;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "ExecHostLogQueryRequest", description = "批量执行主机日志 查询请求对象")
|
||||
public class ExecHostLogQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "执行日志id")
|
||||
private Long logId;
|
||||
|
||||
@Schema(description = "主机id")
|
||||
private Long hostId;
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "主机名称")
|
||||
private String hostName;
|
||||
|
||||
@Size(max = 12)
|
||||
@Schema(description = "执行状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@Schema(description = "执行参数")
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "退出码")
|
||||
private Integer exitStatus;
|
||||
|
||||
@Size(max = 512)
|
||||
@Schema(description = "日志路径")
|
||||
private String logPath;
|
||||
|
||||
@Schema(description = "执行开始时间")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
@Schema(description = "执行结束时间")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date finishTime;
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 执行日志 查询请求对象
|
||||
* 批量执行日志 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "ExecLogQueryRequest", description = "执行日志 查询请求对象")
|
||||
@Schema(name = "ExecLogQueryRequest", description = "批量执行日志 查询请求对象")
|
||||
public class ExecLogQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "id")
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.orion.ops.module.asset.entity.request.exec;
|
||||
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行 请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/3/11 11:46
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "ExecRequest", description = "批量执行 请求对象")
|
||||
public class ExecRequest extends PageRequest {
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "执行描述")
|
||||
private String desc;
|
||||
|
||||
@Schema(description = "执行模板id")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@Schema(description = "执行参数")
|
||||
private String parameter;
|
||||
|
||||
@NotEmpty
|
||||
@Schema(description = "执行主机")
|
||||
private List<Long> hostIdList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.orion.ops.module.asset.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 视图响应对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "ExecHostLogVO", description = "批量执行主机日志 视图响应对象")
|
||||
public class ExecHostLogVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "执行日志id")
|
||||
private Long logId;
|
||||
|
||||
@Schema(description = "主机id")
|
||||
private Long hostId;
|
||||
|
||||
@Schema(description = "主机名称")
|
||||
private String hostName;
|
||||
|
||||
@Schema(description = "执行状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@Schema(description = "执行参数")
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "退出码")
|
||||
private Integer exitStatus;
|
||||
|
||||
@Schema(description = "日志路径")
|
||||
private String logPath;
|
||||
|
||||
@Schema(description = "执行开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@Schema(description = "执行结束时间")
|
||||
private Date finishTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 执行日志 视图响应对象
|
||||
* 批量执行日志 视图响应对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "ExecLogVO", description = "执行日志 视图响应对象")
|
||||
@Schema(name = "ExecLogVO", description = "批量执行日志 视图响应对象")
|
||||
public class ExecLogVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orion.ops.module.asset.service;
|
||||
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecHostLogQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
public interface ExecHostLogService {
|
||||
|
||||
/**
|
||||
* 查询全部批量执行主机日志
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
List<ExecHostLogVO> getExecHostLogList(ExecHostLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除批量执行主机日志
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteExecHostLogById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除批量执行主机日志
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteExecHostLogByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import com.orion.ops.module.asset.entity.vo.ExecLogVO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行日志 服务类
|
||||
* 批量执行日志 服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
public interface ExecLogService {
|
||||
|
||||
/**
|
||||
* 查询执行日志
|
||||
* 查询批量执行日志
|
||||
*
|
||||
* @param id id
|
||||
* @return row
|
||||
@@ -24,7 +24,7 @@ public interface ExecLogService {
|
||||
ExecLogVO getExecLogById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询执行日志
|
||||
* 分页查询批量执行日志
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
@@ -40,7 +40,7 @@ public interface ExecLogService {
|
||||
Integer deleteExecLogById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除执行日志
|
||||
* 批量删除批量执行日志
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.orion.ops.module.asset.service;
|
||||
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecRequest;
|
||||
|
||||
/**
|
||||
* 批量执行服务
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/3/11 12:02
|
||||
*/
|
||||
public interface ExecService {
|
||||
|
||||
/**
|
||||
* 批量执行
|
||||
*
|
||||
* @param request request
|
||||
*/
|
||||
void startExecCommand(ExecRequest request);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.orion.ops.module.asset.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.asset.convert.ExecHostLogConvert;
|
||||
import com.orion.ops.module.asset.dao.ExecHostLogDAO;
|
||||
import com.orion.ops.module.asset.entity.domain.ExecHostLogDO;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecHostLogQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||
import com.orion.ops.module.asset.service.ExecHostLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行主机日志 服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 14:05
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ExecHostLogServiceImpl implements ExecHostLogService {
|
||||
|
||||
@Resource
|
||||
private ExecHostLogDAO execHostLogDAO;
|
||||
|
||||
@Override
|
||||
public List<ExecHostLogVO> getExecHostLogList(ExecHostLogQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<ExecHostLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return execHostLogDAO.of(wrapper).list(ExecHostLogConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteExecHostLogById(Long id) {
|
||||
log.info("ExecHostLogService-deleteExecHostLogById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
ExecHostLogDO record = execHostLogDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 删除
|
||||
int effect = execHostLogDAO.deleteById(id);
|
||||
log.info("ExecHostLogService-deleteExecHostLogById id: {}, effect: {}", id, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteExecHostLogByIdList(List<Long> idList) {
|
||||
log.info("ExecHostLogService-deleteExecHostLogByIdList idList: {}", idList);
|
||||
int effect = execHostLogDAO.deleteBatchIds(idList);
|
||||
log.info("ExecHostLogService-deleteExecHostLogByIdList effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<ExecHostLogDO> buildQueryWrapper(ExecHostLogQueryRequest request) {
|
||||
return execHostLogDAO.wrapper()
|
||||
.eq(ExecHostLogDO::getId, request.getId())
|
||||
.eq(ExecHostLogDO::getLogId, request.getLogId())
|
||||
.eq(ExecHostLogDO::getHostId, request.getHostId())
|
||||
.eq(ExecHostLogDO::getHostName, request.getHostName())
|
||||
.eq(ExecHostLogDO::getStatus, request.getStatus())
|
||||
.eq(ExecHostLogDO::getCommand, request.getCommand())
|
||||
.eq(ExecHostLogDO::getParameter, request.getParameter())
|
||||
.eq(ExecHostLogDO::getExitStatus, request.getExitStatus())
|
||||
.eq(ExecHostLogDO::getLogPath, request.getLogPath())
|
||||
.eq(ExecHostLogDO::getStartTime, request.getStartTime())
|
||||
.eq(ExecHostLogDO::getFinishTime, request.getFinishTime())
|
||||
.orderByDesc(ExecHostLogDO::getId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行日志 服务实现类
|
||||
* 批量执行日志 服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.ops.module.asset.service.impl;
|
||||
|
||||
import com.orion.ops.module.asset.dao.ExecLogDAO;
|
||||
import com.orion.ops.module.asset.entity.request.exec.ExecRequest;
|
||||
import com.orion.ops.module.asset.service.ExecService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 批量执行服务实现
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/3/11 12:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ExecServiceImpl implements ExecService {
|
||||
|
||||
@Resource
|
||||
private ExecLogDAO execLogDAO;
|
||||
|
||||
@Override
|
||||
public void startExecCommand(ExecRequest request) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orion.ops.module.asset.dao.ExecHostLogDAO">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.orion.ops.module.asset.entity.domain.ExecHostLogDO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="log_id" property="logId"/>
|
||||
<result column="host_id" property="hostId"/>
|
||||
<result column="host_name" property="hostName"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="command" property="command"/>
|
||||
<result column="parameter" property="parameter"/>
|
||||
<result column="exit_status" property="exitStatus"/>
|
||||
<result column="log_path" property="logPath"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
<result column="finish_time" property="finishTime"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="updater" property="updater"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, log_id, host_id, host_name, status, command, parameter, exit_status, log_path, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user