refactor(缺陷管理): 增加关联用例的自定字段
--bug=1039553 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001039553
This commit is contained in:
parent
e73d14e680
commit
5365e7818c
|
@ -0,0 +1,37 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.system.domain.CustomFieldOption;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BaseCaseCustomFieldDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "用例ID")
|
||||
private String caseId;
|
||||
|
||||
@Schema(description = "字段ID")
|
||||
private String fieldId;
|
||||
|
||||
@Schema(description = "字段值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "字段名称")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "是否内置字段")
|
||||
private Boolean internal;
|
||||
|
||||
@Schema(title = "选项值")
|
||||
private List<CustomFieldOption> options;
|
||||
|
||||
@Schema(title = "字段类型")
|
||||
private String type;
|
||||
|
||||
}
|
|
@ -46,4 +46,7 @@ public class TestCaseProviderDTO {
|
|||
@Schema(description = "版本名称")
|
||||
private String versionName;
|
||||
|
||||
@Schema(description = "自定义字段集合")
|
||||
private List<BaseCaseCustomFieldDTO> customFields;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.functional.provider;
|
||||
|
||||
import io.metersphere.dto.BaseCaseCustomFieldDTO;
|
||||
import io.metersphere.dto.TestCaseProviderDTO;
|
||||
import io.metersphere.functional.dto.FunctionalCaseCustomFieldDTO;
|
||||
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
||||
|
@ -7,16 +8,14 @@ import io.metersphere.functional.service.FunctionalCaseService;
|
|||
import io.metersphere.provider.BaseAssociateCaseProvider;
|
||||
import io.metersphere.request.AssociateOtherCaseRequest;
|
||||
import io.metersphere.request.TestCasePageProviderRequest;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class AssociateCaseProvider implements BaseAssociateCaseProvider {
|
||||
|
@ -36,8 +35,13 @@ public class AssociateCaseProvider implements BaseAssociateCaseProvider {
|
|||
Map<String, List<FunctionalCaseCustomFieldDTO>> caseCustomFiledMap = functionalCaseService.getCaseCustomFiledMap(ids, testCasePageProviderRequest.getProjectId());
|
||||
functionalCases.forEach(functionalCase -> {
|
||||
List<FunctionalCaseCustomFieldDTO> customFields = caseCustomFiledMap.get(functionalCase.getId());
|
||||
Optional<FunctionalCaseCustomFieldDTO> priorityField = customFields.stream().filter(field -> StringUtils.equals(Translator.get("custom_field.functional_priority"), field.getFieldName())).findFirst();
|
||||
priorityField.ifPresent(functionalCaseCustomFieldDTO -> functionalCase.setPriority(functionalCaseCustomFieldDTO.getDefaultValue()));
|
||||
List<BaseCaseCustomFieldDTO> baseCaseCustomFieldDTOS = new ArrayList<>();
|
||||
for (FunctionalCaseCustomFieldDTO customField : customFields) {
|
||||
BaseCaseCustomFieldDTO baseCaseCustomFieldDTO = new BaseCaseCustomFieldDTO();
|
||||
BeanUtils.copyBean(baseCaseCustomFieldDTO, customField);
|
||||
baseCaseCustomFieldDTOS.add(baseCaseCustomFieldDTO);
|
||||
}
|
||||
functionalCase.setCustomFields(baseCaseCustomFieldDTOS);
|
||||
});
|
||||
return functionalCases;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue