feat(用例管理): 关联附件-文件库列表分页接口
This commit is contained in:
parent
bff4a60c58
commit
c89d59f530
|
@ -0,0 +1,40 @@
|
||||||
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
|
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
||||||
|
import io.metersphere.project.dto.filemanagement.response.FileInformationResponse;
|
||||||
|
import io.metersphere.project.service.FileMetadataService;
|
||||||
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
import io.metersphere.system.utils.Pager;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wx
|
||||||
|
*/
|
||||||
|
@Tag(name = "用例管理-功能用例-附件")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/attachment/")
|
||||||
|
public class FunctionalCaseAttachmentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileMetadataService fileMetadataService;
|
||||||
|
|
||||||
|
|
||||||
|
//TODO 附件操作:文件删除/文件下载/文件预览/文件转存/文件更新
|
||||||
|
|
||||||
|
@PostMapping("/page")
|
||||||
|
@Operation(summary = "功能用例-关联文件列表分页接口")
|
||||||
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
||||||
|
public Pager<List<FileInformationResponse>> page(@Validated @RequestBody FileMetadataTableRequest request) {
|
||||||
|
return fileMetadataService.page(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,6 @@ public class FunctionalCaseController {
|
||||||
|
|
||||||
//TODO 获取模板列表(多模板功能暂时不做)
|
//TODO 获取模板列表(多模板功能暂时不做)
|
||||||
|
|
||||||
//TODO 附件操作:文件删除/文件下载/文件预览/文件转存/文件更新
|
|
||||||
|
|
||||||
@GetMapping("/default/template/field/{projectId}")
|
@GetMapping("/default/template/field/{projectId}")
|
||||||
@Operation(summary = "功能用例-获取默认模板自定义字段")
|
@Operation(summary = "功能用例-获取默认模板自定义字段")
|
||||||
|
@ -65,7 +64,7 @@ public class FunctionalCaseController {
|
||||||
@Operation(summary = "功能用例-新增用例")
|
@Operation(summary = "功能用例-新增用例")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_ADD)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_ADD)
|
||||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addFunctionalCaseLog(#request, #files)", msClass = FunctionalCaseLogService.class)
|
@Log(type = OperationLogType.ADD, expression = "#msClass.addFunctionalCaseLog(#request, #files)", msClass = FunctionalCaseLogService.class)
|
||||||
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getMainFunctionalCaseDTO(#request.name, #request.caseEditType, #request.projectId, #request.customsFields)", targetClass = FunctionalCaseNoticeService.class)
|
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getMainFunctionalCaseDTO(#request.name, #request.caseEditType, #request.projectId, #request.customFields)", targetClass = FunctionalCaseNoticeService.class)
|
||||||
public FunctionalCase addFunctionalCase(@Validated @RequestPart("request") FunctionalCaseAddRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> files) {
|
public FunctionalCase addFunctionalCase(@Validated @RequestPart("request") FunctionalCaseAddRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> files) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
return functionalCaseService.addFunctionalCase(request, files, userId);
|
return functionalCaseService.addFunctionalCase(request, files, userId);
|
||||||
|
@ -84,7 +83,7 @@ public class FunctionalCaseController {
|
||||||
@Operation(summary = "功能用例-更新用例")
|
@Operation(summary = "功能用例-更新用例")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateFunctionalCaseLog(#request, #files)", msClass = FunctionalCaseLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateFunctionalCaseLog(#request, #files)", msClass = FunctionalCaseLogService.class)
|
||||||
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getMainFunctionalCaseDTO(#request.name, #request.caseEditType, #request.projectId, #request.customsFields)", targetClass = FunctionalCaseNoticeService.class)
|
@SendNotice(taskType = NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getMainFunctionalCaseDTO(#request.name, #request.caseEditType, #request.projectId, #request.customFields)", targetClass = FunctionalCaseNoticeService.class)
|
||||||
public FunctionalCase updateFunctionalCase(@Validated @RequestPart("request") FunctionalCaseEditRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> files) {
|
public FunctionalCase updateFunctionalCase(@Validated @RequestPart("request") FunctionalCaseEditRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> files) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
return functionalCaseService.updateFunctionalCase(request, files, userId);
|
return functionalCaseService.updateFunctionalCase(request, files, userId);
|
||||||
|
@ -149,8 +148,8 @@ public class FunctionalCaseController {
|
||||||
@GetMapping("/custom/field/{projectId}")
|
@GetMapping("/custom/field/{projectId}")
|
||||||
@Operation(summary = "功能用例-获取表头自定义字段(高级搜索中的自定义字段)")
|
@Operation(summary = "功能用例-获取表头自定义字段(高级搜索中的自定义字段)")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
||||||
public List<CustomFieldOptions> getTableCustomsField(@PathVariable String projectId) {
|
public List<CustomFieldOptions> getTableCustomField(@PathVariable String projectId) {
|
||||||
return projectTemplateService.getTableCustomsField(projectId, TemplateScene.FUNCTIONAL.name());
|
return projectTemplateService.getTableCustomField(projectId, TemplateScene.FUNCTIONAL.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch/move")
|
@PostMapping("/batch/move")
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class CaseCustomsFieldDTO implements Serializable {
|
public class CaseCustomFieldDTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class CaseCustomsFieldDTO implements Serializable {
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
CaseCustomsFieldDTO that = (CaseCustomsFieldDTO) o;
|
CaseCustomFieldDTO that = (CaseCustomFieldDTO) o;
|
||||||
return Objects.equals(fieldId, that.fieldId) && Objects.equals(value, that.value);
|
return Objects.equals(fieldId, that.fieldId) && Objects.equals(value, that.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,5 @@ public class FunctionalCasePageDTO extends FunctionalCase {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "自定义字段集合")
|
@Schema(description = "自定义字段集合")
|
||||||
private List<FunctionalCaseCustomField> customsFields;
|
private List<FunctionalCaseCustomField> customFields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package io.metersphere.functional.request;
|
package io.metersphere.functional.request;
|
||||||
|
|
||||||
import io.metersphere.functional.dto.CaseCustomsFieldDTO;
|
import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -65,7 +65,7 @@ public class FunctionalCaseAddRequest implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "自定义字段集合")
|
@Schema(description = "自定义字段集合")
|
||||||
private List<CaseCustomsFieldDTO> customsFields;
|
private List<CaseCustomFieldDTO> customFields;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "关联文件ID集合")
|
@Schema(description = "关联文件ID集合")
|
||||||
|
|
|
@ -3,7 +3,7 @@ package io.metersphere.functional.service;
|
||||||
|
|
||||||
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseCustomFieldExample;
|
import io.metersphere.functional.domain.FunctionalCaseCustomFieldExample;
|
||||||
import io.metersphere.functional.dto.CaseCustomsFieldDTO;
|
import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||||
import io.metersphere.functional.mapper.ExtFunctionalCaseCustomFieldMapper;
|
import io.metersphere.functional.mapper.ExtFunctionalCaseCustomFieldMapper;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -34,14 +34,14 @@ public class FunctionalCaseCustomFieldService {
|
||||||
/**
|
/**
|
||||||
* 保存 用例-自定义字段关系
|
* 保存 用例-自定义字段关系
|
||||||
*
|
*
|
||||||
* @param customsFields
|
* @param customFields
|
||||||
*/
|
*/
|
||||||
public void saveCustomField(String caseId, List<CaseCustomsFieldDTO> customsFields) {
|
public void saveCustomField(String caseId, List<CaseCustomFieldDTO> customFields) {
|
||||||
customsFields.forEach(customsField -> {
|
customFields.forEach(custom -> {
|
||||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||||
customField.setCaseId(caseId);
|
customField.setCaseId(caseId);
|
||||||
customField.setFieldId(customsField.getFieldId());
|
customField.setFieldId(custom.getFieldId());
|
||||||
customField.setValue(customsField.getValue());
|
customField.setValue(custom.getValue());
|
||||||
functionalCaseCustomFieldMapper.insertSelective(customField);
|
functionalCaseCustomFieldMapper.insertSelective(customField);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,21 +69,21 @@ public class FunctionalCaseCustomFieldService {
|
||||||
* 更新自定义字段
|
* 更新自定义字段
|
||||||
*
|
*
|
||||||
* @param caseId
|
* @param caseId
|
||||||
* @param customsFields
|
* @param customFields
|
||||||
*/
|
*/
|
||||||
public void updateCustomField(String caseId, List<CaseCustomsFieldDTO> customsFields) {
|
public void updateCustomField(String caseId, List<CaseCustomFieldDTO> customFields) {
|
||||||
List<String> fieldIds = customsFields.stream().map(CaseCustomsFieldDTO::getFieldId).collect(Collectors.toList());
|
List<String> fieldIds = customFields.stream().map(CaseCustomFieldDTO::getFieldId).collect(Collectors.toList());
|
||||||
FunctionalCaseCustomFieldExample example = new FunctionalCaseCustomFieldExample();
|
FunctionalCaseCustomFieldExample example = new FunctionalCaseCustomFieldExample();
|
||||||
example.createCriteria().andFieldIdIn(fieldIds).andCaseIdEqualTo(caseId);
|
example.createCriteria().andFieldIdIn(fieldIds).andCaseIdEqualTo(caseId);
|
||||||
List<FunctionalCaseCustomField> defaultFields = functionalCaseCustomFieldMapper.selectByExample(example);
|
List<FunctionalCaseCustomField> defaultFields = functionalCaseCustomFieldMapper.selectByExample(example);
|
||||||
Map<String, FunctionalCaseCustomField> collect = defaultFields.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getFieldId, (item) -> item));
|
Map<String, FunctionalCaseCustomField> collect = defaultFields.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getFieldId, (item) -> item));
|
||||||
List<CaseCustomsFieldDTO> addFields = new ArrayList<>();
|
List<CaseCustomFieldDTO> addFields = new ArrayList<>();
|
||||||
List<CaseCustomsFieldDTO> updateFields = new ArrayList<>();
|
List<CaseCustomFieldDTO> updateFields = new ArrayList<>();
|
||||||
customsFields.forEach(customsField -> {
|
customFields.forEach(customField -> {
|
||||||
if (collect.containsKey(customsField.getFieldId())) {
|
if (collect.containsKey(customField.getFieldId())) {
|
||||||
updateFields.add(customsField);
|
updateFields.add(customField);
|
||||||
} else {
|
} else {
|
||||||
addFields.add(customsField);
|
addFields.add(customField);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (CollectionUtils.isNotEmpty(addFields)) {
|
if (CollectionUtils.isNotEmpty(addFields)) {
|
||||||
|
@ -95,12 +95,12 @@ public class FunctionalCaseCustomFieldService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateField(String caseId, List<CaseCustomsFieldDTO> updateFields) {
|
private void updateField(String caseId, List<CaseCustomFieldDTO> updateFields) {
|
||||||
updateFields.forEach(customsField -> {
|
updateFields.forEach(custom -> {
|
||||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||||
customField.setCaseId(caseId);
|
customField.setCaseId(caseId);
|
||||||
customField.setFieldId(customsField.getFieldId());
|
customField.setFieldId(custom.getFieldId());
|
||||||
customField.setValue(customsField.getValue());
|
customField.setValue(custom.getValue());
|
||||||
functionalCaseCustomFieldMapper.updateByPrimaryKeySelective(customField);
|
functionalCaseCustomFieldMapper.updateByPrimaryKeySelective(customField);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package io.metersphere.functional.service;
|
||||||
import io.metersphere.functional.domain.FunctionalCase;
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
import io.metersphere.functional.domain.FunctionalCaseCustomField;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseCustomFieldExample;
|
import io.metersphere.functional.domain.FunctionalCaseCustomFieldExample;
|
||||||
import io.metersphere.functional.dto.CaseCustomsFieldDTO;
|
import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseDTO;
|
import io.metersphere.functional.dto.FunctionalCaseDTO;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||||
|
@ -114,7 +114,7 @@ public class FunctionalCaseNoticeService {
|
||||||
return optionDTOList;
|
return optionDTOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionalCaseDTO getMainFunctionalCaseDTO(String name, String caseEditType,String projectId, List<CaseCustomsFieldDTO> customsFields) {
|
public FunctionalCaseDTO getMainFunctionalCaseDTO(String name, String caseEditType,String projectId, List<CaseCustomFieldDTO> customFields) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
FunctionalCaseDTO functionalCaseDTO = new FunctionalCaseDTO();
|
FunctionalCaseDTO functionalCaseDTO = new FunctionalCaseDTO();
|
||||||
functionalCaseDTO.setName(name);
|
functionalCaseDTO.setName(name);
|
||||||
|
@ -122,15 +122,15 @@ public class FunctionalCaseNoticeService {
|
||||||
functionalCaseDTO.setCaseEditType(caseEditType);
|
functionalCaseDTO.setCaseEditType(caseEditType);
|
||||||
functionalCaseDTO.setCreateUser(userId);
|
functionalCaseDTO.setCreateUser(userId);
|
||||||
List<OptionDTO> fields = new ArrayList<>();
|
List<OptionDTO> fields = new ArrayList<>();
|
||||||
if (CollectionUtils.isNotEmpty(customsFields)) {
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
for (CaseCustomsFieldDTO customsFieldDTO : customsFields) {
|
for (CaseCustomFieldDTO customFieldDTO : customFields) {
|
||||||
OptionDTO optionDTO = new OptionDTO();
|
OptionDTO optionDTO = new OptionDTO();
|
||||||
CustomField customField = customFieldMapper.selectByPrimaryKey(customsFieldDTO.getFieldId());
|
CustomField customField = customFieldMapper.selectByPrimaryKey(customFieldDTO.getFieldId());
|
||||||
if (customField == null) {
|
if (customField == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
optionDTO.setId(customField.getName());
|
optionDTO.setId(customField.getName());
|
||||||
optionDTO.setName(customsFieldDTO.getValue());
|
optionDTO.setName(customFieldDTO.getValue());
|
||||||
fields.add(optionDTO);
|
fields.add(optionDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.functional.service;
|
package io.metersphere.functional.service;
|
||||||
|
|
||||||
import io.metersphere.functional.domain.*;
|
import io.metersphere.functional.domain.*;
|
||||||
import io.metersphere.functional.dto.CaseCustomsFieldDTO;
|
import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseDetailDTO;
|
import io.metersphere.functional.dto.FunctionalCaseDetailDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCasePageDTO;
|
import io.metersphere.functional.dto.FunctionalCasePageDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseVersionDTO;
|
import io.metersphere.functional.dto.FunctionalCaseVersionDTO;
|
||||||
|
@ -117,10 +117,10 @@ public class FunctionalCaseService {
|
||||||
BeanUtils.copyBean(functionalCaseBlob, request);
|
BeanUtils.copyBean(functionalCaseBlob, request);
|
||||||
functionalCaseBlobMapper.insertSelective(functionalCaseBlob);
|
functionalCaseBlobMapper.insertSelective(functionalCaseBlob);
|
||||||
//保存自定义字段
|
//保存自定义字段
|
||||||
List<CaseCustomsFieldDTO> customsFields = request.getCustomsFields();
|
List<CaseCustomFieldDTO> customFields = request.getCustomFields();
|
||||||
if (CollectionUtils.isNotEmpty(customsFields)) {
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
customsFields = customsFields.stream().distinct().collect(Collectors.toList());
|
customFields = customFields.stream().distinct().collect(Collectors.toList());
|
||||||
functionalCaseCustomFieldService.saveCustomField(caseId, customsFields);
|
functionalCaseCustomFieldService.saveCustomField(caseId, customFields);
|
||||||
}
|
}
|
||||||
return functionalCase;
|
return functionalCase;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ public class FunctionalCaseService {
|
||||||
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
|
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
|
||||||
|
|
||||||
//更新自定义字段
|
//更新自定义字段
|
||||||
functionalCaseCustomFieldService.updateCustomField(request.getId(), request.getCustomsFields());
|
functionalCaseCustomFieldService.updateCustomField(request.getId(), request.getCustomFields());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ public class FunctionalCaseService {
|
||||||
List<FunctionalCaseCustomField> customFields = functionalCaseCustomFieldService.getCustomFieldByCaseIds(ids);
|
List<FunctionalCaseCustomField> customFields = functionalCaseCustomFieldService.getCustomFieldByCaseIds(ids);
|
||||||
Map<String, List<FunctionalCaseCustomField>> collect = customFields.stream().collect(Collectors.groupingBy(FunctionalCaseCustomField::getCaseId));
|
Map<String, List<FunctionalCaseCustomField>> collect = customFields.stream().collect(Collectors.groupingBy(FunctionalCaseCustomField::getCaseId));
|
||||||
functionalCaseLists.forEach(functionalCasePageDTO -> {
|
functionalCaseLists.forEach(functionalCasePageDTO -> {
|
||||||
functionalCasePageDTO.setCustomsFields(collect.get(functionalCasePageDTO.getId()));
|
functionalCasePageDTO.setCustomFields(collect.get(functionalCasePageDTO.getId()));
|
||||||
});
|
});
|
||||||
return functionalCaseLists;
|
return functionalCaseLists;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
|
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
||||||
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
import io.metersphere.system.base.BaseTest;
|
||||||
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
public class FunctionalCaseAttachmentControllerTests extends BaseTest {
|
||||||
|
|
||||||
|
public static final String ATTACHMENT_PAGE_URL = "/attachment/page";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(1)
|
||||||
|
public void testAttachmentPage() throws Exception {
|
||||||
|
FileMetadataTableRequest request = new FileMetadataTableRequest();
|
||||||
|
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
|
request.setCurrent(1);
|
||||||
|
request.setPageSize(10);
|
||||||
|
MvcResult mvcResult = this.requestPostWithOkAndReturn(ATTACHMENT_PAGE_URL, request);
|
||||||
|
String updateReturnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder updateResultHolder = JSON.parseObject(updateReturnData, ResultHolder.class);
|
||||||
|
Assertions.assertNotNull(updateResultHolder);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.functional.controller;
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
import io.metersphere.functional.domain.FunctionalCase;
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
import io.metersphere.functional.dto.CaseCustomsFieldDTO;
|
import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||||
import io.metersphere.functional.request.*;
|
import io.metersphere.functional.request.*;
|
||||||
import io.metersphere.functional.result.FunctionalCaseResultCode;
|
import io.metersphere.functional.result.FunctionalCaseResultCode;
|
||||||
import io.metersphere.functional.utils.FileBaseUtils;
|
import io.metersphere.functional.utils.FileBaseUtils;
|
||||||
|
@ -48,6 +48,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
public static final String FUNCTIONAL_CASE_TABLE_URL = "/functional/case/custom/field/";
|
public static final String FUNCTIONAL_CASE_TABLE_URL = "/functional/case/custom/field/";
|
||||||
public static final String FUNCTIONAL_CASE_BATCH_MOVE_URL = "/functional/case/batch/move";
|
public static final String FUNCTIONAL_CASE_BATCH_MOVE_URL = "/functional/case/batch/move";
|
||||||
public static final String FUNCTIONAL_CASE_BATCH_COPY_URL = "/functional/case/batch/copy";
|
public static final String FUNCTIONAL_CASE_BATCH_COPY_URL = "/functional/case/batch/copy";
|
||||||
|
public static final String FUNCTIONAL_CASE_VERSION_URL = "/functional/case/version/";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private NotificationMapper notificationMapper;
|
private NotificationMapper notificationMapper;
|
||||||
|
@ -73,8 +74,8 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
|
||||||
//设置自定义字段
|
//设置自定义字段
|
||||||
List<CaseCustomsFieldDTO> dtoList = creatCustomsFields();
|
List<CaseCustomFieldDTO> dtoList = creatCustomFields();
|
||||||
request.setCustomsFields(dtoList);
|
request.setCustomFields(dtoList);
|
||||||
|
|
||||||
//设置文件
|
//设置文件
|
||||||
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test.JPG")).getPath();
|
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test.JPG")).getPath();
|
||||||
|
@ -125,30 +126,30 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CaseCustomsFieldDTO> creatCustomsFields() {
|
private List<CaseCustomFieldDTO> creatCustomFields() {
|
||||||
insertCustomField();
|
insertCustomField();
|
||||||
List<CaseCustomsFieldDTO> list = new ArrayList<>();
|
List<CaseCustomFieldDTO> list = new ArrayList<>();
|
||||||
CaseCustomsFieldDTO customsFieldDTO = new CaseCustomsFieldDTO();
|
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
|
||||||
customsFieldDTO.setFieldId("customs_field_id_1");
|
customFieldDTO.setFieldId("custom_field_id_1");
|
||||||
customsFieldDTO.setValue("customs_field_value_1");
|
customFieldDTO.setValue("custom_field_value_1");
|
||||||
list.add(customsFieldDTO);
|
list.add(customFieldDTO);
|
||||||
CaseCustomsFieldDTO customsFieldDTO2 = new CaseCustomsFieldDTO();
|
CaseCustomFieldDTO customFieldDTO2 = new CaseCustomFieldDTO();
|
||||||
customsFieldDTO2.setFieldId("customs_field_id_2");
|
customFieldDTO2.setFieldId("custom_field_id_2");
|
||||||
customsFieldDTO2.setValue("customs_field_value_2");
|
customFieldDTO2.setValue("custom_field_value_2");
|
||||||
list.add(customsFieldDTO2);
|
list.add(customFieldDTO2);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertCustomField() {
|
private void insertCustomField() {
|
||||||
CustomField customField = new CustomField();
|
CustomField customField = new CustomField();
|
||||||
customField.setId("customs_field_id_1");
|
customField.setId("custom_field_id_1");
|
||||||
customField.setName("test_customs_field_id_1");
|
customField.setName("test_custom_field_id_1");
|
||||||
customField.setType(CustomFieldType.INPUT.toString());
|
customField.setType(CustomFieldType.INPUT.toString());
|
||||||
customField.setScene(TemplateScene.FUNCTIONAL.name());
|
customField.setScene(TemplateScene.FUNCTIONAL.name());
|
||||||
customField.setCreateUser("gyq");
|
customField.setCreateUser("gyq");
|
||||||
customField.setCreateTime(System.currentTimeMillis());
|
customField.setCreateTime(System.currentTimeMillis());
|
||||||
customField.setUpdateTime(System.currentTimeMillis());
|
customField.setUpdateTime(System.currentTimeMillis());
|
||||||
customField.setRefId("test_customs_field_id_1");
|
customField.setRefId("test_custom_field_id_1");
|
||||||
customField.setScopeId(DEFAULT_PROJECT_ID);
|
customField.setScopeId(DEFAULT_PROJECT_ID);
|
||||||
customField.setScopeType(TemplateScopeType.PROJECT.name());
|
customField.setScopeType(TemplateScopeType.PROJECT.name());
|
||||||
customField.setInternal(false);
|
customField.setInternal(false);
|
||||||
|
@ -173,8 +174,8 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
public void testUpdateFunctionalCase() throws Exception {
|
public void testUpdateFunctionalCase() throws Exception {
|
||||||
FunctionalCaseEditRequest request = creatEditRequest();
|
FunctionalCaseEditRequest request = creatEditRequest();
|
||||||
//设置自定义字段
|
//设置自定义字段
|
||||||
List<CaseCustomsFieldDTO> list = updateCustomsFields(request);
|
List<CaseCustomFieldDTO> list = updateCustomFields(request);
|
||||||
request.setCustomsFields(list);
|
request.setCustomFields(list);
|
||||||
LinkedMultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
LinkedMultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||||
List<MockMultipartFile> files = new ArrayList<>();
|
List<MockMultipartFile> files = new ArrayList<>();
|
||||||
paramMap.add("request", JSON.toJSONString(request));
|
paramMap.add("request", JSON.toJSONString(request));
|
||||||
|
@ -196,14 +197,14 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CaseCustomsFieldDTO> updateCustomsFields(FunctionalCaseEditRequest editRequest) {
|
private List<CaseCustomFieldDTO> updateCustomFields(FunctionalCaseEditRequest editRequest) {
|
||||||
List<CaseCustomsFieldDTO> list = new ArrayList<>() {{
|
List<CaseCustomFieldDTO> list = new ArrayList<>() {{
|
||||||
add(new CaseCustomsFieldDTO() {{
|
add(new CaseCustomFieldDTO() {{
|
||||||
setFieldId("customs_field_id_1");
|
setFieldId("custom_field_id_1");
|
||||||
setValue("测试更新");
|
setValue("测试更新");
|
||||||
}});
|
}});
|
||||||
add(new CaseCustomsFieldDTO() {{
|
add(new CaseCustomFieldDTO() {{
|
||||||
setFieldId("customs_field_id_2");
|
setFieldId("custom_field_id_2");
|
||||||
setValue("更新时存在新字段");
|
setValue("更新时存在新字段");
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
@ -271,7 +272,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
|
|
||||||
//自定义字段 测试
|
//自定义字段 测试
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("customs", Arrays.asList(new LinkedHashMap() {{
|
map.put("custom", Arrays.asList(new LinkedHashMap() {{
|
||||||
put("id", "TEST_FIELD_ID");
|
put("id", "TEST_FIELD_ID");
|
||||||
put("operator", "in");
|
put("operator", "in");
|
||||||
put("value", "222");
|
put("value", "222");
|
||||||
|
@ -351,4 +352,13 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||||
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_COPY_URL, request);
|
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_COPY_URL, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(2)
|
||||||
|
public void testVersion() throws Exception {
|
||||||
|
MvcResult mvcResult = this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_VERSION_URL + "TEST_FUNCTIONAL_CASE_ID");
|
||||||
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, r
|
||||||
VALUES ('TEST_FUNCTIONAL_CASE_ID_6', 6, 'TEST_MOUDLE_ID', '100001100001', '100001', 'copy_测试多版本', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'TEST_REF_ID_1', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
VALUES ('TEST_FUNCTIONAL_CASE_ID_6', 6, 'TEST_MOUDLE_ID', '100001100001', '100001', 'copy_测试多版本', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'TEST_REF_ID_1', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
||||||
|
|
||||||
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
||||||
VALUES ('TEST_FUNCTIONAL_CASE_ID_7', 7, 'TEST_MOUDLE_ID', '100001100001', '100001', 'copy_测试多版本', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'TEST_REF_ID_2', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
VALUES ('TEST_FUNCTIONAL_CASE_ID_7', 7, 'TEST_MOUDLE_ID', '100001100001', '100001', 'copy_long_name_11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'TEST_REF_ID_2', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
||||||
|
|
||||||
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('TEST_FUNCTIONAL_CASE_ID', 'STEP', '1111', NULL, NULL, 'TEST');
|
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('TEST_FUNCTIONAL_CASE_ID', 'STEP', '1111', NULL, NULL, 'TEST');
|
||||||
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('TEST_FUNCTIONAL_CASE_ID_1', 'STEP', '1111', NULL, NULL, '1111');
|
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('TEST_FUNCTIONAL_CASE_ID_1', 'STEP', '1111', NULL, NULL, '1111');
|
||||||
|
|
|
@ -394,7 +394,7 @@ public class ProjectTemplateService extends BaseTemplateService {
|
||||||
* @param scene
|
* @param scene
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<CustomFieldOptions> getTableCustomsField(String projectId, String scene) {
|
public List<CustomFieldOptions> getTableCustomField(String projectId, String scene) {
|
||||||
TemplateExample example = new TemplateExample();
|
TemplateExample example = new TemplateExample();
|
||||||
example.createCriteria().andScopeIdEqualTo(projectId).andSceneEqualTo(scene);
|
example.createCriteria().andScopeIdEqualTo(projectId).andSceneEqualTo(scene);
|
||||||
List<Template> templates = templateMapper.selectByExample(example);
|
List<Template> templates = templateMapper.selectByExample(example);
|
||||||
|
|
|
@ -454,8 +454,8 @@ public class ProjectTemplateControllerTests extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
public void getCustomFields() throws Exception {
|
public void getCustomFields() throws Exception {
|
||||||
projectTemplateService.getTableCustomsField("DEFAULT_PROJECT_ID", TemplateScene.FUNCTIONAL.name());
|
projectTemplateService.getTableCustomField("DEFAULT_PROJECT_ID", TemplateScene.FUNCTIONAL.name());
|
||||||
projectTemplateService.getTableCustomsField(DEFAULT_PROJECT_ID, TemplateScene.FUNCTIONAL.name());
|
projectTemplateService.getTableCustomField(DEFAULT_PROJECT_ID, TemplateScene.FUNCTIONAL.name());
|
||||||
projectTemplateService.getTableCustomsField("test_project_id_2", TemplateScene.FUNCTIONAL.name());
|
projectTemplateService.getTableCustomField("test_project_id_2", TemplateScene.FUNCTIONAL.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue