refactor(通用功能): 变更请求,记录请求日志

--story=1011948 --user=陈建星 增加请求级别的操作日志 https://www.tapd.cn/55049933/s/1370573
This commit is contained in:
chenjianxing 2023-05-10 15:45:19 +08:00 committed by jianxing
parent adc84b9372
commit 57adf36da4
42 changed files with 488 additions and 25 deletions

View File

@ -1,6 +1,8 @@
package io.metersphere.controller;
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.scenario.ApiScenarioService;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.NoticeConstants;
@ -33,6 +35,7 @@ public class ScheduleController {
}
@PostMapping(value = "/api/schedule/update")
@MsRequestLog(module = OperLogModule.API_AUTOMATION)
public Schedule update(@RequestBody ScheduleInfoRequest request) {
Schedule schedule = baseScheduleService.getSchedule(request.getTaskID());
schedule.setEnable(request.isEnable());

View File

@ -30,6 +30,7 @@ import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RelationshipEdgeDTO;
import io.metersphere.environment.service.BaseEnvironmentService;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.definition.ApiDefinitionService;
@ -248,12 +249,14 @@ public class ApiDefinitionController {
//更新定时任务更新定时任务
@PostMapping(value = "/schedule-switch")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void updateScheduleEnable(@RequestBody Schedule request) {
apiDefinitionService.switchSchedule(request);
}
//删除定时任务和swaggereUrl
@PostMapping("/del-schedule")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void deleteSchedule(@RequestBody ScheduleRequest request) {
apiDefinitionService.deleteSchedule(request);
}
@ -267,6 +270,7 @@ public class ApiDefinitionController {
@PostMapping("/batch/edit")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void editApiBath(@RequestBody ApiBatchRequest request) {
apiDefinitionService.editApiBath(request);
}
@ -293,6 +297,7 @@ public class ApiDefinitionController {
}
@PostMapping("/relevance/review")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiDefinitionService.testCaseReviewRelevance(request);
}
@ -333,6 +338,7 @@ public class ApiDefinitionController {
}
@PostMapping("/relationship/add")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void saveRelationshipBatch(@RequestBody ApiDefinitionRelationshipEdgeRequest request) {
apiDefinitionService.saveRelationshipBatch(request);
}
@ -353,12 +359,14 @@ public class ApiDefinitionController {
}
@PostMapping("/update/follows/{definitionId}")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void saveFollows(@PathVariable String definitionId, @RequestBody List<String> follows) {
apiDefinitionService.saveFollows(definitionId, follows);
}
@PostMapping("/delete/follows/batch")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void deleteFollows(@RequestBody List<String> definitionIds) {
apiDefinitionService.deleteFollows(definitionIds);
}
@ -394,6 +402,7 @@ public class ApiDefinitionController {
}
@PostMapping("/update/file")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void updateFileMetadataId(@RequestBody List<ReplaceFileIdRequest> requestList) {
apiDefinitionService.updateFileMetadataId(requestList);
}

View File

@ -1,5 +1,7 @@
package io.metersphere.controller.definition;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.definition.ApiDefinitionEnvService;
import io.metersphere.base.domain.ApiDefinitionEnv;
import io.metersphere.commons.constants.PermissionConstants;
@ -22,6 +24,7 @@ public class ApiDefinitionEnvController {
@PostMapping(value = "/create")
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API, PermissionConstants.PROJECT_API_DEFINITION_READ}, logical = Logical.OR)
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public void create(@RequestBody ApiDefinitionEnv request) {
apiDefinitionEnvService.insert(request);
}

View File

@ -18,6 +18,7 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.definition.ApiDefinitionExecResultService;
@ -160,6 +161,7 @@ public class ApiTestCaseController {
}
@PostMapping("/sort")
@MsRequestLog(module = OperLogModule.API_DEFINITION_CASE)
public void orderCase(@RequestBody ResetOrderRequest request) {
apiTestCaseService.updateOrder(request);
}
@ -196,11 +198,13 @@ public class ApiTestCaseController {
}
@PostMapping("/relevance")
@MsRequestLog(module = OperLogModule.API_DEFINITION_CASE)
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiTestCaseService.relevanceByCase(request);
}
@PostMapping("/relevance/review")
@MsRequestLog(module = OperLogModule.API_DEFINITION_CASE)
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiTestCaseService.relevanceByApiByReview(request);
}
@ -230,6 +234,7 @@ public class ApiTestCaseController {
}
@PostMapping("/update/follows/{testId}")
@MsRequestLog(module = OperLogModule.API_DEFINITION_CASE)
public void saveFollows(@PathVariable String testId, @RequestBody List<String> follows) {
apiTestCaseService.saveFollows(testId, follows);
}

View File

@ -11,8 +11,10 @@ import io.metersphere.api.dto.mock.config.response.MockExpectConfigResponse;
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
import io.metersphere.base.domain.MockExpectConfig;
import io.metersphere.base.domain.MockExpectConfigWithBLOBs;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.utils.mock.MockApiUtils;
import io.metersphere.commons.utils.mock.MockTestDataUtil;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.MockConfigService;
import io.metersphere.service.definition.ApiDefinitionService;
import org.springframework.web.bind.annotation.*;
@ -42,11 +44,13 @@ public class MockConfigController {
}
@PostMapping(value = "/update/form", consumes = {"multipart/form-data"})
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public MockExpectConfig updateMockExpectConfig(@RequestPart("request") MockExpectConfigRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
return mockConfigService.updateMockExpectConfig(request, bodyFiles);
}
@PostMapping(value = "/update/expect")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public MockExpectConfig updateMockExpectConfig(@RequestBody MockExpectConfigRequest request) {
return mockConfigService.updateMockExpectConfigStatus(request);
}
@ -59,6 +63,7 @@ public class MockConfigController {
}
@GetMapping("/delete/{id}")
@MsRequestLog(module = OperLogModule.API_DEFINITION)
public String deleteMockExpectConfig(@PathVariable String id) {
mockConfigService.deleteMockExpectConfig(id);
return "SUCCESS";

View File

@ -18,6 +18,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.plan.TestPlanApiCaseService;
import jakarta.annotation.Resource;
@ -84,6 +85,7 @@ public class TestPlanApiCaseController {
}
@PostMapping("/relevance/{planId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void testPlanRelevance(@RequestBody List<String> ids, @PathVariable("planId") String planId) {
testPlanApiCaseService.relevanceByTestIds(ids, planId);
}
@ -94,6 +96,7 @@ public class TestPlanApiCaseController {
}
@GetMapping("/plan/copy/{sourcePlanId}/{targetPlanId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void getStatusByTestPlanId(@PathVariable("sourcePlanId") String sourcePlanId, @PathVariable("targetPlanId") String targetPlanId) {
testPlanApiCaseService.copyPlan(sourcePlanId, targetPlanId);
}
@ -131,6 +134,7 @@ public class TestPlanApiCaseController {
}
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanApiCaseService.updateOrder(request);
}
@ -186,6 +190,7 @@ public class TestPlanApiCaseController {
}
@GetMapping("/run/{testId}/{reportId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void runApi(@PathVariable String testId, @PathVariable String reportId) {
testPlanApiCaseService.run(testId, reportId);
}

View File

@ -17,6 +17,7 @@ import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.PlanReportCaseDTO;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.plan.TestPlanScenarioCaseService;
import io.metersphere.service.scenario.ApiScenarioService;
@ -79,6 +80,7 @@ public class TestPlanScenarioCaseController {
}
@PostMapping("/relevance/projectIds")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public ScenarioProjectDTO relevanceProjectIds(@RequestBody ApiScenarioRequest request) {
return testPlanScenarioCaseService.relevanceProjectIds(request);
}
@ -135,6 +137,7 @@ public class TestPlanScenarioCaseController {
}
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanScenarioCaseService.updateOrder(request);
}
@ -155,6 +158,7 @@ public class TestPlanScenarioCaseController {
}
@PostMapping("/relevance/{planId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void testPlanRelevance(@RequestBody List<String> ids, @PathVariable("planId") String planId) {
testPlanScenarioCaseService.relevanceByTestIds(ids, planId);
}

View File

@ -19,6 +19,7 @@ import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.ext.ExtApiTaskService;
@ -348,6 +349,7 @@ public class ApiScenarioController {
}
@PostMapping(value = "/stop/batch")
@MsRequestLog(module = OperLogModule.API_AUTOMATION)
public void stopBatch(@RequestBody List<TaskRequestDTO> reportIds) {
apiTaskService.apiStop(reportIds);
}
@ -402,6 +404,7 @@ public class ApiScenarioController {
}
@PostMapping("/update/follows/{scenarioId}")
@MsRequestLog(module = OperLogModule.API_AUTOMATION)
public void saveFollows(@PathVariable String scenarioId, @RequestBody List<String> follows) {
apiAutomationService.saveFollows(scenarioId, follows);
}

View File

@ -3,6 +3,7 @@ package io.metersphere.controller.scenario;
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.DragApiScenarioModuleRequest;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.scenario.ApiScenarioModuleService;
import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.commons.constants.OperLogConstants;
@ -66,6 +67,7 @@ public class ApiScenarioModuleController {
}
@PostMapping("/pos")
@MsRequestLog(module = OperLogModule.API_AUTOMATION)
public void treeSort(@RequestBody List<String> ids) {
apiScenarioModuleService.sort(ids);
}

View File

@ -1,8 +1,10 @@
package io.metersphere.controller.scenario;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.enums.ApiReportStatus;
import io.metersphere.dto.RerunParametersDTO;
import io.metersphere.dto.TestPlanRerunParametersDTO;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.scenario.ApiScenarioRerunService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -19,6 +21,7 @@ public class ApiScenarioRerunController {
private ApiScenarioRerunService apiScenarioRerunService;
@PostMapping("/rerun")
@MsRequestLog(module = OperLogModule.API_AUTOMATION)
public String rerun(@RequestBody RerunParametersDTO parametersDTO) {
return apiScenarioRerunService.rerun(parametersDTO);
}

View File

@ -2505,6 +2505,9 @@ const message = {
change_field: "变更字段",
before_change: "变更前",
after_change: "变更后",
param_name: "参数名称",
param_value: "参数值",
request_record: "请求记录",
share: "分享",
api_definition: "接口定义",
api_definition_case: "接口定义用例",

View File

@ -6,5 +6,6 @@ public enum OperLogConstants {
IMPORT, EXPORT,
ASSOCIATE_CASE, ASSOCIATE_ISSUE, UN_ASSOCIATE_CASE,
LOGIN, PERMISSION_UPDATE, CREATE_PRE_TEST, OTHER,
MINDER_OPERATION
MINDER_OPERATION,
REQUEST
}

View File

@ -0,0 +1,49 @@
package io.metersphere.log.annotation;
import io.metersphere.commons.constants.OperLogConstants;
import java.lang.annotation.*;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
/**
* MsRequestLog class
* @author jianxing.chen
* @date 2023/05/09
*/
public @interface MsRequestLog {
/**
* 功能模块
*
* @return
*/
String module();
/**
* 项目
*
* @return
*/
String project() default "";
/**
* 操作类型
*
* @return
*/
OperLogConstants type() default OperLogConstants.OTHER;
/**
* 标题
*/
String title() default "";
/**
* 操作内容
*
* @return
*/
String content() default "";
}

View File

@ -0,0 +1,168 @@
package io.metersphere.log.aspect;
import io.metersphere.base.domain.OperatingLogWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.log.service.OperatingLogService;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.StandardReflectionParameterNameDiscoverer;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.lang.reflect.Method;
import java.util.*;
/**
* 系统日志切面处理类
*/
@Aspect
@Component
public class MsRequestLogAspect {
/**
* 解析 spel 表达式
*/
ExpressionParser parser = new SpelExpressionParser();
/**
* 将方法参数纳入Spring管理
*/
StandardReflectionParameterNameDiscoverer discoverer = new StandardReflectionParameterNameDiscoverer();
@Resource
private OperatingLogService operatingLogService;
/**
* 定义切点 @Pointcut 在注解的位置切入代码
*/
@Pointcut("@annotation(io.metersphere.log.annotation.MsRequestLog)")
public void logPointCut() {
}
/**
* 切面 配置通知
*/
@AfterReturning(value = "logPointCut()", returning = "result")
public void saveLog(JoinPoint joinPoint, Object result) {
try {
if (this.hasLogicalFail(result)) {
return;
}
//从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//获取切入点所在的方法
Method method = signature.getMethod();
//获取参数对象数组
Object[] args = joinPoint.getArgs();
//获取操作
MsRequestLog logAnnotation = method.getAnnotation(MsRequestLog.class);
if (logAnnotation != null) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String path = request.getServletPath();
List<DetailColumn> requestParams = new ArrayList<>(3);
//保存日志
OperatingLogWithBLOBs operatingLog = new OperatingLogWithBLOBs();
//保存获取的操作
operatingLog.setId(UUID.randomUUID().toString());
// 操作类型
operatingLog.setOperType(OperLogConstants.REQUEST.name());
operatingLog.setOperModule(logAnnotation.module());
//获取方法参数名
String[] params = discoverer.getParameterNames(method);
//将参数纳入Spring管理
EvaluationContext context = new StandardEvaluationContext();
for (int len = 0; len < params.length; len++) {
context.setVariable(params[len], args[len]);
requestParams.add(new DetailColumn(params[len], params[len], null, args[len]));
}
// 标题
operatingLog.setOperTitle(path);
// 项目ID
operatingLog.setProjectId(expressionParse(context, logAnnotation.project()));
if (StringUtils.isBlank(operatingLog.getProjectId())) {
operatingLog.setProjectId(SessionUtils.getCurrentProjectId());
}
operatingLog.setCreateUser(SessionUtils.getUserId());
operatingLog.setOperUser(SessionUtils.getUserId());
OperatingLogDetails details = new OperatingLogDetails(operatingLog.getSourceId(),
operatingLog.getProjectId(),
operatingLog.getOperTitle(),
operatingLog.getCreateUser(),
requestParams);
operatingLog.setOperContent(JSON.toJSONString(details));
//获取请求的类名
String className = joinPoint.getTarget().getClass().getName();
//获取请求的方法名
String methodName = method.getName();
operatingLog.setOperMethod(className + "." + methodName);
operatingLog.setOperTime(System.currentTimeMillis());
if (StringUtils.isNotEmpty(operatingLog.getOperTitle()) && operatingLog.getOperTitle().length() > 6000) {
operatingLog.setOperTitle(operatingLog.getOperTitle().substring(0, 5999));
}
operatingLog.setOperPath(request.getServletPath());
operatingLogService.create(operatingLog, operatingLog.getSourceId());
}
} catch (Exception e) {
LogUtil.error("操作日志写入异常:" + joinPoint.getSignature());
}
}
private String expressionParse(EvaluationContext context, String value) {
if (StringUtils.isBlank(value)) {
return value;
}
try {
Expression expression = parser.parseExpression(value);
value = expression.getValue(context, String.class);
return value;
} catch (Exception e) {
return value;
}
}
/**
* 方法正常返回但是执行逻辑是失败的
* @param result 方法返回值
* @return boolean
*/
private boolean hasLogicalFail(Object result) {
if (result instanceof ExcelResponse) {
return BooleanUtils.isFalse(((ExcelResponse<?>) result).getSuccess());
}
return false;
}
}

View File

@ -15,6 +15,7 @@ import io.metersphere.consul.CacheNode;
import io.metersphere.consul.ConsulService;
import io.metersphere.dto.*;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.*;
@ -119,6 +120,7 @@ public class PerformanceTestController {
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.PERFORMANCE_TEST)
public void orderCase(@RequestBody ResetOrderRequest request) {
performanceTestService.updateOrder(request);
}
@ -233,6 +235,7 @@ public class PerformanceTestController {
@PostMapping(value = "/schedule/create")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_SCHEDULE)
@MsRequestLog(module = OperLogModule.PERFORMANCE_TEST)
public void createSchedule(@RequestBody ScheduleRequest request) {
performanceTestService.createSchedule(request);
}
@ -266,6 +269,7 @@ public class PerformanceTestController {
}
@PostMapping("test/update/follows/{testId}")
@MsRequestLog(module = OperLogModule.PERFORMANCE_TEST)
public void saveFollows(@PathVariable String testId, @RequestBody List<String> follows) {
performanceTestService.saveFollows(testId, follows);
}
@ -306,6 +310,7 @@ public class PerformanceTestController {
}
@PostMapping("/stop/batch")
@MsRequestLog(module = OperLogModule.PERFORMANCE_TEST)
public void stopBatch(@RequestBody TaskRequestDTO taskRequestDTO) {
performanceTestService.stopBatch(taskRequestDTO);
}

View File

@ -3,9 +3,11 @@ package io.metersphere.controller;
import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.FileModule;
import io.metersphere.commons.constants.FileModuleTypeConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.FileRelevanceCaseDTO;
import io.metersphere.dto.FileVersionDTO;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.metadata.utils.GitRepositoryUtil;
import io.metersphere.request.QueryProjectFileRequest;
@ -49,6 +51,7 @@ public class FileRepositoryController {
}
@PostMapping("/case/version/update/{refId}")
@MsRequestLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT)
public String updateCaseVersion(@PathVariable String refId, @RequestBody QueryProjectFileRequest request) {
return fileRepositoryService.updateCaseVersion(refId, request);
}

View File

@ -14,6 +14,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.GroupDTO;
import io.metersphere.dto.GroupPermissionDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.GroupRequest;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.group.EditGroupUserRequest;
@ -84,6 +85,7 @@ public class GroupController {
@PostMapping("/permission/edit")
@RequiresPermissions(value = {PermissionConstants.SYSTEM_GROUP_READ_SETTING_PERMISSION, PermissionConstants.PROJECT_GROUP_READ_SETTING_PERMISSION}, logical = Logical.OR)
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void editGroupPermission(@RequestBody EditGroupRequest editGroupRequest) {
groupService.editGroupPermission(editGroupRequest);
}
@ -140,11 +142,13 @@ public class GroupController {
}
@PostMapping("/add/member")
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void addGroupUser(@RequestBody EditGroupUserRequest request) {
groupService.addGroupUser(request);
}
@PostMapping("/edit/member")
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void editGroupUser(@RequestBody EditGroupUserRequest request) {
groupService.editGroupUser(request);
}

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.IssueTemplateCopyDTO;
import io.metersphere.dto.IssueTemplateDao;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.BaseQueryRequest;
import io.metersphere.request.CopyIssueTemplateRequest;
import io.metersphere.request.UpdateIssueTemplateRequest;
@ -67,6 +68,7 @@ public class IssueTemplateController {
}
@PostMapping("/copy")
@MsRequestLog(module = OperLogModule.PROJECT_TEMPLATE_MANAGEMENT)
public void copy(@RequestBody CopyIssueTemplateRequest request) {
List<IssueTemplate> copyRecords = issueTemplateService.copy(request);
// 目标项目操作日志

View File

@ -16,6 +16,7 @@ import io.metersphere.dto.ProjectDTO;
import io.metersphere.dto.WorkspaceMemberDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.AddProjectRequest;
import io.metersphere.request.ProjectRequest;
import io.metersphere.request.member.AddMemberRequest;
@ -138,6 +139,7 @@ public class ProjectController {
}
@PostMapping("/member/add")
@MsRequestLog(module = OperLogModule.PROJECT_PROJECT_MEMBER)
public void addProjectMember(@RequestBody AddMemberRequest request) {
projectService.addProjectMember(request);
}

View File

@ -13,7 +13,10 @@
</div>
<div>
<p class="tip">{{ this.$t('report.test_log_details') }} </p>
<div v-if="detail && detail.operType !== 'CREATE' && detail.operType !=='DELETE' && detail.operType !=='COPY' && detail && detail.details && detail.details.columns && detail.details.columns.length >0 ">
<div v-if="detail.operType === 'REQUEST'">
<request-log-detail :detail="detail"/>
</div>
<div v-else-if="detail && detail.operType !== 'CREATE' && detail.operType !=='DELETE' && detail.operType !=='COPY' && detail && detail.details && detail.details.columns && detail.details.columns.length >0 ">
<div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px">
<el-table :data="detail.details.columns">
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')" width="150px" show-overflow-tooltip/>
@ -53,13 +56,14 @@
<script>
import {getLogDetailById} from "../../../api/log";
import RequestLogDetail from "./RequestLogDetail";
const jsondiffpatch = require('jsondiffpatch');
const formattersHtml = jsondiffpatch.formatters.html;
export default {
name: "MsLogDetail",
components: {},
components: {RequestLogDetail},
props: {
title: String,
},
@ -91,7 +95,8 @@ const jsondiffpatch = require('jsondiffpatch');
{id: 'BATCH_ADD', label: this.$t('commons.batch_add')},
{id: 'UN_ASSOCIATE_CASE', label: this.$t('test_track.case.unlink')},
{id: 'BATCH_RESTORE', label: this.$t('commons.batch_restore')},
{id: 'BATCH_GC', label: this.$t('commons.batch_gc')}
{id: 'BATCH_GC', label: this.$t('commons.batch_gc')},
{id: 'REQUEST', label: this.$t('operating_log.request_record')},
],
LOG_TYPE_MAP: new Map([
['CREATE', this.$t('api_test.definition.request.create_info')],
@ -116,6 +121,7 @@ const jsondiffpatch = require('jsondiffpatch');
['BATCH_RESTORE', "批量恢复"],
['BATCH_GC', "批量回收"],
['UN_ASSOCIATE_CASE', this.$t('test_track.case.unlink')],
['REQUEST', this.$t('operating_log.request_record')],
]),
timeDates: ["plannedStartTime", "plannedEndTime", "startTime", "endTime"],
loading: false

View File

@ -0,0 +1,57 @@
<template>
<div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px">
<el-table :data="detail.details.columns">
<el-table-column prop="columnTitle" :label="$t('operating_log.param_name')" width="150px" show-overflow-tooltip/>
<el-table-column prop="newValue" :label="$t('operating_log.param_value')">
<template v-slot:default="scope">
<div v-if="isObject(scope.row.newValue)" class="code-edit-container">
<ms-code-edit
mode="json"
:read-only="true"
:data="getJsonValue(scope.row.newValue)"
:modes="['json']"
theme="eclipse" />
</div>
<div v-else>
{{ scope.row.newValue }}
</div>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
export default {
name: "RequestLogDetail",
components: {MsCodeEdit},
props: {
title: String,
detail: {
Object,
}
},
data() {
return {
}
},
methods: {
getJsonValue(value) {
return JSON.stringify(value);
},
isObject(value) {
if (value instanceof Object) {
return true;
}
return false;
}
}
}
</script>
<style scoped>
.code-edit-container {
height: 300px;
}
</style>

View File

@ -23,7 +23,8 @@ export function LOG_TYPE(_this) {
{id: 'BATCH_UPDATE', label: _this.$t('api_test.definition.request.batch_edit')},
{id: 'BATCH_ADD', label: _this.$t('commons.batch_add')},
{id: 'BATCH_RESTORE', label: _this.$t('commons.batch_restore')},
{id: 'BATCH_GC', label: _this.$t('commons.batch_gc')}
{id: 'BATCH_GC', label: _this.$t('commons.batch_gc')},
{id: 'REQUEST', label: _this.$t('operating_log.request_record')},
];
return LOG_TYPE;
}
@ -52,6 +53,7 @@ export function LOG_TYPE_MAP(_this) {
['BATCH_ADD', _this.$t('commons.batch_add')],
['BATCH_RESTORE', _this.$t('commons.batch_restore')],
['BATCH_GC', _this.$t('commons.batch_gc')],
['REQUEST', _this.$t('operating_log.request_record')],
]);
return LOG_TYPE_MAP;
}

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.reportstatistics.dto.request.EnterpriseTestReportRequest;
import io.metersphere.reportstatistics.dto.response.EnterpriseTestReportDTO;
import io.metersphere.reportstatistics.dto.response.UserGroupResponse;
@ -88,11 +89,13 @@ public class EnterpriseTestReportController {
}
@PostMapping(value = "/schedule/update")
@MsRequestLog(module = OperLogModule.ENTERPRISE_TEST_REPORT)
public void updateSchedule(@RequestBody Schedule request) {
enterpriseTestReportService.updateSchedule(request);
}
@PostMapping(value = "/schedule/create")
@MsRequestLog(module = OperLogModule.ENTERPRISE_TEST_REPORT)
public void createSchedule(@RequestBody ScheduleRequest request) {
enterpriseTestReportService.createSchedule(request);
}

View File

@ -2,6 +2,8 @@ package io.metersphere.reportstatistics.controller;
import io.metersphere.base.domain.ReportStatistics;
import io.metersphere.base.domain.ReportStatisticsWithBLOBs;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.reportstatistics.dto.ReportStatisticsSaveRequest;
import io.metersphere.reportstatistics.service.ReportStatisticsService;
import org.springframework.web.bind.annotation.PostMapping;
@ -36,18 +38,21 @@ public class HistoryReportController {
}
@PostMapping("/update")
@MsRequestLog(module = OperLogModule.ENTERPRISE_TEST_REPORT)
public ReportStatisticsWithBLOBs update(@RequestBody ReportStatisticsSaveRequest request) {
ReportStatisticsWithBLOBs returnData = reportStatisticsService.update(request);
return returnData;
}
@PostMapping("/updateByRequest")
@MsRequestLog(module = OperLogModule.ENTERPRISE_TEST_REPORT)
public ReportStatisticsWithBLOBs updateByRequest(@RequestBody ReportStatisticsSaveRequest request) {
ReportStatisticsWithBLOBs returnData = reportStatisticsService.updateByRequest(request);
return returnData;
}
@PostMapping("/deleteByParam")
@MsRequestLog(module = OperLogModule.ENTERPRISE_TEST_REPORT)
public int deleteById(@RequestBody ReportStatisticsSaveRequest request) {
return reportStatisticsService.deleteById(request.getId());
}

View File

@ -1,7 +1,9 @@
package io.metersphere.controller;
import io.metersphere.base.domain.EnvironmentGroup;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.environment.dto.EnvironmentGroupRequest;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.service.EnvironmentGroupProjectService;
import io.metersphere.service.EnvironmentGroupService;
import org.springframework.web.bind.annotation.*;
@ -19,6 +21,7 @@ public class EnvironmentGroupController {
private EnvironmentGroupProjectService environmentGroupProjectService;
@PostMapping("/add")
@MsRequestLog(module = OperLogModule.PROJECT_ENVIRONMENT_SETTING)
public EnvironmentGroup add(@RequestBody EnvironmentGroupRequest request) {
return environmentGroupService.add(request);
}
@ -29,21 +32,25 @@ public class EnvironmentGroupController {
}
@GetMapping("/delete/{id}")
@MsRequestLog(module = OperLogModule.PROJECT_ENVIRONMENT_SETTING)
public void delete(@PathVariable String id) {
environmentGroupService.delete(id);
}
@PostMapping("/update")
@MsRequestLog(module = OperLogModule.PROJECT_ENVIRONMENT_SETTING)
public EnvironmentGroup update(@RequestBody EnvironmentGroupRequest request) {
return environmentGroupService.update(request);
}
@PostMapping("/modify")
@MsRequestLog(module = OperLogModule.PROJECT_ENVIRONMENT_SETTING)
public void modify(@RequestBody EnvironmentGroupRequest request) {
environmentGroupService.modify(request);
}
@GetMapping("/copy/{id}")
@MsRequestLog(module = OperLogModule.PROJECT_ENVIRONMENT_SETTING)
public void copy(@PathVariable String id) {
environmentGroupService.copy(id);
}

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.GroupRequest;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.group.EditGroupUserRequest;
@ -84,6 +85,7 @@ public class GroupController {
@PostMapping("/permission/edit")
@RequiresPermissions(value = {PermissionConstants.SYSTEM_GROUP_READ_SETTING_PERMISSION, PermissionConstants.PROJECT_GROUP_READ_SETTING_PERMISSION}, logical = Logical.OR)
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void editGroupPermission(@RequestBody EditGroupRequest editGroupRequest) {
groupService.editGroupPermission(editGroupRequest);
}
@ -137,11 +139,13 @@ public class GroupController {
}
@PostMapping("/add/member")
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void addGroupUser(@RequestBody EditGroupUserRequest request) {
groupService.addGroupUser(request);
}
@PostMapping("/edit/member")
@MsRequestLog(module = OperLogModule.GROUP_PERMISSION)
public void editGroupUser(@RequestBody EditGroupUserRequest request) {
groupService.editGroupUser(request);
}

View File

@ -15,6 +15,7 @@ import io.metersphere.dto.UserGroupPermissionDTO;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.member.*;
import io.metersphere.request.resourcepool.UserBatchProcessRequest;
import io.metersphere.service.BaseCheckPermissionService;
@ -30,7 +31,6 @@ import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@RequestMapping("user")
@RestController
@ -164,7 +164,7 @@ public class UserController {
@PostMapping("/project/member/add")
@RequiresPermissions(value = {PermissionConstants.PROJECT_USER_READ_CREATE, PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_ADD_USER}, logical = Logical.OR)
@MsRequestLog(module = OperLogModule.PROJECT_PROJECT_MEMBER)
public void addProjectMember(@RequestBody AddMemberRequest request) {
userService.addProjectMember(request);
}
@ -185,8 +185,8 @@ public class UserController {
}
@GetMapping("/project/member/delete/{projectId}/{userId}")
// @MsAuditLog(module = "workspace_member", type = OperLogConstants.DELETE, title = "删除工作空间成员")
@RequiresPermissions(value={PermissionConstants.PROJECT_USER_READ_DELETE}, logical = Logical.OR)
@MsRequestLog(module = OperLogModule.PROJECT_PROJECT_MEMBER)
public void deleteProjectMember(@PathVariable String projectId, @PathVariable String userId) {
String currentUserId = SessionUtils.getUser().getId();
if (StringUtils.equals(userId, currentUserId)) {

View File

@ -13,7 +13,10 @@
</div>
<div>
<p class="tip">{{ this.$t('report.test_log_details') }} </p>
<div v-if="detail && detail.operType !== 'CREATE' && detail.operType !=='DELETE' && detail.operType !=='COPY' && detail && detail.details && detail.details.columns && detail.details.columns.length >0 ">
<div v-if="detail.operType === 'REQUEST'">
<request-log-detail :detail="detail"/>
</div>
<div v-else-if="detail && detail.operType !== 'CREATE' && detail.operType !=='DELETE' && detail.operType !=='COPY' && detail && detail.details && detail.details.columns && detail.details.columns.length >0 ">
<div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px">
<el-table :data="detail.details.columns">
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')" width="150px" show-overflow-tooltip/>
@ -53,13 +56,14 @@
<script>
import {getLogDetailById} from "../../api/operating-log";
import RequestLogDetail from "@/business/common/RequestLogDetail";
const jsondiffpatch = require('jsondiffpatch');
const formattersHtml = jsondiffpatch.formatters.html;
export default {
name: "MsLogDetail",
components: {},
components: {RequestLogDetail},
props: {
title: String,
},
@ -91,7 +95,8 @@ const jsondiffpatch = require('jsondiffpatch');
{id: 'BATCH_ADD', label: this.$t('commons.batch_add')},
{id: 'UN_ASSOCIATE_CASE', label: this.$t('test_track.case.unlink')},
{id: 'BATCH_RESTORE', label: this.$t('commons.batch_restore')},
{id: 'BATCH_GC', label: this.$t('commons.batch_gc')}
{id: 'BATCH_GC', label: this.$t('commons.batch_gc')},
{id: 'REQUEST', label: this.$t('operating_log.request_record')},
],
LOG_TYPE_MAP: new Map([
['CREATE', this.$t('api_test.definition.request.create_info')],
@ -117,6 +122,7 @@ const jsondiffpatch = require('jsondiffpatch');
['BATCH_GC', "批量回收"],
['UN_ASSOCIATE_CASE', this.$t('test_track.case.unlink')],
['MINDER_OPERATION', this.$t('commons.minder_operation')],
['REQUEST', this.$t('operating_log.request_record')],
]),
timeDates: ["plannedStartTime", "plannedEndTime", "startTime", "endTime"],
loading: false

View File

@ -0,0 +1,57 @@
<template>
<div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px">
<el-table :data="detail.details.columns">
<el-table-column prop="columnTitle" :label="$t('operating_log.param_name')" width="150px" show-overflow-tooltip/>
<el-table-column prop="newValue" :label="$t('operating_log.param_value')">
<template v-slot:default="scope">
<div v-if="isObject(scope.row.newValue)" class="code-edit-container">
<ms-code-edit
mode="json"
:read-only="true"
:data="getJsonValue(scope.row.newValue)"
:modes="['json']"
theme="eclipse" />
</div>
<div v-else>
{{ scope.row.newValue }}
</div>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
export default {
name: "RequestLogDetail",
components: {MsCodeEdit},
props: {
title: String,
detail: {
Object,
}
},
data() {
return {
}
},
methods: {
getJsonValue(value) {
return JSON.stringify(value);
},
isObject(value) {
if (value instanceof Object) {
return true;
}
return false;
}
}
}
</script>
<style scoped>
.code-edit-container {
height: 300px;
}
</style>

View File

@ -25,6 +25,7 @@ export function LOG_TYPE(_this) {
{id: 'BATCH_RESTORE', label: _this.$t('commons.batch_restore')},
{id: 'BATCH_GC', label: _this.$t('commons.batch_gc')},
{id: 'MINDER_OPERATION', label: _this.$t('commons.minder_operation')},
{id: 'REQUEST', label: _this.$t('operating_log.request_record')},
];
return LOG_TYPE;
}
@ -54,6 +55,7 @@ export function LOG_TYPE_MAP(_this) {
['BATCH_RESTORE', _this.$t('commons.batch_restore')],
['BATCH_GC', _this.$t('commons.batch_gc')],
['MINDER_OPERATION', _this.$t('commons.minder_operation')],
['REQUEST', _this.$t('operating_log.request_record')],
]);
return LOG_TYPE_MAP;
}

View File

@ -6,6 +6,7 @@ import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.dto.IssueCommentDTO;
import io.metersphere.request.issues.IssuesRelevanceRequest;
@ -31,6 +32,7 @@ public class IssueCommentController {
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, target = "#targetClass.getIssue(#request.issuesId)", targetClass = IssuesService.class,
event = NoticeConstants.Event.COMMENT, subject = "缺陷")
@MsRequestLog(module = OperLogModule.TRACK_BUG)
public IssueComment saveComment(@RequestBody IssuesRelevanceRequest request) {
request.setId(UUID.randomUUID().toString());
return issueCommentService.saveComment(request);

View File

@ -16,6 +16,7 @@ import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.IssuesStatusCountDao;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.platform.domain.SelectOption;
import io.metersphere.request.PlatformOptionRequest;
@ -131,6 +132,7 @@ public class IssuesController {
}
@PostMapping("/delete/relate")
@MsRequestLog(module = OperLogModule.TRACK_BUG)
public void deleteRelate(@RequestBody IssuesRequest request) {
issuesService.deleteIssueRelate(request);
}
@ -191,6 +193,7 @@ public class IssuesController {
}
@PostMapping("/up/follows/{issueId}")
@MsRequestLog(module = OperLogModule.TRACK_BUG)
public void saveFollows(@PathVariable String issueId,@RequestBody List<String> follows) {
issuesService.saveFollows(issueId,follows);
}

View File

@ -14,6 +14,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.*;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.request.testcase.*;
@ -111,6 +112,7 @@ public class TestCaseController {
}
@PostMapping("/relationship/add")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void saveRelationshipBatch(@RequestBody TestCaseRelationshipEdgeRequest request) {
testCaseService.saveRelationshipBatch(request);
}
@ -151,11 +153,13 @@ public class TestCaseController {
}
@PostMapping("/relate/test/{type}/{caseId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void relateTest(@PathVariable String type, @PathVariable String caseId, @RequestBody List<String> apiIds) {
testCaseService.relateTest(type, caseId, apiIds);
}
@GetMapping("/relate/delete/{caseId}/{testId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void relateDelete(@PathVariable String caseId, @PathVariable String testId) {
testCaseService.relateDelete(caseId, testId);
}
@ -211,6 +215,7 @@ public class TestCaseController {
}
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void orderCase(@RequestBody ResetOrderRequest request) {
trackCheckPermissionService.checkTestCaseOwner(request.getMoveId());
testCaseService.updateOrder(request);
@ -395,6 +400,7 @@ public class TestCaseController {
@PostMapping("/edit/follows/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void editTestFollows(@PathVariable String caseId, @RequestBody List<String> follows) {
testCaseService.saveFollows(caseId, follows);
}

View File

@ -4,6 +4,7 @@ import io.metersphere.base.domain.TestCaseNode;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.testcase.DragNodeRequest;
import io.metersphere.request.testcase.QueryNodeRequest;
import io.metersphere.request.testcase.QueryTestCaseRequest;
@ -158,6 +159,7 @@ public class TestCaseNodeController {
}
@PostMapping("/pos")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE)
public void treeSort(@RequestBody List<String> ids) {
testCaseNodeService.sort(ids);
}

View File

@ -13,6 +13,7 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.testreview.*;
import io.metersphere.service.*;
@ -134,6 +135,7 @@ public class TestCaseReviewController {
@PostMapping("/edit/status/{reviewId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW)
public void editTestPlanStatus(@PathVariable String reviewId) {
trackCheckPermissionService.checkTestReviewOwner(reviewId);
testCaseReviewService.editTestReviewStatus(reviewId);
@ -148,6 +150,7 @@ public class TestCaseReviewController {
@PostMapping("/edit/follows")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW)
public void editTestFollows(@RequestBody SaveTestCaseReviewRequest testCaseReview) {
testCaseReviewService.editCaseRevieweFollow(testCaseReview);
}

View File

@ -13,6 +13,7 @@ import io.metersphere.dto.TestPlanDTOWithMetric;
import io.metersphere.dto.TestPlanRerunParametersDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import io.metersphere.plan.dto.TestPlanDTO;
@ -141,6 +142,7 @@ public class TestPlanController {
}
@PostMapping("/fresh/{planId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public TestPlan freshRecentPlan(@PathVariable String planId) {
AddTestPlanRequest request = new AddTestPlanRequest();
request.setId(planId);
@ -158,13 +160,14 @@ public class TestPlanController {
@PostMapping("/edit/report/config")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
// @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#planId)", content = "#msClass.getLogDetails(#planId)", msClass = TestPlanService.class)
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void editReportConfig(@RequestBody TestPlanDTO testPlanDTO) {
testPlanService.editReportConfig(testPlanDTO);
}
@PostMapping("/edit/follows/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void editTestFollows(@PathVariable String planId, @RequestBody List<String> follows) {
testPlanService.editTestFollows(planId, follows);
}
@ -241,11 +244,13 @@ public class TestPlanController {
@PostMapping("/edit/run/config")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void updateRunModeConfig(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
}
@PostMapping("/run")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public String run(@RequestBody TestPlanRunRequest testplanRunRequest) {
if (baseUserService.getUserDTO(testplanRunRequest.getUserId()) == null) {
MSException.throwException(Translator.get("user_not_exist"));
@ -254,6 +259,7 @@ public class TestPlanController {
}
@PostMapping("/run/save")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public String runAndSave(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
return testPlanService.runPlan(testplanRunRequest);
@ -287,6 +293,7 @@ public class TestPlanController {
}
@PostMapping("/edit/report")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void editReport(@RequestBody TestPlanWithBLOBs testPlanWithBLOBs) {
testPlanService.editReport(testPlanWithBLOBs);
}
@ -339,7 +346,8 @@ public class TestPlanController {
return testPlanService.getPlanFollow(planId);
}
@PostMapping(value = "/schedule/Batch/updateEnable")
@PostMapping(value = "/schedule/batch/update_enable")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE)
public void updateBatchScheduleEnable(@RequestBody ScheduleInfoRequest request) {
testPlanService.batchUpdateScheduleEnable(request);
}
@ -377,11 +385,13 @@ public class TestPlanController {
}
@PostMapping(value = "/rerun")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public String rerun(@RequestBody TestPlanRerunParametersDTO request) {
return testPlanRerunService.rerun(request);
}
@GetMapping(value = "/status/reset/{planId}")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void resetStatus(@PathVariable String planId) {
testPlanService.resetStatus(planId);
}

View File

@ -13,6 +13,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.TestPlanReportDTO;
import io.metersphere.dto.TestPlanScheduleReportInfoDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.plan.dto.TestPlanReportDataStruct;
import io.metersphere.plan.request.TestPlanReportSaveRequest;
@ -89,11 +90,13 @@ public class TestPlanReportController {
}
@PostMapping("/reName")
@MsRequestLog(module = OperLogModule.TRACK_REPORT)
public void reName(@RequestBody TestPlanReport request) {
testPlanReportService.reName(request.getId(), request.getName());
}
@PostMapping("/edit/report")
@MsRequestLog(module = OperLogModule.TRACK_REPORT)
public void editReport(@RequestBody TestPlanReportContentWithBLOBs reportContentWithBLOBs) {
testPlanReportService.editReport(reportContentWithBLOBs);
}

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.TestPlanCaseDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.plan.request.function.QueryTestPlanCaseRequest;
import io.metersphere.plan.request.function.TestPlanCaseBatchRequest;
import io.metersphere.plan.request.function.TestPlanFuncCaseBatchRequest;
@ -147,6 +148,7 @@ public class TestPlanTestCaseController {
}
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.TRACK_TEST_PLAN)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanTestCaseService.updateOrder(request);
}

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.dto.TestReviewCaseDTO;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.request.testreview.DeleteRelevanceRequest;
@ -100,6 +101,7 @@ public class TestReviewTestCaseController {
}
@PostMapping("/edit/order")
@MsRequestLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW)
public void orderCase(@RequestBody ResetOrderRequest request) {
testReviewTestCaseService.updateOrder(request);
}

View File

@ -764,7 +764,7 @@ public class TestCaseService {
addDemandHyperLink(request, "delete");
handleDemandUpdate(request, DemandUpdateRequest.OperateType.DELETE,
projectMapper.selectByPrimaryKey(testCase.getProjectId()));
projectMapper.selectByPrimaryKey(testCaseWithBLOBs.getProjectId()));
}
DeleteTestCaseRequest request = new DeleteTestCaseRequest();

View File

@ -356,7 +356,7 @@ export function getPlanSchedule(planId, taskType) {
}
export function updateBatchScheduleEnable(param) {
return post(BASE_URL + "schedule/Batch/updateEnable", param);
return post(BASE_URL + "schedule/batch/update_enable", param);
}
export function batchDeletePlan(param) {

View File

@ -150,17 +150,19 @@ export default {
this.condition.planId = this.planId;
this.$nextTick(() => {
this.result = {loading: true};
apiDefinitionListRelevance({pageNum: this.$refs.apitable.currentPage, pageSize: this.$refs.apitable.pageSize}, this.condition)
.then(response => {
this.result = {loading: false};
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
if (this.$refs.apitable) {
apiDefinitionListRelevance({pageNum: this.$refs.apitable.currentPage, pageSize: this.$refs.apitable.pageSize}, this.condition)
.then(response => {
this.result = {loading: false};
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
});
});
}
});
},
setEnvironment(data) {