fix(项目设置): 缺陷模板严重程度无法删除
--bug=1036944 --user=陈建星 【系统管理】组织-模板-缺陷模板,关联三方平台时,严重程度字段应该允许删除 https://www.tapd.cn/55049933/s/1474749
This commit is contained in:
parent
717e3ae396
commit
1b04ae1aad
|
@ -0,0 +1,19 @@
|
|||
package io.metersphere.system.constants;
|
||||
|
||||
/**
|
||||
* @Author: jianxing
|
||||
* @CreateTime: 2024-03-14 16:33
|
||||
*/
|
||||
public enum TemplateRequiredCustomField {
|
||||
BUG_DEGREE("bug_degree");
|
||||
|
||||
private String name;
|
||||
|
||||
TemplateRequiredCustomField(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -9,5 +9,12 @@ import java.util.List;
|
|||
@Data
|
||||
public class CustomFieldDTO extends CustomField {
|
||||
private List<CustomFieldOption> options;
|
||||
private boolean used;
|
||||
/**
|
||||
* 是否被模板使用
|
||||
*/
|
||||
private Boolean used = false;
|
||||
/**
|
||||
* 模板中该字段是否必选
|
||||
*/
|
||||
private Boolean templateRequired = false;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.sdk.constants.TemplateScopeType;
|
|||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.constants.TemplateRequiredCustomField;
|
||||
import io.metersphere.system.domain.CustomField;
|
||||
import io.metersphere.system.domain.CustomFieldExample;
|
||||
import io.metersphere.system.domain.CustomFieldOption;
|
||||
|
@ -26,10 +27,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.metersphere.system.controller.handler.result.CommonResultCode.*;
|
||||
|
@ -92,6 +90,13 @@ public class BaseCustomFieldService {
|
|||
createUserOption.setInternal(false);
|
||||
customFieldDTO.setOptions(List.of(createUserOption));
|
||||
}
|
||||
if (BooleanUtils.isTrue(item.getInternal())) {
|
||||
// 设置哪些内置字段是模板里必选的
|
||||
Set<String> templateRequiredCustomFieldSet = Arrays.stream(TemplateRequiredCustomField.values())
|
||||
.map(TemplateRequiredCustomField::getName)
|
||||
.collect(Collectors.toSet());
|
||||
customFieldDTO.setTemplateRequired(templateRequiredCustomFieldSet.contains(item.getName()));
|
||||
}
|
||||
return customFieldDTO;
|
||||
}).toList();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.project.domain.Project;
|
|||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.*;
|
||||
import io.metersphere.system.constants.TemplateRequiredCustomField;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.dto.sdk.CustomFieldDTO;
|
||||
import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest;
|
||||
|
@ -256,8 +257,21 @@ public class OrganizationCustomFieldControllerTests extends BaseTest {
|
|||
Assertions.assertEquals(resultList.get(i).getOptions().stream().sorted(Comparator.comparing(CustomFieldOption::getValue)).toList(),
|
||||
baseCustomFieldOptionService.getByFieldId(customField.getId()).stream().sorted(Comparator.comparing(CustomFieldOption::getValue)).toList());
|
||||
}
|
||||
Assertions.assertFalse(resultList.get(i).getTemplateRequired());
|
||||
}
|
||||
|
||||
mvcResult = this.requestGetWithOk(LIST, DEFAULT_ORGANIZATION_ID, TemplateScene.BUG.name())
|
||||
.andReturn();
|
||||
// 校验数据是否正确
|
||||
resultList = getResultDataArray(mvcResult, CustomFieldDTO.class);
|
||||
resultList.forEach(item -> {
|
||||
if (StringUtils.equals(item.getName(), "bug_degree")) {
|
||||
Assertions.assertTrue(item.getTemplateRequired());
|
||||
} else {
|
||||
Assertions.assertFalse(item.getTemplateRequired());
|
||||
}
|
||||
});
|
||||
|
||||
// @@校验组织是否存在
|
||||
assertErrorCode(this.requestGet(LIST, "1111", scene), NOT_FOUND);
|
||||
|
||||
|
|
Loading…
Reference in New Issue