refactor(功能用例): 功能用例列表自定义字段返回值
This commit is contained in:
parent
3e458c55e8
commit
f904a5e413
|
@ -1,10 +1,12 @@
|
||||||
package io.metersphere.functional.dto;
|
package io.metersphere.functional.dto;
|
||||||
|
|
||||||
|
import io.metersphere.system.domain.CustomFieldOption;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wx
|
* @author wx
|
||||||
|
@ -22,12 +24,18 @@ public class FunctionalCaseCustomFieldDTO implements Serializable {
|
||||||
private String fieldId;
|
private String fieldId;
|
||||||
|
|
||||||
@Schema(description = "字段值")
|
@Schema(description = "字段值")
|
||||||
private String value;
|
private String defaultValue;
|
||||||
|
|
||||||
@Schema(description = "字段名称")
|
@Schema(description = "字段名称")
|
||||||
private String name;
|
private String fieldName;
|
||||||
|
|
||||||
@Schema(description = "是否内置字段")
|
@Schema(description = "是否内置字段")
|
||||||
private Boolean internal;
|
private Boolean internal;
|
||||||
|
|
||||||
|
@Schema(title = "选项值")
|
||||||
|
private List<CustomFieldOption> options;
|
||||||
|
|
||||||
|
@Schema(title = "字段类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
SELECT
|
SELECT
|
||||||
fccf.case_id caseId,
|
fccf.case_id caseId,
|
||||||
fccf.field_id fieldId,
|
fccf.field_id fieldId,
|
||||||
fccf.`value` value,
|
fccf.`value` defaultValue,
|
||||||
cf.NAME name,
|
cf.NAME fieldName,
|
||||||
cf.internal internal
|
cf.internal internal,
|
||||||
|
cf.type type
|
||||||
FROM
|
FROM
|
||||||
functional_case_custom_field fccf
|
functional_case_custom_field fccf
|
||||||
LEFT JOIN custom_field cf ON fccf.field_id = cf.id
|
LEFT JOIN custom_field cf ON fccf.field_id = cf.id
|
||||||
|
|
|
@ -22,9 +22,11 @@ import io.metersphere.sdk.constants.TemplateScene;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
|
import io.metersphere.system.domain.CustomFieldOption;
|
||||||
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
||||||
import io.metersphere.system.dto.sdk.TemplateDTO;
|
import io.metersphere.system.dto.sdk.TemplateDTO;
|
||||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||||
|
import io.metersphere.system.service.BaseCustomFieldOptionService;
|
||||||
import io.metersphere.system.service.BaseCustomFieldService;
|
import io.metersphere.system.service.BaseCustomFieldService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import io.metersphere.system.uid.NumGenerator;
|
import io.metersphere.system.uid.NumGenerator;
|
||||||
|
@ -111,6 +113,8 @@ public class FunctionalCaseService {
|
||||||
private FunctionalCaseRelationshipEdgeMapper functionalCaseRelationshipEdgeMapper;
|
private FunctionalCaseRelationshipEdgeMapper functionalCaseRelationshipEdgeMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private BaseCustomFieldOptionService baseCustomFieldOptionService;
|
||||||
|
|
||||||
|
|
||||||
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> files, String userId) {
|
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> files, String userId) {
|
||||||
|
@ -514,9 +518,15 @@ public class FunctionalCaseService {
|
||||||
List<FunctionalCaseCustomFieldDTO> customFields = functionalCaseCustomFieldService.getCustomFieldsByCaseIds(ids);
|
List<FunctionalCaseCustomFieldDTO> customFields = functionalCaseCustomFieldService.getCustomFieldsByCaseIds(ids);
|
||||||
customFields.forEach(customField -> {
|
customFields.forEach(customField -> {
|
||||||
if (customField.getInternal()) {
|
if (customField.getInternal()) {
|
||||||
customField.setName(baseCustomFieldService.translateInternalField(customField.getName()));
|
customField.setFieldName(baseCustomFieldService.translateInternalField(customField.getFieldName()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
List<String> fieldIds = customFields.stream().map(FunctionalCaseCustomFieldDTO::getFieldId).toList();
|
||||||
|
List<CustomFieldOption> fieldOptions = baseCustomFieldOptionService.getByFieldIds(fieldIds);
|
||||||
|
Map<String, List<CustomFieldOption>> customOptions = fieldOptions.stream().collect(Collectors.groupingBy(CustomFieldOption::getFieldId));
|
||||||
|
customFields.forEach(customField -> {
|
||||||
|
customField.setOptions(customOptions.get(customField.getFieldId()));
|
||||||
|
});
|
||||||
Map<String, List<FunctionalCaseCustomFieldDTO>> collect = customFields.stream().collect(Collectors.groupingBy(FunctionalCaseCustomFieldDTO::getCaseId));
|
Map<String, List<FunctionalCaseCustomFieldDTO>> collect = customFields.stream().collect(Collectors.groupingBy(FunctionalCaseCustomFieldDTO::getCaseId));
|
||||||
functionalCaseLists.forEach(functionalCasePageDTO -> {
|
functionalCaseLists.forEach(functionalCasePageDTO -> {
|
||||||
functionalCasePageDTO.setCustomFields(collect.get(functionalCasePageDTO.getId()));
|
functionalCasePageDTO.setCustomFields(collect.get(functionalCasePageDTO.getId()));
|
||||||
|
|
Loading…
Reference in New Issue