diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostConnectLogOperatorType.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostConnectLogOperatorType.java
index bf9e3418..e9b7f53e 100644
--- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostConnectLogOperatorType.java
+++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostConnectLogOperatorType.java
@@ -25,8 +25,8 @@ public class HostConnectLogOperatorType extends InitializingOperatorTypes {
@Override
public OperatorType[] types() {
return new OperatorType[]{
- new OperatorType(H, DELETE, "删除主机连接记录 ${count}条"),
- new OperatorType(H, CLEAR, "清空主机连接记录 ${count}条"),
+ new OperatorType(H, DELETE, "删除主机连接记录 ${count} 条"),
+ new OperatorType(H, CLEAR, "清空主机连接记录 ${count} 条"),
new OperatorType(M, FORCE_OFFLINE, "强制下线主机连接 ${hostName}"),
};
}
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/OperatorLogController.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/OperatorLogController.java
index 4e806383..96420439 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/OperatorLogController.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/OperatorLogController.java
@@ -1,16 +1,18 @@
package com.orion.ops.module.infra.controller;
import com.orion.lang.define.wrapper.DataGrid;
+import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
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.security.core.utils.SecurityUtils;
import com.orion.ops.framework.web.core.annotation.RestWrapper;
+import com.orion.ops.module.infra.define.operator.OperatorLogOperatorType;
import com.orion.ops.module.infra.entity.request.operator.OperatorLogQueryRequest;
import com.orion.ops.module.infra.entity.vo.LoginHistoryVO;
import com.orion.ops.module.infra.entity.vo.OperatorLogVO;
import com.orion.ops.module.infra.service.OperatorLogService;
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;
@@ -47,6 +49,29 @@ public class OperatorLogController {
return operatorLogService.getOperatorLogPage(request);
}
+ @OperatorLog(OperatorLogOperatorType.DELETE)
+ @DeleteMapping("/delete")
+ @Operation(summary = "删除操作日志")
+ @Parameter(name = "idList", description = "idList", required = true)
+ @PreAuthorize("@ss.hasPermission('infra:operator-log:delete')")
+ public Integer deleteOperatorLog(@RequestParam("idList") List idList) {
+ return operatorLogService.deleteOperatorLog(idList);
+ }
+
+ @PostMapping("/query-count")
+ @Operation(summary = "查询操作日志数量")
+ public Long getOperatorLogCount(@RequestBody OperatorLogQueryRequest request) {
+ return operatorLogService.getOperatorLogCount(request);
+ }
+
+ @OperatorLog(OperatorLogOperatorType.CLEAR)
+ @PostMapping("/clear")
+ @Operation(summary = "清空操作日志")
+ @PreAuthorize("@ss.hasPermission('infra:operator-log:clear')")
+ public Integer clearOperatorLog(@RequestBody OperatorLogQueryRequest request) {
+ return operatorLogService.clearOperatorLog(request);
+ }
+
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/login-history")
@Operation(summary = "查询用户登录日志")
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/convert/OperatorLogConvert.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/convert/OperatorLogConvert.java
index cd3448b2..a2f557dd 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/convert/OperatorLogConvert.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/convert/OperatorLogConvert.java
@@ -6,6 +6,7 @@ import com.orion.ops.module.infra.entity.request.operator.OperatorLogQueryReques
import com.orion.ops.module.infra.entity.vo.LoginHistoryVO;
import com.orion.ops.module.infra.entity.vo.OperatorLogVO;
import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
/**
@@ -24,6 +25,7 @@ public interface OperatorLogConvert {
OperatorLogDO to(OperatorLogQueryRequest request);
+ @Mapping(target = "extra", ignore = true)
OperatorLogVO to(OperatorLogDO domain);
LoginHistoryVO toLoginHistory(OperatorLogDO domain);
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/OperatorLogOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/OperatorLogOperatorType.java
new file mode 100644
index 00000000..4e781b92
--- /dev/null
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/OperatorLogOperatorType.java
@@ -0,0 +1,31 @@
+package com.orion.ops.module.infra.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.H;
+
+/**
+ * 操作日志 操作日志类型
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2024-3-4 16:20
+ */
+@Module("infra:operator-log")
+public class OperatorLogOperatorType extends InitializingOperatorTypes {
+
+ public static final String DELETE = "operator-log:delete";
+
+ public static final String CLEAR = "operator-log:clear";
+
+ @Override
+ public OperatorType[] types() {
+ return new OperatorType[]{
+ new OperatorType(H, DELETE, "删除操作日志 ${count} 条"),
+ new OperatorType(H, CLEAR, "清空操作日志 ${count} 条"),
+ };
+ }
+
+}
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/OperatorLogVO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/OperatorLogVO.java
index ec49e46f..e8bea981 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/OperatorLogVO.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/OperatorLogVO.java
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
+import java.util.Map;
/**
* 操作日志 视图响应对象
@@ -59,7 +60,7 @@ public class OperatorLogVO implements Serializable {
private String logInfo;
@Schema(description = "参数")
- private String extra;
+ private Map extra;
@Schema(description = "操作结果 0失败 1成功")
private Integer result;
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/OperatorLogService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/OperatorLogService.java
index 35322bed..7a4e9f43 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/OperatorLogService.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/OperatorLogService.java
@@ -32,6 +32,30 @@ public interface OperatorLogService {
*/
DataGrid getOperatorLogPage(OperatorLogQueryRequest request);
+ /**
+ * 删除操作日志
+ *
+ * @param idList idList
+ * @return effect
+ */
+ Integer deleteOperatorLog(List idList);
+
+ /**
+ * 查询操作日志数量
+ *
+ * @param request request
+ * @return count
+ */
+ Long getOperatorLogCount(OperatorLogQueryRequest request);
+
+ /**
+ * 清空操作日志
+ *
+ * @param request request
+ * @return effect
+ */
+ Integer clearOperatorLog(OperatorLogQueryRequest request);
+
/**
* 查询用户登录日志
*
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/OperatorLogServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/OperatorLogServiceImpl.java
index 4ae801e5..787a0b4a 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/OperatorLogServiceImpl.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/OperatorLogServiceImpl.java
@@ -1,9 +1,11 @@
package com.orion.ops.module.infra.service.impl;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.define.wrapper.DataGrid;
import com.orion.lang.utils.Arrays1;
import com.orion.ops.framework.biz.operator.log.core.model.OperatorLogModel;
+import com.orion.ops.framework.biz.operator.log.core.utils.OperatorLogs;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.module.infra.convert.OperatorLogConvert;
import com.orion.ops.module.infra.dao.OperatorLogDAO;
@@ -48,7 +50,38 @@ public class OperatorLogServiceImpl implements OperatorLogService {
// 查询
return operatorLogDAO.of(wrapper)
.page(request)
- .dataGrid(OperatorLogConvert.MAPPER::to);
+ .dataGrid(s -> {
+ OperatorLogVO vo = OperatorLogConvert.MAPPER.to(s);
+ vo.setExtra(JSON.parseObject(s.getExtra()));
+ return vo;
+ });
+ }
+
+ @Override
+ public Integer deleteOperatorLog(List idList) {
+ log.info("OperatorLogService.deleteOperatorLog start {}", JSON.toJSONString(idList));
+ int effect = operatorLogDAO.deleteBatchIds(idList);
+ log.info("OperatorLogService.deleteOperatorLog finish {}", effect);
+ // 设置日志参数
+ OperatorLogs.add(OperatorLogs.COUNT, effect);
+ return effect;
+ }
+
+ @Override
+ public Long getOperatorLogCount(OperatorLogQueryRequest request) {
+ return operatorLogDAO.selectCount(this.buildQueryWrapper(request));
+ }
+
+ @Override
+ public Integer clearOperatorLog(OperatorLogQueryRequest request) {
+ log.info("OperatorLogService.clearOperatorLog start {}", JSON.toJSONString(request));
+ // 删除
+ LambdaQueryWrapper wrapper = this.buildQueryWrapper(request);
+ int effect = operatorLogDAO.delete(wrapper);
+ log.info("OperatorLogService.clearOperatorLog finish {}", effect);
+ // 设置日志参数
+ OperatorLogs.add(OperatorLogs.COUNT, effect);
+ return effect;
}
@Override
diff --git a/orion-ops-ui/src/api/user/operator-log.ts b/orion-ops-ui/src/api/user/operator-log.ts
index 73e553ac..f001b88a 100644
--- a/orion-ops-ui/src/api/user/operator-log.ts
+++ b/orion-ops-ui/src/api/user/operator-log.ts
@@ -1,5 +1,6 @@
import type { DataGrid, Pagination } from '@/types/global';
import axios from 'axios';
+import qs from 'query-string';
/**
* 操作日志查询参数
@@ -60,6 +61,32 @@ export function getOperatorLogPage(request: OperatorLogQueryRequest) {
return axios.post>('/infra/operator-log/query', request);
}
+/**
+ * 删除操作日志
+ */
+export function deleteOperatorLog(idList: Array) {
+ return axios.delete('/infra/operator-log/delete', {
+ params: { idList },
+ paramsSerializer: params => {
+ return qs.stringify(params, { arrayFormat: 'comma' });
+ }
+ });
+}
+
+/**
+ * 查询操作日志数量
+ */
+export function getOperatorLogCount(request: OperatorLogQueryRequest) {
+ return axios.post('/infra/operator-log/query-count', request);
+}
+
+/**
+ * 清空操作日志
+ */
+export function clearOperatorLog(request: OperatorLogQueryRequest) {
+ return axios.post('/infra/operator-log/clear', request);
+}
+
/**
* 查询登录日志
*/
diff --git a/orion-ops-ui/src/views/dashboard/workplace/index.vue b/orion-ops-ui/src/views/dashboard/workplace/index.vue
index 7dfc0c01..170f76e6 100644
--- a/orion-ops-ui/src/views/dashboard/workplace/index.vue
+++ b/orion-ops-ui/src/views/dashboard/workplace/index.vue
@@ -14,9 +14,8 @@
title="操作日志"
:header-style="{ paddingBottom: '0' }"
:body-style="{ padding: '8px 20px 8px 20px' }">
-
+
@@ -40,10 +36,9 @@
import type { PropType } from 'vue';
import { ref, onBeforeMount } from 'vue';
import { useCacheStore, useDictStore } from '@/store';
- import { dictKeys } from '../../operator-log/types/const';
- import OperatorLogQueryHeader from '../../operator-log/components/operator-log-query-header.vue';
- import OperatorLogTable from '../../operator-log/components/operator-log-table.vue';
- import JsonEditorModal from '@/components/view/json-editor/json-editor-modal.vue';
+ import { dictKeys } from '@/views/user/operator-log/types/const';
+ import OperatorLogQueryHeader from '@/views/user/operator-log/components/operator-log-query-header.vue';
+ import OperatorLogSimpleTable from '@/views/user/operator-log/components/operator-log-simple-table.vue';
const props = defineProps({
user: Object as PropType,
@@ -53,7 +48,6 @@
const render = ref();
const table = ref();
- const view = ref();
onBeforeMount(async () => {
// 加载字典值
diff --git a/orion-ops-ui/src/views/user/info/index.vue b/orion-ops-ui/src/views/user/info/index.vue
index cafb3145..3d7ab9f4 100644
--- a/orion-ops-ui/src/views/user/info/index.vue
+++ b/orion-ops-ui/src/views/user/info/index.vue
@@ -28,7 +28,7 @@
-
+
@@ -48,14 +48,15 @@
+
+
+
+
diff --git a/orion-ops-ui/src/views/user/operator-log/components/operator-log-simple-table.vue b/orion-ops-ui/src/views/user/operator-log/components/operator-log-simple-table.vue
new file mode 100644
index 00000000..377750a6
--- /dev/null
+++ b/orion-ops-ui/src/views/user/operator-log/components/operator-log-simple-table.vue
@@ -0,0 +1,167 @@
+
+
+ fetchTableData(page, pagination.pageSize)"
+ @page-size-change="(size) => fetchTableData(1, size)"
+ :bordered="false">
+
+
+ {{ getDictValue(operatorLogModuleKey, record.module) }}
+
+ {{ getDictValue(operatorLogTypeKey, record.type) }}
+
+
+
+
+ {{ getDictValue(operatorRiskLevelKey, record.riskLevel) }}
+
+
+
+
+
+ {{ getDictValue(operatorLogResultKey, record.result) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/orion-ops-ui/src/views/user/operator-log/components/operator-log-table.vue b/orion-ops-ui/src/views/user/operator-log/components/operator-log-table.vue
index dbc5f086..a1b241f6 100644
--- a/orion-ops-ui/src/views/user/operator-log/components/operator-log-table.vue
+++ b/orion-ops-ui/src/views/user/operator-log/components/operator-log-table.vue
@@ -1,117 +1,190 @@
- fetchTableData(page, pagination.pageSize)"
- @page-size-change="(size) => fetchTableData(1, size)"
- :bordered="false">
-
-
- {{ getDictValue(operatorLogModuleKey, record.module) }}
-
-
-
- {{ getDictValue(operatorLogTypeKey, record.type) }}
-
-
-
-
- {{ getDictValue(operatorRiskLevelKey, record.riskLevel) }}
-
-
-
-
-
- {{ getDictValue(operatorLogResultKey, record.result) }}
-
-
-
-
-
-
-
-
-
-
-
-
- 详情
-
+
+
+
+ fetchTableData(undefined, undefined, e)" />
+
+
+
+
+
+
+
+
+
+
+
+ 清空
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
+
-
+
+ fetchTableData(page, pagination.pageSize)"
+ @page-size-change="(size) => fetchTableData(1, size)"
+ :bordered="false">
+
+
+ {{ getDictValue(operatorLogModuleKey, record.module) }}
+
+ {{ getDictValue(operatorLogTypeKey, record.type) }}
+
+
+
+
+ {{ getDictValue(operatorRiskLevelKey, record.riskLevel) }}
+
+
+
+
+
+ {{ getDictValue(operatorLogResultKey, record.result) }}
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情
+
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+