feat(用例管理): 脑图自定义字段保存调整

This commit is contained in:
guoyuqi 2024-06-04 19:12:02 +08:00 committed by Craftsman
parent d4f37273fb
commit 4530788d66
1 changed files with 9 additions and 11 deletions

View File

@ -930,21 +930,19 @@ public class FunctionalCaseMinderService {
private List<FunctionalCaseCustomField> addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, Map<String, Object> defaultValueMap) { private List<FunctionalCaseCustomField> addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, Map<String, Object> defaultValueMap) {
List<CaseCustomFieldDTO> customFields = functionalCaseChangeRequest.getCustomFields(); List<CaseCustomFieldDTO> customFields = functionalCaseChangeRequest.getCustomFields();
List<FunctionalCaseCustomField> caseCustomFields; List<String> list = customFields.stream().map(CaseCustomFieldDTO::getFieldId).toList();
if (CollectionUtils.isNotEmpty(customFields)) { List<CaseCustomFieldDTO> customFieldDTOs = new ArrayList<>();
customFields = customFields.stream().distinct().collect(Collectors.toList()); defaultValueMap.forEach((k, v) -> {
caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFields); if (!list.contains(k)) {
} else {
List<CaseCustomFieldDTO> customFieldDTOs = new ArrayList<>();
defaultValueMap.forEach((k,v)->{
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO(); CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
customFieldDTO.setFieldId(k); customFieldDTO.setFieldId(k);
customFieldDTO.setValue(v.toString()); customFieldDTO.setValue(v.toString());
customFieldDTOs.add(customFieldDTO); customFieldDTOs.add(customFieldDTO);
}); }
caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFieldDTOs); });
} customFields.addAll(customFieldDTOs);
return caseCustomFields; customFields = customFields.stream().distinct().collect(Collectors.toList());
return saveCustomField(caseId, caseCustomFieldMapper, customFields);
} }
private List<FunctionalCaseCustomField> saveCustomField(String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, List<CaseCustomFieldDTO> customFields) { private List<FunctionalCaseCustomField> saveCustomField(String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, List<CaseCustomFieldDTO> customFields) {