feat(用例管理): 脑图新增单独修改用例等级和名称的接口
This commit is contained in:
parent
e55d654bb2
commit
b7e8340a7c
|
@ -1,19 +1,25 @@
|
||||||
package io.metersphere.functional.controller;
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
||||||
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
||||||
|
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
|
||||||
|
import io.metersphere.functional.service.FunctionalCaseLogService;
|
||||||
import io.metersphere.functional.service.FunctionalCaseMinderService;
|
import io.metersphere.functional.service.FunctionalCaseMinderService;
|
||||||
|
import io.metersphere.functional.service.FunctionalCaseNoticeService;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
import io.metersphere.system.log.annotation.Log;
|
||||||
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
|
import io.metersphere.system.notice.annotation.SendNotice;
|
||||||
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.security.CheckOwner;
|
import io.metersphere.system.security.CheckOwner;
|
||||||
|
import io.metersphere.system.utils.SessionUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -36,4 +42,26 @@ public class FunctionalCaseMinderController {
|
||||||
return functionalCaseMinderService.getMindFunctionalCase(request, false);
|
return functionalCaseMinderService.getMindFunctionalCase(request, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update/source/name")
|
||||||
|
@Operation(summary = "脑图更新资源名称")
|
||||||
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
||||||
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateMinderFunctionalCaseLog(#request)", msClass = FunctionalCaseLogService.class)
|
||||||
|
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getMainFunctionalCaseMinderDTO(#request)", targetClass = FunctionalCaseNoticeService.class)
|
||||||
|
@CheckOwner(resourceId = "#request.getId()", resourceType = "functional_case")
|
||||||
|
public FunctionalCase updateFunctionalCaseName(@Validated @RequestBody FunctionalCaseMinderEditRequest request) {
|
||||||
|
String userId = SessionUtils.getUserId();
|
||||||
|
return functionalCaseMinderService.updateFunctionalCase(request, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update/source/priority")
|
||||||
|
@Operation(summary = "脑图更新资源名称")
|
||||||
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
||||||
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateMinderFunctionalCaseLog(#request)", msClass = FunctionalCaseLogService.class)
|
||||||
|
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getMainFunctionalCaseMinderDTO(#request)", targetClass = FunctionalCaseNoticeService.class)
|
||||||
|
@CheckOwner(resourceId = "#request.getId()", resourceType = "functional_case")
|
||||||
|
public FunctionalCase updateFunctionalCasePriority(@Validated @RequestBody FunctionalCaseMinderEditRequest request) {
|
||||||
|
String userId = SessionUtils.getUserId();
|
||||||
|
return functionalCaseMinderService.updateFunctionalCase(request, userId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package io.metersphere.functional.request;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wx
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FunctionalCaseMinderEditRequest{
|
||||||
|
|
||||||
|
@Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "{functional_case.id.not_blank}")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "项目id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "{functional_case.project_id.not_blank}")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
@Schema(description = "资源名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "用例等级")
|
||||||
|
private String priority;
|
||||||
|
|
||||||
|
@Schema(description = "评审结果")
|
||||||
|
private String reviewStatus;
|
||||||
|
|
||||||
|
@Schema(description = "执行结果")
|
||||||
|
private String executeStatus;
|
||||||
|
|
||||||
|
}
|
|
@ -13,12 +13,18 @@ import io.metersphere.project.domain.FileAssociation;
|
||||||
import io.metersphere.project.domain.FileAssociationExample;
|
import io.metersphere.project.domain.FileAssociationExample;
|
||||||
import io.metersphere.project.mapper.FileAssociationMapper;
|
import io.metersphere.project.mapper.FileAssociationMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
import io.metersphere.system.domain.CustomField;
|
||||||
|
import io.metersphere.system.domain.CustomFieldExample;
|
||||||
import io.metersphere.system.log.constants.OperationLogModule;
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
|
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -50,11 +56,15 @@ public class FunctionalCaseLogService {
|
||||||
@Resource
|
@Resource
|
||||||
private FileAssociationMapper fileAssociationMapper;
|
private FileAssociationMapper fileAssociationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomFieldMapper customFieldMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BugRelationCaseMapper bugRelationCaseMapper;
|
private BugRelationCaseMapper bugRelationCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugMapper bugMapper;
|
private BugMapper bugMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用例 日志
|
* 更新用例 日志
|
||||||
*
|
*
|
||||||
|
@ -63,17 +73,7 @@ public class FunctionalCaseLogService {
|
||||||
*/
|
*/
|
||||||
public LogDTO updateFunctionalCaseFileLog(FunctionalCaseAssociationFileRequest request) {
|
public LogDTO updateFunctionalCaseFileLog(FunctionalCaseAssociationFileRequest request) {
|
||||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
||||||
LogDTO dto = new LogDTO(
|
LogDTO dto = getUpdateLogDTO(request.getProjectId(), request.getCaseId(), historyLogDTO.getFunctionalCase().getName(), "/attachment/upload/file");
|
||||||
request.getProjectId(),
|
|
||||||
null,
|
|
||||||
request.getCaseId(),
|
|
||||||
null,
|
|
||||||
OperationLogType.UPDATE.name(),
|
|
||||||
OperationLogModule.FUNCTIONAL_CASE,
|
|
||||||
historyLogDTO.getFunctionalCase().getName());
|
|
||||||
dto.setHistory(true);
|
|
||||||
dto.setPath("/attachment/upload/file");
|
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
|
||||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -88,17 +88,7 @@ public class FunctionalCaseLogService {
|
||||||
*/
|
*/
|
||||||
public LogDTO deleteFunctionalCaseFileLog(FunctionalCaseDeleteFileRequest request) {
|
public LogDTO deleteFunctionalCaseFileLog(FunctionalCaseDeleteFileRequest request) {
|
||||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
||||||
LogDTO dto = new LogDTO(
|
LogDTO dto = getUpdateLogDTO(request.getProjectId(), request.getCaseId(), historyLogDTO.getFunctionalCase().getName(), "/attachment/delete/file");
|
||||||
request.getProjectId(),
|
|
||||||
null,
|
|
||||||
request.getCaseId(),
|
|
||||||
null,
|
|
||||||
OperationLogType.UPDATE.name(),
|
|
||||||
OperationLogModule.FUNCTIONAL_CASE,
|
|
||||||
historyLogDTO.getFunctionalCase().getName());
|
|
||||||
dto.setHistory(true);
|
|
||||||
dto.setPath("/attachment/delete/file");
|
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
|
||||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -114,17 +104,7 @@ public class FunctionalCaseLogService {
|
||||||
*/
|
*/
|
||||||
public LogDTO updateFunctionalCaseLog(FunctionalCaseEditRequest requests, List<MultipartFile> files) {
|
public LogDTO updateFunctionalCaseLog(FunctionalCaseEditRequest requests, List<MultipartFile> files) {
|
||||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(requests.getId());
|
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(requests.getId());
|
||||||
LogDTO dto = new LogDTO(
|
LogDTO dto = getUpdateLogDTO(requests.getProjectId(), requests.getId(), requests.getName(), "/functional/case/update");
|
||||||
requests.getProjectId(),
|
|
||||||
null,
|
|
||||||
requests.getId(),
|
|
||||||
null,
|
|
||||||
OperationLogType.UPDATE.name(),
|
|
||||||
OperationLogModule.FUNCTIONAL_CASE,
|
|
||||||
requests.getName());
|
|
||||||
dto.setHistory(true);
|
|
||||||
dto.setPath("/functional/case/update");
|
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
|
||||||
dto.setModifiedValue(JSON.toJSONBytes(requests));
|
dto.setModifiedValue(JSON.toJSONBytes(requests));
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -348,17 +328,7 @@ public class FunctionalCaseLogService {
|
||||||
List<FunctionalCase> functionalCases = extFunctionalCaseMapper.getLogInfo(ids, false);
|
List<FunctionalCase> functionalCases = extFunctionalCaseMapper.getLogInfo(ids, false);
|
||||||
functionalCases.forEach(functionalCase -> {
|
functionalCases.forEach(functionalCase -> {
|
||||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(functionalCase.getId());
|
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(functionalCase.getId());
|
||||||
LogDTO dto = new LogDTO(
|
LogDTO dto = getUpdateLogDTO(functionalCase.getProjectId(), functionalCase.getId(), functionalCase.getName(), "/functional/case/batch/edit");
|
||||||
functionalCase.getProjectId(),
|
|
||||||
null,
|
|
||||||
functionalCase.getId(),
|
|
||||||
null,
|
|
||||||
OperationLogType.UPDATE.name(),
|
|
||||||
OperationLogModule.FUNCTIONAL_CASE,
|
|
||||||
functionalCase.getName());
|
|
||||||
dto.setHistory(true);
|
|
||||||
dto.setPath("/functional/case/batch/edit");
|
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||||
dtoList.add(dto);
|
dtoList.add(dto);
|
||||||
});
|
});
|
||||||
|
@ -444,4 +414,46 @@ public class FunctionalCaseLogService {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogDTO updateMinderFunctionalCaseLog(FunctionalCaseMinderEditRequest request) {
|
||||||
|
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getId());
|
||||||
|
LogDTO dto = getUpdateLogDTO(request.getProjectId(), request.getId(), request.getName(), "/functional/case/update");
|
||||||
|
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||||
|
FunctionalCaseHistoryLogDTO newDto = new FunctionalCaseHistoryLogDTO();
|
||||||
|
BeanUtils.copyBean(newDto, historyLogDTO);
|
||||||
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
|
newDto.getFunctionalCase().setName(request.getName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getPriority())) {
|
||||||
|
List<FunctionalCaseCustomField> functionalCaseCustomFields = newDto.getCustomFields();
|
||||||
|
CustomFieldExample example = new CustomFieldExample();
|
||||||
|
example.createCriteria().andNameEqualTo("functional_priority").andSceneEqualTo("FUNCTIONAL").andScopeIdEqualTo(request.getProjectId());
|
||||||
|
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||||
|
String field = customFields.get(0).getId();
|
||||||
|
for (FunctionalCaseCustomField customField : functionalCaseCustomFields) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(customField.getFieldId(), field)) {
|
||||||
|
customField.setValue(request.getPriority());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newDto.setCustomFields(functionalCaseCustomFields);
|
||||||
|
}
|
||||||
|
dto.setModifiedValue(JSON.toJSONBytes(newDto));
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static LogDTO getUpdateLogDTO(String projectId, String sourceId, String content, String path) {
|
||||||
|
LogDTO dto = new LogDTO(
|
||||||
|
projectId,
|
||||||
|
null,
|
||||||
|
sourceId,
|
||||||
|
null,
|
||||||
|
OperationLogType.UPDATE.name(),
|
||||||
|
OperationLogModule.FUNCTIONAL_CASE,
|
||||||
|
content);
|
||||||
|
dto.setHistory(true);
|
||||||
|
dto.setPath(path);
|
||||||
|
dto.setMethod(HttpMethodConstants.POST.name());
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
package io.metersphere.functional.service;
|
package io.metersphere.functional.service;
|
||||||
|
|
||||||
import io.metersphere.functional.constants.MinderLabel;
|
import io.metersphere.functional.constants.MinderLabel;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseMindDTO;
|
import io.metersphere.functional.dto.FunctionalCaseMindDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
|
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalMinderTreeNodeDTO;
|
import io.metersphere.functional.dto.FunctionalMinderTreeNodeDTO;
|
||||||
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
||||||
|
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
||||||
|
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||||
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
||||||
|
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
import io.metersphere.system.domain.CustomField;
|
||||||
|
import io.metersphere.system.domain.CustomFieldExample;
|
||||||
|
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -29,6 +38,14 @@ public class FunctionalCaseMinderService {
|
||||||
@Resource
|
@Resource
|
||||||
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
|
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FunctionalCaseMapper functionalCaseMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomFieldMapper customFieldMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能用例-脑图用例列表查询
|
* 功能用例-脑图用例列表查询
|
||||||
|
@ -109,4 +126,35 @@ public class FunctionalCaseMinderService {
|
||||||
return functionalMinderTreeDTO;
|
return functionalMinderTreeDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FunctionalCase updateFunctionalCase(FunctionalCaseMinderEditRequest request, String userId) {
|
||||||
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
|
FunctionalCase functionalCase = new FunctionalCase();
|
||||||
|
functionalCase.setName(request.getName());
|
||||||
|
buildUpdateCaseParam(request, userId, functionalCase);
|
||||||
|
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
|
||||||
|
return functionalCase;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getPriority())) {
|
||||||
|
CustomFieldExample example = new CustomFieldExample();
|
||||||
|
example.createCriteria().andNameEqualTo("functional_priority").andSceneEqualTo("FUNCTIONAL").andScopeIdEqualTo(request.getProjectId());
|
||||||
|
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||||
|
String field = customFields.get(0).getId();
|
||||||
|
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||||
|
customField.setCaseId(request.getId());
|
||||||
|
customField.setFieldId(field);
|
||||||
|
customField.setValue(request.getPriority());
|
||||||
|
functionalCaseCustomFieldMapper.updateByPrimaryKeySelective(customField);
|
||||||
|
FunctionalCase functionalCase = new FunctionalCase();
|
||||||
|
buildUpdateCaseParam(request, userId, functionalCase);
|
||||||
|
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
|
||||||
|
return functionalCase;
|
||||||
|
}
|
||||||
|
return new FunctionalCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void buildUpdateCaseParam(FunctionalCaseMinderEditRequest request, String userId, FunctionalCase functionalCase) {
|
||||||
|
functionalCase.setId(request.getId());
|
||||||
|
functionalCase.setUpdateUser(userId);
|
||||||
|
functionalCase.setUpdateTime(System.currentTimeMillis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||||
import io.metersphere.functional.request.FunctionalCaseAddRequest;
|
import io.metersphere.functional.request.FunctionalCaseAddRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCaseCommentRequest;
|
import io.metersphere.functional.request.FunctionalCaseCommentRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCaseEditRequest;
|
import io.metersphere.functional.request.FunctionalCaseEditRequest;
|
||||||
|
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.system.domain.CustomField;
|
import io.metersphere.system.domain.CustomField;
|
||||||
import io.metersphere.system.domain.CustomFieldExample;
|
import io.metersphere.system.domain.CustomFieldExample;
|
||||||
|
@ -251,4 +252,41 @@ public class FunctionalCaseNoticeService {
|
||||||
return dtoList;
|
return dtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FunctionalCaseDTO getMainFunctionalCaseMinderDTO(FunctionalCaseMinderEditRequest request) {
|
||||||
|
FunctionalCaseDTO functionalCaseDTO = new FunctionalCaseDTO();
|
||||||
|
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(request.getId());
|
||||||
|
BeanUtils.copyBean(functionalCaseDTO, functionalCase);
|
||||||
|
setReviewName(request.getId(), functionalCaseDTO);
|
||||||
|
functionalCaseDTO.setTriggerMode(NoticeConstants.TriggerMode.MANUAL_EXECUTION);
|
||||||
|
List<OptionDTO> fields = new ArrayList<>();
|
||||||
|
FunctionalCaseCustomFieldExample fieldExample = new FunctionalCaseCustomFieldExample();
|
||||||
|
fieldExample.createCriteria().andCaseIdEqualTo(request.getId());
|
||||||
|
List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(fieldExample);
|
||||||
|
CustomFieldExample example = new CustomFieldExample();
|
||||||
|
example.createCriteria().andNameEqualTo("functional_priority").andSceneEqualTo("FUNCTIONAL").andScopeIdEqualTo(request.getProjectId());
|
||||||
|
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||||
|
String field = customFields.get(0).getId();
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(functionalCaseCustomFields)) {
|
||||||
|
for (FunctionalCaseCustomField customFieldDTO : functionalCaseCustomFields) {
|
||||||
|
OptionDTO optionDTO = new OptionDTO();
|
||||||
|
CustomField customField = customFieldMapper.selectByPrimaryKey(customFieldDTO.getFieldId());
|
||||||
|
if (customField == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
optionDTO.setId(customField.getName());
|
||||||
|
if (StringUtils.equalsIgnoreCase(customField.getId(),field) && StringUtils.isNotBlank(request.getPriority())) {
|
||||||
|
optionDTO.setName(request.getPriority());
|
||||||
|
} else {
|
||||||
|
optionDTO.setName(customFieldDTO.getValue());
|
||||||
|
}
|
||||||
|
fields.add(optionDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
functionalCaseDTO.setFields(fields);
|
||||||
|
//TODO:设置测试计划名称
|
||||||
|
return functionalCaseDTO;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
package io.metersphere.functional.controller;
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseBlob;
|
import io.metersphere.functional.domain.FunctionalCaseBlob;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseCustomFieldExample;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
|
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseBlobMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseBlobMapper;
|
||||||
|
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
||||||
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
import io.metersphere.functional.request.FunctionalCaseMindRequest;
|
||||||
|
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
@ -20,14 +26,21 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class FunctionalCaseMinderControllerTest extends BaseTest {
|
public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||||
|
|
||||||
public static final String FUNCTIONAL_CASE_LIST_URL = "/functional/mind/case/list";
|
public static final String FUNCTIONAL_CASE_LIST_URL = "/functional/mind/case/list";
|
||||||
|
|
||||||
|
public static final String FUNCTIONAL_CASE_UPDATE_NAME_URL = "/functional/mind/case/update/source/name";
|
||||||
|
|
||||||
|
public static final String FUNCTIONAL_CASE_UPDATE_PRIORITY_URL = "/functional/mind/case/update/source/priority";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseBlobMapper functionalCaseBlobMapper;
|
private FunctionalCaseBlobMapper functionalCaseBlobMapper;
|
||||||
|
@Resource
|
||||||
|
private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -68,9 +81,54 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||||
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
|
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
|
||||||
Assertions.assertNotNull(baseTreeNodes);
|
Assertions.assertNotNull(baseTreeNodes);
|
||||||
String jsonString = JSON.toJSONString(baseTreeNodes);
|
String jsonString = JSON.toJSONString(baseTreeNodes);
|
||||||
System.out.println(jsonString);
|
System.out.println(jsonString);
|
||||||
Assertions.assertEquals(2,baseTreeNodes.size());
|
Assertions.assertEquals(2, baseTreeNodes.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(2)
|
||||||
|
public void testUpdateCase() throws Exception {
|
||||||
|
|
||||||
|
FunctionalCaseMinderEditRequest request = new FunctionalCaseMinderEditRequest();
|
||||||
|
request.setProjectId("project-case-minder-test");
|
||||||
|
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
|
||||||
|
request.setName("TEST_FUNCTIONAL_MINDER_CASE_ID_Change_Name");
|
||||||
|
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
|
||||||
|
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
|
FunctionalCase baseTreeNodes = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), FunctionalCase.class);
|
||||||
|
Assertions.assertNotNull(baseTreeNodes);
|
||||||
|
String jsonString = JSON.toJSONString(baseTreeNodes);
|
||||||
|
System.out.println(jsonString);
|
||||||
|
Assertions.assertEquals(baseTreeNodes.getName(), "TEST_FUNCTIONAL_MINDER_CASE_ID_Change_Name");
|
||||||
|
|
||||||
|
request = new FunctionalCaseMinderEditRequest();
|
||||||
|
request.setProjectId("project-case-minder-test");
|
||||||
|
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
|
||||||
|
request.setPriority("P0");
|
||||||
|
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_PRIORITY_URL, request);
|
||||||
|
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
|
baseTreeNodes = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), FunctionalCase.class);
|
||||||
|
Assertions.assertNotNull(baseTreeNodes);
|
||||||
|
jsonString = JSON.toJSONString(baseTreeNodes);
|
||||||
|
System.out.println(jsonString);
|
||||||
|
FunctionalCaseCustomFieldExample customField = new FunctionalCaseCustomFieldExample();
|
||||||
|
customField.createCriteria().andCaseIdEqualTo(request.getId()).andFieldIdEqualTo("custom_field_minder_gyq_id_3");
|
||||||
|
List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customField);
|
||||||
|
Assertions.assertEquals(functionalCaseCustomFields.get(0).getValue(), "P0");
|
||||||
|
|
||||||
|
request = new FunctionalCaseMinderEditRequest();
|
||||||
|
request.setProjectId("project-case-minder-test");
|
||||||
|
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
|
||||||
|
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_PRIORITY_URL, request);
|
||||||
|
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
|
baseTreeNodes = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), FunctionalCase.class);
|
||||||
|
Assertions.assertTrue(StringUtils.isBlank(baseTreeNodes.getName()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ INSERT INTO functional_case_blob(id, steps, text_description, expected_result, p
|
||||||
|
|
||||||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_1', 'custom_field_minder_gyq_id_3', 'P0');
|
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_1', 'custom_field_minder_gyq_id_3', 'P0');
|
||||||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_2', 'custom_field_minder_gyq_id_3', 'P3');
|
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_2', 'custom_field_minder_gyq_id_3', 'P3');
|
||||||
|
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_6', 'custom_field_minder_gyq_id_3', 'P2');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user)
|
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user)
|
||||||
|
@ -27,8 +29,10 @@ VALUES
|
||||||
('TEST_MINDER_MODULE_ID_GYQ5', 'project-case-minder-test', '测试所属模块5', 'TEST_MINDER_MODULE_ID_GYQ4', 0, 1669174143999, 1669174143999, 'admin', 'admin');
|
('TEST_MINDER_MODULE_ID_GYQ5', 'project-case-minder-test', '测试所属模块5', 'TEST_MINDER_MODULE_ID_GYQ4', 0, 1669174143999, 1669174143999, 'admin', 'admin');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUE
|
INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUES
|
||||||
('custom_field_minder_gyq_id_3', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001');
|
('custom_field_minder_gyq_id_2', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001'),
|
||||||
|
('custom_field_minder_gyq_id_3', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'PROJECT', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'project-case-minder-test');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user)
|
INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user)
|
||||||
|
|
Loading…
Reference in New Issue