提交 e8233e50 编写于 作者: sq3536's avatar sq3536

默认值

上级 189eef7c
...@@ -259,6 +259,23 @@ public class DynamicModelService { ...@@ -259,6 +259,23 @@ public class DynamicModelService {
modes.add("query"); modes.add("query");
metaFieldModel.set("search_modes",String.join(",",modes)); metaFieldModel.set("search_modes",String.join(",",modes));
} }
if((!StringUtils.isEmpty(defield.getDefaultValueType()))||(!StringUtils.isEmpty(defield.getDefaultValue())))
{
String defaultValue="";
if(StringUtils.isEmpty(defield.getDefaultValueType())||"NONE".equalsIgnoreCase(defield.getDefaultValueType()))
{
defaultValue=defield.getDefaultValue();
}
else if(!StringUtils.isEmpty(defield.getDefaultValue()))
{
defaultValue=String.format("${%1$s.%2$s}",defield.getDefaultValueType(),defield.getDefaultValue());
}
else
{
defaultValue=String.format("${%1$s}",defield.getDefaultValueType());
}
metaFieldModel.set("default_value",defaultValue);
}
fieldModel.setCodeName(metaFieldModel.getCodeName()).setColumnName(metaFieldModel.getFieldName()).setUnionName(metaFieldModel.getFieldUniName()).setShowName(metaFieldModel.getFieldShowName()) fieldModel.setCodeName(metaFieldModel.getCodeName()).setColumnName(metaFieldModel.getFieldName()).setUnionName(metaFieldModel.getFieldUniName()).setShowName(metaFieldModel.getFieldShowName())
.setComment(metaFieldModel.getFieldLogicName()).setField(metaFieldModel); .setComment(metaFieldModel.getFieldLogicName()).setField(metaFieldModel);
......
...@@ -402,6 +402,13 @@ public class POSchema { ...@@ -402,6 +402,13 @@ public class POSchema {
@JSONField(ordinal = 11) @JSONField(ordinal = 11)
private Set<String> searchModes; private Set<String> searchModes;
public Column setDefaultValue(String defaultValue)
{
if((!StringUtils.isEmpty(defaultValue))&&(!defaultValue.startsWith("$")))
this.defaultValue=defaultValue;
return this;
}
public Column putSearchModes(String searchModes) public Column putSearchModes(String searchModes)
{ {
......
...@@ -232,11 +232,11 @@ public class PojoOption extends DataObj ...@@ -232,11 +232,11 @@ public class PojoOption extends DataObj
return this.set("dict",dict); return this.set("dict",dict);
} }
public String getDefaultValue() { public String getDefaultValue() {
return this.getStringValue("defaultValue"); return this.getStringValue("default_value");
} }
public PojoOption setDefaultValue(String defaultValue) { public PojoOption setDefaultValue(String defaultValue) {
return this.set("defaultValue",defaultValue); return this.set("default_value",defaultValue);
} }
public String getDataType() { public String getDataType() {
return this.getStringValue("data_type"); return this.getStringValue("data_type");
......
...@@ -4,6 +4,7 @@ import cn.ibizlab.core.data.domain.POModel; ...@@ -4,6 +4,7 @@ import cn.ibizlab.core.data.domain.POModel;
import cn.ibizlab.core.data.lite.*; import cn.ibizlab.core.data.lite.*;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -102,7 +103,7 @@ public class TransUtils { ...@@ -102,7 +103,7 @@ public class TransUtils {
} }
else { else {
property.setPropertyType(PojoModel.PropertyType.valueOf(sub.getType())); property.setPropertyType(PojoModel.PropertyType.valueOf(sub.getType()));
if(sub.getOptions()!=null&&(!StringUtils.isEmpty(sub.getOptions().getDict()))) if(!StringUtils.isEmpty(sub.getOptions().getDict()))
property.setDict(sub.getOptions().getDict()); property.setDict(sub.getOptions().getDict());
} }
...@@ -140,9 +141,13 @@ public class TransUtils { ...@@ -140,9 +141,13 @@ public class TransUtils {
.setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField())))); .setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField()))));
Object searchModes=fieldModel.getField().get("search_modes"); Object searchModes=fieldModel.getField().get("search_modes");
if(searchModes!=null) if(!ObjectUtils.isEmpty(searchModes))
sub.getOptions().setSearchModes(searchModes.toString()); sub.getOptions().setSearchModes(searchModes.toString());
Object defaultValue=fieldModel.getField().get("default_value");
if(!ObjectUtils.isEmpty(defaultValue))
sub.getOptions().setDefaultValue(defaultValue.toString());
sub.getOptions().remove("ext_params"); sub.getOptions().remove("ext_params");
......
...@@ -240,12 +240,9 @@ public class BaseDataService implements IDataService { ...@@ -240,12 +240,9 @@ public class BaseDataService implements IDataService {
{ {
refProperties.entrySet().forEach(propEntry->{ refProperties.entrySet().forEach(propEntry->{
PojoSchema prop=propEntry.getValue(); PojoSchema prop=propEntry.getValue();
if(prop.getOptions()!=null)
{
String refFieldCodeName=prop.getOptions().getRefFieldCodeName(); String refFieldCodeName=prop.getOptions().getRefFieldCodeName();
if((!StringUtils.isEmpty(refFieldCodeName))&&parentData.get(refFieldCodeName.toLowerCase())!=null) if((!StringUtils.isEmpty(refFieldCodeName))&&parentData.get(refFieldCodeName.toLowerCase())!=null)
et.set(propEntry.getKey().toLowerCase(), parentData.get(refFieldCodeName.toLowerCase())); et.set(propEntry.getKey().toLowerCase(), parentData.get(refFieldCodeName.toLowerCase()));
}
}); });
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册