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

vo

上级 f8ac6c7d
......@@ -40,6 +40,17 @@ public class Catalog extends BaseModel
return (IPSAppCodeList)opt;
}
public String getValueSeparator()
{
return getCodeList().getValueSeparator()==null?";":getCodeList().getValueSeparator();
}
public String getTextSeparator()
{
return getCodeList().getTextSeparator()==null?";":getCodeList().getTextSeparator();
}
@JsonIgnore
@JSONField(serialize = false)
public String getValueType()
......@@ -64,7 +75,7 @@ public class Catalog extends BaseModel
@JSONField(serialize = false)
public Collection getOptionItems()
{
if (getSets().size()>100)
if (getSets().size()>1000)
return options;
else
return sets.values();
......
......@@ -9,6 +9,7 @@ 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.IPSFileUploader;
import net.ibizsys.model.control.editor.IPSMDropDownList;
import net.ibizsys.model.control.form.IPSDEFDCatGroupLogic;
import net.ibizsys.model.control.form.IPSDEForm;
......@@ -92,13 +93,52 @@ public class VoFieldModel extends BaseModel {
javaType=getType().getJava();
if(this.getDict()!=null) {
javaType = StringAdvUtils.pascalcase(this.getDictCodeName())+"Dict";
if(!singleSelect)
javaType=javaType+"[]";
if(!singleSelect) {
javaType = javaType + ".LIST";
formatShape="STRING";
serializeUsing="com.alibaba.fastjson.serializer.ToStringSerializer.class";
}
else {
javaType = javaType + ".ENUM";
if("Integer".equals(getType().getJava()))
formatShape="NUMBER";
else
formatShape="STRING";
}
}
else if(this.getPSEditor()!=null&&(this.getPSDEFormItem() instanceof IPSFileUploader||"FILEUPLOADER".equals(this.getPSEditor().getEditorType())))
{
javaType = "List<FileDto>";
}
else if(this.getPSEditor()!=null&&("hfh".equals(this.getPSEditor().getEditorStyle())||"zp".equals(this.getPSEditor().getEditorStyle())))
{
javaType = "FileDto";
serializeUsing="com.alibaba.fastjson.serializer.ToStringSerializer.class";
}
}
return javaType;
}
private String serializeUsing;
public String getSerializeUsing()
{
if(serializeUsing==null)
{
serializeUsing="";
getJavaType();
}
return serializeUsing;
}
private String formatShape;
public String getFormatShape(){
if(formatShape==null)
{
formatShape="";
getJavaType();
}
return formatShape;
}
private String dictCodeName;
private boolean singleSelect = true;
private Catalog dict;
......@@ -110,8 +150,6 @@ public class VoFieldModel extends BaseModel {
IPSCodeListEditor codeListEditor=(IPSCodeListEditor)getPSDEFormItem().getPSEditor();
if(codeListEditor.getPSAppCodeList()!=null) {
dictCodeName = codeListEditor.getPSAppCodeList().getCodeName();
if(dictCodeName.equals("CL_TYYW_36"))
System.out.println(1);
dict=this.getVoModel().getApp().getDictMaps().get(dictCodeName);
if(dict==null)
{
......@@ -202,7 +240,7 @@ public class VoFieldModel extends BaseModel {
public String getDefaultValue(String dv) {
if(!ObjectUtils.isEmpty(dv)) {
if (this.getDict() != null ) {
dv = StringAdvUtils.pascalcase(dictCodeName) + "Dict.V_" + dv.replace("(", "").replace(")", "")
dv = StringAdvUtils.pascalcase(dictCodeName) + "Dict.ENUM.V_" + dv.replace("(", "").replace(")", "")
.replace("(", "").replace(")", "")
.replace(":", "").replace(":", "")
.replace("、", "").replace(".", "")
......
package cn.ibizlab.util.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwaggerDisplayEnum {
String code() default "value";
String desc() default "label";
Class<?> type() default String.class;
}
\ No newline at end of file
package cn.ibizlab.util.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel("字典项")
public class DictItem {
@ApiModelProperty(value = "实际值", position = 1)
private String value;
@ApiModelProperty(value = "显示内容", position = 2)
private String label;
@ApiModelProperty(value = "上级", position = 3)
private String parent;
}
package cn.ibizlab.util.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
@ApiModel("文件")
public class FileDto
{
@ApiModelProperty(value = "文件标识", position = 1)
private String id;
@ApiModelProperty(value = "文件名", position = 2)
private String name;
@ApiModelProperty(value = "文件流/base64", position = 3)
private byte[] content;
}
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.dict;
import cn.ibizlab.util.domain.DictItem;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import cn.ibizlab.util.annotation.SwaggerDisplayEnum;
import io.swagger.annotations.ApiModelProperty;
import java.util.*;
/**
* 字典:{{dict.name}}
*/
@SwaggerDisplayEnum{{#eq dict.valueType "Integer"}}(type = Integer.class){{/eq}}
@ApiModel(value = "字典:{{dict.name}}", description = "{{dict.codeName}}")
public enum {{pascalCase dict.codeName}}Dict {
{{#each dict.optionItems}}
{{#eq dict.valueType "String"}}
{{name}} ("{{value}}","{{label}}",{{#if parent}}"{{parent}}"{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{#eq dict.valueType "Integer"}}
{{name}} ({{value}},"{{label}}",{{#if parent}}{{parent}}{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{/each}}
private {{dict.valueType}} value;
@JsonValue
@JSONField
public {{dict.valueType}} getValue() {
return value;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "{{pascalCase dict.codeName}}Dict", description = "字典:{{dict.name}}")
public class {{pascalCase dict.codeName}}Dict {
private String label;
public String getLabel() {
return label;
}
@SwaggerDisplayEnum
public static enum ENUM{
{{#each dict.optionItems}}
{{#eq dict.valueType "String"}}
{{name}} ("{{value}}","{{label}}",{{#if parent}}"{{parent}}"{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{#eq dict.valueType "Integer"}}
{{name}} ({{value}},"{{label}}",{{#if parent}}{{parent}}{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{/each}}
private {{dict.valueType}} value;
@JsonValue
@JSONField
public {{dict.valueType}} getValue() {
return value;
}
private String label;
public String getLabel() {
return label;
}
private {{dict.valueType}} parent;
public {{dict.valueType}} getParent() {
return parent;
}
private {{dict.valueType}} parent;
public {{dict.valueType}} getParent() {
return parent;
ENUM({{dict.valueType}} value, String label, {{dict.valueType}} parent) {
this.value = value;
this.label = label;
this.parent = parent;
}
@JsonCreator
@JSONCreator
public static ENUM from(Object tag) {
if(tag==null)
return null;
for (ENUM item : values())
if (item.getValue().equals(tag){{#eq dict.valueType "Integer"}}||item.getValue().toString().equals(tag){{/eq}})
return item;
ENUM ret =null;
for (ENUM item : values())
if (item.getLabel().equals(tag))
ret = item;
return ret;
}
}
{{pascalCase dict.codeName}}Dict({{dict.valueType}} value, String label, {{dict.valueType}} parent) {
this.value = value;
this.label = label;
this.parent = parent;
@SwaggerDisplayEnum
public static class LIST extends ArrayList<ENUM> {
public boolean isEnum() {
return true;
}
@JsonValue
public String getValue() {
if(this.size()==0)
return null;
List<String> values=new ArrayList<>();
this.forEach(item->values.add(item.getValue().toString()));
return String.join("{{dict.valueSeparator}}",values);
}
public String getLabel() {
if(this.size()==0)
return null;
List<String> values=new ArrayList<>();
this.forEach(item->values.add(item.getLabel()));
return String.join("{{dict.textSeparator}}",values);
}
@Override
public String toString() {
return getValue();
}
@JsonCreator
@JSONCreator
public static LIST form(Object tags) {
LIST list=new LIST();
Arrays.asList(tags.toString().split(";|,")).forEach(tag->{
ENUM item=ENUM.from(tag);
if(item!=null)
list.add(item);
});
if(list.size()==0)
return null;
return list;
}
}
@JsonCreator
@JSONCreator
public static {{pascalCase dict.codeName}}Dict valueOf(Object tag) {
if(tag==null)
return null;
for ({{pascalCase dict.codeName}}Dict item : values())
if (item.getValue().equals(tag){{#eq dict.valueType "Integer"}}||item.getValue().toString().equals(tag){{/eq}})
return item;
{{pascalCase dict.codeName}}Dict ret =null;
for ({{pascalCase dict.codeName}}Dict item : values())
if (item.getLabel().equals(tag))
ret = item;
return ret;
@ApiModelProperty(value = "字典:{{dict.name}},示例", position = 1)
public ENUM example;
@ApiModelProperty(value = "字典项清单", position = 2)
private List<DictItem> allItems;
public List<DictItem> getAllItems()
{
if(allItems==null) {
allItems=new ArrayList<>();
Arrays.asList(ENUM.values()).forEach(item->allItems.add(new DictItem().setValue(item.getValue().toString()).setLabel(item.getLabel()).setParent(item.getParent()!=null?item.getParent().toString():null)));
}
return allItems;
}
}
{{/eq}}
\ No newline at end of file
......@@ -23,6 +23,7 @@ import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import cn.ibizlab.util.domain.*;
import {{packageName}}.api.{{apps}}.dict.*;
/**
......@@ -39,12 +40,15 @@ public class {{pascalCase ctrl.codeName}}AddDto extends {{pascalCase ctrl.codeNa
/**
* {{logicName}}
*/
@JsonProperty("{{camelCase codeName}}")
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
@DateTimeFormat(pattern = "{{format}}")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#if dict}}
@JsonFormat(shape = JsonFormat.Shape.{{#if singleSelect}}{{#eq type.java "String"}}STRING{{/eq}}{{#eq type.java "Integer"}}NUMBER{{/eq}}{{else}}STRING{{/if}})
{{/if}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}}{{#if serializeUsing}} , serializeUsing = {{serializeUsing}}{{/if}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
......
......@@ -23,6 +23,7 @@ import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import cn.ibizlab.util.domain.*;
import {{packageName}}.api.{{apps}}.dict.*;
/**
......@@ -39,7 +40,7 @@ public class {{pascalCase ctrl.codeName}}BaseDto implements Serializable {
/**
* {{logicName}}
*/
@JsonProperty("{{camelCase codeName}}")
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
@DateTimeFormat(pattern = "{{format}}")
......@@ -47,7 +48,7 @@ public class {{pascalCase ctrl.codeName}}BaseDto implements Serializable {
{{#if dict}}
@JsonFormat(shape = JsonFormat.Shape.{{#if singleSelect}}{{#eq type.java "String"}}STRING{{/eq}}{{#eq type.java "Integer"}}NUMBER{{/eq}}{{else}}STRING{{/if}})
{{/if}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}}{{#if serializeUsing}} , serializeUsing = {{serializeUsing}}{{/if}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
......
......@@ -23,6 +23,7 @@ import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import cn.ibizlab.util.domain.*;
import {{packageName}}.api.{{apps}}.dict.*;
/**
......@@ -39,12 +40,15 @@ public class {{pascalCase ctrl.codeName}}Dto extends {{pascalCase ctrl.codeName}
/**
* {{logicName}}
*/
@JsonProperty("{{camelCase codeName}}")
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
@DateTimeFormat(pattern = "{{format}}")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#if dict}}
@JsonFormat(shape = JsonFormat.Shape.{{#if singleSelect}}{{#eq type.java "String"}}STRING{{/eq}}{{#eq type.java "Integer"}}NUMBER{{/eq}}{{else}}STRING{{/if}})
{{/if}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}}{{#if serializeUsing}} , serializeUsing = {{serializeUsing}}{{/if}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
......
......@@ -23,6 +23,7 @@ import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import cn.ibizlab.util.domain.*;
import {{packageName}}.api.{{apps}}.dict.*;
/**
......@@ -39,12 +40,15 @@ public class {{pascalCase ctrl.codeName}}UpdateDto extends {{pascalCase ctrl.cod
/**
* {{logicName}}
*/
@JsonProperty("{{camelCase codeName}}")
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
@DateTimeFormat(pattern = "{{format}}")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#if dict}}
@JsonFormat(shape = JsonFormat.Shape.{{#if singleSelect}}{{#eq type.java "String"}}STRING{{/eq}}{{#eq type.java "Integer"}}NUMBER{{/eq}}{{else}}STRING{{/if}})
{{/if}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}}{{#if serializeUsing}} , serializeUsing = {{serializeUsing}}{{/if}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
......
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import {{packageName}}.api.{{apps}}.dict.*;
@Slf4j
@Api(tags = {"数据字典" })
@RestController("{{lowerCase app.codeName}}-DictResource")
@RequestMapping("/{{lowerCase app.codeName}}/dict")
public class DictResource {
{{#each app.dicts}}
@ApiOperation(value = "字典:{{name}}[{{pascalCase codeName}}Dict]", tags = {"数据字典" }, notes = "字典:{{name}}[{{pascalCase codeName}}Dict]")
@RequestMapping(method = RequestMethod.GET, value = "/{{pascalCase codeName}}Dict")
public ResponseEntity<{{pascalCase codeName}}Dict> get{{pascalCase codeName}}Dict() {
return ResponseEntity.ok(new {{pascalCase codeName}}Dict());
}
{{/each}}
}
{{/eq}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册