fix(用例管理): 用例导入校验,用例等级不区分大小写
--bug=1035534 --user=王旭 【用例管理】建议不区分大小写,并且给出具体不能为空的字段名称 https://www.tapd.cn/55049933/s/1462436
This commit is contained in:
parent
d9ad727c3b
commit
ecbf7b49b6
|
@ -43,6 +43,9 @@ public class CustomFieldSelectValidator extends AbstractCustomFieldValidator {
|
|||
prepareCache(customField);
|
||||
Set<String> idSet = optionValueSetCache.get(customField.getFieldId());
|
||||
Set<String> textSet = optionTextSetCache.get(customField.getFieldId());
|
||||
if (customField.getFieldName().equals(Translator.get("custom_field.functional_priority"))) {
|
||||
value = value.toUpperCase();
|
||||
}
|
||||
if (!idSet.contains(value) && !textSet.contains(value)) {
|
||||
CustomFieldValidateException.throwException(String.format(Translator.get("custom_field_select_tip"), customField.getFieldName(), textSet));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.system.dto.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
|
@ -7,6 +8,7 @@ import jakarta.validation.Validator;
|
|||
import jakarta.validation.groups.Default;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
|
@ -22,7 +24,10 @@ public class ExcelValidateHelper {
|
|||
Set<ConstraintViolation<T>> set = excelValidateHelper.validator.validate(obj, Default.class);
|
||||
if (set != null && !set.isEmpty()) {
|
||||
for (ConstraintViolation<T> cv : set) {
|
||||
result.append(cv.getMessage()).append("; ");
|
||||
Field declaredField = obj.getClass().getDeclaredField(cv.getPropertyPath().toString());
|
||||
ExcelProperty annotation = declaredField.getAnnotation(ExcelProperty.class);
|
||||
//拼接错误信息,包含当前出错数据的标题名字+错误信息
|
||||
result.append(annotation.value()[0] + cv.getMessage()).append("; ");
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
|
|
Loading…
Reference in New Issue