From 33ef30984827c3edff2325b4a2943877c36dadbb Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 18 Aug 2023 18:10:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=97=A5=E5=BF=97=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3-=E7=B3=BB=E7=BB=9F=E8=8F=9C=E5=8D=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/sdk/domain/OperationLog.java | 7 +- .../sdk/domain/OperationLogExample.java | 70 ------------------- .../sdk/mapper/OperationLogMapper.xml | 41 +++-------- .../migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql | 1 - .../sdk/log/constants/OperationLogModule.java | 19 +++++ .../sdk/log/service/OperationLogService.java | 5 +- .../sdk/mapper/BaseOperationLogMapper.xml | 7 +- .../sdk/service/SystemParameterService.java | 4 +- .../resources/i18n/system_en_US.properties | 3 +- .../resources/i18n/system_zh_CN.properties | 2 + .../resources/i18n/system_zh_TW.properties | 2 + .../controller/OperationLogController.java | 20 ++++-- .../system/controller/UserController.java | 8 --- .../system/service/AuthSourceLogService.java | 8 +-- .../src/main/resources/permission.json | 18 +++++ .../OperationLogControllerTests.java | 8 +-- .../SystemParameterControllerTests.java | 2 +- 17 files changed, 86 insertions(+), 139 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java index eefa3c8a10..bd10212c88 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java @@ -36,11 +36,7 @@ public class OperationLog implements Serializable { @Schema(description = "资源id") private String sourceId; - @Schema(description = "批次id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operation_log.batch_id.not_blank}", groups = {Created.class}) - private String batchId; - - @Schema(description = "操作方法", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "操作方法", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{operation_log.method.not_blank}", groups = {Created.class}) @Size(min = 1, max = 255, message = "{operation_log.method.length_range}", groups = {Created.class, Updated.class}) private String method; @@ -68,7 +64,6 @@ public class OperationLog implements Serializable { createTime("create_time", "createTime", "BIGINT", false), createUser("create_user", "createUser", "VARCHAR", false), sourceId("source_id", "sourceId", "VARCHAR", false), - batchId("batch_id", "batchId", "VARCHAR", false), method("method", "method", "VARCHAR", true), type("type", "type", "VARCHAR", true), module("module", "module", "VARCHAR", true), diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java index 8a0b5cd2a0..4bea901000 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java @@ -514,76 +514,6 @@ public class OperationLogExample { return (Criteria) this; } - public Criteria andBatchIdIsNull() { - addCriterion("batch_id is null"); - return (Criteria) this; - } - - public Criteria andBatchIdIsNotNull() { - addCriterion("batch_id is not null"); - return (Criteria) this; - } - - public Criteria andBatchIdEqualTo(String value) { - addCriterion("batch_id =", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdNotEqualTo(String value) { - addCriterion("batch_id <>", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdGreaterThan(String value) { - addCriterion("batch_id >", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdGreaterThanOrEqualTo(String value) { - addCriterion("batch_id >=", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdLessThan(String value) { - addCriterion("batch_id <", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdLessThanOrEqualTo(String value) { - addCriterion("batch_id <=", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdLike(String value) { - addCriterion("batch_id like", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdNotLike(String value) { - addCriterion("batch_id not like", value, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdIn(List values) { - addCriterion("batch_id in", values, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdNotIn(List values) { - addCriterion("batch_id not in", values, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdBetween(String value1, String value2) { - addCriterion("batch_id between", value1, value2, "batchId"); - return (Criteria) this; - } - - public Criteria andBatchIdNotBetween(String value1, String value2) { - addCriterion("batch_id not between", value1, value2, "batchId"); - return (Criteria) this; - } - public Criteria andMethodIsNull() { addCriterion("`method` is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml index 427f462572..15b5ff3288 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml @@ -8,7 +8,6 @@ - @@ -74,8 +73,8 @@ - id, project_id, organization_id, create_time, create_user, source_id, batch_id, `method`, - `type`, `module`, content, `path` + id, project_id, organization_id, create_time, create_user, source_id, `method`, `type`, + `module`, content, `path` SELECT - t.id, t.project_id, t.organization_id, t.create_time, @@ -21,10 +20,10 @@ AND t.create_time BETWEEN #{request.startTime} AND #{request.endTime} - + AND t.project_id ]]> 'SYSTEM' - + AND t.project_id ]]> 'ORGANIZATION' @@ -49,7 +48,7 @@ AND t.content like CONCAT('%', #{request.content},'%') - ORDER BY t.oper_time DESC + ORDER BY t.create_time DESC diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java index 4084463171..5a669530e4 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java @@ -228,7 +228,7 @@ public class SystemParameterService { "system-parameter", null, OperationLogType.ADD.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER, "基础设置"); dto.setPath("/system/parameter/save/base-info"); @@ -245,7 +245,7 @@ public class SystemParameterService { "system-parameter", null, OperationLogType.ADD.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER, "基础设置"); dto.setPath("/system/parameter/edit/email-info"); diff --git a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties index 01e60975b6..4f034f23d5 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties @@ -197,7 +197,8 @@ permission.service_integration.name=Service Integration permission.system_auth=Authorization Management permission.system_organization_project_member.add=Add member permission.system_organization_project_member.delete=Delete member - +permission.system_operation_log.name=Operation log +permission.organization_operation_log.name=Operation log diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties index a08fe3ee6a..f1b36bfd80 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties @@ -196,6 +196,8 @@ permission.service_integration.name=服务集成 permission.system_auth=授权管理 permission.system_organization_project_member.add=添加成员 permission.system_organization_project_member.delete=删除成员 +permission.system_operation_log.name=日志 +permission.organization_operation_log.name=日志 diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties index 7c9d410112..46ef98410d 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties @@ -196,4 +196,6 @@ permission.service_integration.name=服務集成 permission.system_auth=授權管理 permission.system_organization_project_member.add=添加成员 permission.system_organization_project_member.delete=删除成员 +permission.system_operation_log.name=日志 +permission.organization_operation_log.name=日志 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java index 885372b5b8..74d2c46669 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java @@ -4,21 +4,21 @@ package io.metersphere.system.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.sdk.constants.PermissionConstants; - import io.metersphere.sdk.log.service.OperationLogService; import io.metersphere.sdk.log.vo.OperationLogRequest; import io.metersphere.sdk.log.vo.OperationLogResponse; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; +import io.metersphere.system.domain.User; import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse; import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.SystemProjectService; +import io.metersphere.system.service.UserService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -39,10 +39,13 @@ public class OperationLogController { @Resource private OperationLogService operationLogService; + @Resource + private UserService userService; + @GetMapping("/get/options") @Operation(summary = "获取组织/项目级联下拉框选项") - @RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR) + @RequiresPermissions(PermissionConstants.SYSTEM_OPERATING_LOG_READ) public OrganizationProjectOptionsResponse getOptions() { //获取全部组织 @@ -59,11 +62,20 @@ public class OperationLogController { @PostMapping("/list") - @Operation(summary = "操作日志列表查询") + @Operation(summary = "组织操作日志列表查询") @RequiresPermissions(PermissionConstants.SYSTEM_OPERATING_LOG_READ) public Pager> list(@Validated @RequestBody OperationLogRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); return PageUtils.setPageInfo(page, operationLogService.list(request)); } + + + @GetMapping("/user/list") + @Operation(summary = "系统日志页面,获取用户列表") + @RequiresPermissions(PermissionConstants.SYSTEM_OPERATING_LOG_READ) + public List getUserList() { + List userList = userService.getUserList(); + return userList; + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java index e81375c26e..8540f53f20 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java @@ -15,7 +15,6 @@ import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.sdk.util.SessionUtils; import io.metersphere.system.domain.Organization; -import io.metersphere.system.domain.User; import io.metersphere.system.dto.UserBatchCreateDTO; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.OrganizationMemberBatchRequest; @@ -108,13 +107,6 @@ public class UserController { return userService.deleteUser(request, SessionUtils.getUserId()); } - @GetMapping("/list") - @Operation(summary = "系统/组织日志页面,获取用户列表") - @RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR) - public List getUserList() { - return userService.getUserList(); - } - @PostMapping("/reset/password") @Operation(summary = "重置用户密码") @RequiresPermissions(PermissionConstants.SYSTEM_USER_READ_UPDATE) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java index 0bf0195ca0..79d7069c19 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java @@ -32,7 +32,7 @@ public class AuthSourceLogService { request.getId(), null, OperationLogType.ADD.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER_AUTH_CONFIG, request.getName()); dto.setModifiedValue(JSON.toJSONBytes(request)); @@ -55,7 +55,7 @@ public class AuthSourceLogService { request.getId(), null, OperationLogType.UPDATE.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER_AUTH_CONFIG, request.getName()); dto.setOriginalValue(JSON.toJSONBytes(authSource)); @@ -73,7 +73,7 @@ public class AuthSourceLogService { id, null, OperationLogType.UPDATE.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER_AUTH_CONFIG, authSource.getName()); dto.setOriginalValue(JSON.toJSONBytes(authSource)); @@ -98,7 +98,7 @@ public class AuthSourceLogService { authSource.getId(), null, OperationLogType.DELETE.name(), - OperationLogModule.SYSTEM_PARAMETER_SETTING, + OperationLogModule.SETTING_SYSTEM_PARAMETER_AUTH_CONFIG, authSource.getName()); dto.setOriginalValue(JSON.toJSONBytes(authSource)); diff --git a/backend/services/system-setting/src/main/resources/permission.json b/backend/services/system-setting/src/main/resources/permission.json index fe66097adf..ee3e9bbc67 100644 --- a/backend/services/system-setting/src/main/resources/permission.json +++ b/backend/services/system-setting/src/main/resources/permission.json @@ -136,6 +136,15 @@ "id": "SYSTEM_AUTH:READ+UPDATE" } ] + }, + { + "id": "SYSTEM_OPERATION_LOG", + "name": "permission.system_operation_log.name", + "permissions": [ + { + "id": "SYSTEM_OPERATING_LOG:READ" + } + ] } ] }, @@ -227,6 +236,15 @@ } ] + }, + { + "id": "ORGANIZATION_OPERATION_LOG", + "name": "permission.organization_operation_log.name", + "permissions": [ + { + "id": "ORGANIZATION_OPERATING_LOG:READ" + } + ] } ] } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java index f6692c9e5b..5f11ab17b5 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java @@ -28,11 +28,11 @@ public class OperationLogControllerTests extends BaseTest { public static final String OPTIONS_LIST = "/operation/log/get/options"; - public static final String USER_LIST = "/system/user/list"; + public static final String USER_LIST = "/operation/log/user/list"; - public static final String SYSTEM = "system"; - public static final String ORGANIZATION = "organization"; - public static final String PROJECT = "project"; + public static final String SYSTEM = "SYSTEM"; + public static final String ORGANIZATION = "ORGANIZATION"; + public static final String PROJECT = "PROJECT"; /** diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java index 0ed99aba5c..7d21a838ff 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java @@ -131,7 +131,7 @@ public class SystemParameterControllerTests extends BaseTest { hashMap.put("smtp.password", "test"); hashMap.put("smtp.from", "aaa@fit2cloud.com"); hashMap.put("smtp.recipient", "aaa@fit2cloud.com"); - hashMap.put("smtp.ssl", "ture"); + hashMap.put("smtp.ssl", "true"); hashMap.put("smtp.tsl", "false"); this.requestPost(EMAIL_INFO_TEST_CONNECT_URL, hashMap, ERROR_REQUEST_MATCHER); }