From 45169b489acde57519abe219ddfce8efedd54033 Mon Sep 17 00:00:00 2001 From: wangbing <1919101440@qq.com> Date: Sun, 24 Nov 2019 23:55:44 +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 --- .../SpringBoot/java/action/ajax/Ajax.java | 3 ++ .../java/action/ajax/system/DictAjax.java | 3 ++ .../java/action/ajax/system/DictItemAjax.java | 3 ++ .../SpringBoot/java/frame/excel/WSheet.java | 2 +- .../java/frame/utils/MapperUtil.java | 32 +++++++++++++------ .../SpringBoot/resources/application-dev.ftl | 2 +- .../resources/templates/control/nav.ftl | 29 +++++++++-------- .../resources/templates/screen/index.ftl | 16 ++++++++-- .../resources/templates/screen/module/mgr.ftl | 8 +++-- .../templates/screen/module/system/dict.ftl | 4 +-- .../screen/module/system/dictItem.ftl | 26 ++++++--------- 11 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/Ajax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/Ajax.java index e6cc89a8..0433f63c 100644 --- a/src/main/resources/modules/SpringBoot/java/action/ajax/Ajax.java +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/Ajax.java @@ -85,6 +85,9 @@ public class ${table.getCName()}Ajax{ ${table.getCName()}FindResponse response = ${table.getFName()}Manager.find(request, LocalData.getToken()); if (response.hasError()) { return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; } return ResponseUtil.apply(new WSheet<>(response.getResult())); } 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 bf18c96c..11df6f3e 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 @@ -65,6 +65,9 @@ public class DictAjax { DictFindResponse response = dictManager.find(request, LocalData.getToken()); if (response.hasError()) { return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; } return ResponseUtil.apply(new WSheet<>(response.getResult())); } diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictItemAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictItemAjax.java index c320eb01..2eb53f83 100644 --- a/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictItemAjax.java +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DictItemAjax.java @@ -60,6 +60,9 @@ public class DictItemAjax { DictItemFindResponse response = dictItemManager.find(request, LocalData.getToken()); if (response.hasError()) { return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; } return ResponseUtil.apply(new WSheet<>(response.getResult())); } 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 38bfdd28..2bf46776 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java +++ b/src/main/resources/modules/SpringBoot/java/frame/excel/WSheet.java @@ -168,7 +168,7 @@ public class WSheet implements Serializable, Cloneable { */ public WSheet(List list) { if (list == null || list.size() == 0) { - throw new RuntimeException("不允许传入空的列表"); + throw new RuntimeException("导出数据为空"); } if (list.size() > 0) { List wColumns = initColumns(list.get(0).getClass()); diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/MapperUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/MapperUtil.java index 9dcd7baf..12c03abb 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/MapperUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/MapperUtil.java @@ -7,8 +7,11 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.*; import org.dozer.DozerBeanMapper; import org.dozer.Mapper; +import ${basePackage}.frame.auth.LocalData; + import java.io.IOException; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.List; /** @@ -23,16 +26,25 @@ public class MapperUtil { private static Mapper mapper; static { - //初始化 - om = new ObjectMapper(); - //序列化时忽略null属性 - om.setSerializationInclusion(JsonInclude.Include.NON_NULL); - //序列化时排序 - om.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); - //反序列化是忽略多余字段 - om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //支持空类序列化时出错InvalidDefinitionException - om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false); + try {// 优先获取SpringBoot默认配置 + om = LocalData.getBean(ObjectMapper.class); + } catch (Exception e) { + e.printStackTrace(); + } + if (null == om) { + //初始化 + om = new ObjectMapper(); + // 日期格式化 + om.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + //序列化时忽略null属性 + om.setSerializationInclusion(JsonInclude.Include.NON_NULL); + //序列化时排序 + om.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); + //反序列化是忽略多余字段 + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + //支持空类序列化时出错InvalidDefinitionException + om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + } mapper = new DozerBeanMapper(); } diff --git a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl index 1a075204..a503ef47 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl @@ -41,7 +41,7 @@ pagehelper.params=count=countSql # jackson 相关配置 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.time-zone=GMT+8 -spring.jackson.default-property-inclusion=use_defaults +spring.jackson.default-property-inclusion=non_null spring.jackson.mapper.sort-properties-alphabetically=true spring.jackson.deserialization.fail-on-unknown-properties=false # freemarker 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 3d01690a..ec0a4b97 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -483,22 +483,23 @@ type: 'warning' }).then(function () { for (var i = 0; i < this.select.length; i++) { - var obj = this.select[i]; - this.$ajax.delete(this.module, this.target, {id: obj.id}).then(function (response) { - if (response.errors.length > 0) { - this.e(response.errors[0].message); - } else { - for (var j = 0; j < this.select.length; j++) { - if (this.select[j].id == obj.id) { - this.select.splice(j, 1); + (function (obj) { + this.$ajax.delete(this.module, this.target, {id: obj.id}).then(function (response) { + if (response.errors.length > 0) { + this.e(response.errors[0].message); + } else { + for (var j = 0; j < this.select.length; j++) { + if (this.select[j].id === obj.id) { + this.select.splice(j, 1); + } + } + if (this.select.length === 0) { + this.s("删除成功") + this.onFind(); } } - if (this.select.length == 0) { - this.s("删除成功") - this.onFind(); - } - } - }.bind(this)) + }.bind(this)) + }.bind(this))(this.select[i]); } }.bind(this)).catch(function (action) { diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl index af09ba49..c12b9398 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl @@ -16,7 +16,7 @@ 系统设置 - 字典管理 + 字典管理 <#list modules as item> @@ -25,7 +25,7 @@ ${item.moduleComment} <#list item.tables as table> - ${table.tableComment} + ${table.tableComment} @@ -121,6 +121,18 @@ border-right: solid 0 #e6e6e6; } + .el-submenu__title{ + height: 40px!important; + line-height: 40px!important; + } + .el-menu-item { + height: 40px!important; + line-height: 40px!important; + } + .el-menu--popup-right-start{ + padding: 0px; + } + #main { height: 100%; margin-left: 200px; diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl index f537fcab..4852de4d 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl @@ -1,6 +1,6 @@
- + <#list fields as item> <#if item.isQuery> <#if item.fieldType.javaType() =="Boolean"> @@ -51,6 +51,8 @@ @@ -77,7 +79,7 @@ 导出 - + <#list fields as item> <#if !item.isSystem> <#if item.fieldType.javaType() =="Boolean"> @@ -128,6 +130,8 @@ diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl index 252bd7d6..0b8a1b62 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl @@ -1,6 +1,6 @@
- + @@ -28,7 +28,7 @@ 导出 - + diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl index 0b14a342..21cd1c4b 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl @@ -1,6 +1,6 @@
- + @@ -31,18 +31,16 @@ 导出 - - - - - + + - + - - + @@ -175,8 +173,8 @@ pageNumber: 1, pageSize: 10, totalCount: 0, - sortKey:'CREATE_TIME', - sortType:'DESC' + sortKey: 'CREATE_TIME', + sortType: 'DESC' }, form: { title: "", @@ -190,10 +188,6 @@ rowVersion: "" }, formRules: { - dictName: [ - {required: true, message: '字典名称不能为空', trigger: 'blur'}, - {min: 1, max: 50, message: '字典名称长度在 1 到 50 个字符', trigger: 'blur'} - ], key: [ {required: true, message: '请输入字典名称', trigger: 'blur'}, {min: 1, max: 50, message: '长度在 3 到 5 个字符', trigger: 'blur'} @@ -217,7 +211,7 @@ this.form.dictName = location.getParam("dictName"); this.form.key = ''; this.form.value = ''; - this.form.sort = this.vm.totalCount; + this.form.sort = this.vm.totalCount + 1; this.form.valid = true; }, onCommand: function (arg) {