From b84e7013d23e0947bff4a3c4ce15fc6af6a8ad05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B0=8F=E6=B3=95?= Date: Tue, 14 Sep 2021 15:15:22 +0800 Subject: [PATCH 01/41] =?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 | 103 +++++++++++----------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/ruoyi-ui/src/components/DictTag/index.vue b/ruoyi-ui/src/components/DictTag/index.vue index 542c6edd..b0484bc1 100644 --- a/ruoyi-ui/src/components/DictTag/index.vue +++ b/ruoyi-ui/src/components/DictTag/index.vue @@ -1,51 +1,52 @@ - - - - \ No newline at end of file + + + + From dbe3446b633bcf374fc529da8a6bf3e0abf67afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=9A=E5=B1=BF?= <1491182878@qq.com> Date: Tue, 14 Sep 2021 13:53:32 +0000 Subject: [PATCH 02/41] =?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-generator/src/main/resources/vm/java/mapper.java.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm index 42d015db..7e7d7c26 100644 --- a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm +++ b/ruoyi-generator/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 23270c60bcb9128c6a6b2fec734472397e992642 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Sep 2021 16:03:49 +0800 Subject: [PATCH 03/41] =?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 --- .../main/java/com/ruoyi/common/annotation/Log.java | 5 +++++ .../java/com/ruoyi/framework/aspectj/LogAspect.java | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java index 3458c882..4b1f1307 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java @@ -38,4 +38,9 @@ public @interface Log * 是否保存请求的参数 */ public boolean isSaveRequestData() default true; + + /** + * 是否保存响应的参数 + */ + public boolean isSaveResponseData() default true; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index b7cf17bb..97c24905 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -92,9 +92,6 @@ public class LogAspect // 请求的地址 String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); operLog.setOperIp(ip); - // 返回参数 - operLog.setJsonResult(JSON.toJSONString(jsonResult)); - operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); if (loginUser != null) { @@ -113,7 +110,7 @@ public class LogAspect // 设置请求方式 operLog.setRequestMethod(ServletUtils.getRequest().getMethod()); // 处理设置注解上的参数 - getControllerMethodDescription(joinPoint, controllerLog, operLog); + getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult); // 保存数据库 AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); } @@ -133,7 +130,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()); @@ -147,6 +144,11 @@ public class LogAspect // 获取参数的信息,传入到数据库中。 setRequestValue(joinPoint, operLog); } + // 是否需要保存response,参数和值 + if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) + { + operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); + } } /** From 12ab8b03d9acb77848c4db9bb0451e77af60acb6 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 17 Sep 2021 15:36:54 +0800 Subject: [PATCH 04/41] =?UTF-8?q?=E4=BD=BF=E7=94=A8vue-data-dict=EF=BC=8C?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/generator/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 +++---- .../src/views/monitor/logininfor/index.vue | 16 ++-- ruoyi-ui/src/views/monitor/operlog/index.vue | 33 +++----- 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 +++--- ruoyi-ui/src/views/system/menu/index.vue | 37 ++++----- ruoyi-ui/src/views/system/notice/index.vue | 39 ++++----- 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 | 35 +++----- 28 files changed, 503 insertions(+), 325 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-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index 6481057c..2683ec8f 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/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-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index 51c447ee..c2383c05 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/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-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 00865594..67d72b1c 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -25,10 +25,10 @@ @@ -137,7 +137,7 @@ #elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $javaField) @@ -206,10 +206,10 @@ @@ -224,10 +224,10 @@ - {{dict.dictLabel}} + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} @@ -241,11 +241,11 @@ {{dict.dictLabel}} + >{{dict.label}} #elseif($column.htmlType == "radio" && $dictType) @@ -317,6 +317,9 @@ import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${Busin export default { name: "${BusinessName}", +#if(${dicts} != '') + dicts: [${dicts}], +#end data() { return { // 遮罩层 @@ -348,16 +351,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}: [], @@ -397,13 +391,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 b0484bc1..4c196c48 100644 --- a/ruoyi-ui/src/components/DictTag/index.vue +++ b/ruoyi-ui/src/components/DictTag/index.vue @@ -1,23 +1,23 @@