提交 576834e2 编写于 作者: ibiz4j's avatar ibiz4j

提交

上级 200f1b52
......@@ -163,7 +163,7 @@ public class AppModel extends BaseModel{
Map<String,Catalog> catalogs= new LinkedHashMap<>();
if(!ObjectUtils.isEmpty(rootPath))
{
java.nio.file.Path path = Paths.get(rootPath,getApplication().getDynaModelFilePath().replace("/PSSYSAPP.json","/ALLCODELIST.json"));
java.nio.file.Path path = Paths.get(rootPath,"PSSYSAPPS","/ALLCODELIST.json");
if(Files.exists(path))
{
try {
......@@ -201,7 +201,9 @@ public class AppModel extends BaseModel{
catalog.setCodeItem(codeList.getPSCodeItems());
}
}
dictMaps.put(catalog.getCodeName(),catalog);
if(!ObjectUtils.isEmpty(catalog.getOptions()))
catalog.setOpt(codeList);
dictMaps.put(catalog.getCodeName(),catalog);
});
}
}
......
......@@ -11,6 +11,8 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.IPSApplication;
import net.ibizsys.model.app.codelist.IPSAppCodeList;
import net.ibizsys.model.codelist.IPSCodeItem;
import org.springframework.util.ObjectUtils;
......@@ -31,6 +33,13 @@ public class Catalog extends BaseModel
private List<Option> options = new ArrayList<>();
@JsonIgnore
@JSONField(serialize = false)
public IPSAppCodeList getCodeList()
{
return (IPSAppCodeList)opt;
}
@JsonIgnore
@JSONField(serialize = false)
public String getValueType()
......@@ -38,6 +47,29 @@ public class Catalog extends BaseModel
return ObjectUtils.isEmpty(options)?"String":options.get(0).getValueType();
}
@JsonIgnore
@JSONField(serialize = false)
private Map<String,Option> sets;
@JsonIgnore
@JSONField(serialize = false)
public Map<String,Option> getSets() {
if(sets==null) {
sets = new LinkedHashMap<>();
this.getOptions().forEach(opt->loop(opt));
}
return sets;
}
private void loop(Option opt) {
sets.put(opt.getValue().toString(),opt);
if(!ObjectUtils.isEmpty(opt.getChildren()))
opt.getChildren().forEach(sub->{
loop(sub);
});
}
public Option findCodeItem(Object value)
{
return findCodeItem(value,this.options);
......
......@@ -51,6 +51,22 @@ public class Option
return "Integer";
}
@JsonIgnore
@JSONField(serialize = false)
public String getName()
{
String name = "V_" + getValue().toString().replace("(","").replace(")","")
.replace("(","").replace(")","")
.replace(":","").replace(":","")
.replace("、","").replace(".","")
.replace("。","").replace(";","")
.replace(";","").replace("-","")
.replace(",","").replace("\\","")
.replace("/","").replace(",","");
return name;
}
public Option addChildren(Option item) {
if(children==null)
children=new ArrayList<Option>();
......
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.dataentity.IPSAppDEField;
import net.ibizsys.model.control.IPSEditor;
import net.ibizsys.model.control.editor.IPSCheckBoxList;
import net.ibizsys.model.control.editor.IPSCodeListEditor;
import net.ibizsys.model.control.editor.IPSMDropDownList;
import net.ibizsys.model.control.form.IPSDEFDCatGroupLogic;
import net.ibizsys.model.control.form.IPSDEForm;
import net.ibizsys.model.control.form.IPSDEFormItem;
import net.ibizsys.model.dataentity.service.IPSDEMethodDTOField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@Getter
......@@ -57,21 +63,60 @@ public class VoFieldModel extends BaseModel {
return type;
}
private String logicName;
public String getLogicName() {
String logicName=this.getPSDEFormItem().getCaption();
if(logicName==null)
{
logicName=this.getPSDEFormItem().getCaption();
if (StringUtils.isEmpty(logicName)&&this.getPSEditor()!=null) {
logicName=this.getPSEditor().getLogicName();
}
if (StringUtils.isEmpty(logicName)&&this.getAppDEField()!=null) {
logicName=this.getAppDEField().getLogicName();
}
if (StringUtils.isEmpty(logicName)&&this.getPSEditor()!=null) {
logicName=this.getPSEditor().getLogicName();
}
if (StringUtils.isEmpty(logicName)&&this.getAppDEField()!=null) {
logicName=this.getAppDEField().getLogicName();
}
return logicName;
}
public String javaType()
private String javaType;
public String getJavaType()
{
return getType().getJava();
if(javaType==null)
{
javaType=getType().getJava();
if(this.getDict()!=null) {
javaType = StringAdvUtils.pascalcase(this.getDictCodeName())+"Dict";
if(!singleSelect)
javaType=javaType+"[]";
}
}
return javaType;
}
private String dictCodeName;
private boolean singleSelect = true;
private Catalog dict;
public Catalog getDict() {
if(dictCodeName==null) {
dictCodeName = "";
if(getPSEditor()!=null&&getPSEditor() instanceof IPSCodeListEditor) {
IPSCodeListEditor codeListEditor=(IPSCodeListEditor)getPSDEFormItem().getPSEditor();
if(codeListEditor.getPSAppCodeList()!=null) {
dictCodeName = codeListEditor.getPSAppCodeList().getCodeName();
dict=this.getVoModel().getApp().getDictMaps().get(dictCodeName);
if ("treempick".equalsIgnoreCase(codeListEditor.getEditorType())||codeListEditor instanceof IPSMDropDownList
||codeListEditor instanceof IPSCheckBoxList)
singleSelect=false;
}
}
}
return dict;
}
private String format;
......@@ -106,8 +151,67 @@ public class VoFieldModel extends BaseModel {
return getCodeName().toLowerCase();
}
public boolean isRequired() {
if(!getPSDEFormItem().isAllowEmpty())
{
if(!ObjectUtils.isEmpty(getPSDEFormItem().getPSDEFDGroupLogics())) {
for(IPSDEFDCatGroupLogic logic:getPSDEFormItem().getPSDEFDGroupLogics())
if("ITEMBLANK".equalsIgnoreCase(logic.getLogicCat()))
return false;
}
return true;
}
return false;
}
public String getDefaultValue() {
String dv="";
if(!ObjectUtils.isEmpty(this.getPSDEFormItem().getCreateDV())) {
if(ObjectUtils.isEmpty(this.getPSDEFormItem().getCreateDVT()))
dv=this.getPSDEFormItem().getCreateDV();
}
if(ObjectUtils.isEmpty(dv)) {
if(!ObjectUtils.isEmpty(this.getPSDEFormItem().getUpdateDV())) {
if(ObjectUtils.isEmpty(this.getPSDEFormItem().getUpdateDVT()))
dv=this.getPSDEFormItem().getUpdateDV();
}
}
if(!ObjectUtils.isEmpty(dv)) {
if (this.getDict() != null ) {
dv = StringAdvUtils.pascalcase(dictCodeName) + "Dict.V_" + dv.replace("(", "").replace(")", "")
.replace("(", "").replace(")", "")
.replace(":", "").replace(":", "")
.replace("、", "").replace(".", "")
.replace("。", "").replace(";", "")
.replace(";", "").replace("-", "")
.replace(",", "").replace("\\", "")
.replace("/", "").replace(",", "");
if(!this.isSingleSelect())
return "";
}
else if(getType().isString())
dv = "\""+dv+"\"";
}
return dv;
}
private String example;
public String getExample() {
if(example==null) {
example = "";
}
if (this.getDict() != null && !ObjectUtils.isEmpty(this.getDict().getOptions()))
{
example = this.getDict().getOptions().get(0).getValue().toString();
if(!this.isSingleSelect()&&this.getDict().getOptions().size()>1)
{
example+=this.getDict().getCodeList().getValueSeparator()==null?";":this.getDict().getCodeList().getValueSeparator();
example+= this.getDict().getOptions().get(0).getValue().toString();
}
}
return example;
}
}
......@@ -12,7 +12,35 @@
<artifactId>{{projectName}}-api</artifactId>
<name>{{projectDesc}} Api</name>
<description>{{projectDesc}} Api</description>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
......@@ -32,7 +60,7 @@
../
</output>
<inputSpec>
../../XFOnline_1_3/model
</inputSpec>
<templateDirs>
${basedir}/src/main/resources/templ
......
package {{packageName}}.api.{{apps}}.dict.{{pascalCase dict.codeName}};
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.dict;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
/**
* {{dict.name}}
* 字典:{{dict.name}}
*/
public class {{pascalCase dict.codeName}} {
@ApiModel(value = "{{dict.codeName}}", description = "字典:{{dict.name}}")
public enum {{pascalCase dict.codeName}}Dict {
{{#each dict.options}}
{{#each dict.sets}}
{{#eq dict.valueType "String"}}
V_{{value}}_N_{{label}} ("{{value}}","{{label}}",{{#if parent}}"{{parent}}"{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{name}} ("{{value}}","{{label}}",{{#if parent}}"{{parent}}"{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{#eq dict.valueType "Integer"}}
V_{{value}}_N_{{label}} ({{value}},"{{label}}",{{#if parent}}{{parent}}{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{name}} ({{value}},"{{label}}",{{#if parent}}{{parent}}{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{/each}}
......@@ -36,7 +39,7 @@ public class {{pascalCase dict.codeName}} {
return parent;
}
{{pascalCase dict.codeName}}({{dict.valueType}} value, String label, {{dict.valueType}} parent) {
{{pascalCase dict.codeName}}Dict({{dict.valueType}} value, String label, {{dict.valueType}} parent) {
this.value = value;
this.label = label;
this.parent = parent;
......@@ -44,16 +47,17 @@ public class {{pascalCase dict.codeName}} {
@JsonCreator
@JSONCreator
public static {{pascalCase dict.codeName}} valueOf(Object tag) {
public static {{pascalCase dict.codeName}}Dict valueOf(Object tag) {
if(tag==null)
return null;
for ({{pascalCase dict.codeName}} item : values())
for ({{pascalCase dict.codeName}}Dict item : values())
if (item.getValue().equals(tag){{#eq dict.valueType "Integer"}}||item.getValue().toString().equals(tag){{/eq}})
return item;
Sjjcy ret =null;
for ({{pascalCase dict.codeName}} item : values())
{{pascalCase dict.codeName}}Dict ret =null;
for ({{pascalCase dict.codeName}}Dict item : values())
if (item.getLabel().equals(tag))
ret = item;
return ret;
}
}
\ No newline at end of file
}
{{/eq}}
\ No newline at end of file
package {{packageName}}.api.{{apps}}.dto.{{pascalCase appEntity.codeName}};
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.dto.{{pascalCase appEntities}};
import java.sql.Timestamp;
import java.util.ArrayList;
......@@ -21,15 +22,16 @@ import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import {{packageName}}.api.{{apps}}.dict.*;
/**
* {{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]{{replace ctrl.logicName "编辑" ""}}
* {{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]{{replace ctrl.logicName "表单" ""}}
*/
@Getter
@Setter
@NoArgsConstructor
@ApiModel("{{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]")
public class {{ctrl.codeName}}Dto implements Serializable {
@ApiModel(value = "{{appEntities}}-{{ctrl.codeName}}", description = "{{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]{{replace ctrl.logicName "表单" ""}}")
public class {{pascalCase ctrl.codeName}}Dto implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -45,8 +47,9 @@ public class {{ctrl.codeName}}Dto implements Serializable {
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
@ApiModelProperty("{{logicName}}")
private {{javaType}} {{camelCase codeName}};
@ApiModelProperty(value = "{{logicName}}"{{#if timeType}}, notes = "格式:{{format}}"{{/if}}{{#if dict}}, notes = "字典:{{dict.name}}", dataType = "{{lowerCase type.java}}", reference = "{{dictCodeName}}"{{/if}}{{#if required}}, required = true{{/if}}{{#if hidden}}, hidden = true{{/if}}{{#if example}}, example = "{{example}}"{{/if}})
private {{javaType}} {{camelCase codeName}} {{#if defaultValue}}= {{defaultValue}}{{/if}};
{{/each}}
}
\ No newline at end of file
}
{{/eq}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册