From 356331b1fc44b0397fd1c828634740cc3de66203 Mon Sep 17 00:00:00 2001 From: wangbing <1919101440@qq.com> Date: Wed, 20 Nov 2019 00:37:27 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/action/GlobalController.java | 2 +- .../java/action/ajax/system/DictAjax.java | 12 +- .../java/frame/base/BaseEntity.java | 46 ++++--- .../SpringBoot/java/frame/excel/WColumn.java | 16 +++ .../SpringBoot/java/frame/excel/WSheet.java | 124 ++++++------------ .../excel/converter/BooleanConverter.java | 30 ++++- .../java/frame/excel/converter/Converter.java | 4 +- .../exception/ValueConverterException.java | 15 +++ .../java/frame/utils/ClassUtil.java | 71 ++++------ .../SpringBoot/java/module/ent/entity.ftl | 4 +- .../java/module/system/ent/Dict.java | 24 ++-- .../java/module/system/ent/DictItem.java | 12 -- .../module/system/req/DictCreateRequest.java | 12 -- .../resources/templates/control/nav.ftl | 1 + 14 files changed, 176 insertions(+), 197 deletions(-) create mode 100644 src/main/resources/modules/SpringBoot/java/frame/excel/exception/ValueConverterException.java diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java index fd12ddd5..ca1d4680 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java @@ -309,7 +309,7 @@ public class GlobalController implements ErrorController { return baseResponse; } catch (InvocationTargetException e) { BaseResponse baseResponse = new BaseResponse(); - baseResponse.addError(ErrorType.BUSINESS_ERROR, "方法执行错误!"); + baseResponse.addError(ErrorType.BUSINESS_ERROR, "方法执行错误[" + e.getTargetException().getMessage() + "]"); return baseResponse; } } diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictAjax.java index 060afd93..ee056115 100644 --- a/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictAjax.java +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictAjax.java @@ -11,12 +11,14 @@ import ${basePackage}.frame.excel.exception.ReadErrorException; import ${basePackage}.frame.excel.exception.TemplateNotMatchException; import ${basePackage}.frame.utils.MapperUtil; import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.module.system.ent.Dict; import ${basePackage}.module.system.mgr.DictManager; import ${basePackage}.module.system.req.*; import ${basePackage}.module.system.rsp.*; import java.io.IOException; +import java.util.List; public class DictAjax { @@ -69,10 +71,16 @@ public class DictAjax { public Object imports(MultipartFile file) { BaseResponse baseResponse = new BaseResponse(); try { - WSheet sheet = new WSheet<>(file.getBytes(), Dict.class); + WSheet sheet = new WSheet<>(file.getBytes(), Dict.class, new WSheet.Validator() { + @Override + public List validate(Dict o) { + DictCreateRequest request = MapperUtil.map(o, DictCreateRequest.class); + return ValidationUtil.validate(request); + } + }); if (sheet.hasError()) { - return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-err.xlsx"); + return ResponseUtil.apply(sheet.getBytes(true), sheet.getName() + "-err.xlsx"); } else { return baseResponse; } diff --git a/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java b/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java index 60d9db25..85588a0f 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java +++ b/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java @@ -11,9 +11,13 @@ import java.util.Date; * @version 0.0.1 * @since 2017-01-01 */ - public class BaseEntity implements Serializable { + /** + * 主键 + */ + private long id; + /** * 行版本 */ @@ -48,14 +52,6 @@ public class BaseEntity implements Serializable { @JsonIgnore private boolean isDeleted; - public boolean getIsDeleted() { - return isDeleted; - } - - public void setIsDeleted(boolean isDeleted) { - this.isDeleted = isDeleted; - } - public long getRowVersion() { return rowVersion; } @@ -64,20 +60,20 @@ public class BaseEntity implements Serializable { this.rowVersion = rowVersion; } - public long getCreateBy() { - return createBy; + public long getId() { + return id; } - public void setCreateBy(long createBy) { - this.createBy = createBy; + public void setId(long id) { + this.id = id; } - public long getLastUpdateBy() { - return lastUpdateBy; + public long getCreateBy() { + return createBy; } - public void setLastUpdateBy(long lastUpdateBy) { - this.lastUpdateBy = lastUpdateBy; + public void setCreateBy(long createBy) { + this.createBy = createBy; } public Date getCreateTime() { @@ -88,6 +84,14 @@ public class BaseEntity implements Serializable { this.createTime = createTime; } + public long getLastUpdateBy() { + return lastUpdateBy; + } + + public void setLastUpdateBy(long lastUpdateBy) { + this.lastUpdateBy = lastUpdateBy; + } + public Date getLastUpdateTime() { return lastUpdateTime; } @@ -95,4 +99,12 @@ public class BaseEntity implements Serializable { public void setLastUpdateTime(Date lastUpdateTime) { this.lastUpdateTime = lastUpdateTime; } + + public boolean isDeleted() { + return isDeleted; + } + + public void setDeleted(boolean deleted) { + isDeleted = deleted; + } } diff --git a/src/main/resources/modules/SpringBoot/java/frame/excel/WColumn.java b/src/main/resources/modules/SpringBoot/java/frame/excel/WColumn.java index 0e70b3d2..af7917ed 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/excel/WColumn.java +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/WColumn.java @@ -6,6 +6,7 @@ import ${basePackage}.frame.utils.StringUtil; import java.io.Serializable; import java.lang.reflect.Field; +import java.lang.reflect.Method; /** * WColumn - Excel列对象(包含列名,长度,必须项,列描述,指定转换器) @@ -36,7 +37,14 @@ public class WColumn implements Serializable { */ private Converter converter; + /** + * Field对象 + */ private Field field; + /** + * set方法 + */ + private Method setMethod; private int cellType = 1; @@ -112,4 +120,12 @@ public class WColumn implements Serializable { public void setCellType(int cellType) { this.cellType = cellType; } + + public Method getSetMethod() { + return setMethod; + } + + public void setSetMethod(Method setMethod) { + this.setMethod = setMethod; + } } diff --git a/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java b/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java index eb6f2c38..8c8febae 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java @@ -1,12 +1,13 @@ package ${basePackage}.frame.excel; +import ${basePackage}.frame.excel.converter.Converter; +import ${basePackage}.frame.excel.exception.ValueConverterException; import ${basePackage}.frame.excel.style.DataCellStyle; import ${basePackage}.frame.excel.style.ErrorCellStyle; import ${basePackage}.frame.excel.style.HeadCellStyle; import ${basePackage}.frame.excel.style.RedFont; import ${basePackage}.frame.utils.ClassUtil; import ${basePackage}.frame.utils.LogUtil; -import ${basePackage}.frame.utils.StringUtil; import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.excel.annotation.*; import ${basePackage}.frame.excel.converter.*; @@ -64,7 +65,7 @@ public class WSheet implements Serializable, Cloneable { /** * 根据模板类对DataTable添加相应的列。 * - * @return 包含@Name标记的字段Set + * @return WColumn集合 */ private List initColumns(Class clazz) { //获取工作簿名称,没有则以类名为默认工作簿名称 @@ -87,6 +88,9 @@ public class WSheet implements Serializable, Cloneable { WColumn WColumn = new WColumn(); WColumn.setField(field); + Method set = ClassUtil.setMethod(field.getName(), clazz, field.getType()); + WColumn.setSetMethod(set); + //获取列名称 if (!field.isAnnotationPresent(ColumnName.class)) { WColumn.setName(field.getName()); @@ -110,7 +114,7 @@ public class WSheet implements Serializable, Cloneable { ${basePackage}.frame.excel.annotation.Converter converter = field.getAnnotation(${basePackage}.frame.excel.annotation.Converter.class); Class target = converter.target(); try { - WColumn.setConverter((${basePackage}.frame.excel.converter.Converter) target.newInstance()); + WColumn.setConverter((Converter) target.newInstance()); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { @@ -162,9 +166,6 @@ public class WSheet implements Serializable, Cloneable { * 并不会对数据的格式和合法性进行检验。 * * @param list 需要导出的对象列表 - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException */ public WSheet(List list) { if (list == null || list.size() == 0) { @@ -180,19 +181,7 @@ public class WSheet implements Serializable, Cloneable { continue; } Field field = column.getField(); - String att = StringUtil.upperFirstWord(field.getName()); - Method method = null; - try { - // 尝试获取get方法 - method = t.getClass().getMethod("get" + att); - } catch (NoSuchMethodException e) { - // 尝试获取is方法,工具生成布尔值可能是is而不是get - try { - method = t.getClass().getMethod("is" + att); - } catch (NoSuchMethodException e1) { - LogUtil.w(field.getName()+"can not find get method"); - } - } + Method method = ClassUtil.setMethod(field.getName(), t.getClass(), field.getType()); try { Object value = method.invoke(t); if (null == value) { @@ -202,7 +191,7 @@ public class WSheet implements Serializable, Cloneable { row.put(column.getName(), new WCell(string)); } } catch (IllegalAccessException e) { - LogUtil.w( "can not invoke get method!"); + LogUtil.w("can not invoke get method!"); } catch (InvocationTargetException e) { LogUtil.w(method.getName() + " unexpected exception!"); } @@ -315,17 +304,17 @@ public class WSheet implements Serializable, Cloneable { } try { - T t = transferOneObject(clazz, i); - List validate = ValidationUtil.validate(t); - validate.addAll(validator != null ? validator.validate(t) : null); - if (validate.size() > 0) { - for (String s : validate) { + T t = clazz.newInstance(); + List errs = transferMap(row, t); + errs.addAll(ValidationUtil.validate(t)); + errs.addAll(validator != null ? validator.validate(t) : Collections.emptyList()); + if (errs.size() > 0) { + for (String s : errs) { row.addError(s); } } - } catch (Exception e) { - e.printStackTrace(); - row.addError("数据检查错误"); + } catch (InstantiationException | IllegalAccessException e) { + row.addError("模板对象默认构造函数错误"); } } } @@ -333,67 +322,38 @@ public class WSheet implements Serializable, Cloneable { /** * 转换某行为一个对象 * - * @param clazz 类型 - * @param rowIndex 行号 - * @return 对象 - * @throws IllegalAccessException - * @throws InstantiationException - * @throws NoSuchMethodException - * @throws InvocationTargetException + * @param row 行对象 + * @param target 模板对象 + * @return 模板对象 */ - public T transferOneObject(Class clazz, int rowIndex) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { - T object = clazz.newInstance(); - ParentFirst parentFirstAnnotation = clazz.getAnnotation(ParentFirst.class); - boolean parentFirst = parentFirstAnnotation != null && parentFirstAnnotation.value(); - Field[] fields = ClassUtil.getFields(clazz, parentFirst); - Set set = new HashSet<>(); - for (Field field : fields) { - set.add(field); - } - - for (int j = 0; j < this.columnList.size(); j++) { - String key = this.columnList.get(j).getName(); - + public List transferMap(WRow row, T target) { + List err = new ArrayList<>(); + for (String key : row.keySet()) { for (WColumn column : columnList) { - Field field = column.getField(); - ColumnName fieldColumnName = field.getAnnotation(ColumnName.class); - - if (key.equals(fieldColumnName.value())) { + String name = column.getName(); + Method setMethod = column.getSetMethod(); - String att = StringUtil.upperFirstWord(field.getName()); - - WCell WCell = this.rowList.get(rowIndex).get(column.getName()); + if (key.equals(name)) { + WCell WCell = row.get(column.getName()); if (null != WCell) { String value = WCell.getValue(); - Method method = clazz.getMethod("set" + att, field.getType()); //获取转换器 - ${basePackage}.frame.excel.converter.Converter converter = column.getConverter(); - method.invoke(object, converter.convert(value)); + Converter converter = column.getConverter(); + try { + setMethod.invoke(target, converter.convert(value)); + } catch (ValueConverterException e) { + e.printStackTrace(); + err.add(e.getMessage()); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + err.add("[" + setMethod.getName() + "]执行错误"); + } } break; } } } - return object; - } - - /** - * 将DataTable转为T型的List

- * 如果你试图这么做,请确保在每个字段上都加上了@Name注解
- * 并确保该注解的值与DataTable中列的名字一致。
- * 注解的值在这里作为唯一的标识。 - * - * @return T型列表 - * @see WColumn 列名称 - */ - public List transferList(Class clazz) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { - List list = new ArrayList<>(); - - for (int i = 0; i < this.rowList.size(); i++) { - T object = transferOneObject(clazz, i); - list.add(object); - } - return list; + return err; } /** @@ -508,7 +468,6 @@ public class WSheet implements Serializable, Cloneable { for (int j = 0; j < this.columnList.size(); j++) { WColumn column = this.columnList.get(j); - Field field = column.getField(); Cell firstCell = firstRow.createCell(j + offset); String columnName = column.getName(); XSSFRichTextString textString; @@ -522,13 +481,6 @@ public class WSheet implements Serializable, Cloneable { } StringBuilder sb = new StringBuilder(); sb.append(column.getDescription()).append("\n"); - // 添加数据说明信息。 - if (field.isAnnotationPresent(ColumnDescription.class)) { - // 获取声明字段上的Description信息。 - ColumnDescription columnDescription = field.getAnnotation(ColumnDescription.class); - sb.append(columnDescription.value()); - sb.append("\n"); - } // 如果填写了注释信息 if (sb.length() > 1) { diff --git a/src/main/resources/modules/SpringBoot/java/frame/excel/converter/BooleanConverter.java b/src/main/resources/modules/SpringBoot/java/frame/excel/converter/BooleanConverter.java index ce897e4b..bc3e67e2 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/excel/converter/BooleanConverter.java +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/converter/BooleanConverter.java @@ -1,5 +1,7 @@ package ${basePackage}.frame.excel.converter; + import ${basePackage}.frame.excel.exception.ValueConverterException; + /** * BooleanConverter - Boolean转化器,重写了对象到String,String到对象的转化方式 * @@ -10,12 +12,28 @@ package ${basePackage}.frame.excel.converter; public class BooleanConverter implements Converter { @Override - public Boolean convert(String var) { - try { - return Boolean.parseBoolean(var); - } catch (Exception e) { + public Boolean convert(String var) throws ValueConverterException { + if (null == var || "".equals(var)) { return false; } + + String lowerCase = var.toLowerCase(); + + if (lowerCase.matches("y|n")) { + return "y".equals(lowerCase); + } else if (lowerCase.matches("yes|no")) { + return "yes".equals(lowerCase); + } else if (lowerCase.matches("true|false")) { + return "true".equals(lowerCase); + } else if (lowerCase.matches("是|否")) { + return "是".equals(lowerCase); + } else if (lowerCase.matches("有|无")) { + return "有".equals(lowerCase); + } else if (lowerCase.matches("是|不是")) { + return "是".equals(lowerCase); + } else { + throw new ValueConverterException("[" + var + "] can not convert to Boolean"); + } } @Override @@ -23,6 +41,6 @@ public class BooleanConverter implements Converter { if (var == null) { return ""; } - return String.valueOf(var); + return var ? "Y" : "N"; } -} +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/frame/excel/converter/Converter.java b/src/main/resources/modules/SpringBoot/java/frame/excel/converter/Converter.java index 1adea27f..0d51fc70 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/excel/converter/Converter.java +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/converter/Converter.java @@ -1,5 +1,7 @@ package ${basePackage}.frame.excel.converter; +import ${basePackage}.frame.excel.exception.ValueConverterException; + /** * Converter - 转化器接口,所有转化器必须实现该接口 * @@ -9,7 +11,7 @@ package ${basePackage}.frame.excel.converter; */ public interface Converter { - T convert(String var); + T convert(String var) throws ValueConverterException; String string(T var); } diff --git a/src/main/resources/modules/SpringBoot/java/frame/excel/exception/ValueConverterException.java b/src/main/resources/modules/SpringBoot/java/frame/excel/exception/ValueConverterException.java new file mode 100644 index 00000000..b848c467 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/exception/ValueConverterException.java @@ -0,0 +1,15 @@ +package xyz.wbsite.frame.excel.exception; + +/** + * 值转换异常 + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class ValueConverterException extends Exception { + + public ValueConverterException(String s) { + super(s); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/ClassUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/ClassUtil.java index 5f3cdd6d..bc1460e1 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/ClassUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/ClassUtil.java @@ -1,8 +1,8 @@ package ${basePackage}.frame.utils; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; + import java.lang.reflect.Field; + import java.lang.reflect.Method; + import java.util.*; /** * ClassUtil @@ -30,25 +30,6 @@ public class ClassUtil { return fields; } - /** - * 获取class的 包括父类的 - * - * @param clazz - * @return - */ - public static Field[] getClassFields(Class clazz) { - List list = new ArrayList(); - Field[] fields; - do { - fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - list.add(fields[i]); - } - clazz = clazz.getSuperclass(); - } while (clazz != Object.class && clazz != null); - return list.toArray(fields); - } - /** * 判断是不是集合的实现类 * @@ -62,40 +43,38 @@ public class ClassUtil { /** * 获取GET方法 * - * @param name - * @param pojoClass - * @return - * @throws Exception + * @param name 成员变量名 + * @param pojoClass POJO对象 + * @return 方法 */ - public static Method getMethod(String name, Class pojoClass) throws Exception { - StringBuffer getMethodName = new StringBuffer("get"); - getMethodName.append(name.substring(0, 1).toUpperCase()); - getMethodName.append(name.substring(1)); - Method method = null; + public static Method getMethod(String name, Class pojoClass) throws RuntimeException { + String getMethodName = "get" + StringUtil.upperFirstWord(name); try { - method = pojoClass.getMethod(getMethodName.toString()); + return pojoClass.getMethod(getMethodName); } catch (Exception e) { - method = pojoClass.getMethod( - getMethodName.toString().replace("get", "is") - ); + getMethodName = "is" + StringUtil.upperFirstWord(name); + try { + return pojoClass.getMethod(getMethodName); + } catch (NoSuchMethodException e1) { + throw new RuntimeException("can not find[" + name + "]method"); + } } - return method; } /** * 获取SET方法 * - * @param name - * @param pojoClass - * @param type - * @return - * @throws Exception + * @param name 成员变量名 + * @param pojoClass POJO对象 + * @return 方法 */ - public static Method getMethod(String name, Class pojoClass, Class type) throws Exception { - StringBuffer getMethodName = new StringBuffer("set"); - getMethodName.append(name.substring(0, 1).toUpperCase()); - getMethodName.append(name.substring(1)); - return pojoClass.getMethod(getMethodName.toString(), type); + public static Method setMethod(String name, Class pojoClass, Class type) { + String setMethodName = "set" + StringUtil.upperFirstWord(name); + try { + return pojoClass.getMethod(setMethodName, type); + } catch (Exception e) { + return null; + } } public static boolean isJavaClass(Field field) { diff --git a/src/main/resources/modules/SpringBoot/java/module/ent/entity.ftl b/src/main/resources/modules/SpringBoot/java/module/ent/entity.ftl index 5862b0a1..89f97191 100644 --- a/src/main/resources/modules/SpringBoot/java/module/ent/entity.ftl +++ b/src/main/resources/modules/SpringBoot/java/module/ent/entity.ftl @@ -15,7 +15,7 @@ import ${basePackage}.frame.base.BaseEntity; public class ${table.getCName()} extends BaseEntity { <#list table.fields as field> -<#if !field.isSystem || field.fieldName == 'ID'> +<#if !field.isSystem> /** * ${field.fieldName} - ${field.fieldComment?default("")} */ @@ -23,7 +23,7 @@ public class ${table.getCName()} extends BaseEntity { <#list table.fields as field> -<#if !field.isSystem || field.fieldName == 'ID' > +<#if !field.isSystem> public ${field.fieldType.javaType()} ${field.getterName()}() { return this.${field.getFName()}; diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/Dict.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/Dict.java index 0bc85fc2..9808cfae 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/ent/Dict.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/Dict.java @@ -1,6 +1,9 @@ package ${basePackage}.module.system.ent; import ${basePackage}.frame.base.BaseEntity; +import ${basePackage}.frame.excel.annotation.ColumnDescription; +import ${basePackage}.frame.excel.annotation.ColumnName; +import ${basePackage}.frame.excel.annotation.SheetName; /** * DICT - 字典 @@ -9,37 +12,34 @@ import ${basePackage}.frame.base.BaseEntity; * @version 0.0.1 * @since 2019-07-20 */ +@SheetName("字典") public class Dict extends BaseEntity { - /** - * ID - 主键 - */ - private Long id; /** * DICT_NAME - 字典名称 */ + @ColumnName("字典名称") + @ColumnDescription("1-50长度的字典名称") private String dictName; /** * DICT_CODE - 字典代码 */ + @ColumnName("字典代码") + @ColumnDescription("1-50长度的字典代码") private String dictCode; /** * VERSION - 字典版本号 */ + @ColumnName("字典版本号") + @ColumnDescription("字典版本号.例如:(yyyy-MM-dd HH:mm:ss)") private String version; /** * VALID - 是否有效 */ + @ColumnName("是否有效") + @ColumnDescription("true/false") private Boolean valid; - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - public String getDictName() { return this.dictName; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/DictItem.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/DictItem.java index 0b0dc791..673ec041 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/ent/DictItem.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/DictItem.java @@ -11,10 +11,6 @@ import ${basePackage}.frame.base.BaseEntity; */ public class DictItem extends BaseEntity { - /** - * ID - 主键 - */ - private Long id; /** * DICT_ID - 字典ID */ @@ -36,14 +32,6 @@ public class DictItem extends BaseEntity { */ private Boolean valid; - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - public Long getDictId() { return this.dictId; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java index 4465d8a9..2329b2d2 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java @@ -2,9 +2,6 @@ package ${basePackage}.module.system.req; import org.hibernate.validator.constraints.Length; import ${basePackage}.frame.base.BaseRequest; -import ${basePackage}.frame.excel.annotation.ColumnDescription; -import ${basePackage}.frame.excel.annotation.ColumnName; -import ${basePackage}.frame.excel.annotation.SheetName; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; @@ -15,14 +12,11 @@ import javax.validation.constraints.NotNull; * @version 0.0.1 * @since 2019-07-20 */ -@SheetName("字典") public class DictCreateRequest extends BaseRequest { /** * 字典名称 */ - @ColumnName("字典名称") - @ColumnDescription("1-50长度的字典名称") @NotEmpty(message = "字典名称不能为空") @Length(min = 1, max = 50, message = "字典名称长度不合法(1-50)") private String dictName; @@ -30,8 +24,6 @@ public class DictCreateRequest extends BaseRequest { /** * 字典代码 */ - @ColumnName("字典代码") - @ColumnDescription("1-50长度的字典代码") @NotEmpty(message = "字典代码不能为空") @Length(min = 1, max = 50, message = "字典代码长度不合法(1-50)") private String dictCode; @@ -39,8 +31,6 @@ public class DictCreateRequest extends BaseRequest { /** * 字典版本号 */ - @ColumnName("字典版本号") - @ColumnDescription("字典版本号.例如:(yyyy-MM-dd HH:mm:ss)") @NotEmpty(message = "字典版本号不能为空") @Length(min = 1, max = 50, message = "字典版本号长度不合法(1-50)") private String version; @@ -48,8 +38,6 @@ public class DictCreateRequest extends BaseRequest { /** * 是否有效 */ - @ColumnName("是否有效") - @ColumnDescription("true/false") @NotNull(message = "是否有效不能为NULL") private Boolean valid; diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl index 046ac37a..26bca7dd 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -413,6 +413,7 @@ onImport: function (item) { const file = item.target.files[0]; this.$ajax.imports(this.module, this.target, file); + this.$refs['excel'].value = '' }, onExport: function () { this.$ajax.exports(this.module, this.target, this.vm);