From efa46b94544c9c244890fdc4277667de65f06e5e Mon Sep 17 00:00:00 2001 From: Fxz <2235602974@qq.com> Date: Wed, 27 Apr 2022 02:24:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:sparkles:=20=E3=80=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=80=91=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=94=AF=E6=8C=81=20uview=20=E9=A3=8E=E6=A0=BC?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/constant/CommonConstants.java | 5 + .../core/constant/enums/StyleTypeEnum.java | 7 +- .../pigx/codegen/entity/GenConfig.java | 2 +- .../pig4cloud/pigx/codegen/util/GenUtils.java | 38 +++++- .../main/resources/template/uview/api.js.vm | 18 +++ .../main/resources/template/uview/form.vue.vm | 86 ++++++++++++ .../resources/template/uview/index.vue.vm | 122 ++++++++++++++++++ .../resources/template/uview/page.json.vm | 17 +++ 8 files changed, 291 insertions(+), 4 deletions(-) create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/uview/api.js.vm create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/uview/form.vue.vm create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/uview/index.vue.vm create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/uview/page.json.vm diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java index 7926ece5a..987337d68 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java @@ -70,6 +70,11 @@ public interface CommonConstants { */ String FRONT_END_PROJECT = "pigx-ui"; + /** + * 移动端工程名 + */ + String UNI_END_PROJECT = "pigx-app"; + /** * 后端工程名 */ diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java index b92180589..90e9f516d 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java @@ -21,7 +21,12 @@ public enum StyleTypeEnum { /** * 前端类型-element 风格 */ - ELEMENT("1", "element 风格"); + ELEMENT("1", "element 风格"), + + /** + * 前端风格-uview 风格 + */ + UVIEW("2", "uview 风格"); /** * 类型 diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/entity/GenConfig.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/entity/GenConfig.java index dd6bf91a9..8091a825f 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/entity/GenConfig.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/entity/GenConfig.java @@ -62,7 +62,7 @@ public class GenConfig { private String comments; /** - * 代码风格 0 - avue 1 - element + * 代码风格 0 - avue 1 - element 2 - uview */ private String style; diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenUtils.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenUtils.java index 804bcbddc..646430727 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenUtils.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenUtils.java @@ -89,6 +89,14 @@ public class GenUtils { private final String AVUE_CRUD_JS_VM = "avue/crud.js.vm"; + private final String UVIEW_API_JS_VM = "uview/api.js.vm"; + + private final String UVIEW_FORM_VUE_VM = "uview/form.vue.vm"; + + private final String UVIEW_INDEX_VUE_VM = "uview/index.vue.vm"; + + private final String UVIEW_PAGE_JSON_VM = "uview/page.json.vm"; + /** * 配置 * @param config @@ -103,15 +111,22 @@ public class GenUtils { templates.add("template/ServiceImpl.java.vm"); templates.add("template/Controller.java.vm"); templates.add("template/menu.sql.vm"); - templates.add("template/avue/api.js.vm"); if (StyleTypeEnum.AVUE.getStyle().equals(config.getStyle())) { templates.add("template/avue/index.vue.vm"); templates.add("template/avue/crud.js.vm"); + templates.add("template/avue/api.js.vm"); } - else { + else if (StyleTypeEnum.ELEMENT.getStyle().equals(config.getStyle())) { templates.add("template/element/index.vue.vm"); templates.add("template/element/form.vue.vm"); + templates.add("template/avue/api.js.vm"); + } + else { + templates.add("template/uview/api.js.vm"); + templates.add("template/uview/form.vue.vm"); + templates.add("template/uview/index.vue.vm"); + templates.add("template/uview/page.json.vm"); } return templates; @@ -406,6 +421,25 @@ public class GenUtils { + className.toLowerCase() + "-form.vue"; } + if (template.contains(UVIEW_INDEX_VUE_VM)) { + return CommonConstants.UNI_END_PROJECT + File.separator + "pages" + File.separator + moduleName + + File.separator + className.toLowerCase() + File.separator + className.toLowerCase() + + "-index.vue"; + } + + if (template.contains(UVIEW_FORM_VUE_VM)) { + return CommonConstants.UNI_END_PROJECT + File.separator + "pages" + File.separator + moduleName + + File.separator + className.toLowerCase() + File.separator + className.toLowerCase() + "-form.vue"; + } + + if (template.contains(UVIEW_API_JS_VM)) { + return CommonConstants.UNI_END_PROJECT + File.separator + "common" + File.separator + "http.api.js"; + } + + if (template.contains(UVIEW_PAGE_JSON_VM)) { + return "page.json"; + } + return null; } diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/uview/api.js.vm b/pigx-visual/pigx-codegen/src/main/resources/template/uview/api.js.vm new file mode 100644 index 000000000..16798df41 --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/uview/api.js.vm @@ -0,0 +1,18 @@ +// 以下内容请复制到http.api.js中 +pigx${className}: { + // 分页 + #[[fetchList: (params={}) => vm.$u.get]]#('/${moduleName}/${pathName}/page',params), + + // 新增 + #[[addObj: (obj={}) => vm.$u.post]]#('/${moduleName}/${pathName}', obj), + + // 修改 + #[[putObj: (obj={}) => vm.$u.put]]#('/${moduleName}/${pathName}',obj), + + // 删除 + #[[delObj: (id) => vm.$u.delete]]#('/${moduleName}/${pathName}/'+id), + + // 查询 + #[[getObj: (id) => vm.$u.get]]#('/${moduleName}/${pathName}/' + id) +} + diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/uview/form.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/uview/form.vue.vm new file mode 100644 index 000000000..116fc394a --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/uview/form.vue.vm @@ -0,0 +1,86 @@ + + + + diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/uview/index.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/uview/index.vue.vm new file mode 100644 index 000000000..4ab6cd599 --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/uview/index.vue.vm @@ -0,0 +1,122 @@ + + + diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/uview/page.json.vm b/pigx-visual/pigx-codegen/src/main/resources/template/uview/page.json.vm new file mode 100644 index 000000000..6ba4471b5 --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/uview/page.json.vm @@ -0,0 +1,17 @@ +// 以下内容请复制到pages.json +"pages": [ + + /**${comments}**/ + { + "path": "pages/${moduleName}/${pathName}/${pathName}+'-index.vue'", + "style": { + "navigationBarTitleText": "${comments}" + } + }, + { + "path": "pages/${moduleName}/${pathName}/${pathName}+'-form.vue'", + "style": { + "navigationBarTitleText": "${comments}详情" + } + } +} \ No newline at end of file From 459a2e910988b735d9479f89e170749ca3cc3844 Mon Sep 17 00:00:00 2001 From: Fxz <2235602974@qq.com> Date: Wed, 27 Apr 2022 02:35:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:sparkles:=20=E3=80=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=80=91=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=94=AF=E6=8C=81=20uview=20=E9=A3=8E=E6=A0=BC?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/db/2pigxx.sql b/db/2pigxx.sql index 64ff058cf..bd394b44c 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -249,12 +249,13 @@ INSERT INTO `sys_dict_item` VALUES (54, 17, 'refresh_token', '刷新模式', 'gr INSERT INTO `sys_dict_item` VALUES (55, 17, 'implicit', '简化模式', 'grant_types', 'oauth2 简化模式', 4, ' ', ' ', '2019-08-13 07:39:32', '2019-08-13 07:39:32', NULL, '0', 1); INSERT INTO `sys_dict_item` VALUES (56, 18, '0', 'Avue', 'style_type', 'Avue风格', 0, ' ', ' ', '2020-02-07 03:52:52', '2020-02-07 03:52:52', '', '0', 1); INSERT INTO `sys_dict_item` VALUES (57, 18, '1', 'element', 'style_type', 'element-ui', 1, ' ', ' ', '2020-02-07 03:53:12', '2020-02-07 03:53:12', '', '0', 1); -INSERT INTO `sys_dict_item` VALUES (58, 19, '0', '关', 'captcha_flag_types', '不校验验证码', 0, ' ', ' ', '2020-11-18 06:53:58', '2020-11-18 06:53:58', '不校验验证码 -0', '0', 1); -INSERT INTO `sys_dict_item` VALUES (59, 19, '1', '开', 'captcha_flag_types', '校验验证码', 1, ' ', ' ', '2020-11-18 06:54:15', '2020-11-18 06:54:15', '不校验验证码-1', '0', 1); -INSERT INTO `sys_dict_item` VALUES (60, 20, '0', '否', 'enc_flag_types', '不加密', 0, ' ', ' ', '2020-11-18 06:55:31', '2020-11-18 06:55:31', '不加密-0', '0', 1); -INSERT INTO `sys_dict_item` VALUES (61, 20, '1', '是', 'enc_flag_types', '加密', 1, ' ', ' ', '2020-11-18 06:55:51', '2020-11-18 06:55:51', '加密-1', '0', 1); -INSERT INTO `sys_dict_item` VALUES (62, 15, 'MERGE_PAY', '聚合支付', 'channel_id', '聚合支付', 1, ' ', ' ', '2019-05-30 19:08:08', '2019-06-18 13:51:53', '聚合支付', '0', 1); -INSERT INTO `sys_dict_item` VALUES (63, 2, 'CAS', 'CAS登录', 'social_type', 'CAS 单点登录系统', 3, ' ', ' ', '2022-02-18 13:56:25', '2022-02-18 13:56:28', NULL, '0', 0); +INSERT INTO `sys_dict_item` VALUES (58, 18, '2', 'uview', 'style_type', 'uview风格', 1, ' ', ' ', '2020-02-07 03:53:12', '2020-02-07 03:53:12', '', '0', 1); +INSERT INTO `sys_dict_item` VALUES (59, 19, '0', '关', 'captcha_flag_types', '不校验验证码', 0, ' ', ' ', '2020-11-18 06:53:58', '2020-11-18 06:53:58', '不校验验证码 -0', '0', 1); +INSERT INTO `sys_dict_item` VALUES (60, 19, '1', '开', 'captcha_flag_types', '校验验证码', 1, ' ', ' ', '2020-11-18 06:54:15', '2020-11-18 06:54:15', '不校验验证码-1', '0', 1); +INSERT INTO `sys_dict_item` VALUES (61, 20, '0', '否', 'enc_flag_types', '不加密', 0, ' ', ' ', '2020-11-18 06:55:31', '2020-11-18 06:55:31', '不加密-0', '0', 1); +INSERT INTO `sys_dict_item` VALUES (62, 20, '1', '是', 'enc_flag_types', '加密', 1, ' ', ' ', '2020-11-18 06:55:51', '2020-11-18 06:55:51', '加密-1', '0', 1); +INSERT INTO `sys_dict_item` VALUES (63, 15, 'MERGE_PAY', '聚合支付', 'channel_id', '聚合支付', 1, ' ', ' ', '2019-05-30 19:08:08', '2019-06-18 13:51:53', '聚合支付', '0', 1); +INSERT INTO `sys_dict_item` VALUES (64, 2, 'CAS', 'CAS登录', 'social_type', 'CAS 单点登录系统', 3, ' ', ' ', '2022-02-18 13:56:25', '2022-02-18 13:56:28', NULL, '0', 0); COMMIT; -- ----------------------------