fix(用例管理): 导入自定义字段问题

--bug=1036812 --user=王旭 【用例管理】功能用例-模板有设置自定义字段的默认值,Excel导入用例中自定义值是空,导入后数据是空 https://www.tapd.cn/55049933/s/1500263
This commit is contained in:
WangXu10 2024-04-17 19:56:27 +08:00 committed by Craftsman
parent e64630f330
commit 98905dd20f
1 changed files with 7 additions and 1 deletions

View File

@ -46,6 +46,8 @@ import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.OperationHistoryMapper;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.resolver.field.AbstractCustomFieldResolver;
import io.metersphere.system.resolver.field.CustomFieldResolverFactory;
import io.metersphere.system.service.*;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.uid.NumGenerator;
@ -1189,7 +1191,11 @@ public class FunctionalCaseService {
caseCustomField.setCaseId(caseId);
caseCustomField.setFieldId(v.getFieldId());
Optional.ofNullable(value).ifPresentOrElse(v1 -> {
setCustomFieldValue(v1.toString(), caseCustomField);
if((v1.toString().length()==2&&StringUtils.equals(v1.toString(),"[]"))||!StringUtils.isNotBlank(v1.toString())){
setCustomFieldValue(v.getDefaultValue(), caseCustomField);
}else{
setCustomFieldValue(v1, caseCustomField);
}
}, () -> {
setCustomFieldValue(v.getDefaultValue(), caseCustomField);
});