🔨 执行日志.
This commit is contained in:
@@ -55,14 +55,13 @@
|
|||||||
|
|
||||||
| 参数 | 描述 |
|
| 参数 | 描述 |
|
||||||
|:----------------|:-------------------------|
|
|:----------------|:-------------------------|
|
||||||
|
| execId | 执行记录id |
|
||||||
| hostId | 执行主机id |
|
| hostId | 执行主机id |
|
||||||
| hostName | 执行主机名称 |
|
| hostName | 执行主机名称 |
|
||||||
| hostCode | 执行主机编码 |
|
| hostCode | 执行主机编码 |
|
||||||
| hostAddress | 执行主机地址 |
|
| hostAddress | 执行主机地址 |
|
||||||
| userId | 执行用户id |
|
| userId | 执行用户id |
|
||||||
| username | 执行用户名 |
|
| username | 执行用户名 |
|
||||||
| execId | 执行记录id |
|
|
||||||
| execHostId | 执行主机记录id |
|
|
||||||
| uuid | 生成任务维度 uuid |
|
| uuid | 生成任务维度 uuid |
|
||||||
| uuidShort | 生成任务维度 uuid 无 '-' |
|
| uuidShort | 生成任务维度 uuid 无 '-' |
|
||||||
| hostUuid | 生成机器维度 uuid |
|
| hostUuid | 生成机器维度 uuid |
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
### 分页查询批量执行主机日志
|
|
||||||
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}}
|
|
||||||
|
|
||||||
###
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -8,7 +8,9 @@ import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
|||||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||||
import com.orion.ops.module.asset.define.operator.ExecOperatorType;
|
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.request.exec.ExecLogQueryRequest;
|
||||||
|
import com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||||
import com.orion.ops.module.asset.entity.vo.ExecLogVO;
|
import com.orion.ops.module.asset.entity.vo.ExecLogVO;
|
||||||
|
import com.orion.ops.module.asset.service.ExecHostLogService;
|
||||||
import com.orion.ops.module.asset.service.ExecLogService;
|
import com.orion.ops.module.asset.service.ExecLogService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -22,13 +24,13 @@ import javax.annotation.Resource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量执行日志 api
|
* 执行日志 api
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
* @version 1.0.1
|
* @version 1.0.1
|
||||||
* @since 2024-3-11 11:31
|
* @since 2024-3-11 11:31
|
||||||
*/
|
*/
|
||||||
@Tag(name = "asset - 批量执行日志服务")
|
@Tag(name = "asset - 执行日志服务")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Validated
|
@Validated
|
||||||
@RestWrapper
|
@RestWrapper
|
||||||
@@ -40,9 +42,12 @@ public class ExecLogController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ExecLogService execLogService;
|
private ExecLogService execLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ExecHostLogService execHostLogService;
|
||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "查询批量执行日志")
|
@Operation(summary = "查询执行日志")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
||||||
public ExecLogVO getExecLog(@RequestParam("id") Long id) {
|
public ExecLogVO getExecLog(@RequestParam("id") Long id) {
|
||||||
@@ -51,15 +56,23 @@ public class ExecLogController {
|
|||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
@Operation(summary = "分页查询批量执行日志")
|
@Operation(summary = "分页查询执行日志")
|
||||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
||||||
public DataGrid<ExecLogVO> getExecLogPage(@Validated(Page.class) @RequestBody ExecLogQueryRequest request) {
|
public DataGrid<ExecLogVO> getExecLogPage(@Validated(Page.class) @RequestBody ExecLogQueryRequest request) {
|
||||||
return execLogService.getExecLogPage(request);
|
return execLogService.getExecLogPage(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "查询全部执行主机日志")
|
||||||
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:query')")
|
||||||
|
public List<ExecHostLogVO> getExecHostLogList(@RequestParam("logId") Long logId) {
|
||||||
|
return execHostLogService.getExecHostLogList(logId);
|
||||||
|
}
|
||||||
|
|
||||||
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除批量执行日志")
|
@Operation(summary = "删除执行日志")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
||||||
public Integer deleteExecLog(@RequestParam("id") Long id) {
|
public Integer deleteExecLog(@RequestParam("id") Long id) {
|
||||||
@@ -68,12 +81,20 @@ public class ExecLogController {
|
|||||||
|
|
||||||
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
@OperatorLog(ExecOperatorType.DELETE_LOG)
|
||||||
@DeleteMapping("/batch-delete")
|
@DeleteMapping("/batch-delete")
|
||||||
@Operation(summary = "批量删除批量执行日志")
|
@Operation(summary = "删除执行日志")
|
||||||
@Parameter(name = "idList", description = "idList", required = true)
|
@Parameter(name = "idList", description = "idList", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
||||||
public Integer batchDeleteExecLog(@RequestParam("idList") List<Long> idList) {
|
public Integer batchDeleteExecLog(@RequestParam("idList") List<Long> idList) {
|
||||||
return execLogService.deleteExecLogByIdList(idList);
|
return execLogService.deleteExecLogByIdList(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-host")
|
||||||
|
@Operation(summary = "删除执行主机日志")
|
||||||
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('asset:exec-log:delete')")
|
||||||
|
public Integer deleteExecHostLog(@RequestParam("id") Long id) {
|
||||||
|
return execHostLogService.deleteExecHostLogById(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.orion.ops.module.asset.convert;
|
package com.orion.ops.module.asset.convert;
|
||||||
|
|
||||||
import com.orion.ops.module.asset.entity.domain.ExecHostLogDO;
|
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.entity.vo.ExecHostLogVO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
@@ -20,8 +19,6 @@ public interface ExecHostLogConvert {
|
|||||||
|
|
||||||
ExecHostLogConvert MAPPER = Mappers.getMapper(ExecHostLogConvert.class);
|
ExecHostLogConvert MAPPER = Mappers.getMapper(ExecHostLogConvert.class);
|
||||||
|
|
||||||
ExecHostLogDO to(ExecHostLogQueryRequest request);
|
|
||||||
|
|
||||||
ExecHostLogVO to(ExecHostLogDO domain);
|
ExecHostLogVO to(ExecHostLogDO domain);
|
||||||
|
|
||||||
List<ExecHostLogVO> to(List<ExecHostLogDO> list);
|
List<ExecHostLogVO> to(List<ExecHostLogDO> list);
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
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, "删除批量执行主机日志"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -61,16 +61,4 @@ public class ExecHostLogVO implements Serializable {
|
|||||||
@Schema(description = "执行结束时间")
|
@Schema(description = "执行结束时间")
|
||||||
private Date finishTime;
|
private Date finishTime;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
@Schema(description = "修改时间")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@Schema(description = "创建人")
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
@Schema(description = "修改人")
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.orion.ops.module.asset.service;
|
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 com.orion.ops.module.asset.entity.vo.ExecHostLogVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,10 +16,18 @@ public interface ExecHostLogService {
|
|||||||
/**
|
/**
|
||||||
* 查询全部批量执行主机日志
|
* 查询全部批量执行主机日志
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param logId logId
|
||||||
* @return rows
|
* @return rows
|
||||||
*/
|
*/
|
||||||
List<ExecHostLogVO> getExecHostLogList(ExecHostLogQueryRequest request);
|
List<ExecHostLogVO> getExecHostLogList(Long logId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除批量执行主机日志
|
||||||
|
*
|
||||||
|
* @param logIdList logIdList
|
||||||
|
* @return effect
|
||||||
|
*/
|
||||||
|
Integer deleteExecHostLogByLogId(List<Long> logIdList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除批量执行主机日志
|
* 删除批量执行主机日志
|
||||||
@@ -30,12 +37,4 @@ public interface ExecHostLogService {
|
|||||||
*/
|
*/
|
||||||
Integer deleteExecHostLogById(Long id);
|
Integer deleteExecHostLogById(Long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除批量执行主机日志
|
|
||||||
*
|
|
||||||
* @param idList idList
|
|
||||||
* @return effect
|
|
||||||
*/
|
|
||||||
Integer deleteExecHostLogByIdList(List<Long> idList);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ public interface ExecLogService {
|
|||||||
*/
|
*/
|
||||||
DataGrid<ExecLogVO> getExecLogPage(ExecLogQueryRequest request);
|
DataGrid<ExecLogVO> getExecLogPage(ExecLogQueryRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批量执行日志数量
|
||||||
|
*
|
||||||
|
* @param request request
|
||||||
|
* @return count
|
||||||
|
*/
|
||||||
|
Long queryExecLogCount(ExecLogQueryRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除执行日志
|
* 删除执行日志
|
||||||
*
|
*
|
||||||
@@ -47,4 +55,12 @@ public interface ExecLogService {
|
|||||||
*/
|
*/
|
||||||
Integer deleteExecLogByIdList(List<Long> idList);
|
Integer deleteExecLogByIdList(List<Long> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理执行日志
|
||||||
|
*
|
||||||
|
* @param request request
|
||||||
|
* @return effect
|
||||||
|
*/
|
||||||
|
Integer clearExecLog(ExecLogQueryRequest request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package com.orion.ops.module.asset.service.impl;
|
package com.orion.ops.module.asset.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.ops.framework.common.utils.Valid;
|
import com.orion.ops.framework.common.utils.Valid;
|
||||||
import com.orion.ops.module.asset.convert.ExecHostLogConvert;
|
import com.orion.ops.module.asset.convert.ExecHostLogConvert;
|
||||||
import com.orion.ops.module.asset.dao.ExecHostLogDAO;
|
import com.orion.ops.module.asset.dao.ExecHostLogDAO;
|
||||||
import com.orion.ops.module.asset.entity.domain.ExecHostLogDO;
|
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.entity.vo.ExecHostLogVO;
|
||||||
import com.orion.ops.module.asset.service.ExecHostLogService;
|
import com.orion.ops.module.asset.service.ExecHostLogService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,11 +31,31 @@ public class ExecHostLogServiceImpl implements ExecHostLogService {
|
|||||||
private ExecHostLogDAO execHostLogDAO;
|
private ExecHostLogDAO execHostLogDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ExecHostLogVO> getExecHostLogList(ExecHostLogQueryRequest request) {
|
public List<ExecHostLogVO> getExecHostLogList(Long logId) {
|
||||||
// 条件
|
return execHostLogDAO.of()
|
||||||
LambdaQueryWrapper<ExecHostLogDO> wrapper = this.buildQueryWrapper(request);
|
.createWrapper()
|
||||||
// 查询
|
.eq(ExecHostLogDO::getLogId, logId)
|
||||||
return execHostLogDAO.of(wrapper).list(ExecHostLogConvert.MAPPER::to);
|
.then()
|
||||||
|
.list(ExecHostLogConvert.MAPPER::to);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Integer deleteExecHostLogByLogId(List<Long> logIdList) {
|
||||||
|
log.info("ExecHostLogService-deleteExecHostLogByLogId logIdList: {}", logIdList);
|
||||||
|
int effect = 0;
|
||||||
|
if (Lists.isEmpty(logIdList)) {
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
// 分批次删除
|
||||||
|
List<List<Long>> partitions = Lists.partition(logIdList, 500);
|
||||||
|
for (List<Long> batch : partitions) {
|
||||||
|
LambdaQueryWrapper<ExecHostLogDO> wrapper = execHostLogDAO.wrapper()
|
||||||
|
.in(ExecHostLogDO::getLogId, batch);
|
||||||
|
effect += execHostLogDAO.delete(wrapper);
|
||||||
|
}
|
||||||
|
log.info("ExecHostLogService-deleteExecHostLogByLogId effect: {}", logIdList);
|
||||||
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,34 +70,4 @@ public class ExecHostLogServiceImpl implements ExecHostLogService {
|
|||||||
return 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package com.orion.ops.module.asset.service.impl;
|
package com.orion.ops.module.asset.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.orion.lang.define.wrapper.DataGrid;
|
import com.orion.lang.define.wrapper.DataGrid;
|
||||||
import com.orion.lang.utils.Arrays1;
|
import com.orion.lang.utils.Arrays1;
|
||||||
|
import com.orion.ops.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.ops.framework.common.utils.Valid;
|
import com.orion.ops.framework.common.utils.Valid;
|
||||||
import com.orion.ops.module.asset.convert.ExecLogConvert;
|
import com.orion.ops.module.asset.convert.ExecLogConvert;
|
||||||
import com.orion.ops.module.asset.dao.ExecLogDAO;
|
import com.orion.ops.module.asset.dao.ExecLogDAO;
|
||||||
import com.orion.ops.module.asset.entity.domain.ExecLogDO;
|
import com.orion.ops.module.asset.entity.domain.ExecLogDO;
|
||||||
|
import com.orion.ops.module.asset.entity.domain.HostConnectLogDO;
|
||||||
import com.orion.ops.module.asset.entity.request.exec.ExecLogQueryRequest;
|
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.entity.vo.ExecLogVO;
|
||||||
import com.orion.ops.module.asset.service.ExecLogService;
|
import com.orion.ops.module.asset.service.ExecLogService;
|
||||||
@@ -16,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量执行日志 服务实现类
|
* 批量执行日志 服务实现类
|
||||||
@@ -50,6 +54,11 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
.dataGrid(ExecLogConvert.MAPPER::to);
|
.dataGrid(ExecLogConvert.MAPPER::to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long queryExecLogCount(ExecLogQueryRequest request) {
|
||||||
|
return execLogDAO.selectCount(this.buildQueryWrapper(request));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deleteExecLogById(Long id) {
|
public Integer deleteExecLogById(Long id) {
|
||||||
log.info("ExecLogService-deleteExecLogById id: {}", id);
|
log.info("ExecLogService-deleteExecLogById id: {}", id);
|
||||||
@@ -70,6 +79,29 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer clearExecLog(ExecLogQueryRequest request) {
|
||||||
|
log.info("ExecLogService.clearExecLog start {}", JSON.toJSONString(request));
|
||||||
|
// 查询
|
||||||
|
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request)
|
||||||
|
.select(ExecLogDO::getId);
|
||||||
|
List<Long> idList = execLogDAO.selectList(wrapper)
|
||||||
|
.stream()
|
||||||
|
.map(ExecLogDO::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
int effect = 0;
|
||||||
|
if (!idList.isEmpty()) {
|
||||||
|
// 删除
|
||||||
|
effect = execLogDAO.delete(wrapper);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
log.info("ExecLogService.clearExecLog finish {}", effect);
|
||||||
|
// 设置日志参数
|
||||||
|
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建查询 wrapper
|
* 构建查询 wrapper
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user