From dc804ba46f6eb63273114fbccb65860010bd472b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 3 Jul 2023 13:58:07 +0800 Subject: [PATCH] build: Log rename --- .../log/annotation/{RequestLog.java => Log.java} | 6 +++--- .../sdk/log/aspect/OperationLogAspect.java | 16 ++++++++-------- .../api/controller/ApiDefinitionController.java | 6 +++--- .../system/controller/AuthSourceController.java | 8 ++++---- .../controller/SystemParameterController.java | 6 +++--- .../controller/SystemProjectController.java | 10 +++++----- .../controller/TestResourcePoolController.java | 8 ++++---- .../system/controller/UserController.java | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) rename backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/{RequestLog.java => Log.java} (92%) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/Log.java similarity index 92% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/Log.java index 1caea4deb8..237aeb26bc 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/Log.java @@ -12,7 +12,7 @@ import java.lang.annotation.*; * 操作日志注解类 * @author mr.zhao */ -public @interface RequestLog { +public @interface Log { /** * 功能模块 * @@ -37,14 +37,14 @@ public @interface RequestLog { /** * 资源ID */ - String sourceId() default ""; + String sourceId() default "NONE"; /** * 创建用户 * * @return */ - String createUser() default ""; + String createUser() default "admin"; /** * 操作内容 diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java index 25decc6c3b..6594ea003e 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java @@ -1,6 +1,6 @@ package io.metersphere.sdk.log.aspect; -import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.service.OperationLogService; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; @@ -69,7 +69,7 @@ public class OperationLogAspect { /** * 定义切点 @Pointcut 在注解的位置切入代码 */ - @Pointcut("@annotation(io.metersphere.sdk.log.annotation.RequestLog)") + @Pointcut("@annotation(io.metersphere.sdk.log.annotation.Log)") public void logPointCut() { } @@ -80,7 +80,7 @@ public class OperationLogAspect { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); //获取切入点所在的方法 Method method = signature.getMethod(); - RequestLog msLog = method.getAnnotation(RequestLog.class); + Log msLog = method.getAnnotation(Log.class); if (msLog != null && msLog.isBefore()) { //获取参数对象数组 Object[] args = joinPoint.getArgs(); @@ -119,7 +119,7 @@ public class OperationLogAspect { .anyMatch(input -> input.contains(keyword)); } - private void initDetails(RequestLog msLog, EvaluationContext context) { + private void initDetails(Log msLog, EvaluationContext context) { try { // 批量内容处理 if (StringUtils.isNotBlank(msLog.details()) && msLog.details().startsWith("#msClass")) { @@ -145,7 +145,7 @@ public class OperationLogAspect { } } - private void initResourceId(RequestLog msLog, EvaluationContext context) { + private void initResourceId(Log msLog, EvaluationContext context) { try { // 批量内容处理 if (StringUtils.isNotBlank(msLog.sourceId()) && msLog.sourceId().startsWith("#msClass")) { @@ -165,7 +165,7 @@ public class OperationLogAspect { } } - private String getProjectId(RequestLog msLog, EvaluationContext context) { + private String getProjectId(Log msLog, EvaluationContext context) { try { if (StringUtils.isNotBlank(msLog.projectId()) && msLog.projectId().startsWith("#")) { Expression titleExp = parser.parseExpression(msLog.projectId()); @@ -178,7 +178,7 @@ public class OperationLogAspect { } } - private void add(OperationLog operationLog, RequestLog msLog, JoinPoint joinPoint, Object result) { + private void add(OperationLog operationLog, Log msLog, JoinPoint joinPoint, Object result) { //从切面织入点处通过反射机制获取织入点处的方法 MethodSignature signature = (MethodSignature) joinPoint.getSignature(); //获取切入点所在的方法 @@ -271,7 +271,7 @@ public class OperationLogAspect { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); operationLog.setPath(request.getServletPath()); // 获取操作 - RequestLog msLog = method.getAnnotation(RequestLog.class); + Log msLog = method.getAnnotation(Log.class); if (msLog != null) { add(operationLog, msLog, joinPoint, result); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index 4d20dd6991..2590e41f27 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -7,7 +7,7 @@ import io.metersphere.api.dto.definition.ApiDefinitionDTO; import io.metersphere.api.dto.definition.ListRequestDTO; import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.sdk.constants.PermissionConstants; -import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -32,7 +32,7 @@ public class ApiDefinitionController { @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_ADD_API) - @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.API_DEFINITION, projectId = "#request.projectId", details = "#request.name") + @Log(type = OperationLogType.ADD, module = OperationLogModule.API_DEFINITION, projectId = "#request.projectId", details = "#request.name") public ApiDefinitionDTO add(@Validated({Created.class}) @RequestBody ApiDefinitionDTO request, @RequestParam(value = "files") List bodyFiles) { return apiDefinitionService.create(request, bodyFiles); @@ -40,7 +40,7 @@ public class ApiDefinitionController { @PostMapping(value = "/batch-del") @RequiresPermissions(PermissionConstants.PROJECT_API_REPORT_READ_DELETE) - @RequestLog(isBatch = true, isBefore = true, details = "#msClass.getLogs(#ids)", msClass = ApiDefinitionService.class) + @Log(isBatch = true, isBefore = true, details = "#msClass.getLogs(#ids)", msClass = ApiDefinitionService.class) public void batchDelete(@RequestBody List ids) { apiDefinitionService.batchDelete(ids); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/AuthSourceController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/AuthSourceController.java index 0cc23551d5..38192dd9f1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/AuthSourceController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/AuthSourceController.java @@ -3,7 +3,7 @@ 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.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -32,7 +32,7 @@ public class AuthSourceController { @PostMapping("/add") @RequiresPermissions(PermissionConstants.SYSTEM_SETTING_READ_CREAT) - @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, + @Log(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "认证设置") public void add(@Validated @RequestBody AuthSource authSource) { authSourceService.addAuthSource(authSource); @@ -40,7 +40,7 @@ public class AuthSourceController { @PostMapping("/update") @RequiresPermissions(PermissionConstants.SYSTEM_SETTING_READ_UPDATE) - @RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, + @Log(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "认证设置", sourceId = "#authSource.id") public void update(@Validated @RequestBody AuthSource authSource) { authSourceService.updateAuthSource(authSource); @@ -54,7 +54,7 @@ public class AuthSourceController { @GetMapping("/delete/{id}") @RequiresPermissions(PermissionConstants.SYSTEM_SETTING_READ_DELETE) - @RequestLog(type = OperationLogType.DELETE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, + @Log(type = OperationLogType.DELETE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "认证设置", sourceId = "#id") public void delete(@PathVariable(value = "id") String id) { authSourceService.deleteAuthSource(id); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java index d44f9ac358..e570bf2f8d 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java @@ -4,7 +4,7 @@ package io.metersphere.system.controller; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.EMailInfoDto; -import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.service.SystemParameterService; @@ -32,7 +32,7 @@ public class SystemParameterController { */ @PostMapping("/save/base-info") @RequiresPermissions(PermissionConstants.SYSTEM_SETTING_READ_UPDATE) - @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "基本配置", sourceId = "#systemParameter.get(0).paramKey") + @Log(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "基本配置", sourceId = "#systemParameter.get(0).paramKey") public void saveBaseParameter(@Validated @RequestBody List systemParameter) { systemParameterService.saveBaseInfo(systemParameter); } @@ -58,7 +58,7 @@ public class SystemParameterController { @PostMapping("/edit/email-info") @RequiresPermissions(PermissionConstants.SYSTEM_SETTING_READ_UPDATE) - @RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "邮件配置", sourceId = "#systemParameter.get(0).paramKey") + @Log(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PARAMETER_SETTING, details = "邮件配置", sourceId = "#systemParameter.get(0).paramKey") public void editEMailInfo(@Validated @RequestBody List systemParameter) { systemParameterService.editEMailInfo(systemParameter); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java index 7d9f63a84e..0d33bfd405 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java @@ -6,7 +6,7 @@ import com.github.pagehelper.PageHelper; import io.metersphere.project.domain.Project; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.ProjectDTO; -import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -34,7 +34,7 @@ public class SystemProjectController { @PostMapping("/add") @RequiresPermissions(PermissionConstants.SYSTEM_PROJECT_READ_ADD) - @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PROJECT, details = "#project.name") + @Log(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_PROJECT, details = "#project.name") public Project addProject(@RequestBody @Validated({Created.class}) Project project) { project.setCreateUser(SessionUtils.getUserId()); return systemProjectService.add(project); @@ -56,7 +56,7 @@ public class SystemProjectController { } @PostMapping("/update") - @RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PROJECT, + @Log(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PROJECT, sourceId = "#project.id", details = "#project.name") @RequiresPermissions(PermissionConstants.SYSTEM_PROJECT_READ_UPDATE) public void updateProject(@RequestBody @Validated({Updated.class}) Project project) { @@ -66,7 +66,7 @@ public class SystemProjectController { @GetMapping("/delete/{id}") @RequiresPermissions(PermissionConstants.SYSTEM_PROJECT_READ_DELETE) - @RequestLog(isBefore = true, type = OperationLogType.DELETE, module = OperationLogModule.SYSTEM_PROJECT, + @Log(isBefore = true, type = OperationLogType.DELETE, module = OperationLogModule.SYSTEM_PROJECT, details = "#msClass.getLogDetails(#id)", msClass = SystemProjectService.class, sourceId = "#id") public void deleteProject(@PathVariable String id) { Project project = new Project(); @@ -77,7 +77,7 @@ public class SystemProjectController { @GetMapping("/revoke/{id}") @RequiresPermissions(PermissionConstants.SYSTEM_PROJECT_READ_DELETE) - @RequestLog(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PROJECT, + @Log(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_PROJECT, details = "#msClass.getLogDetails(#id)", msClass = SystemProjectService.class, sourceId = "#id") public void revokeProject(@PathVariable String id) { systemProjectService.revoke(id); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/TestResourcePoolController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/TestResourcePoolController.java index 847bdab99e..5d68f22d2a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/TestResourcePoolController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/TestResourcePoolController.java @@ -3,7 +3,7 @@ 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.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -29,7 +29,7 @@ public class TestResourcePoolController { @PostMapping("/add") @RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_ADD) - @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#poolDTO.name") + @Log(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#poolDTO.name") public TestResourcePoolDTO addTestResourcePool(@Validated @RequestBody TestResourcePoolDTO poolDTO) { return testResourcePoolService.addTestResourcePool(poolDTO); } @@ -37,7 +37,7 @@ public class TestResourcePoolController { @GetMapping("/delete/{poolId}") @CacheNode // 把监控节点缓存起来 @RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_DELETE) - @RequestLog(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, + @Log(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#msClass.getLogDetails(#testResourcePoolId)", msClass = TestResourcePoolService.class) public void deleteTestResourcePool(@PathVariable(value = "poolId") String testResourcePoolId) { testResourcePoolService.deleteTestResourcePool(testResourcePoolId); @@ -46,7 +46,7 @@ public class TestResourcePoolController { @PostMapping("/update") @CacheNode // 把监控节点缓存起来 @RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_UPDATE) - @RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, + @Log(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, sourceId = "#testResourcePoolDTO.id", details = "#testResourcePoolDTO.name") public void updateTestResourcePool(@Validated @RequestBody TestResourcePoolDTO testResourcePoolDTO) { testResourcePoolService.updateTestResourcePool(testResourcePoolDTO); 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 84a4f48248..1b1567aca5 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 @@ -7,7 +7,7 @@ import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.UserSourceEnum; import io.metersphere.sdk.dto.BasePageRequest; import io.metersphere.sdk.dto.UserDTO; -import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -58,7 +58,7 @@ public class UserController { @PostMapping("/update") @RequiresPermissions(PermissionConstants.SYSTEM_USER_READ_UPDATE) - @RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_USER, + @Log(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_USER, sourceId = "#request.id", details = "#request.name") public UserEditRequest updateUser(@Validated({Updated.class}) @RequestBody UserEditRequest request) { return userService.updateUser(request, SessionUtils.getUserId());