fix(用例管理): 标签个数限制
--bug=1038362 --user=王旭 【用例管理】功能用例-用例已有10个标签-批量编辑追加标签还是能继续添加标签 https://www.tapd.cn/55049933/s/1486281
This commit is contained in:
parent
7cd042f961
commit
46d6a93614
|
@ -207,6 +207,7 @@ case_comment.id_is_null=The current comment id is empty
|
|||
case_comment.user_self=You can only delete your own comments
|
||||
un_follow_functional_case=unfollow functional case
|
||||
follow_functional_case=followed functional case
|
||||
tags_length_large_than=The number of tags cannot exceed {0}
|
||||
#module
|
||||
case_module.not.exist=Case module does not exist
|
||||
file.transfer.failed=File transfer FAILED
|
||||
|
|
|
@ -206,6 +206,7 @@ case_comment.id_is_null=当前评论id为空
|
|||
case_comment.user_self=只能删除自己的评论
|
||||
un_follow_functional_case=取消关注用例
|
||||
follow_functional_case=关注用例
|
||||
tags_length_large_than=标签数量超过{0}个
|
||||
#module
|
||||
case_module.not.exist=用例模块不存在
|
||||
file.transfer.failed=文件转存失败
|
||||
|
|
|
@ -207,6 +207,7 @@ case_comment.id_is_null=目前評論id為空
|
|||
case_comment.user_self=只能刪除自己的評論
|
||||
un_follow_functional_case=取消關注用例
|
||||
follow_functional_case=關注用例
|
||||
tags_length_large_than=標籤數量不能超過{max}
|
||||
#module
|
||||
case_module.not.exist=用例模組不存在
|
||||
file.transfer.failed=文件轉存失敗
|
||||
|
|
|
@ -173,6 +173,8 @@ public class FunctionalCaseService {
|
|||
@Resource
|
||||
private ProjectService projectService;
|
||||
|
||||
private static final int MAX_TAG_SIZE = 10;
|
||||
|
||||
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> files, String userId, String organizationId) {
|
||||
String caseId = IDGenerator.nextStr();
|
||||
//添加功能用例
|
||||
|
@ -470,7 +472,8 @@ public class FunctionalCaseService {
|
|||
customFields.forEach(item -> {
|
||||
if (StringUtils.equalsAnyIgnoreCase(item.getType(), CustomFieldType.MEMBER.name(), CustomFieldType.MULTIPLE_MEMBER.name())) {
|
||||
item.setOptions(memberCustomOption);
|
||||
};
|
||||
}
|
||||
;
|
||||
FunctionalCaseCustomField caseCustomField = functionalCaseCustomFieldService.getCustomField(item.getFieldId(), functionalCase.getId());
|
||||
Optional.ofNullable(caseCustomField).ifPresentOrElse(customField -> {
|
||||
item.setDefaultValue(customField.getValue());
|
||||
|
@ -901,6 +904,7 @@ public class FunctionalCaseService {
|
|||
if (CollectionUtils.isNotEmpty(collect.get(id).getTags())) {
|
||||
List<String> tags = collect.get(id).getTags();
|
||||
tags.addAll(request.getTags());
|
||||
checkTagsLength(tags);
|
||||
List<String> newTags = tags.stream().distinct().collect(Collectors.toList());
|
||||
functionalCase.setTags(newTags);
|
||||
} else {
|
||||
|
@ -926,6 +930,17 @@ public class FunctionalCaseService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验追加标签长度
|
||||
*
|
||||
* @param tags
|
||||
*/
|
||||
private void checkTagsLength(List<String> tags) {
|
||||
if (tags.size() > MAX_TAG_SIZE) {
|
||||
throw new MSException(Translator.getWithArgs("tags_length_large_than", String.valueOf(MAX_TAG_SIZE)));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Long> moduleCount(FunctionalCasePageRequest request, boolean delete) {
|
||||
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
||||
request.setModuleIds(null);
|
||||
|
|
|
@ -590,6 +590,8 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
|||
request.setAppend(true);
|
||||
request.setTags(Arrays.asList("追加标签_1", "追加标签_2"));
|
||||
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request);
|
||||
request.setTags(Arrays.asList("追加标签_1", "追加标签_2","追加标签_3","追加标签_4","追加标签_5","追加标签_6","追加标签_7","追加标签_8","追加标签_9","追加标签_10","追加标签_11"));
|
||||
this.requestPost(FUNCTIONAL_CASE_BATCH_EDIT_URL, request);
|
||||
request.setAppend(false);
|
||||
request.setTags(Arrays.asList("覆盖标签1", "覆盖标签2"));
|
||||
request.setSelectAll(true);
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
}
|
||||
|
||||
function validateTagsCountBlur() {
|
||||
if (tagsLength.value > 10) {
|
||||
if (tagsLength.value >= 10) {
|
||||
Message.warning(t('common.tagCountMax'));
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue