bug fixed

This commit is contained in:
liweiyi 2025-03-04 23:30:34 +08:00
parent 0274696789
commit ce9423cbef
2 changed files with 9 additions and 5 deletions

View File

@ -16,6 +16,7 @@
package com.chestnut.exmodel.service;
import com.chestnut.common.utils.NumberUtils;
import com.chestnut.common.utils.ObjectUtils;
import com.chestnut.contentcore.domain.CmsCatalog;
import com.chestnut.contentcore.domain.CmsContent;
import com.chestnut.contentcore.service.ICatalogService;
@ -79,8 +80,8 @@ public class ExModelService {
List<XModelFieldDataDTO> list = new ArrayList<>();
metaModel.getFields().forEach(f -> {
Object fv = data.get(f.getCode());
if(Objects.isNull(fv) || fv.toString().isEmpty()) {
fv = f.getDefaultValue();
if(Objects.isNull(fv)) {
fv = ObjectUtils.nonNullOrElseAsString(f.getDefaultValue(), Object::toString);
}
XModelFieldDataDTO dto = XModelFieldDataDTO.newInstance(f, fv);
list.add(dto);

View File

@ -209,10 +209,13 @@ public class ModelDataServiceImpl implements IModelDataService {
sqlBuilder.eq(pkField.getFieldName(), pkValues.get(pkField.getCode()));
}
Map<String, Object> map = sqlBuilder.selectOne();
if (map == null) {
return Map.of();
}
Map<String, Object> dataMap = new HashMap<>();
if (map == null) {
model.getFields().forEach(f -> {
dataMap.put(f.getCode(), getControlType(f.getControlType()).stringAsValue(StringUtils.EMPTY));
});
return dataMap;
}
// 固定字段
mmt.getFixedFields().forEach(f -> {
Object v = map.get(f.getFieldName());