build: Log rename

This commit is contained in:
fit2-zhao 2023-07-03 13:58:07 +08:00 committed by fit2-zhao
parent 7a29fdc13d
commit dc804ba46f
8 changed files with 32 additions and 32 deletions

View File

@ -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";
/**
* 操作内容

View File

@ -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);
}

View File

@ -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<MultipartFile> 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<String> ids) {
apiDefinitionService.batchDelete(ids);
}

View File

@ -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);

View File

@ -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> 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> systemParameter) {
systemParameterService.editEMailInfo(systemParameter);
}

View File

@ -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);

View File

@ -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);

View File

@ -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());