From d6188aa009d264966d78e05acabd4bbfe39f57f5 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Sep 2021 16:18:48 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E4=B8=BB=E5=AD=90=E8=A1=A8=E4=BB=A3=E7=A0=81=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D=E7=94=9F=E6=88=90=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi-gen/src/main/resources/vm/java/mapper.java.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/mapper.java.vm b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/mapper.java.vm index f7446402..6f031790 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/mapper.java.vm +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/mapper.java.vm @@ -69,7 +69,7 @@ public interface ${ClassName}Mapper * @param ${pkColumn.javaField}s 需要删除的数据主键集合 * @return 结果 */ - public int delete${subClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); /** * 批量新增${subTable.functionName} From 524982c7bd5a8e28b00ada44619190b3c10b12c0 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Sep 2021 16:19:11 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E7=A6=81=E7=94=A8el-tag=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=B8=90=E5=8F=98=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/DictTag/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/components/DictTag/index.vue b/ruoyi-ui/src/components/DictTag/index.vue index 542c6edd..1ff2c19f 100644 --- a/ruoyi-ui/src/components/DictTag/index.vue +++ b/ruoyi-ui/src/components/DictTag/index.vue @@ -11,6 +11,7 @@ > \ No newline at end of file + From ab8215d1ce6487d33a726e76cd64032a31b9698d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Sep 2021 16:19:23 +0800 Subject: [PATCH 03/20] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=98=AF=E5=90=A6=E4=BF=9D=E5=AD=98=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/log/annotation/Log.java | 5 +++++ .../java/com/ruoyi/common/log/aspect/LogAspect.java | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/annotation/Log.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/annotation/Log.java index 8cb5c184..41163441 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/annotation/Log.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/annotation/Log.java @@ -38,4 +38,9 @@ public @interface Log * 是否保存请求的参数 */ public boolean isSaveRequestData() default true; + + /** + * 是否保存响应的参数 + */ + public boolean isSaveResponseData() default true; } diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java index 1d77eeb7..ea57fe6f 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java @@ -90,9 +90,6 @@ public class LogAspect // 请求的地址 String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); operLog.setOperIp(ip); - // 返回参数 - operLog.setJsonResult(JSON.toJSONString(jsonResult)); - operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); String username = SecurityUtils.getUsername(); if (StringUtils.isNotBlank(username)) @@ -112,7 +109,7 @@ public class LogAspect // 设置请求方式 operLog.setRequestMethod(ServletUtils.getRequest().getMethod()); // 处理设置注解上的参数 - getControllerMethodDescription(joinPoint, controllerLog, operLog); + getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult); // 保存数据库 asyncLogService.saveSysLog(operLog); } @@ -132,7 +129,7 @@ public class LogAspect * @param operLog 操作日志 * @throws Exception */ - public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception + public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception { // 设置action动作 operLog.setBusinessType(log.businessType().ordinal()); @@ -146,6 +143,11 @@ public class LogAspect // 获取参数的信息,传入到数据库中。 setRequestValue(joinPoint, operLog); } + // 是否需要保存response,参数和值 + if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) + { + operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); + } } /** From a10384c0099ce411b5dd56127e43fc60ad469fad Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 17 Sep 2021 15:43:02 +0800 Subject: [PATCH 04/20] =?UTF-8?q?=E4=BD=BF=E7=94=A8vue-data-dict=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/gen/util/VelocityUtils.java | 22 +++++ .../main/resources/vm/vue/index-tree.vue.vm | 55 +++++-------- .../src/main/resources/vm/vue/index.vue.vm | 55 +++++-------- ruoyi-ui/src/components/DictData/index.js | 21 +++++ ruoyi-ui/src/components/DictTag/index.vue | 20 ++--- ruoyi-ui/src/main.js | 3 + ruoyi-ui/src/utils/dict/Dict.js | 82 +++++++++++++++++++ ruoyi-ui/src/utils/dict/DictConverter.js | 17 ++++ ruoyi-ui/src/utils/dict/DictData.js | 13 +++ ruoyi-ui/src/utils/dict/DictMeta.js | 38 +++++++++ ruoyi-ui/src/utils/dict/DictOptions.js | 51 ++++++++++++ ruoyi-ui/src/utils/dict/index.js | 33 ++++++++ ruoyi-ui/src/utils/ruoyi.js | 20 ++++- ruoyi-ui/src/views/monitor/job/index.vue | 47 +++++------ ruoyi-ui/src/views/monitor/job/log.vue | 31 +++---- ruoyi-ui/src/views/system/config/index.vue | 24 +++--- ruoyi-ui/src/views/system/dept/index.vue | 24 +++--- ruoyi-ui/src/views/system/dict/data.vue | 24 +++--- ruoyi-ui/src/views/system/dict/index.vue | 24 +++--- .../src/views/system/logininfor/index.vue | 16 ++-- ruoyi-ui/src/views/system/menu/index.vue | 37 ++++----- ruoyi-ui/src/views/system/notice/index.vue | 39 ++++----- ruoyi-ui/src/views/system/operlog/index.vue | 33 +++----- ruoyi-ui/src/views/system/post/index.vue | 24 +++--- ruoyi-ui/src/views/system/role/authUser.vue | 8 +- ruoyi-ui/src/views/system/role/index.vue | 22 ++--- ruoyi-ui/src/views/system/role/selectUser.vue | 10 +-- ruoyi-ui/src/views/system/user/index.vue | 38 ++++----- 28 files changed, 505 insertions(+), 326 deletions(-) create mode 100644 ruoyi-ui/src/components/DictData/index.js create mode 100644 ruoyi-ui/src/utils/dict/Dict.js create mode 100644 ruoyi-ui/src/utils/dict/DictConverter.js create mode 100644 ruoyi-ui/src/utils/dict/DictData.js create mode 100644 ruoyi-ui/src/utils/dict/DictMeta.js create mode 100644 ruoyi-ui/src/utils/dict/DictOptions.js create mode 100644 ruoyi-ui/src/utils/dict/index.js diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java index 02673453..18e6fbec 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java @@ -58,6 +58,7 @@ public class VelocityUtils velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); velocityContext.put("columns", genTable.getColumns()); velocityContext.put("table", genTable); + velocityContext.put("dicts", getDicts(genTable)); setMenuVelocityContext(velocityContext, genTable); if (GenConstants.TPL_TREE.equals(tplCategory)) { @@ -260,6 +261,27 @@ public class VelocityUtils return importList; } + /** + * 根据列类型获取字典组 + * + * @param genTable 业务表对象 + * @return 返回字典组 + */ + public static String getDicts(GenTable genTable) + { + List columns = genTable.getColumns(); + List dicts = new ArrayList(); + for (GenTableColumn column : columns) + { + if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( + column.getHtmlType(), new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO })) + { + dicts.add("'" + column.getDictType() + "'"); + } + } + return StringUtils.join(dicts, ", "); + } + /** * 获取权限前缀 * diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm index 51c447ee..c2383c05 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm @@ -25,10 +25,10 @@ @@ -108,7 +108,7 @@ #elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $javaField) @@ -184,10 +184,10 @@ @@ -202,10 +202,10 @@ - {{dict.dictLabel}} + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} @@ -219,11 +219,11 @@ {{dict.dictLabel}} + >{{dict.label}} #elseif($column.htmlType == "radio" && $dictType) @@ -265,6 +265,9 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"; export default { name: "${BusinessName}", +#if(${dicts} != '') + dicts: [${dicts}], +#end components: { Treeselect }, @@ -283,16 +286,7 @@ export default { // 是否显示弹出层 open: false, #foreach ($column in $columns) -#set($parentheseIndex=$column.columnComment.indexOf("(")) -#if($parentheseIndex != -1) -#set($comment=$column.columnComment.substring(0, $parentheseIndex)) -#else -#set($comment=$column.columnComment) -#end -#if(${column.dictType} != '') - // $comment字典 - ${column.javaField}Options: [], -#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) // $comment时间范围 daterange${AttrName}: [], @@ -330,13 +324,6 @@ export default { }, created() { this.getList(); -#foreach ($column in $columns) -#if(${column.dictType} != '') - this.getDicts("${column.dictType}").then(response => { - this.${column.javaField}Options = response.data; - }); -#end -#end }, methods: { /** 查询${functionName}列表 */ diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm index ca68f624..78d15eb7 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm @@ -25,10 +25,10 @@ @@ -136,7 +136,7 @@ #elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $javaField) @@ -205,10 +205,10 @@ @@ -223,10 +223,10 @@ - {{dict.dictLabel}} + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} @@ -240,11 +240,11 @@ {{dict.dictLabel}} + >{{dict.label}} #elseif($column.htmlType == "radio" && $dictType) @@ -316,6 +316,9 @@ import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${Busin export default { name: "${BusinessName}", +#if(${dicts} != '') + dicts: [${dicts}], +#end data() { return { // 遮罩层 @@ -345,16 +348,7 @@ export default { // 是否显示弹出层 open: false, #foreach ($column in $columns) -#set($parentheseIndex=$column.columnComment.indexOf("(")) -#if($parentheseIndex != -1) -#set($comment=$column.columnComment.substring(0, $parentheseIndex)) -#else -#set($comment=$column.columnComment) -#end -#if(${column.dictType} != '') - // $comment字典 - ${column.javaField}Options: [], -#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) // $comment时间范围 daterange${AttrName}: [], @@ -394,13 +388,6 @@ export default { }, created() { this.getList(); -#foreach ($column in $columns) -#if(${column.dictType} != '') - this.getDicts("${column.dictType}").then(response => { - this.${column.javaField}Options = response.data; - }); -#end -#end }, methods: { /** 查询${functionName}列表 */ diff --git a/ruoyi-ui/src/components/DictData/index.js b/ruoyi-ui/src/components/DictData/index.js new file mode 100644 index 00000000..24e3e9c8 --- /dev/null +++ b/ruoyi-ui/src/components/DictData/index.js @@ -0,0 +1,21 @@ +import Vue from 'vue' +import DataDict from '@/utils/dict' +import { getDicts as getDicts } from '@/api/system/dict/data' + +function install() { + Vue.use(DataDict, { + metas: { + '*': { + labelField: 'dictLabel', + valueField: 'dictValue', + request(dictMeta) { + return getDicts(dictMeta.type).then(res => res.data) + }, + }, + }, + }) +} + +export default { + install, +} \ No newline at end of file diff --git a/ruoyi-ui/src/components/DictTag/index.vue b/ruoyi-ui/src/components/DictTag/index.vue index 1ff2c19f..c635dee2 100644 --- a/ruoyi-ui/src/components/DictTag/index.vue +++ b/ruoyi-ui/src/components/DictTag/index.vue @@ -1,23 +1,23 @@