feat(接口测试): 完成接口测试操作记录

This commit is contained in:
fit2-zhao 2021-05-17 16:48:56 +08:00 committed by fit2-zhao
parent 0914d5945f
commit c33e6bf947
32 changed files with 564 additions and 60 deletions

View File

@ -8,10 +8,12 @@ import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.api.dto.automation.APIScenarioReportResult;
import io.metersphere.api.dto.automation.ExecuteType;
import io.metersphere.api.service.ApiScenarioReportService;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
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 org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
@ -47,11 +49,13 @@ public class APIScenarioReportController {
}
@PostMapping("/delete")
@MsAuditLog(module = "api_automation_report", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request.id)", msClass = ApiScenarioReportService.class)
public void delete(@RequestBody DeleteAPIReportRequest request) {
apiReportService.delete(request);
}
@PostMapping("/batch/delete")
@MsAuditLog(module = "api_automation_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = ApiScenarioReportService.class)
public void deleteAPIReportBatch(@RequestBody APIReportBatchRequest reportRequest) {
apiReportService.deleteAPIReportBatch(reportRequest);
}

View File

@ -11,11 +11,13 @@ import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import io.metersphere.track.request.testplan.FileOperationRequest;
import org.apache.shiro.authz.annotation.Logical;
@ -58,7 +60,6 @@ public class ApiAutomationController {
}
@PostMapping("/id/all")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<String> idAll(@RequestBody ApiScenarioBatchRequest request) {
@ -75,41 +76,49 @@ public class ApiAutomationController {
}
@PostMapping(value = "/create")
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
return apiAutomationService.create(request, bodyFiles);
}
@PostMapping(value = "/update")
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
apiAutomationService.update(request, bodyFiles);
}
@GetMapping("/delete/{id}")
@MsAuditLog(module = "api_automation", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiAutomationService.class)
public void delete(@PathVariable String id) {
apiAutomationService.delete(id);
}
@PostMapping("/deleteBatch")
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiAutomationService.class)
public void deleteBatch(@RequestBody List<String> ids) {
apiAutomationService.deleteBatch(ids);
}
@PostMapping("/deleteBatchByCondition")
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void deleteBatchByCondition(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.deleteBatchByCondition(request);
}
@PostMapping("/removeToGc")
@MsAuditLog(module = "api_automation", type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiAutomationService.class)
public void removeToGc(@RequestBody List<String> ids) {
apiAutomationService.removeToGc(ids);
}
@PostMapping("/removeToGcByBatch")
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void removeToGcByBatch(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.removeToGcByBatch(request);
}
@PostMapping("/reduction")
@MsAuditLog(module = "api_automation", type = OperLogConstants.RESTORE, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiAutomationService.class)
public void reduction(@RequestBody List<String> ids) {
apiAutomationService.reduction(ids);
}
@ -140,12 +149,14 @@ public class ApiAutomationController {
}
@PostMapping(value = "/run/debug")
@MsAuditLog(module = "api_automation", type = OperLogConstants.DEBUG, title = "#request.scenarioName", project = "#request.projectId")
public void runDebug(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
request.setExecuteType(ExecuteType.Debug.name());
apiAutomationService.debugRun(request, bodyFiles);
}
@PostMapping(value = "/run")
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public String run(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Completed.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
@ -154,6 +165,7 @@ public class ApiAutomationController {
}
@PostMapping(value = "/run/jenkins")
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
public String runByJenkins(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.API.name());
@ -162,6 +174,7 @@ public class ApiAutomationController {
}
@PostMapping(value = "/run/batch")
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public String runBatch(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
@ -171,12 +184,14 @@ public class ApiAutomationController {
@PostMapping("/batch/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void bathEdit(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.bathEdit(request);
}
@PostMapping("/batch/update/env")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void batchUpdateEnv(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.batchUpdateEnv(request);
}
@ -228,18 +243,21 @@ public class ApiAutomationController {
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ScenarioImport scenarioImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
return apiAutomationService.scenarioImport(file, request);
}
@PostMapping(value = "/export")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiScenrioExportResult export(@RequestBody ApiScenarioBatchRequest request) {
return apiAutomationService.export(request);
}
@PostMapping(value = "/export/jmx")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
return apiAutomationService.exportJmx(request);
}

View File

@ -112,7 +112,7 @@ public class ApiDefinitionController {
@GetMapping("/delete/{id}")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiDefinitionService.class)
public void delete(@PathVariable String id) {
apiDefinitionService.delete(id);
}
@ -171,7 +171,7 @@ public class ApiDefinitionController {
}
@PostMapping(value = "/run", consumes = {"multipart/form-data"})
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXECUTE, title = "#request.name", project = "#request.projectId")
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXECUTE, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
request.setReportId(null);
return apiDefinitionService.run(request, bodyFiles);
@ -194,14 +194,14 @@ public class ApiDefinitionController {
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, title = "#request.name", project = "#request.projectId")
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
return apiDefinitionService.apiTestImport(file, request);
}
@PostMapping(value = "/export/{type}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXPORT, title = "#request.name", project = "#request.projectId")
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiExportResult export(@RequestBody ApiBatchRequest request, @PathVariable String type) {
return apiDefinitionService.export(request, type);
}

View File

@ -4,7 +4,9 @@ import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
import io.metersphere.api.dto.automation.DragApiScenarioModuleRequest;
import io.metersphere.api.service.ApiScenarioModuleService;
import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.CheckPermissionService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
@ -31,12 +33,14 @@ public class ApiScenarioModuleController {
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = ApiScenarioModuleService.class)
public String addNode(@RequestBody ApiScenarioModule node) {
return apiScenarioModuleService.addNode(node);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#node)", title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = ApiScenarioModuleService.class)
public int editNode(@RequestBody DragApiScenarioModuleRequest node) {
return apiScenarioModuleService.editNode(node);
}
@ -49,6 +53,7 @@ public class ApiScenarioModuleController {
@PostMapping("/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#nodeIds)", msClass = ApiScenarioModuleService.class)
public int deleteNode(@RequestBody List<String> nodeIds) {
//nodeIds 包含删除节点ID及其所有子节点ID
return apiScenarioModuleService.deleteNode(nodeIds);
@ -56,6 +61,7 @@ public class ApiScenarioModuleController {
@PostMapping("/drag")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#node)", title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = ApiScenarioModuleService.class)
public void dragNode(@RequestBody DragApiScenarioModuleRequest node) {
apiScenarioModuleService.dragNode(node);
}

View File

@ -7,6 +7,7 @@ import lombok.Setter;
@Getter
public class ApiTestImportRequest {
private String name;
private String id;
private String moduleId;
private String modulePath;
private String environmentId;

View File

@ -12,6 +12,8 @@ import java.util.Map;
@Setter
public class ApiScenarioBatchRequest extends ApiScenarioWithBLOBs {
private List<String> ids;
private String id;
private String name;
private String projectId;
private String environmentId;

View File

@ -35,6 +35,10 @@ import io.metersphere.i18n.Translator;
import io.metersphere.job.sechedule.ApiScenarioTestJob;
import io.metersphere.job.sechedule.SwaggerUrlImportJob;
import io.metersphere.job.sechedule.TestPlanTestJob;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.definition.AutomationReference;
import io.metersphere.service.ScheduleService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.track.dto.TestPlanDTO;
@ -314,6 +318,8 @@ public class ApiAutomationService {
scenario.setStepTotal(request.getStepTotal());
scenario.setUpdateTime(System.currentTimeMillis());
scenario.setDescription(request.getDescription());
scenario.setCreateUser(SessionUtils.getUserId());
scenario.setScenarioDefinition(JSON.toJSONString(request.getScenarioDefinition()));
if (StringUtils.isNotEmpty(request.getStatus())) {
scenario.setStatus(request.getStatus());
@ -650,6 +656,7 @@ public class ApiAutomationService {
report.setProjectId(projectId);
report.setScenarioName(scenarioName);
report.setScenarioId(scenarioId);
report.setCreateUser(SessionUtils.getUserId());
return report;
}
@ -1513,6 +1520,12 @@ public class ApiAutomationService {
}
if (apiImport != null) {
editScenario(request, apiImport);
if (CollectionUtils.isNotEmpty(apiImport.getData())) {
List<String> names = apiImport.getData().stream().map(ApiScenarioWithBLOBs::getName).collect(Collectors.toList());
List<String> ids = apiImport.getData().stream().map(ApiScenarioWithBLOBs::getId).collect(Collectors.toList());
request.setName(String.join(",", names));
request.setId(JSON.toJSONString(ids));
}
}
return apiImport;
}
@ -1531,6 +1544,12 @@ public class ApiAutomationService {
result.setData(getExportResult(request));
result.setProjectId(request.getProjectId());
result.setVersion(System.getenv("MS_VERSION"));
if (CollectionUtils.isNotEmpty(result.getData())) {
List<String> names = result.getData().stream().map(ApiScenarioWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = result.getData().stream().map(ApiScenarioWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
return result;
}
@ -1547,6 +1566,12 @@ public class ApiAutomationService {
}
}
});
if (CollectionUtils.isNotEmpty(apiScenarioWithBLOBs)) {
List<String> names = apiScenarioWithBLOBs.stream().map(ApiScenarioWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = apiScenarioWithBLOBs.stream().map(ApiScenarioWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
return resList;
}
@ -1779,4 +1804,26 @@ public class ApiAutomationService {
List<ApiScenarioWithBLOBs> list = extApiScenarioMapper.listWithIds(request.getIds());
return list;
}
public String getLogDetails(String id) {
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(id);
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, AutomationReference.automationColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), bloBs.getProjectId(), bloBs.getName(), bloBs.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)) {
ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andIdIn(ids);
List<ApiScenario> definitions = apiScenarioMapper.selectByExample(example);
List<String> names = definitions.stream().map(ApiScenario::getName).collect(Collectors.toList());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), definitions.get(0).getProjectId(), String.join(",", names), definitions.get(0).getCreateUser(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;
}
}

View File

@ -679,6 +679,8 @@ public class ApiDefinitionService {
if (CollectionUtils.isNotEmpty(apiImport.getData())) {
List<String> names = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
return apiImport;
}
@ -989,6 +991,8 @@ public class ApiDefinitionService {
if (CollectionUtils.isNotEmpty(((MsApiExportResult) apiExportResult).getData())) {
List<String> names = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
return apiExportResult;
}
@ -1076,7 +1080,7 @@ public class ApiDefinitionService {
ApiDefinitionWithBLOBs bloBs = apiDefinitionMapper.selectByPrimaryKey(id);
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, DefinitionReference.definitionColumns);
OperatingLogDetails details = new OperatingLogDetails(id, bloBs.getProjectId(), bloBs.getCreateUser(), columns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), bloBs.getProjectId(), bloBs.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;

View File

@ -18,7 +18,7 @@ import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.definition.DefinitionReference;
import io.metersphere.log.vo.definition.ModuleReference;
import io.metersphere.service.NodeTreeService;
import io.metersphere.service.ProjectService;
import io.metersphere.track.service.TestPlanApiCaseService;
@ -422,8 +422,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
}
}
if (module != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(module, DefinitionReference.moduleColumns);
OperatingLogDetails details = new OperatingLogDetails(module.getId(), module.getProjectId(), module.getCreateUser(), columns);
List<DetailColumn> columns = ReflexObjectUtil.getColumns(module, ModuleReference.moduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(module.getId()), module.getProjectId(), module.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;

View File

@ -12,7 +12,12 @@ import io.metersphere.base.mapper.ApiScenarioModuleMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.definition.ModuleReference;
import io.metersphere.service.NodeTreeService;
import io.metersphere.service.ProjectService;
import io.metersphere.track.service.TestPlanProjectService;
@ -98,6 +103,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
node.setId(UUID.randomUUID().toString());
node.setCreateTime(System.currentTimeMillis());
node.setUpdateTime(System.currentTimeMillis());
node.setCreateUser(SessionUtils.getUserId());
double pos = getNextLevelPos(node.getProjectId(), node.getLevel(), node.getParentId());
node.setPos(pos);
apiScenarioModuleMapper.insertSelective(node);
@ -324,4 +330,45 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
sqlSession.flushStatements();
}
public String getLogDetails(List<String> ids) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andIdIn(ids);
List<ApiScenarioModule> nodes = apiScenarioModuleMapper.selectByExample(example);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(nodes)) {
List<String> names = nodes.stream().map(ApiScenarioModule::getName).collect(Collectors.toList());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), nodes.get(0).getProjectId(), String.join(",", names), nodes.get(0).getCreateUser(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(ApiScenarioModule node) {
ApiScenarioModule module = null;
if (StringUtils.isNotEmpty(node.getId())) {
module = apiScenarioModuleMapper.selectByPrimaryKey(node.getId());
}
if (module == null && StringUtils.isNotEmpty(node.getName())) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
ApiScenarioModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()).andProjectIdEqualTo(node.getProjectId());
if (StringUtils.isNotEmpty(node.getParentId())) {
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotEmpty(node.getId())) {
criteria.andIdNotEqualTo(node.getId());
}
List<ApiScenarioModule> list = apiScenarioModuleMapper.selectByExample(example);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(list)) {
module = list.get(0);
}
}
if (module != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(module, ModuleReference.moduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(module.getId()), module.getProjectId(), module.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;
}
}

View File

@ -24,6 +24,10 @@ import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.definition.ModuleReference;
import io.metersphere.track.service.TestPlanReportService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -627,4 +631,26 @@ public class ApiScenarioReportService {
return new ArrayList<>(0);
}
}
public String getLogDetails(String id) {
ApiScenarioReport bloBs = apiScenarioReportMapper.selectByPrimaryKey(id);
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, ModuleReference.moduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), bloBs.getProjectId(), bloBs.getName(), bloBs.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(List<String> ids) {
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)) {
ApiScenarioReportExample example = new ApiScenarioReportExample();
example.createCriteria().andIdIn(ids);
List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(example);
List<String> names = reportList.stream().map(ApiScenarioReport::getName).collect(Collectors.toList());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), reportList.get(0).getProjectId(), String.join(",", names), reportList.get(0).getCreateUser(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;
}
}

View File

@ -710,6 +710,15 @@ public class ApiTestCaseService {
return list;
}
public String getLogDetails(String id) {
ApiTestCaseWithBLOBs bloBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (bloBs != null) {
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), bloBs.getProjectId(), bloBs.getName(), bloBs.getCreateUserId(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(List<String> ids) {
ApiTestCaseExample example = new ApiTestCaseExample();
ApiTestCaseExample.Criteria criteria = example.createCriteria();
@ -723,15 +732,6 @@ public class ApiTestCaseService {
return null;
}
public String getLogDetails(String id) {
ApiTestCaseWithBLOBs bloBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (bloBs != null) {
OperatingLogDetails details = new OperatingLogDetails(id, bloBs.getProjectId(), bloBs.getName(), bloBs.getCreateUserId(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(SaveApiTestCaseRequest request) {
ApiTestCaseWithBLOBs bloBs = null;
if (StringUtils.isNotEmpty(request.getId())) {
@ -748,7 +748,7 @@ public class ApiTestCaseService {
}
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, DefinitionReference.caseColumns);
OperatingLogDetails details = new OperatingLogDetails(bloBs.getId(), bloBs.getProjectId(), bloBs.getCreateUserId(), columns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(bloBs.getId()), bloBs.getProjectId(), bloBs.getCreateUserId(), columns);
return JSON.toJSONString(details);
}
return null;

View File

@ -1,8 +1,9 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApiScenario implements Serializable {
private String id;
@ -47,5 +48,7 @@ public class ApiScenario implements Serializable {
private String customNum;
private String createUser;
private static final long serialVersionUID = 1L;
}

View File

@ -1533,6 +1533,76 @@ public class ApiScenarioExample {
addCriterion("custom_num not between", value1, value2, "customNum");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -21,5 +21,7 @@ public class ApiScenarioModule implements Serializable {
private Double pos;
private String createUser;
private static final long serialVersionUID = 1L;
}

View File

@ -623,6 +623,76 @@ public class ApiScenarioModuleExample {
addCriterion("pos not between", value1, value2, "pos");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiScenarioReport implements Serializable {
@ -28,6 +27,8 @@ public class ApiScenarioReport implements Serializable {
private String scenarioId;
private String createUser;
private String description;
private static final long serialVersionUID = 1L;

View File

@ -853,6 +853,76 @@ public class ApiScenarioReportExample {
addCriterion("scenario_id not between", value1, value2, "scenarioId");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -23,6 +23,7 @@
<result column="num" jdbcType="INTEGER" property="num" />
<result column="original_state" jdbcType="VARCHAR" property="originalState" />
<result column="custom_num" jdbcType="VARCHAR" property="customNum" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioWithBLOBs">
<result column="scenario_definition" jdbcType="LONGVARCHAR" property="scenarioDefinition" />
@ -89,7 +90,7 @@
<sql id="Base_Column_List">
id, project_id, tags, user_id, api_scenario_module_id, module_path, `name`, `level`,
`status`, principal, step_total, follow_people, schedule, create_time, update_time,
pass_rate, last_result, report_id, num, original_state, custom_num
pass_rate, last_result, report_id, num, original_state, custom_num, create_user
</sql>
<sql id="Blob_Column_List">
scenario_definition, description
@ -150,7 +151,7 @@
schedule, create_time, update_time,
pass_rate, last_result, report_id,
num, original_state, custom_num,
scenario_definition, description
create_user, scenario_definition, description
)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR},
@ -159,7 +160,7 @@
#{schedule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{passRate,jdbcType=VARCHAR}, #{lastResult,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{num,jdbcType=INTEGER}, #{originalState,jdbcType=VARCHAR}, #{customNum,jdbcType=VARCHAR},
#{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
#{createUser,jdbcType=VARCHAR}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
@ -228,6 +229,9 @@
<if test="customNum != null">
custom_num,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="scenarioDefinition != null">
scenario_definition,
</if>
@ -299,6 +303,9 @@
<if test="customNum != null">
#{customNum,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="scenarioDefinition != null">
#{scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -379,6 +386,9 @@
<if test="record.customNum != null">
custom_num = #{record.customNum,jdbcType=VARCHAR},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.scenarioDefinition != null">
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -413,6 +423,7 @@
num = #{record.num,jdbcType=INTEGER},
original_state = #{record.originalState,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -441,7 +452,8 @@
report_id = #{record.reportId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER},
original_state = #{record.originalState,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=VARCHAR}
custom_num = #{record.customNum,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -509,6 +521,9 @@
<if test="customNum != null">
custom_num = #{customNum,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="scenarioDefinition != null">
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -540,6 +555,7 @@
num = #{num,jdbcType=INTEGER},
original_state = #{originalState,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -565,7 +581,8 @@
report_id = #{reportId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER},
original_state = #{originalState,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=VARCHAR}
custom_num = #{customNum,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -10,6 +10,7 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="pos" jdbcType="DOUBLE" property="pos" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -70,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, project_id, `name`, parent_id, `level`, create_time, update_time, pos
id, project_id, `name`, parent_id, `level`, create_time, update_time, pos, create_user
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultMap="BaseResultMap">
select
@ -105,10 +106,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioModule">
insert into api_scenario_module (id, project_id, `name`,
parent_id, `level`, create_time,
update_time, pos)
update_time, pos, create_user
)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{parentId,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{pos,jdbcType=DOUBLE})
#{updateTime,jdbcType=BIGINT}, #{pos,jdbcType=DOUBLE}, #{createUser,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioModule">
insert into api_scenario_module
@ -137,6 +140,9 @@
<if test="pos != null">
pos,
</if>
<if test="createUser != null">
create_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -163,6 +169,9 @@
<if test="pos != null">
#{pos,jdbcType=DOUBLE},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultType="java.lang.Long">
@ -198,6 +207,9 @@
<if test="record.pos != null">
pos = #{record.pos,jdbcType=DOUBLE},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -212,7 +224,8 @@
`level` = #{record.level,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
pos = #{record.pos,jdbcType=DOUBLE}
pos = #{record.pos,jdbcType=DOUBLE},
create_user = #{record.createUser,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -241,6 +254,9 @@
<if test="pos != null">
pos = #{pos,jdbcType=DOUBLE},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -252,7 +268,8 @@
`level` = #{level,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
pos = #{pos,jdbcType=DOUBLE}
pos = #{pos,jdbcType=DOUBLE},
create_user = #{createUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -13,6 +13,7 @@
<result column="execute_type" jdbcType="VARCHAR" property="executeType" />
<result column="scenario_name" jdbcType="VARCHAR" property="scenarioName" />
<result column="scenario_id" jdbcType="VARCHAR" property="scenarioId" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReport">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -77,7 +78,7 @@
</sql>
<sql id="Base_Column_List">
id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode,
execute_type, scenario_name, scenario_id
execute_type, scenario_name, scenario_id, create_user
</sql>
<sql id="Blob_Column_List">
description
@ -134,13 +135,13 @@
insert into api_scenario_report (id, project_id, `name`,
create_time, update_time, `status`,
user_id, trigger_mode, execute_type,
scenario_name, scenario_id, description
)
scenario_name, scenario_id, create_user,
description)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR},
#{scenarioName,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
#{scenarioName,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR},
#{description,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReport">
insert into api_scenario_report
@ -178,6 +179,9 @@
<if test="scenarioId != null">
scenario_id,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="description != null">
description,
</if>
@ -216,6 +220,9 @@
<if test="scenarioId != null">
#{scenarioId,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -263,6 +270,9 @@
<if test="record.scenarioId != null">
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -284,6 +294,7 @@
execute_type = #{record.executeType,jdbcType=VARCHAR},
scenario_name = #{record.scenarioName,jdbcType=VARCHAR},
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -301,7 +312,8 @@
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
execute_type = #{record.executeType,jdbcType=VARCHAR},
scenario_name = #{record.scenarioName,jdbcType=VARCHAR},
scenario_id = #{record.scenarioId,jdbcType=VARCHAR}
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -339,6 +351,9 @@
<if test="scenarioId != null">
scenario_id = #{scenarioId,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -357,6 +372,7 @@
execute_type = #{executeType,jdbcType=VARCHAR},
scenario_name = #{scenarioName,jdbcType=VARCHAR},
scenario_id = #{scenarioId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -371,7 +387,8 @@
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
execute_type = #{executeType,jdbcType=VARCHAR},
scenario_name = #{scenarioName,jdbcType=VARCHAR},
scenario_id = #{scenarioId,jdbcType=VARCHAR}
scenario_id = #{scenarioId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -46,6 +46,12 @@ public @interface MsAuditLog {
*/
String title() default "";
/**
* 资源ID
*/
String sourceId() default "";
/**
* 操作内容
*

View File

@ -160,6 +160,17 @@ public class MsLogAspect {
msOperLog.setOperTitle(title);
}
}
// 资源ID
if (StringUtils.isNotEmpty(msLog.sourceId())) {
try {
String sourceId = msLog.sourceId();
Expression titleExp = parser.parseExpression(sourceId);
sourceId = titleExp.getValue(context, String.class);
msOperLog.setSourceId(sourceId);
} catch (Exception e) {
}
}
// 操作内容
if (StringUtils.isNotEmpty(msLog.content())) {
Expression expression = parser.parseExpression(msLog.content());
@ -221,7 +232,6 @@ public class MsLogAspect {
String path = request.getServletPath();
msOperLog.setOperPath(path);
operatingLogService.create(msOperLog);
}
} catch (Exception e) {

View File

@ -101,25 +101,25 @@ public class ReflexObjectUtil {
StringBuilder oldValue = new StringBuilder();
for (Diff item : after) {
if (item.getOperation().equals(Operation.ADD)) {
addBuff.append(item.getPath() + "" + item.getValue()).append("/n");
addBuff.append(item.getPath() + "" + item.getValue()).append("\n");
}
if (item.getOperation().equals(Operation.REMOVE)) {
removeBuff.append(item.getPath() + "" + item.getValue()).append("/n");
removeBuff.append(item.getPath() + "" + item.getValue()).append("\n");
}
if (item.getOperation().equals(Operation.REPLACE)) {
repBuff.append(item.getPath() + "" + item.getValue()).append("/n");
oldValue.append(item.getPath() + "" + item.getSrcValue()).append("/n");
repBuff.append(item.getPath() + "" + item.getValue()).append("\n");
oldValue.append(item.getPath() + "" + item.getSrcValue()).append("\n");
}
}
StringBuilder newValue = new StringBuilder();
if (addBuff != null && addBuff.toString().length() > 0) {
newValue.append("添加:").append(addBuff).append("/n");
newValue.append("添加:").append(addBuff).append("\n");
}
if (removeBuff != null && removeBuff.toString().length() > 0) {
newValue.append("移除:").append(removeBuff).append("/n");
newValue.append("移除:").append(removeBuff).append("\n");
}
if (repBuff != null && repBuff.toString().length() > 0) {
newValue.append("修改:").append(repBuff).append("/n");
newValue.append("修改:").append(repBuff).append("\n");
}
DetailColumn column = new DetailColumn();
BeanUtils.copyBean(column, originalColumns.get(i));

View File

@ -0,0 +1,27 @@
package io.metersphere.log.vo.definition;
import java.util.LinkedHashMap;
import java.util.Map;
public class AutomationReference {
public static Map<String, String> automationColumns = new LinkedHashMap<>();
static {
automationColumns.clear();
automationColumns.put("name", "场景名称");
automationColumns.put("createUser", "创建人");
automationColumns.put("method", "请求类型");
automationColumns.put("modulePath", "模块");
automationColumns.put("level", "场景级别");
automationColumns.put("status", "场景状态");
automationColumns.put("principal", "责任人");
automationColumns.put("stepTotal", "步骤数");
automationColumns.put("passRate", "通过率");
automationColumns.put("lastResult", "最后执行结果");
automationColumns.put("tags", "标签");
automationColumns.put("scenarioDefinition", "场景步骤");
automationColumns.put("description", "描述");
// 需要深度对比的字段可以支持多个req1,req2
automationColumns.put("ms-dff-col", "scenarioDefinition");
}
}

View File

@ -5,12 +5,10 @@ import java.util.Map;
public class DefinitionReference {
public static Map<String, String> definitionColumns = new LinkedHashMap<>();
public static Map<String, String> moduleColumns = new LinkedHashMap<>();
public static Map<String, String> caseColumns = new LinkedHashMap<>();
static {
definitionColumns.clear();
moduleColumns.clear();
caseColumns.clear();
definitionColumns.put("name", "接口名称");
definitionColumns.put("createUser", "创建人");
@ -27,11 +25,6 @@ public class DefinitionReference {
// 需要深度对比的字段可以支持多个req1,req2
definitionColumns.put("ms-dff-col", "request,response");
// 模块列数据
moduleColumns.put("name", "模块名称");
moduleColumns.put("createUser", "创建人");
moduleColumns.put("protocol", "协议");
moduleColumns.put("level", "模块级别");
// 用例列数据
caseColumns.put("name", "用例名称");
caseColumns.put("priority", "用例级别");

View File

@ -0,0 +1,18 @@
package io.metersphere.log.vo.definition;
import java.util.LinkedHashMap;
import java.util.Map;
public class ModuleReference {
public static Map<String, String> moduleColumns = new LinkedHashMap<>();
static {
moduleColumns.clear();
// 模块列数据
moduleColumns.put("name", "模块名称");
moduleColumns.put("createUser", "创建人");
moduleColumns.put("protocol", "协议");
moduleColumns.put("level", "模块级别");
}
}

View File

@ -55,3 +55,6 @@ CREATE TABLE `operating_log` (
-- add all table create_user
ALTER TABLE api_definition ADD create_user VARCHAR(100) NULL;
ALTER TABLE api_module ADD create_user VARCHAR(100) NULL;
ALTER TABLE api_scenario ADD create_user VARCHAR(100) NULL;
ALTER TABLE api_scenario_module ADD create_user VARCHAR(100) NULL;
ALTER TABLE api_scenario_report ADD create_user VARCHAR(100) NULL;

View File

@ -222,3 +222,12 @@ template_already=A template already exists under this workspace:
expect_name_exists=Expect name is exists
ssl_password_error=The authentication password is wrong, please re-enter the password
ssl_file_error=Failed to load the certification file, please check the certification file
#log
api_definition=Api definition
api_automation=Api automation
api_automation_report=Test Report
track_test_case=Test case
track_test_case_review=Case review
track_test_plan=Test plan
track_bug=Defect management
track_report=Report

View File

@ -223,3 +223,10 @@ ssl_password_error=认证密码错误,请重新输入密码
ssl_file_error=认证文件加载失败,请检查认证文件
#log
api_definition=接口定义
api_automation=接口自动化
api_automation_report=测试报告
track_test_case=测试用例
track_test_case_review=用例评审
track_test_plan=测试计划
track_bug=缺陷管理
track_report=报告

View File

@ -223,3 +223,12 @@ template_already=工作空間下已存在該模板:
expect_name_exists=預期名稱已存在
ssl_password_error=認證密碼錯誤,請重新輸入密碼
ssl_file_error=認證文件加載失敗,請檢查認證文件
#log
api_definition=接口定義
api_automation=接口自動化
api_automation_report=測試報告
track_test_case=測試用例
track_test_case_review=用例評審
track_test_plan=測試計劃
track_bug=缺陷管理
track_report=報告

View File

@ -13,7 +13,7 @@
</div>
<div>
<p class="tip">{{ this.$t('report.test_log_details') }} </p>
<div v-if="detail && detail.operType !== 'CREATE' && detail && detail.details && detail.details.columns && detail.details.columns.length >0 ">
<div v-if="detail && detail.operType !== 'CREATE' && detail.operType !=='DELETE' && 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')"/>
@ -22,7 +22,7 @@
</el-table>
</div>
</div>
<div v-else-if="detail && (detail.details === null || (detail.details && detail.details.columns && detail.details.columns.length === 0))">
<div v-else-if="detail && (detail.operType ==='DELETE' || detail.details === null || (detail.details && detail.details.columns && detail.details.columns.length === 0))">
<span>{{detail.operTitle}} </span>
<span style="color: #409EFF">{{getType(detail.operType)}} </span>
<span style="color: #409EFF"> {{$t('api_test.home_page.detail_card.success')}}</span>