From 0c493bad143fbaf3b93eb9aa210f26cecad34c65 Mon Sep 17 00:00:00 2001 From: liuyes Date: Wed, 20 Nov 2019 08:20:58 +0800 Subject: [PATCH 001/130] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90=E7=A4=BA=E4=BE=8B=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-visual/pigx-dynamic-datasource/README.md | 91 +++++++++ .../pigx-dynamic-datasource-api/pom.xml | 27 +++ .../pigx/dynamic/feign/packge-info.java | 6 + .../pigx-dynamic-datasource-biz/pom.xml | 99 ++++++++++ .../PigxDynamicDatasourceApplication.java | 25 +++ .../dynamic/controller/TestController.java | 96 ++++++++++ .../pigx/dynamic/mapper/TestMapper.java | 50 +++++ .../com/pig4cloud/pigx/dynamic/vo/UserVO.java | 10 + .../src/main/resources/bootstrap.yml | 16 ++ .../src/main/resources/logback-spring.xml | 70 +++++++ .../src/main/resources/mapper/TestMapper.xml | 13 ++ pigx-visual/pigx-dynamic-datasource/pom.xml | 179 ++++++++++++++++++ pigx-visual/pom.xml | 1 + 13 files changed, 683 insertions(+) create mode 100644 pigx-visual/pigx-dynamic-datasource/README.md create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml create mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml create mode 100644 pigx-visual/pigx-dynamic-datasource/pom.xml diff --git a/pigx-visual/pigx-dynamic-datasource/README.md b/pigx-visual/pigx-dynamic-datasource/README.md new file mode 100644 index 000000000..79907b1b0 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/README.md @@ -0,0 +1,91 @@ +## 快速入门 +### 创建测试数据库 +``` +create database `test1` default character set utf8mb4 collate utf8mb4_general_ci; +create database `test2` default character set utf8mb4 collate utf8mb4_general_ci; +create database `test3` default character set utf8mb4 collate utf8mb4_general_ci; +``` +### 创建测试表 +``` + CREATE TABLE `user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `username` varchar(255) DEFAULT NULL COMMENT '用户名', + `password` varchar(255) DEFAULT NULL COMMENT '密码', + PRIMARY KEY (`id`) USING BTREE + ) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COMMENT='用户测试表'; +``` +### 插入测试数据 +``` +use test1; +BEGIN; +INSERT INTO `user` VALUES (1, 'test1测试一', '123'); +INSERT INTO `user` VALUES (2, 'test1测试二', '123'); +INSERT INTO `user` VALUES (3, 'test1测试三', '123'); +COMMIT; +use test2; +BEGIN; +INSERT INTO `user` VALUES (1, 'test2测试一', '123'); +INSERT INTO `user` VALUES (2, 'test2测试二', '123'); +INSERT INTO `user` VALUES (3, 'test2测试三', '123'); +COMMIT; +use test3; +BEGIN; +INSERT INTO `user` VALUES (1, 'test3测试一', '123'); +INSERT INTO `user` VALUES (2, 'test3测试二', '123'); +INSERT INTO `user` VALUES (3, 'test3测试三', '123'); +COMMIT; +``` +### Nocas新增配置 +``` +## pigx-dynamic-datasource-biz.yml +## spring security 配置 +security: + oauth2: + client: + client-id: ENC(ltJPpR50wT0oIY9kfOe1Iw==) + client-secret: ENC(ltJPpR50wT0oIY9kfOe1Iw==) + scope: server + +# 数据源 +spring: + datasource: + dynamic: + primary: test1 #设置默认的数据源 + druid: + filters: stat + datasource: + test1: + username: ${MYSQL-USER:root} + password: ${MYSQL-USER:root} + url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true + driver-class-name: com.mysql.cj.jdbc.Driver + test2: + username: ${MYSQL-USER:root} + password: ${MYSQL-USER:root} + url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test2?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true + driver-class-name: com.mysql.cj.jdbc.Driver + test3: + username: ${MYSQL-USER:root} + password: ${MYSQL-USER:root} + url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test3?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true + driver-class-name: com.mysql.cj.jdbc.Driver +``` +### 启动以下应用 ++ PigxNacosApplication ++ PigxSentinelApplication ++ PigxAuthApplication ++ PigxAdminApplication ++ PigxGatewayApplication ++ PigxDynamicDatasourceApplication +### Postman看效果 +``` +http://localhost:6060/test/getTest1 +http://localhost:6060/test/getTest2?current=1&size=5 +http://localhost:6060/test/getTest3?current=1&size=5 +``` +![test1数据库](http://i1.fuimg.com/704023/83e168e45242e135.png "test1数据库") +![test2数据库](http://i1.fuimg.com/704023/cf8c42fbc3512c32.png "test2数据库") +![test3数据库](http://i1.fuimg.com/704023/534483515e3f7cd0.png "test3数据库") + +### 联系我 +QQ:55215085 \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml new file mode 100644 index 000000000..d44172a36 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.pig4cloud + pigx-dynamic-datasource + 3.5.0 + + + pigx-dynamic-datasource-api + + + + + com.pig4cloud + pigx-common-core + + + + com.baomidou + mybatis-plus-extension + + + \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java new file mode 100644 index 000000000..b497b9232 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java @@ -0,0 +1,6 @@ +/* + @author pigx archetype + *

+ * feign client 存放目录,注意 @EnablePigxFeignClients 的扫描范围 + */ +package com.pig4cloud.pigx.dynamic.feign; \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml new file mode 100644 index 000000000..481d203cd --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + com.pig4cloud + pigx-dynamic-datasource + 3.5.0 + + + pigx-dynamic-datasource-biz + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.pig4cloud + pigx-common-data + + + com.baomidou + mybatis-plus-boot-starter + + + druid-spring-boot-starter + com.alibaba + 1.1.20 + + + + com.baomidou + dynamic-datasource-spring-boot-starter + 2.5.6 + + + mysql + mysql-connector-java + + + com.pig4cloud + pigx-common-log + + + + com.pig4cloud + pigx-common-security + + + + com.pig4cloud + pigx-common-sentinel + + + + com.pig4cloud + pigx-dynamic-datasource-api + 3.5.0 + + + + com.pig4cloud + pigx-common-swagger + + + + org.springframework.boot + spring-boot-starter-test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java new file mode 100644 index 000000000..e572a2d4e --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java @@ -0,0 +1,25 @@ +package com.pig4cloud.pigx.dynamic; + +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; +import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.cloud.client.SpringCloudApplication; + +/** + * @author pigx archetype + *

+ * 项目启动类 + */ +@EnablePigxSwagger2 +@SpringCloudApplication +@EnablePigxFeignClients +@EnablePigxResourceServer +@EnableAutoConfiguration(exclude={DruidDataSourceAutoConfigure.class}) +public class PigxDynamicDatasourceApplication { + public static void main(String[] args) { + SpringApplication.run(PigxDynamicDatasourceApplication.class, args); + } +} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java new file mode 100644 index 000000000..8f6208e7d --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java @@ -0,0 +1,96 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.dynamic.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import com.pig4cloud.pigx.dynamic.mapper.TestMapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @author liuyes + * @date 2019/11/19 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/test") +@Api(value = "test", tags = "动态多数据源示例模块") +public class TestController { + + private TestMapper testMapper; + + /** + * 获取test1数据库用户信息 + * + * @return 用户信息 + */ + @ApiOperation(value = "查询test1数据库用户信息", notes = "查询test1数据库用户信息") + @SysLog("查询test1数据库用户信息" ) + @PostMapping("/getTest1") + public R getTest1() { + List> list = testMapper.getTest1(); + if (list == null) { + return R.failed(null, "查询失败!"); + } + return R.ok(list,"操作成功!"); + } + + /** + * 获取test2数据库用户信息 + * + * @return 用户信息 + */ + @ApiOperation(value = "查询test2数据库用户信息", notes = "查询test2数据库用户信息") + @SysLog("查询test2数据库用户信息" ) + @PostMapping("/getTest2") + public R getTest2(Page page) { + IPage>> list = testMapper.getTest2(page); + if (list == null) { + return R.failed(null, "查询失败!"); + } + return R.ok(list,"操作成功!"); + } + /** + * 获取test3数据库用户信息 + * + * @return 用户信息 + */ + @ApiOperation(value = "查询test3数据库用户信息", notes = "查询test3数据库用户信息") + @SysLog("查询test3数据库用户信息" ) + @PostMapping("/getTest3") + public R getTest3(Page page) { + IPage>> list = testMapper.getTest3(page); + if (list == null) { + return R.failed(null, "查询失败!"); + } + return R.ok(list,"操作成功!"); + } + +} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java new file mode 100644 index 000000000..4a4bbfa3d --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.dynamic.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** + *

+ * test Mapper 接口 + *

+ * + * @author liuyes + * @date 2019/11/19 + */ +public interface TestMapper { + + @Select("SELECT * FROM user") + @DS("test1") + List> getTest1(); + + @DS("test2") + IPage>> getTest2(Page page); + + @DS("test3") + IPage>> getTest3(Page page); + +} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java new file mode 100644 index 000000000..0950a4b28 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java @@ -0,0 +1,10 @@ +package com.pig4cloud.pigx.dynamic.vo; + +import lombok.Data; + +@Data +public class UserVO { + private Integer id; + private String username; + private String password; +} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..05389d5f5 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml @@ -0,0 +1,16 @@ +server: + port: 6060 + +spring: + application: + name: @artifactId@ + cloud: + nacos: + discovery: + server-addr: ${NACOS-HOST:pigx-register}:${NACOS-PORT:8848} + config: + server-addr: ${spring.cloud.nacos.discovery.server-addr} + file-extension: yml + shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + profiles: + active: dev diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..964ca8735 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + + + + + + + + diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml new file mode 100644 index 000000000..fcbe041f9 --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/pigx-visual/pigx-dynamic-datasource/pom.xml b/pigx-visual/pigx-dynamic-datasource/pom.xml new file mode 100644 index 000000000..bbb59f65c --- /dev/null +++ b/pigx-visual/pigx-dynamic-datasource/pom.xml @@ -0,0 +1,179 @@ + + + + pigx-visual + com.pig4cloud + 3.5.0 + + + 4.0.0 + + pigx-dynamic-datasource + pom + pigx-dynamic-datasource + + + 2.1.10.RELEASE + Greenwich.SR3 + 2.1.0.RELEASE + Cairo-SR8 + UTF-8 + 1.8 + 1.8 + 5.0.5 + 3.5.0 + 0.0.9 + 2.1.1 + 2.10.2 + 2.1.6 + 2.3.6.RELEASE + + + + + pigx-dynamic-datasource-api + pigx-dynamic-datasource-biz + + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + ${jasypt.version} + + + + org.springframework.boot + spring-boot-starter-actuator + + + + de.codecentric + spring-boot-admin-starter-client + ${spring-boot-admin.version} + + + + org.projectlombok + lombok + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + io.spring.platform + platform-bom + ${spring-platform.version} + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + com.pig4cloud + pigx-common-bom + ${pigx.bom.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + + + + org.springframework.security.oauth + spring-security-oauth2 + ${security.oauth.version} + + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + + + ${project.name} + + + src/main/resources + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + + + maven-compiler-plugin + 3.8.0 + + ${maven.compiler.target} + ${maven.compiler.source} + UTF-8 + true + + + + pl.project13.maven + git-commit-id-plugin + 2.2.5 + + + + diff --git a/pigx-visual/pom.xml b/pigx-visual/pom.xml index 20bcf2785..af477a99e 100644 --- a/pigx-visual/pom.xml +++ b/pigx-visual/pom.xml @@ -42,5 +42,6 @@ pigx-sso-client-demo pigx-sentinel-dashboard pigx-tx-manager + pigx-dynamic-datasource From 475b0b1c8f1bb90c7cc94d58e8e2e478026971ff Mon Sep 17 00:00:00 2001 From: liuyes Date: Wed, 20 Nov 2019 08:29:09 +0800 Subject: [PATCH 002/130] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-visual/pigx-dynamic-datasource/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pigx-visual/pigx-dynamic-datasource/README.md b/pigx-visual/pigx-dynamic-datasource/README.md index 79907b1b0..4ac44ffb0 100644 --- a/pigx-visual/pigx-dynamic-datasource/README.md +++ b/pigx-visual/pigx-dynamic-datasource/README.md @@ -86,6 +86,9 @@ http://localhost:6060/test/getTest3?current=1&size=5 ![test1数据库](http://i1.fuimg.com/704023/83e168e45242e135.png "test1数据库") ![test2数据库](http://i1.fuimg.com/704023/cf8c42fbc3512c32.png "test2数据库") ![test3数据库](http://i1.fuimg.com/704023/534483515e3f7cd0.png "test3数据库") - +### 切换数据源 +``` +请参考:com/pig4cloud/pigx/dynamic/mapper/TestMapper.java +``` ### 联系我 QQ:55215085 \ No newline at end of file From 882b1c8a64c2492959894cd00c1067e033815d26 Mon Sep 17 00:00:00 2001 From: liuyes Date: Fri, 20 Dec 2019 20:44:03 +0800 Subject: [PATCH 003/130] =?UTF-8?q?=E5=A2=9E=E5=8A=A0pigx-code=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E4=BD=BF=E7=94=A8dynamic-datasource=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-visual/pigx-code/Dockerfile | 15 + pigx-visual/pigx-code/pom.xml | 107 ++++++ .../pigx/code/PigxCodeApplication.java | 44 +++ .../JdbcDynamicDataSourceProperties.java | 21 ++ .../config/JdbcDynamicDataSourceProvider.java | 47 +++ .../code/controller/GenDsConfController.java | 141 ++++++++ .../controller/GenFormConfController.java | 127 +++++++ .../code/controller/GeneratorController.java | 74 +++++ .../pigx/code/entity/ColumnEntity.java | 70 ++++ .../pig4cloud/pigx/code/entity/GenConfig.java | 59 ++++ .../pigx/code/entity/GenDatasourceConf.java | 79 +++++ .../pigx/code/entity/GenFormConf.java | 79 +++++ .../pigx/code/entity/TableEntity.java | 55 +++ .../code/mapper/GenDatasourceConfMapper.java | 30 ++ .../pigx/code/mapper/GenFormConfMapper.java | 33 ++ .../pigx/code/mapper/GeneratorMapper.java | 59 ++++ .../service/GenDatasourceConfService.java | 44 +++ .../pigx/code/service/GenFormConfService.java | 40 +++ .../pigx/code/service/GeneratorService.java | 48 +++ .../impl/GenDatasourceConfServiceImpl.java | 68 ++++ .../service/impl/GenFormConfServiceImpl.java | 98 ++++++ .../service/impl/GeneratorServiceImpl.java | 106 ++++++ .../pig4cloud/pigx/code/util/GenUtils.java | 312 ++++++++++++++++++ .../src/main/resources/bootstrap.yml | 16 + .../src/main/resources/generator.properties | 37 +++ .../resources/mapper/GenFormConfMapper.xml | 33 ++ .../main/resources/mapper/GeneratorMapper.xml | 23 ++ .../resources/template/Controller.java.vm | 110 ++++++ .../main/resources/template/Entity.java.vm | 56 ++++ .../main/resources/template/Mapper.java.vm | 31 ++ .../src/main/resources/template/Mapper.xml.vm | 35 ++ .../main/resources/template/Service.java.vm | 31 ++ .../resources/template/ServiceImpl.java.vm | 34 ++ .../src/main/resources/template/api.js.vm | 56 ++++ .../src/main/resources/template/crud.js.vm | 17 + .../src/main/resources/template/index.vue.vm | 121 +++++++ .../src/main/resources/template/menu.sql.vm | 16 + pigx-visual/pom.xml | 1 + 38 files changed, 2373 insertions(+) create mode 100644 pigx-visual/pigx-code/Dockerfile create mode 100644 pigx-visual/pigx-code/pom.xml create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java create mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java create mode 100644 pigx-visual/pigx-code/src/main/resources/bootstrap.yml create mode 100644 pigx-visual/pigx-code/src/main/resources/generator.properties create mode 100644 pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml create mode 100644 pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml create mode 100644 pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/Service.java.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/api.js.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/crud.js.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/index.vue.vm create mode 100644 pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm diff --git a/pigx-visual/pigx-code/Dockerfile b/pigx-visual/pigx-code/Dockerfile new file mode 100644 index 000000000..fed99aa53 --- /dev/null +++ b/pigx-visual/pigx-code/Dockerfile @@ -0,0 +1,15 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + +RUN mkdir -p /pigx-code + +WORKDIR /pigx-code + +EXPOSE 5003 + +ADD ./pigx-visual/pigx-code/target/pigx-code.jar ./ + +CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-code.jar diff --git a/pigx-visual/pigx-code/pom.xml b/pigx-visual/pigx-code/pom.xml new file mode 100644 index 000000000..1ffaa6de9 --- /dev/null +++ b/pigx-visual/pigx-code/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + + com.pig4cloud + pigx-visual + 3.5.0 + + + pigx-code + jar + + 多数据源代码生成模块 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.pig4cloud + pigx-common-data + + + + com.baomidou + dynamic-datasource-spring-boot-starter + 2.5.6 + + + + com.baomidou + mybatis-plus-boot-starter + + + mysql + mysql-connector-java + + + + com.alibaba + druid-spring-boot-starter + + + + com.pig4cloud + pigx-common-core + + + + com.pig4cloud + pigx-common-swagger + + + + com.pig4cloud + pigx-common-security + + + + com.pig4cloud + pigx-common-sentinel + + + com.pig4cloud + pigx-common-log + + + + velocity + org.apache.velocity + ${velocity.version} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + com.spotify + docker-maven-plugin + + + + diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java new file mode 100644 index 000000000..18def63af --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code; + +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; +import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.cloud.client.SpringCloudApplication; + +/** + * @author lengleng + * @date 2018/07/29 + * 代码生成模块 + */ +@EnablePigxSwagger2 +@SpringCloudApplication +@EnablePigxFeignClients +@EnablePigxResourceServer +@EnableAutoConfiguration(exclude={DruidDataSourceAutoConfigure.class}) +public class PigxCodeApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxCodeApplication.class, args); + } + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java new file mode 100644 index 000000000..20b157fd6 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java @@ -0,0 +1,21 @@ +package com.pig4cloud.pigx.code.config; + +import lombok.AllArgsConstructor; +import lombok.Data; +import org.jasypt.encryption.StringEncryptor; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties("spring.datasource.dynamic") +public class JdbcDynamicDataSourceProperties { + private final StringEncryptor stringEncryptor; + private String username; + private String password; + private String url; + private String driverClassName; + private String sql; + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java new file mode 100644 index 000000000..198a10ae9 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java @@ -0,0 +1,47 @@ +package com.pig4cloud.pigx.code.config; + +import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider; +import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import lombok.AllArgsConstructor; +import org.jasypt.encryption.StringEncryptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; + +@Configuration +@AllArgsConstructor +public class JdbcDynamicDataSourceProvider { + private final StringEncryptor stringEncryptor; + private final JdbcDynamicDataSourceProperties properties; + + @Bean + public DynamicDataSourceProvider dynamicDataSourceProvider() { + return new AbstractJdbcDataSourceProvider(properties.getDriverClassName(), properties.getUrl(), properties.getUsername(), properties.getPassword()) { + @Override + protected Map executeStmt(Statement statement) throws SQLException { + Map map = new HashMap<>(); + ResultSet rs = statement.executeQuery(properties.getSql()); + while (rs.next()) { + String name = rs.getString("name"); + String username = rs.getString("username"); + String password = rs.getString("password"); + String url = rs.getString("url"); +// String driver = rs.getString("driver"); + DataSourceProperty property = new DataSourceProperty(); + property.setUsername(username); + property.setPassword(stringEncryptor.decrypt(password)); + property.setUrl(url); +// property.setDriverClassName(driver); + map.put(name, property); + } + return map; + } + }; + } +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java new file mode 100644 index 000000000..a43ad053c --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.controller; + +import com.baomidou.dynamic.datasource.DynamicDataSourceCreator; +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.code.entity.GenDatasourceConf; +import com.pig4cloud.pigx.code.service.GenDatasourceConfService; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import lombok.AllArgsConstructor; +import org.jasypt.encryption.StringEncryptor; +import org.springframework.web.bind.annotation.*; + +import javax.sql.DataSource; + + +/** + * 数据源管理 + * + * @author lengleng + * @date 2019-03-31 16:00:20 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/dsconf") +public class GenDsConfController { + private final GenDatasourceConfService datasourceConfService; + private final StringEncryptor stringEncryptor; + private DataSource dataSource; + private DynamicDataSourceCreator dataSourceCreator; + + /** + * 分页查询 + * + * @param page 分页对象 + * @param datasourceConf 数据源表 + * @return + */ + @GetMapping("/page") + public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { + return R.ok(datasourceConfService.page(page, Wrappers.query(datasourceConf))); + } + + /** + * 查询全部数据源 + * + * @return + */ + @GetMapping("/list") + public R list() { + return R.ok(datasourceConfService.list()); + } + + + /** + * 通过id查询数据源表 + * + * @param id id + * @return R + */ + @GetMapping("/{id}") + public R getById(@PathVariable("id") Integer id) { + return R.ok(datasourceConfService.getById(id)); + } + + /** + * 新增数据源表 + * + * @param datasourceConf 数据源表 + * @return R + */ + @SysLog("新增数据源表") + @PostMapping + public R save(@RequestBody GenDatasourceConf datasourceConf) { + DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; + DataSourceProperty dataSourceProperty = new DataSourceProperty(); + dataSourceProperty.setPollName(datasourceConf.getName()); + dataSourceProperty.setUrl(datasourceConf.getUrl()); + dataSourceProperty.setUsername(datasourceConf.getUsername()); + dataSourceProperty.setPassword(datasourceConf.getPassword()); + DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty); + ds.addDataSource(dataSourceProperty.getPollName(), dataSource); + return R.ok(datasourceConfService.saveDsByEnc(datasourceConf)); + } + + /** + * 修改数据源表 + * + * @param sysDatasourceConf 数据源表 + * @return R + */ + @SysLog("修改数据源表") + @PutMapping + public R updateById(@RequestBody GenDatasourceConf sysDatasourceConf) { + DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; + //先移除 + ds.removeDataSource(datasourceConfService.getById(sysDatasourceConf.getId()).getName()); + //再添加 + DataSourceProperty dataSourceProperty = new DataSourceProperty(); + dataSourceProperty.setPollName(sysDatasourceConf.getName()); + dataSourceProperty.setUrl(sysDatasourceConf.getUrl()); + dataSourceProperty.setUsername(sysDatasourceConf.getUsername()); + dataSourceProperty.setPassword(sysDatasourceConf.getPassword()); + DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty); + ds.addDataSource(dataSourceProperty.getPollName(), dataSource); + return R.ok(datasourceConfService.updateDsByEnc(sysDatasourceConf)); + } + + /** + * 通过id删除数据源表 + * + * @param id id + * @return R + */ + @SysLog("删除数据源表") + @DeleteMapping("/{id}") + public R removeById(@PathVariable Integer id) { + DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; + ds.removeDataSource(datasourceConfService.getById(id).getName()); + return R.ok(datasourceConfService.removeById(id)); + } + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java new file mode 100644 index 000000000..a2243bf2b --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.code.entity.GenFormConf; +import com.pig4cloud.pigx.code.service.GenFormConfService; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +/** + * 表单管理 + * + * @author lengleng + * @date 2019-08-12 15:55:35 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/form") +@Api(value = "form", tags = "表单管理") +public class GenFormConfController { + private final GenFormConfService genRecordService; + + /** + * 分页查询 + * + * @param page 分页对象 + * @param formConf 生成记录 + * @return + */ + @ApiOperation(value = "分页查询", notes = "分页查询") + @GetMapping("/page") + public R getGenFormConfPage(Page page, GenFormConf formConf) { + return R.ok(genRecordService.page(page, Wrappers.query(formConf))); + } + + + /** + * 通过id查询生成记录 + * + * @param id id + * @return R + */ + @ApiOperation(value = "通过id查询", notes = "通过id查询") + @GetMapping("/{id}") + public R getById(@PathVariable("id") Integer id) { + return R.ok(genRecordService.getById(id)); + } + + /** + * 通过id查询生成记录 + * + * @param dsId 数据源ID + * @param tableName tableName + * @return R + */ + @ApiOperation(value = "通过tableName查询表单信息") + @GetMapping("/info") + public R form(Integer dsId, String tableName) { + return R.ok(genRecordService.getForm(dsId, tableName)); + } + + /** + * 新增生成记录 + * + * @param formConf 生成记录 + * @return R + */ + @ApiOperation(value = "新增生成记录", notes = "新增生成记录") + @SysLog("新增生成记录") + @PostMapping + @PreAuthorize("@pms.hasPermission('gen_form_add')") + public R save(@RequestBody GenFormConf formConf) { + return R.ok(genRecordService.save(formConf)); + } + + /** + * 修改生成记录 + * + * @param formConf 生成记录 + * @return R + */ + @ApiOperation(value = "修改生成记录", notes = "修改生成记录") + @SysLog("修改生成记录") + @PutMapping + @PreAuthorize("@pms.hasPermission('gen_form_edit')") + public R updateById(@RequestBody GenFormConf formConf) { + return R.ok(genRecordService.updateById(formConf)); + } + + /** + * 通过id删除生成记录 + * + * @param id id + * @return R + */ + @ApiOperation(value = "通过id删除生成记录", notes = "通过id删除生成记录") + @SysLog("通过id删除生成记录") + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('gen_form_del')") + public R removeById(@PathVariable Integer id) { + return R.ok(genRecordService.removeById(id)); + } + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java new file mode 100644 index 000000000..be97fa249 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.controller; + +import cn.hutool.core.io.IoUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.code.entity.GenConfig; +import com.pig4cloud.pigx.code.service.GeneratorService; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import org.apache.commons.lang3.StringUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 代码生成器 + * + * @author lengleng + * @date 2018-07-30 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/generator") +public class GeneratorController { + private final GeneratorService generatorService; + + /** + * 列表 + * + * @param tableName 参数集 + * @param id 数据源编号 + * @return 数据库表 + */ + @GetMapping("/page") + public R getPage(Page page, String tableName, String name, HttpServletRequest request) { + name = StringUtils.isEmpty(name) ? "master" : name; + request.getSession().setAttribute("dataSourceName", name); + return R.ok(generatorService.getPage(page, tableName)); + } + + /** + * 生成代码 + */ + @SneakyThrows + @PostMapping("/code") + public void generatorCode(@RequestBody GenConfig genConfig, HttpServletResponse response) { + byte[] data = generatorService.generatorCode(genConfig); + response.reset(); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", genConfig.getTableName())); + response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); + response.setContentType("application/octet-stream; charset=UTF-8"); + + IoUtil.write(response.getOutputStream(), Boolean.TRUE, data); + } +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java new file mode 100644 index 000000000..92b0854a5 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.entity; + +import lombok.Data; + +/** + * @author lengleng + * @date 2018/07/29 + * 列属性: https://blog.csdn.net/lkforce/article/details/79557482 + */ +@Data +public class ColumnEntity { + /** + * 列表 + */ + private String columnName; + /** + * 数据类型 + */ + private String dataType; + /** + * 备注 + */ + private String comments; + + /** + * 驼峰属性 + */ + private String caseAttrName; + /** + * 普通属性 + */ + private String lowerAttrName; + /** + * 属性类型 + */ + private String attrType; + /** + * 其他信息 + */ + private String extra; + /** + * 字段类型 + */ + private String columnType; + /** + * 是否可以为空 + */ + private Boolean nullable; + /** + * 是否隐藏 + */ + private Boolean hidden; +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java new file mode 100644 index 000000000..c23aa006c --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.entity; + +import lombok.Data; + +/** + * @author lengleng + * @date 2018/8/2 + * 生成配置 + */ +@Data +public class GenConfig { + /** + * 数据源ID + */ + private Integer id; + /** + * 包名 + */ + private String packageName; + /** + * 作者 + */ + private String author; + /** + * 模块名称 + */ + private String moduleName; + /** + * 表前缀 + */ + private String tablePrefix; + + /** + * 表名称 + */ + private String tableName; + + /** + * 表备注 + */ + private String comments; +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java new file mode 100644 index 000000000..d2965821f --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 数据源表 + * + * @author lengleng + * @date 2019-03-31 16:00:20 + */ +@Data +@TableName("gen_datasource_conf") +@EqualsAndHashCode(callSuper = true) +public class GenDatasourceConf extends Model { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId + private Integer id; + /** + * 名称 + */ + private String name; + /** + * jdbcurl + */ + private String url; + /** + * 用户名 + */ + private String username; + /** + * 密码 + */ + private String password; + /** + * 创建时间 + */ + private LocalDateTime createDate; + /** + * 更新 + */ + private LocalDateTime updateDate; + /** + * 删除标记 + */ + @TableLogic + private String delFlag; + /** + * 租户ID + */ + private Integer tenantId; + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java new file mode 100644 index 000000000..4c6ae7d56 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 生成记录 + * + * @author lengleng + * @date 2019-08-12 15:55:35 + */ +@Data +@TableName("gen_form_conf") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "生成记录") +public class GenFormConf extends Model { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId + @ApiModelProperty(value = "ID") + private Integer id; + /** + * 表名称 + */ + @ApiModelProperty(value = "表名称") + private String tableName; + /** + * 表单信息 + */ + @ApiModelProperty(value = "表单信息") + private String formInfo; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + /** + * 修改时间 + */ + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + /** + * 删除标记 + */ + @ApiModelProperty(value = "删除标记") + private String delFlag; + /** + * 所属租户 + */ + @ApiModelProperty(value = "所属租户", hidden = true) + private Integer tenantId; +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java new file mode 100644 index 000000000..4f0cf207c --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @author lengleng + * @date 2018/07/29 + * 表属性: https://blog.csdn.net/lkforce/article/details/79557482 + */ +@Data +public class TableEntity { + /** + * 名称 + */ + private String tableName; + /** + * 备注 + */ + private String comments; + /** + * 主键 + */ + private ColumnEntity pk; + /** + * 列名 + */ + private List columns; + /** + * 驼峰类型 + */ + private String caseClassName; + /** + * 普通类型 + */ + private String lowerClassName; +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java new file mode 100644 index 000000000..c761e1cbc --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pigx.code.entity.GenDatasourceConf; + +/** + * 数据源表 + * + * @author lengleng + * @date 2019-03-31 16:00:20 + */ +public interface GenDatasourceConfMapper extends BaseMapper { + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java new file mode 100644 index 000000000..145faf1a1 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pigx.code.entity.GenFormConf; + +/** + * 生成记录 + * + * @author lengleng + * @date 2019-08-12 15:55:35 + */ +@DS("master") +public interface GenFormConfMapper extends BaseMapper { + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java new file mode 100644 index 000000000..975b08d16 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 代码生成器 + * + * @author lengleng + * @date 2018-07-30 + */ +public interface GeneratorMapper { + + /** + * 分页查询表格 + * + * @param page + * @param tableName + * @return + */ + IPage>> queryList(Page page, @Param("tableName") String tableName); + + /** + * 查询表信息 + * + * @param tableName 表名称 + * @return + */ + Map queryTable(String tableName); + + /** + * 查询表列信息 + * + * @param tableName 表名称 + * @return + */ + List> queryColumns(String tableName); +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java new file mode 100644 index 000000000..c441b5cec --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pigx.code.entity.GenDatasourceConf; + +/** + * 数据源表 + * + * @author lengleng + * @date 2019-03-31 16:00:20 + */ +public interface GenDatasourceConfService extends IService { + /** + * 保存数据源并且加密 + * + * @param genDatasourceConf + * @return + */ + Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf); + + /** + * 更新数据源 + * + * @param genDatasourceConf + * @return + */ + Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf); +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java new file mode 100644 index 000000000..c6468db33 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pigx.code.entity.GenFormConf; + +/** + * 表单管理 + * + * @author lengleng + * @date 2019-08-12 15:55:35 + */ +public interface GenFormConfService extends IService { + + /** + * 获取表单信息 + * + * @param dsId 数据源ID + * @param tableName 表名称 + * @return + */ + String getForm(Integer dsId, String tableName); + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java new file mode 100644 index 000000000..5186eb6cc --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.code.entity.GenConfig; + +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2018/7/29 + */ +public interface GeneratorService { + /** + * 生成代码 + * + * @param tableNames 表名称 + * @return + */ + byte[] generatorCode(GenConfig tableNames); + + /** + * 分页查询表 + * + * @param page 分页信息 + * @param tableName 表名 + * @return + */ + IPage>> getPage(Page page, String tableName); +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java new file mode 100644 index 000000000..49b6deea1 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pigx.code.entity.GenDatasourceConf; +import com.pig4cloud.pigx.code.mapper.GenDatasourceConfMapper; +import com.pig4cloud.pigx.code.service.GenDatasourceConfService; +import lombok.AllArgsConstructor; +import org.jasypt.encryption.StringEncryptor; +import org.springframework.stereotype.Service; + +/** + * 数据源表 + * + * @author lengleng + * @date 2019-03-31 16:00:20 + */ +@Service +@AllArgsConstructor +public class GenDatasourceConfServiceImpl extends ServiceImpl implements GenDatasourceConfService { + private final StringEncryptor stringEncryptor; + + /** + * 保存数据源并且加密 + * + * @param genDatasourceConf + * @return + */ + @Override + public Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf) { + genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); + this.baseMapper.insert(genDatasourceConf); + return true; +// return dynamicDataSourceConfig.reload(); + } + + /** + * 更新数据源 + * + * @param genDatasourceConf + * @return + */ + @Override + public Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf) { + if (StrUtil.isNotBlank(genDatasourceConf.getPassword())) { + genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); + } + this.baseMapper.updateById(genDatasourceConf); + return true; +// return dynamicDataSourceConfig.reload(); + } +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java new file mode 100644 index 000000000..7c033efd3 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.code.service.impl; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pigx.code.entity.ColumnEntity; +import com.pig4cloud.pigx.code.entity.GenFormConf; +import com.pig4cloud.pigx.code.mapper.GenFormConfMapper; +import com.pig4cloud.pigx.code.mapper.GeneratorMapper; +import com.pig4cloud.pigx.code.service.GenFormConfService; +import com.pig4cloud.pigx.code.util.GenUtils; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import org.apache.commons.lang.StringUtils; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; +import org.springframework.stereotype.Service; + +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * 表单管理 + * + * @author lengleng + * @date 2019-08-12 15:55:35 + */ +@Service +@AllArgsConstructor +public class GenFormConfServiceImpl extends ServiceImpl implements GenFormConfService { + private final GeneratorMapper generatorMapper; + + /** + * 1. 根据数据源、表名称,查询已配置表单信息 + * 2. 不存在调用模板生成 + * + * @param dsId 数据源ID + * @param tableName 表名称 + * @return + */ + @DS("pigxx") + @Override + @SneakyThrows + public String getForm(Integer dsId, String tableName) { + GenFormConf form = getOne(Wrappers.lambdaQuery() + .eq(GenFormConf::getTableName, tableName) + .orderByDesc(GenFormConf::getCreateTime), false); + + if (form != null) { + return form.getFormInfo(); + } + +// DynamicDataSourceContextHolder.setDataSourceType(dsId); + List> columns = generatorMapper.queryColumns(tableName); + //设置velocity资源加载器 + Properties prop = new Properties(); + prop.put("file.resource.loader.class", ClasspathResourceLoader.class.getName()); + Velocity.init(prop); + Template template = Velocity.getTemplate("template/crud.js.vm", CharsetUtil.UTF_8); + VelocityContext context = new VelocityContext(); + + List columnList = new ArrayList<>(); + for (Map column : columns) { + ColumnEntity columnEntity = new ColumnEntity(); + columnEntity.setComments(column.get("columnComment")); + columnEntity.setLowerAttrName(StringUtils.uncapitalize(GenUtils.columnToJava(column.get("columnName")))); + columnList.add(columnEntity); + } + context.put("columns", columnList); + StringWriter writer = new StringWriter(); + template.merge(context, writer); + return StrUtil.trim(StrUtil.removePrefix(writer.toString(), GenUtils.CRUD_PREFIX)); + } + +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java new file mode 100644 index 000000000..72e94731f --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.code.entity.GenConfig; +import com.pig4cloud.pigx.code.entity.GenFormConf; +import com.pig4cloud.pigx.code.mapper.GenFormConfMapper; +import com.pig4cloud.pigx.code.mapper.GeneratorMapper; +import com.pig4cloud.pigx.code.service.GeneratorService; +import com.pig4cloud.pigx.code.util.GenUtils; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayOutputStream; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipOutputStream; + +/** + * @author lengleng + * @date 2018-07-30 + *

+ * 代码生成器 + */ +@Service +@AllArgsConstructor +public class GeneratorServiceImpl implements GeneratorService { + private final GeneratorMapper generatorMapper; + private final GenFormConfMapper genFormConfMapper; + + /** + * 分页查询表 + * + * @param tableName 查询条件 + * @return + */ + @DS("#session.dataSourceName") + @Override + public IPage>> getPage(Page page, String tableName) { + return generatorMapper.queryList(page, tableName); + } + + /** + * 生成代码 + * + * @param genConfig 生成配置 + * @return + */ + @DS("#session.dataSourceName") + @Override + public byte[] generatorCode(GenConfig genConfig) { + //根据tableName 查询最新的表单配置 + List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery() + .eq(GenFormConf::getTableName, genConfig.getTableName()) + .orderByDesc(GenFormConf::getCreateTime)); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + + String tableNames = genConfig.getTableName(); + for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) { + //查询表信息 + Map table = queryTable(tableName); + //查询列信息 + List> columns = queryColumns(tableName); + //生成代码 + if (CollUtil.isNotEmpty(formConfList)) { + GenUtils.generatorCode(genConfig, table, columns, zip, formConfList.get(0)); + } else { + GenUtils.generatorCode(genConfig, table, columns, zip, null); + } + } + IoUtil.close(zip); + return outputStream.toByteArray(); + } + + private Map queryTable(String tableName) { + return generatorMapper.queryTable(tableName); + } + + private List> queryColumns(String tableName) { + return generatorMapper.queryColumns(tableName); + } +} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java new file mode 100644 index 000000000..8907bdc96 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.code.util; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.code.entity.ColumnEntity; +import com.pig4cloud.pigx.code.entity.GenConfig; +import com.pig4cloud.pigx.code.entity.GenFormConf; +import com.pig4cloud.pigx.code.entity.TableEntity; +import com.pig4cloud.pigx.common.core.constant.CommonConstants; +import com.pig4cloud.pigx.common.core.exception.CheckedException; +import lombok.SneakyThrows; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.WordUtils; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; + +import java.io.File; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * 代码生成器 工具类 + * + * @author lengleng + * @date 2018-07-30 + */ +@Slf4j +@UtilityClass +public class GenUtils { + public final String CRUD_PREFIX = "export const tableOption ="; + private final String ENTITY_JAVA_VM = "Entity.java.vm"; + private final String MAPPER_JAVA_VM = "Mapper.java.vm"; + private final String SERVICE_JAVA_VM = "Service.java.vm"; + private final String SERVICE_IMPL_JAVA_VM = "ServiceImpl.java.vm"; + private final String CONTROLLER_JAVA_VM = "Controller.java.vm"; + private final String MAPPER_XML_VM = "Mapper.xml.vm"; + private final String MENU_SQL_VM = "menu.sql.vm"; + private final String INDEX_VUE_VM = "index.vue.vm"; + private final String API_JS_VM = "api.js.vm"; + private final String CRUD_JS_VM = "crud.js.vm"; + + private List getTemplates() { + List templates = new ArrayList<>(); + templates.add("template/Entity.java.vm"); + templates.add("template/Mapper.java.vm"); + templates.add("template/Mapper.xml.vm"); + templates.add("template/Service.java.vm"); + templates.add("template/ServiceImpl.java.vm"); + templates.add("template/Controller.java.vm"); + templates.add("template/menu.sql.vm"); + + templates.add("template/index.vue.vm"); + templates.add("template/api.js.vm"); + templates.add("template/crud.js.vm"); + return templates; + } + + /** + * 生成代码 + */ + @SneakyThrows + public void generatorCode(GenConfig genConfig, Map table, + List> columns, ZipOutputStream zip, GenFormConf formConf) { + //配置信息 + Configuration config = getConfig(); + boolean hasBigDecimal = false; + //表信息 + TableEntity tableEntity = new TableEntity(); + tableEntity.setTableName(table.get("tableName")); + + if (StrUtil.isNotBlank(genConfig.getComments())) { + tableEntity.setComments(genConfig.getComments()); + } else { + tableEntity.setComments(table.get("tableComment")); + } + + String tablePrefix; + if (StrUtil.isNotBlank(genConfig.getTablePrefix())) { + tablePrefix = genConfig.getTablePrefix(); + } else { + tablePrefix = config.getString("tablePrefix"); + } + + //表名转换成Java类名 + String className = tableToJava(tableEntity.getTableName(), tablePrefix); + tableEntity.setCaseClassName(className); + tableEntity.setLowerClassName(StringUtils.uncapitalize(className)); + //获取需要在swagger文档中隐藏的属性字段 + List hiddenColumns = config.getList("hiddenColumn"); + //列信息 + List columnList = new ArrayList<>(); + for (Map column : columns) { + ColumnEntity columnEntity = new ColumnEntity(); + columnEntity.setColumnName(column.get("columnName")); + columnEntity.setDataType(column.get("dataType")); + columnEntity.setComments(column.get("columnComment")); + columnEntity.setExtra(column.get("extra")); + columnEntity.setNullable("NO".equals(column.get("isNullable"))); + columnEntity.setColumnType(column.get("columnType")); + //隐藏不需要的在接口文档中展示的字段 + if (hiddenColumns.contains(column.get("columnName"))) { + columnEntity.setHidden(Boolean.TRUE); + } else { + columnEntity.setHidden(Boolean.FALSE); + } + //列名转换成Java属性名 + String attrName = columnToJava(columnEntity.getColumnName()); + columnEntity.setCaseAttrName(attrName); + columnEntity.setLowerAttrName(StringUtils.uncapitalize(attrName)); + + //列的数据类型,转换成Java类型 + String attrType = config.getString(columnEntity.getDataType(), "unknowType"); + columnEntity.setAttrType(attrType); + if (!hasBigDecimal && "BigDecimal".equals(attrType)) { + hasBigDecimal = true; + } + //是否主键 + if ("PRI".equalsIgnoreCase(column.get("columnKey")) && tableEntity.getPk() == null) { + tableEntity.setPk(columnEntity); + } + + columnList.add(columnEntity); + } + tableEntity.setColumns(columnList); + + //没主键,则第一个字段为主键 + if (tableEntity.getPk() == null) { + tableEntity.setPk(tableEntity.getColumns().get(0)); + } + + //设置velocity资源加载器 + Properties prop = new Properties(); + prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + Velocity.init(prop); + //封装模板数据 + Map map = new HashMap<>(16); + map.put("tableName", tableEntity.getTableName()); + map.put("pk", tableEntity.getPk()); + map.put("className", tableEntity.getCaseClassName()); + map.put("classname", tableEntity.getLowerClassName()); + map.put("pathName", tableEntity.getLowerClassName().toLowerCase()); + map.put("columns", tableEntity.getColumns()); + map.put("hasBigDecimal", hasBigDecimal); + map.put("datetime", DateUtil.now()); + + if (StrUtil.isNotBlank(genConfig.getComments())) { + map.put("comments", genConfig.getComments()); + } else { + map.put("comments", tableEntity.getComments()); + } + + if (StrUtil.isNotBlank(genConfig.getAuthor())) { + map.put("author", genConfig.getAuthor()); + } else { + map.put("author", config.getString("author")); + } + + if (StrUtil.isNotBlank(genConfig.getModuleName())) { + map.put("moduleName", genConfig.getModuleName()); + } else { + map.put("moduleName", config.getString("moduleName")); + } + + if (StrUtil.isNotBlank(genConfig.getPackageName())) { + map.put("package", genConfig.getPackageName()); + map.put("mainPath", genConfig.getPackageName()); + } else { + map.put("package", config.getString("package")); + map.put("mainPath", config.getString("mainPath")); + } + VelocityContext context = new VelocityContext(map); + + //获取模板列表 + List templates = getTemplates(); + for (String template : templates) { + // 如果是crud + if (template.contains(CRUD_JS_VM) && formConf != null) { + zip.putNextEntry(new ZipEntry(Objects + .requireNonNull(getFileName(template, tableEntity.getCaseClassName() + , map.get("package").toString(), map.get("moduleName").toString())))); + IoUtil.write(zip, StandardCharsets.UTF_8, false, CRUD_PREFIX + formConf.getFormInfo()); + zip.closeEntry(); + continue; + } + + + //渲染模板 + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, CharsetUtil.UTF_8); + tpl.merge(context, sw); + + //添加到zip + zip.putNextEntry(new ZipEntry(Objects + .requireNonNull(getFileName(template, tableEntity.getCaseClassName() + , map.get("package").toString(), map.get("moduleName").toString())))); + IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); + IoUtil.close(sw); + zip.closeEntry(); + } + } + + + /** + * 列名转换成Java属性名 + */ + public String columnToJava(String columnName) { + return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", ""); + } + + /** + * 表名转换成Java类名 + */ + private String tableToJava(String tableName, String tablePrefix) { + if (StringUtils.isNotBlank(tablePrefix)) { + tableName = tableName.replaceFirst(tablePrefix, ""); + } + return columnToJava(tableName); + } + + /** + * 获取配置信息 + */ + private Configuration getConfig() { + try { + return new PropertiesConfiguration("generator.properties"); + } catch (ConfigurationException e) { + throw new CheckedException("获取配置文件失败,", e); + } + } + + /** + * 获取文件名 + */ + private String getFileName(String template, String className, String packageName, String moduleName) { + String packagePath = CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator; + if (StringUtils.isNotBlank(packageName)) { + packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; + } + + if (template.contains(ENTITY_JAVA_VM)) { + return packagePath + "entity" + File.separator + className + ".java"; + } + + if (template.contains(MAPPER_JAVA_VM)) { + return packagePath + "mapper" + File.separator + className + "Mapper.java"; + } + + if (template.contains(SERVICE_JAVA_VM)) { + return packagePath + "service" + File.separator + className + "Service.java"; + } + + if (template.contains(SERVICE_IMPL_JAVA_VM)) { + return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java"; + } + + if (template.contains(CONTROLLER_JAVA_VM)) { + return packagePath + "controller" + File.separator + className + "Controller.java"; + } + + if (template.contains(MAPPER_XML_VM)) { + return CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml"; + } + + if (template.contains(MENU_SQL_VM)) { + return className.toLowerCase() + "_menu.sql"; + } + + if (template.contains(INDEX_VUE_VM)) { + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + "index.vue"; + } + + if (template.contains(API_JS_VM)) { + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js"; + } + + if (template.contains(CRUD_JS_VM)) { + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" + + File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; + } + + return null; + } +} diff --git a/pigx-visual/pigx-code/src/main/resources/bootstrap.yml b/pigx-visual/pigx-code/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..370893775 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/bootstrap.yml @@ -0,0 +1,16 @@ +server: + port: 5003 + +spring: + application: + name: @artifactId@ + cloud: + nacos: + discovery: + server-addr: ${NACOS-HOST:pigx-register}:${NACOS-PORT:8848} + config: + server-addr: ${spring.cloud.nacos.discovery.server-addr} + file-extension: yml + shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + profiles: + active: @profiles.active@ \ No newline at end of file diff --git a/pigx-visual/pigx-code/src/main/resources/generator.properties b/pigx-visual/pigx-code/src/main/resources/generator.properties new file mode 100644 index 000000000..dfe6d305a --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/generator.properties @@ -0,0 +1,37 @@ +#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F + +mainPath=com.pig4cloud.pigx +#\u5305\u540D +package=com.pig4cloud.pigx +moduleName=generator +#\u4F5C\u8005 +author=pigx code generator + +#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) +tablePrefix=tb_ + +#\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F +tinyint=Integer +smallint=Integer +mediumint=Integer +int=Integer +integer=Integer +bigint=Long +float=Float +double=Double +decimal=BigDecimal +bit=Boolean + +char=String +varchar=String +tinytext=String +text=String +mediumtext=String +longtext=String + +date=LocalDateTime +datetime=LocalDateTime +timestamp=LocalDateTime + +# hidden columns in Swagger Models +hiddenColumn=tenant_id diff --git a/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml b/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml new file mode 100644 index 000000000..22270ac54 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + diff --git a/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml b/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml new file mode 100644 index 000000000..7ef05fc4d --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + diff --git a/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm new file mode 100644 index 000000000..9eb5102e8 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package ${package}.${moduleName}.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import ${package}.${moduleName}.entity.${className}; +import ${package}.${moduleName}.service.${className}Service; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + + +/** + * ${comments} + * + * @author ${author} + * @date ${datetime} + */ +@RestController +@AllArgsConstructor +@RequestMapping("/${pathName}" ) +@Api(value = "${pathName}", tags = "${comments}管理") +public class ${className}Controller { + + private final ${className}Service ${classname}Service; + + /** + * 分页查询 + * @param page 分页对象 + * @param ${classname} ${comments} + * @return + */ + @ApiOperation(value = "分页查询", notes = "分页查询") + @GetMapping("/page" ) + public R get${className}Page(Page page, ${className} ${classname}) { + return R.ok(${classname}Service.page(page, Wrappers.query(${classname}))); + } + + + /** + * 通过id查询${comments} + * @param ${pk.lowerAttrName} id + * @return R + */ + @ApiOperation(value = "通过id查询", notes = "通过id查询") + @GetMapping("/{${pk.lowerAttrName}}" ) + public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) { + return R.ok(${classname}Service.getById(${pk.lowerAttrName})); + } + + /** + * 新增${comments} + * @param ${classname} ${comments} + * @return R + */ + @ApiOperation(value = "新增${comments}", notes = "新增${comments}") + @SysLog("新增${comments}" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" ) + public R save(@RequestBody ${className} ${classname}) { + return R.ok(${classname}Service.save(${classname})); + } + + /** + * 修改${comments} + * @param ${classname} ${comments} + * @return R + */ + @ApiOperation(value = "修改${comments}", notes = "修改${comments}") + @SysLog("修改${comments}" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" ) + public R updateById(@RequestBody ${className} ${classname}) { + return R.ok(${classname}Service.updateById(${classname})); + } + + /** + * 通过id删除${comments} + * @param ${pk.lowerAttrName} id + * @return R + */ + @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}") + @SysLog("通过id删除${comments}" ) + @DeleteMapping("/{${pk.lowerAttrName}}" ) + @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" ) + public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) { + return R.ok(${classname}Service.removeById(${pk.lowerAttrName})); + } + +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm new file mode 100644 index 000000000..eb9a71379 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package ${package}.${moduleName}.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +#if(${hasBigDecimal}) +import java.math.BigDecimal; +#end +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * ${comments} + * + * @author ${author} + * @date ${datetime} + */ +@Data +@TableName("${tableName}") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "${comments}") +public class ${className} extends Model<${className}> { +private static final long serialVersionUID = 1L; + + #foreach ($column in $columns) +/** + * $column.comments + */ + #if($column.columnName == $pk.columnName) +@TableId + #end +@ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end) + private $column.attrType $column.lowerAttrName; + #end +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm new file mode 100644 index 000000000..867859b51 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package ${package}.${moduleName}.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import ${package}.${moduleName}.entity.${className}; + +/** + * ${comments} + * + * @author ${author} + * @date ${datetime} + */ +public interface ${className}Mapper extends BaseMapper<${className}> { + +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm b/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm new file mode 100644 index 000000000..864e3d9ea --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm @@ -0,0 +1,35 @@ + + + + + + + + + + #foreach($column in $columns) + #if($column.lowerAttrName==$pk.lowerAttrName) + + #else + + #end + #end + + diff --git a/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm new file mode 100644 index 000000000..5d808ef57 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package ${package}.${moduleName}.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import ${package}.${moduleName}.entity.${className}; + +/** + * ${comments} + * + * @author ${author} + * @date ${datetime} + */ +public interface ${className}Service extends IService<${className}> { + +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm b/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm new file mode 100644 index 000000000..bce38eeea --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package ${package}.${moduleName}.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import ${package}.${moduleName}.entity.${className}; +import ${package}.${moduleName}.mapper.${className}Mapper; +import ${package}.${moduleName}.service.${className}Service; +import org.springframework.stereotype.Service; + +/** + * ${comments} + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service { + +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/api.js.vm b/pigx-visual/pigx-code/src/main/resources/template/api.js.vm new file mode 100644 index 000000000..e257ce767 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/api.js.vm @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +import request from '@/router/axios' + +export function fetchList(query) { + return request({ + url: '/${moduleName}/${pathName}/page', + method: 'get', + params: query + }) +} + +export function addObj(obj) { + return request({ + url: '/${moduleName}/${pathName}', + method: 'post', + data: obj + }) +} + +export function getObj(id) { + return request({ + url: '/${moduleName}/${pathName}/' + id, + method: 'get' + }) +} + +export function delObj(id) { + return request({ + url: '/${moduleName}/${pathName}/' + id, + method: 'delete' + }) +} + +export function putObj(obj) { + return request({ + url: '/${moduleName}/${pathName}', + method: 'put', + data: obj + }) +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm b/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm new file mode 100644 index 000000000..0c9e51fa2 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm @@ -0,0 +1,17 @@ +export const tableOption = { + "border": true, + "index": true, + "indexLabel": "序号", + "stripe": true, + "menuAlign": "center", + "align": "center", + "column": [ +#foreach ($column in $columns) + { + "type": "input", + "label": "$column.comments", + "prop": "$column.lowerAttrName" + }#if($foreach.hasNext),#end +#end + ] +} diff --git a/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm b/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm new file mode 100644 index 000000000..47fd26051 --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm @@ -0,0 +1,121 @@ + + + + \ No newline at end of file diff --git a/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm b/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm new file mode 100644 index 000000000..c8a353d2a --- /dev/null +++ b/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm @@ -0,0 +1,16 @@ +-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点1000 + +-- 菜单SQL +insert into `sys_menu` ( `parent_id`, `path`, `permission`, `type`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) + values ( '1000', '/${moduleName}/${pathName}/index', '', '0', 'icon-bangzhushouji', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理'); + +-- 按钮父菜单ID +set @parentId = @@identity; + +-- 菜单对应按钮SQL +insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) + SELECT @parentId, '${moduleName}_${pathName}_add', '1', null, '1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增'; +insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) + SELECT @parentId, '${moduleName}_${pathName}_edit', '1', null, '1', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改'; +insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) + SELECT @parentId, '${moduleName}_${pathName}_del', '1', null, '1', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除'; diff --git a/pigx-visual/pom.xml b/pigx-visual/pom.xml index af477a99e..dbdfa87e8 100644 --- a/pigx-visual/pom.xml +++ b/pigx-visual/pom.xml @@ -43,5 +43,6 @@ pigx-sentinel-dashboard pigx-tx-manager pigx-dynamic-datasource + pigx-code From 7687eb13481a173867fc7418189b5d60f2a54b2d Mon Sep 17 00:00:00 2001 From: liuyes Date: Fri, 20 Dec 2019 21:03:52 +0800 Subject: [PATCH 004/130] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-visual/pigx-code/README.md | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 pigx-visual/pigx-code/README.md diff --git a/pigx-visual/pigx-code/README.md b/pigx-visual/pigx-code/README.md new file mode 100644 index 000000000..ea4825ff0 --- /dev/null +++ b/pigx-visual/pigx-code/README.md @@ -0,0 +1,45 @@ +## 使用说明 +``` +本模块是pigx-codegen的重写版本,使用dynamic-datasource实现,去除pigx-common-datasource依赖,功能未做扩展。 +``` +### pigx-code-dev.yml +``` +## spring security 配置 +security: + oauth2: + client: + client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==) + client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==) + scope: server + resources: + static-locations: classpath:/static/,classpath:/views/ + +# 数据源 +spring: + datasource: + dynamic: + username: ${MYSQL-USER:root} + password: ${MYSQL-USER:root} + url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true + driverClassName: com.mysql.cj.jdbc.Driver + sql: select * from gen_datasource_conf + + +pigx: + tenant: + column: tenant_id + tables: + - sys_datasource_conf +``` +### 示例中的pigxx_codegen数据库及sql说明 +``` +pigxx_codegen数据库中gen_datasource_conf表必须存在一个name为master的数据库连接配置 + +INSERT INTO `gen_datasource_conf` VALUES ('8', 'master', 'jdbc:mysql://pigx-mysql:3306/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'ZkxR9PxP6sWvasdc9CG9Ww==', '2019-09-18 09:44:55', '2019-12-17 17:07:17', '0', null); +``` +### yml配置文件切换数据源 +``` +请参考:https://git.pig4cloud.com/pigx/pigx/src/liuyes_dev/pigx-visual/pigx-dynamic-datasource +``` +### 联系我 +QQ:55215085 \ No newline at end of file From be502be2b3bcb8d8dc97d3ee6adef2873cc70ccf Mon Sep 17 00:00:00 2001 From: liuyes Date: Fri, 20 Dec 2019 21:12:59 +0800 Subject: [PATCH 005/130] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-visual/pigx-code/README.md | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/pigx-visual/pigx-code/README.md b/pigx-visual/pigx-code/README.md index ea4825ff0..fc2b73f3a 100644 --- a/pigx-visual/pigx-code/README.md +++ b/pigx-visual/pigx-code/README.md @@ -37,6 +37,51 @@ pigxx_codegen数据库中gen_datasource_conf表必须存在一个name为master INSERT INTO `gen_datasource_conf` VALUES ('8', 'master', 'jdbc:mysql://pigx-mysql:3306/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'ZkxR9PxP6sWvasdc9CG9Ww==', '2019-09-18 09:44:55', '2019-12-17 17:07:17', '0', null); ``` +### 修改菜单的url +``` +开发平台菜单下的/gen全部改为/code +如 /gen/datasource 改为 /code/datasource +``` +### 修改动态路由 +``` +{ + "routeId": "pigx-codegen", + "routeName": "代码生成模块", + "predicates": [ + { + "args": { + "_genkey_0": "/gen/**" + }, + "name": "Path" + } + ], + "filters": [], + "uri": "lb://pigx-codegen", + "order": 0, + "createTime": "2019-10-16 16:44:41", + "updateTime": "2019-11-05 22:36:58", + "delFlag": "0" + }, +改为 +{ + "routeId": "pigx-code", + "routeName": "多数据源代码生成模块", + "predicates": [ + { + "args": { + "_genkey_0": "/code/**" + }, + "name": "Path" + } + ], + "filters": [], + "uri": "lb://pigx-code", + "order": 0, + "createTime": "2019-10-16 16:44:41", + "updateTime": "2019-11-05 22:36:58", + "delFlag": "0" + }, +``` ### yml配置文件切换数据源 ``` 请参考:https://git.pig4cloud.com/pigx/pigx/src/liuyes_dev/pigx-visual/pigx-dynamic-datasource From 933f986ba07b6f1caec517d8a05b4d59dd90cf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Fri, 3 Jan 2020 15:53:55 +0800 Subject: [PATCH 006/130] =?UTF-8?q?:sparkles:=20Introducing=20new=20featur?= =?UTF-8?q?es.=20=E6=94=AF=E6=8C=81=E9=9D=9Eweb=20=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20=E5=88=86=E5=B8=83=E5=BC=8F=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/TxManagerInterceptor.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/interceptor/TxManagerInterceptor.java b/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/interceptor/TxManagerInterceptor.java index 51d1d4b43..8d40d51dd 100755 --- a/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/interceptor/TxManagerInterceptor.java +++ b/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/interceptor/TxManagerInterceptor.java @@ -18,9 +18,10 @@ package com.pig4cloud.pigx.common.transaction.tx.springcloud.interceptor; import com.codingapi.tx.aop.service.AspectBeforeService; +import lombok.AllArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; @@ -34,17 +35,23 @@ import javax.servlet.http.HttpServletRequest; * @since 4.1.0 */ +@Slf4j @Component +@AllArgsConstructor public class TxManagerInterceptor { - - @Autowired - private AspectBeforeService aspectBeforeService; + private final AspectBeforeService aspectBeforeService; @SneakyThrows public Object around(ProceedingJoinPoint point) { - RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); - HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); - String groupId = request.getHeader("tx-group"); + RequestAttributes requestAttributes; + String groupId = null; + try { + requestAttributes = RequestContextHolder.currentRequestAttributes(); + HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); + groupId = request.getHeader("tx-group"); + } catch (IllegalStateException e) { + log.info("非web 环境调用 不包含请求上下文"); + } return aspectBeforeService.around(groupId, point); } } From b5152a2c8096f72434ad0572d123b17458ee8612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Tue, 7 Jan 2020 12:38:03 +0800 Subject: [PATCH 007/130] :whale: Work about Docker. edit docker-compose.yml --- docker-compose.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 15da3982a..9331f1fb4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,10 +21,12 @@ services: command: --lower_case_table_names=1 pigx-zookeeper: + container_name: pigx-zookeeper image: zookeeper:3.4.13 restart: always pigx-xxl: + container_name: pigx-xxl image: pig4cloud/xxl-job-admin:2.1.1 restart: always environment: @@ -33,13 +35,14 @@ services: - 9080:8080 pigx-redis: + container_name: pigx-redis image: redis:5.0.7 restart: always - container_name: pigx-redis ports: - 6379:6379 pigx-minio: + container_name: pigx-minio image: minio/minio command: server /data ports: From 006cbbb95327101809414f14954b22f7df2538a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Wed, 8 Jan 2020 21:56:41 +0800 Subject: [PATCH 008/130] =?UTF-8?q?:sparkles:=20Introducing=20new=20featur?= =?UTF-8?q?es.=20=E7=99=BB=E5=BD=95=E6=95=8F=E6=84=9F=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20post=20body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/filter/PasswordDecoderFilter.java | 125 +++++++++++++----- 1 file changed, 93 insertions(+), 32 deletions(-) diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java index 033c382fd..8c500bdc2 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java @@ -25,76 +25,137 @@ import cn.hutool.crypto.Padding; import cn.hutool.crypto.symmetric.AES; import cn.hutool.http.HttpUtil; import com.pig4cloud.pigx.common.core.constant.SecurityConstants; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutputMessage; +import org.springframework.cloud.gateway.support.BodyInserterContext; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpRequestDecorator; import org.springframework.stereotype.Component; -import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.reactive.function.BodyInserter; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerStrategies; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import java.net.URI; import java.nio.charset.StandardCharsets; -import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; /** * @author lengleng - * @date 2018/7/15 + * @date 2020/1/8 * 密码解密工具类 + *

+ * 参考 ModifyRequestBodyGatewayFilterFactory 实现 */ @Slf4j @Component public class PasswordDecoderFilter extends AbstractGatewayFilterFactory { + private final List> messageReaders = HandlerStrategies.withDefaults().messageReaders(); + private static final String PASSWORD = "password"; private static final String KEY_ALGORITHM = "AES"; @Value("${security.encode.key:1234567812345678}") private String encodeKey; - @SneakyThrows - private static String decryptAES(String data, String pass) { - AES aes = new AES(Mode.CBC,Padding.NoPadding, - new SecretKeySpec(pass.getBytes(), KEY_ALGORITHM), - new IvParameterSpec(pass.getBytes())); - byte[] result = aes.decrypt(Base64.decode(data.getBytes(StandardCharsets.UTF_8))); - return new String(result, StandardCharsets.UTF_8); - } @Override public GatewayFilter apply(Object config) { return (exchange, chain) -> { ServerHttpRequest request = exchange.getRequest(); - // 不是登录请求,直接向下执行 if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), SecurityConstants.OAUTH_TOKEN_URL)) { return chain.filter(exchange); } - URI uri = exchange.getRequest().getURI(); - String queryParam = uri.getRawQuery(); - Map paramMap = HttpUtil.decodeParamMap(queryParam, CharsetUtil.UTF_8); + Class inClass = String.class; + Class outClass = String.class; + ServerRequest serverRequest = ServerRequest.create(exchange, + messageReaders); - String password = paramMap.get(PASSWORD); - if (StrUtil.isNotBlank(password)) { - try { - password = decryptAES(password, encodeKey); - } catch (Exception e) { - log.error("密码解密失败:{}", password); - return Mono.error(e); + // 解密生成新的报文 + Mono modifiedBody = serverRequest.bodyToMono(inClass) + .flatMap(decryptAES()); + + BodyInserter bodyInserter = BodyInserters.fromPublisher(modifiedBody, outClass); + HttpHeaders headers = new HttpHeaders(); + headers.putAll(exchange.getRequest().getHeaders()); + headers.remove(HttpHeaders.CONTENT_LENGTH); + + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + CachedBodyOutputMessage outputMessage = new CachedBodyOutputMessage( + exchange, headers); + return bodyInserter.insert(outputMessage, new BodyInserterContext()) + .then(Mono.defer(() -> { + ServerHttpRequest decorator = decorate(exchange, headers, + outputMessage); + return chain + .filter(exchange.mutate().request(decorator).build()); + })); + }; + } + + /** + * 原文解密 + * + * @return + */ + private Function decryptAES() { + return s -> { + // 构建前端对应解密AES 因子 + AES aes = new AES(Mode.CBC, Padding.NoPadding, + new SecretKeySpec(encodeKey.getBytes(), KEY_ALGORITHM), + new IvParameterSpec(encodeKey.getBytes())); + + // 获取请求密码并解密 + HashMap inParamsMap = HttpUtil.decodeParamMap((String) s, CharsetUtil.UTF_8); + byte[] result = aes.decrypt(Base64.decode(inParamsMap.get(PASSWORD) + .getBytes(StandardCharsets.UTF_8))); + String password = new String(result, StandardCharsets.UTF_8); + + // 返回修改后报文字符 + inParamsMap.put(PASSWORD, password.trim()); + return Mono.just(HttpUtil.toParams(inParamsMap)); + }; + } + + /** + * 报文转换 + * + * @return + */ + private ServerHttpRequestDecorator decorate(ServerWebExchange exchange, HttpHeaders headers, + CachedBodyOutputMessage outputMessage) { + return new ServerHttpRequestDecorator(exchange.getRequest()) { + @Override + public HttpHeaders getHeaders() { + long contentLength = headers.getContentLength(); + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.putAll(super.getHeaders()); + if (contentLength > 0) { + httpHeaders.setContentLength(contentLength); + } else { + httpHeaders.set(HttpHeaders.TRANSFER_ENCODING, "chunked"); } - paramMap.put(PASSWORD, password.trim()); + return httpHeaders; } - URI newUri = UriComponentsBuilder.fromUri(uri) - .replaceQuery(HttpUtil.toParams(paramMap)) - .build(true) - .toUri(); - - ServerHttpRequest newRequest = exchange.getRequest().mutate().uri(newUri).build(); - return chain.filter(exchange.mutate().request(newRequest).build()); + @Override + public Flux getBody() { + return outputMessage.getBody(); + } }; } } From 93fdad4dd03f84a3e190594ec8f791ec72a2fcae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 12 Jan 2020 15:57:04 +0800 Subject: [PATCH 009/130] =?UTF-8?q?:sparkles:=20Introducing=20new=20featur?= =?UTF-8?q?es.=20=E6=94=AF=E6=8C=81=E5=85=A8=E5=B1=80=E7=9A=84=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=81=B0=E5=BA=A6=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-auth/pom.xml | 5 + pigx-common/pigx-common-bom/pom.xml | 5 + .../pigx/common/core/util/WebUtils.java | 10 +- pigx-common/pigx-common-gateway/pom.xml | 4 + .../GrayLoadBalancerClientConfiguration.java | 55 +++++++++ .../PigxRibbonRuleAutoConfiguration.java | 76 ------------ .../filter/GrayLoadBalancerClientFilter.java | 49 -------- .../GrayReactiveLoadBalancerClientFilter.java | 108 ++++++++++++++++++ .../AbstractDiscoveryEnabledPredicate.java | 51 --------- .../predicate/GrayMetadataAwarePredicate.java | 67 ----------- .../rule/AbstractDiscoveryEnabledRule.java | 76 ------------ .../common/gateway/rule/GrayLoadBalancer.java | 39 +++++++ .../gateway/rule/MetadataAwareRule.java | 91 --------------- .../gateway/rule/VersionGrayLoadBalancer.java | 81 +++++++++++++ pigx-common/pigx-common-gray/pom.xml | 49 ++++++++ .../GrayRibbonLoadBalancerConfiguration.java | 43 +++++++ .../feign/GrayFeignRequestInterceptor.java | 50 ++++++++ .../gray/rule/GrayRibbonLoadBalancerRule.java | 82 +++++++++++++ .../main/resources/META-INF/spring.factories | 2 + .../ElasticJobAutoConfiguration.java | 10 +- .../XxlJobAutoConfiguration.java | 6 +- .../annotation/EnablePigxElasticJob.java | 4 +- .../annotation/EnablePigxXxlJob.java | 4 +- .../jobinit/AbstractJobInitialization.java | 6 +- .../jobinit/DataflowJobInitialization.java | 4 +- .../jobinit/ScriptJobInitialization.java | 4 +- .../jobinit/SimpleJobInitialization.java | 4 +- .../properties/ElasticJobProperties.java | 4 +- .../properties/XxlAdminProperties.java | 2 +- .../properties/XxlExecutorProperties.java | 2 +- .../properties/XxlJobProperties.java | 2 +- .../service/PigxUserDetailsServiceImpl.java | 8 -- pigx-common/pom.xml | 1 + pigx-gateway/pom.xml | 4 + pigx-gateway/src/main/resources/bootstrap.yml | 5 +- .../PigxDaemonElasticJobApplication.java | 2 +- 36 files changed, 566 insertions(+), 449 deletions(-) create mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java delete mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/PigxRibbonRuleAutoConfiguration.java delete mode 100644 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayLoadBalancerClientFilter.java create mode 100644 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayReactiveLoadBalancerClientFilter.java delete mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/AbstractDiscoveryEnabledPredicate.java delete mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/GrayMetadataAwarePredicate.java delete mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/AbstractDiscoveryEnabledRule.java create mode 100644 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/GrayLoadBalancer.java delete mode 100755 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/MetadataAwareRule.java create mode 100644 pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/VersionGrayLoadBalancer.java create mode 100644 pigx-common/pigx-common-gray/pom.xml create mode 100644 pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java create mode 100644 pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/feign/GrayFeignRequestInterceptor.java create mode 100644 pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java create mode 100644 pigx-common/pigx-common-gray/src/main/resources/META-INF/spring.factories rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/ElasticJobAutoConfiguration.java (91%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/XxlJobAutoConfiguration.java (92%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/annotation/EnablePigxElasticJob.java (90%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/annotation/EnablePigxXxlJob.java (90%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/jobinit/AbstractJobInitialization.java (98%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/jobinit/DataflowJobInitialization.java (94%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/jobinit/ScriptJobInitialization.java (94%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/jobinit/SimpleJobInitialization.java (94%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/properties/ElasticJobProperties.java (98%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/properties/XxlAdminProperties.java (96%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/properties/XxlExecutorProperties.java (97%) rename pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/{job => gray}/properties/XxlJobProperties.java (95%) diff --git a/pigx-auth/pom.xml b/pigx-auth/pom.xml index 3c2fa96c8..0adc34f60 100644 --- a/pigx-auth/pom.xml +++ b/pigx-auth/pom.xml @@ -68,6 +68,11 @@ com.pig4cloud pigx-common-sentinel + + + com.pig4cloud + pigx-common-gray + org.springframework.boot diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index a912c9bbb..73e9930db 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -42,6 +42,11 @@ pigx-common-gateway ${pigx.version} + + com.pig4cloud + pigx-common-gray + ${pigx.version} + com.pig4cloud pigx-common-datasource diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java index bcffaa807..ba927567e 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java @@ -51,8 +51,8 @@ import java.nio.charset.StandardCharsets; @Slf4j @UtilityClass public class WebUtils extends org.springframework.web.util.WebUtils { - private final String BASIC_ = "Basic "; - private final String UNKNOWN = "unknown"; + private final String BASIC_ = "Basic "; + private final String UNKNOWN = "unknown"; /** * 判断是否ajax请求 @@ -122,7 +122,11 @@ public class WebUtils extends org.springframework.web.util.WebUtils { * @return {HttpServletRequest} */ public HttpServletRequest getRequest() { - return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + try { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + } catch (IllegalStateException e) { + return null; + } } /** diff --git a/pigx-common/pigx-common-gateway/pom.xml b/pigx-common/pigx-common-gateway/pom.xml index 182eede61..c97fff40c 100644 --- a/pigx-common/pigx-common-gateway/pom.xml +++ b/pigx-common/pigx-common-gateway/pom.xml @@ -50,5 +50,9 @@ spring-cloud-alibaba-nacos-discovery compile + + org.springframework.cloud + spring-cloud-starter-loadbalancer + diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java new file mode 100755 index 000000000..c160cfc82 --- /dev/null +++ b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gateway.configuration; + +import com.pig4cloud.pigx.common.gateway.rule.GrayLoadBalancer; +import com.pig4cloud.pigx.common.gateway.rule.VersionGrayLoadBalancer; +import com.pig4cloud.pigx.common.gateway.filter.GrayReactiveLoadBalancerClientFilter; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.cloud.gateway.config.GatewayReactiveLoadBalancerClientAutoConfiguration; +import org.springframework.cloud.gateway.config.LoadBalancerProperties; +import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Mica ribbon rule auto configuration. + * + * @author L.cm + * @link https://github.com/lets-mica/mica + */ +@Configuration +@EnableConfigurationProperties(LoadBalancerProperties.class) +@ConditionalOnProperty(value = "gray.rule.enabled", havingValue = "true") +@AutoConfigureBefore(GatewayReactiveLoadBalancerClientAutoConfiguration.class) +public class GrayLoadBalancerClientConfiguration { + + @Bean + public ReactiveLoadBalancerClientFilter gatewayLoadBalancerClientFilter(GrayLoadBalancer grayLoadBalancer, + LoadBalancerProperties properties) { + return new GrayReactiveLoadBalancerClientFilter(properties, grayLoadBalancer); + } + + @Bean + public GrayLoadBalancer grayLoadBalancer(DiscoveryClient discoveryClient) { + return new VersionGrayLoadBalancer(discoveryClient); + } +} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/PigxRibbonRuleAutoConfiguration.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/PigxRibbonRuleAutoConfiguration.java deleted file mode 100755 index 0c3aa42f2..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/PigxRibbonRuleAutoConfiguration.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.configuration; - -import com.alibaba.cloud.nacos.ribbon.NacosServer; -import com.pig4cloud.pigx.common.gateway.filter.GrayLoadBalancerClientFilter; -import com.pig4cloud.pigx.common.gateway.rule.AbstractDiscoveryEnabledRule; -import com.pig4cloud.pigx.common.gateway.rule.MetadataAwareRule; -import com.pig4cloud.pigx.common.gateway.support.PigxRibbonRuleProperties; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.gateway.config.LoadBalancerProperties; -import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter; -import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration; -import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient; -import org.springframework.cloud.netflix.ribbon.SpringClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; - -/** - * Mica ribbon rule auto configuration. - * - * @author L.cm - * @link https://github.com/lets-mica/mica - */ -@Configuration -@RequiredArgsConstructor -@ConditionalOnClass(NacosServer.class) -@AutoConfigureBefore(RibbonClientConfiguration.class) -@EnableConfigurationProperties(PigxRibbonRuleProperties.class) -@ConditionalOnProperty(value = "ribbon.rule.enabled", matchIfMissing = true) -public class PigxRibbonRuleAutoConfiguration { - - @Bean - @ConditionalOnMissingBean - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public AbstractDiscoveryEnabledRule metadataAwareRule() { - return new MetadataAwareRule(); - } - - @Bean - @ConditionalOnMissingBean(LoadBalancerClient.class) - public LoadBalancerClient loadBalancerClient(SpringClientFactory springClientFactory) { - return new RibbonLoadBalancerClient(springClientFactory); - } - - @Bean - @ConditionalOnMissingBean(LoadBalancerClientFilter.class) - public LoadBalancerClientFilter loadBalancerClientFilter(RibbonLoadBalancerClient client - , LoadBalancerProperties properties) { - return new GrayLoadBalancerClientFilter(client, properties); - } - -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayLoadBalancerClientFilter.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayLoadBalancerClientFilter.java deleted file mode 100644 index 256e16a82..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayLoadBalancerClientFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.filter; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.gateway.config.LoadBalancerProperties; -import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter; -import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient; -import org.springframework.http.HttpHeaders; -import org.springframework.web.server.ServerWebExchange; - -import java.net.URI; - -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; - -/** - * @author Spencer Gibb - * @author Tim Ysewyn - */ -public class GrayLoadBalancerClientFilter extends LoadBalancerClientFilter { - private final RibbonLoadBalancerClient loadBalancer; - - public GrayLoadBalancerClientFilter(RibbonLoadBalancerClient loadBalancer, LoadBalancerProperties properties) { - super(loadBalancer, properties); - this.loadBalancer = loadBalancer; - } - - @Override - protected ServiceInstance choose(ServerWebExchange exchange) { - HttpHeaders headers = exchange.getRequest().getHeaders(); - return loadBalancer.choose(((URI) exchange.getAttribute(GATEWAY_REQUEST_URL_ATTR)).getHost(), headers); - } - -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayReactiveLoadBalancerClientFilter.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayReactiveLoadBalancerClientFilter.java new file mode 100644 index 000000000..248f2e5ea --- /dev/null +++ b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/filter/GrayReactiveLoadBalancerClientFilter.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gateway.filter; + +import com.pig4cloud.pigx.common.gateway.rule.GrayLoadBalancer; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools; +import org.springframework.cloud.client.loadbalancer.reactive.DefaultResponse; +import org.springframework.cloud.client.loadbalancer.reactive.Response; +import org.springframework.cloud.gateway.config.LoadBalancerProperties; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter; +import org.springframework.cloud.gateway.support.DelegatingServiceInstance; +import org.springframework.cloud.gateway.support.NotFoundException; +import org.springframework.cloud.gateway.support.ServerWebExchangeUtils; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +import java.net.URI; + +/** + * @author lengleng + * @date 2020/1/11 + */ +@Slf4j +public class GrayReactiveLoadBalancerClientFilter extends ReactiveLoadBalancerClientFilter { + private static final int LOAD_BALANCER_CLIENT_FILTER_ORDER = 10150; + private LoadBalancerProperties properties; + + private GrayLoadBalancer grayLoadBalancer; + + public GrayReactiveLoadBalancerClientFilter(LoadBalancerProperties properties, GrayLoadBalancer grayLoadBalancer) { + super(null, properties); + this.properties = properties; + this.grayLoadBalancer = grayLoadBalancer; + } + + @Override + public int getOrder() { + return LOAD_BALANCER_CLIENT_FILTER_ORDER; + } + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + URI url = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR); + String schemePrefix = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR); + if (url == null + || (!"lb".equals(url.getScheme()) && !"lb".equals(schemePrefix))) { + return chain.filter(exchange); + } + // preserve the original url + ServerWebExchangeUtils.addOriginalRequestUrl(exchange, url); + + if (log.isTraceEnabled()) { + log.trace(ReactiveLoadBalancerClientFilter.class.getSimpleName() + + " url before: " + url); + } + + return choose(exchange).doOnNext(response -> { + + if (!response.hasServer()) { + throw NotFoundException.create(properties.isUse404(), + "Unable to find instance for " + url.getHost()); + } + + URI uri = exchange.getRequest().getURI(); + + // if the `lb:` mechanism was used, use `` as the default, + // if the loadbalancer doesn't provide one. + String overrideScheme = null; + if (schemePrefix != null) { + overrideScheme = url.getScheme(); + } + + DelegatingServiceInstance serviceInstance = new DelegatingServiceInstance( + response.getServer(), overrideScheme); + + URI requestUrl = LoadBalancerUriTools.reconstructURI(serviceInstance, uri); + + if (log.isTraceEnabled()) { + log.trace("LoadBalancerClientFilter url chosen: " + requestUrl); + } + exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, requestUrl); + }).then(chain.filter(exchange)); + } + + private Mono> choose(ServerWebExchange exchange) { + URI uri = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR); + ServiceInstance serviceInstance = grayLoadBalancer.choose(uri.getHost(),exchange.getRequest()); + return Mono.just(new DefaultResponse(serviceInstance)); + } +} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/AbstractDiscoveryEnabledPredicate.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/AbstractDiscoveryEnabledPredicate.java deleted file mode 100755 index ace152074..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/AbstractDiscoveryEnabledPredicate.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.predicate; - -import com.alibaba.cloud.nacos.ribbon.NacosServer; -import com.netflix.loadbalancer.AbstractServerPredicate; -import com.netflix.loadbalancer.PredicateKey; -import org.springframework.http.HttpHeaders; -import org.springframework.lang.Nullable; - -/** - * 过滤服务 - * - * @author L.cm - */ -public abstract class AbstractDiscoveryEnabledPredicate extends AbstractServerPredicate { - - /** - * {@inheritDoc} - */ - @Override - public boolean apply(@Nullable PredicateKey input) { - return input != null - && input.getServer() instanceof NacosServer - && apply((NacosServer) input.getServer(), (HttpHeaders) input.getLoadBalancerKey()); - } - - /** - * Returns whether the specific {@link NacosServer} matches this predicate. - * - * @param server the discovered server - * @param headers 请求头 - * @return whether the server matches the predicate - */ - abstract boolean apply(NacosServer server, HttpHeaders headers); -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/GrayMetadataAwarePredicate.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/GrayMetadataAwarePredicate.java deleted file mode 100755 index 4f3be07a0..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/predicate/GrayMetadataAwarePredicate.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.predicate; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.cloud.nacos.ribbon.NacosServer; -import com.pig4cloud.pigx.common.core.constant.CommonConstants; -import com.pig4cloud.pigx.common.core.util.SpringContextHolder; -import com.pig4cloud.pigx.common.gateway.support.PigxRibbonRuleProperties; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpHeaders; - -import java.util.Map; - -/** - * 基于 Metadata version 的服务筛选 - * - * @author L.cm - * @author lengleng - */ -@Slf4j -public class GrayMetadataAwarePredicate extends AbstractDiscoveryEnabledPredicate { - - @Override - protected boolean apply(NacosServer server, HttpHeaders headers) { - PigxRibbonRuleProperties ribbonProperties = SpringContextHolder.getBean(PigxRibbonRuleProperties.class); - - if (!ribbonProperties.isGrayEnabled()) { - log.debug("gray closed,GrayMetadataAwarePredicate return true"); - return true; - } - - final Map metadata = server.getMetadata(); - String version = metadata.get(CommonConstants.VERSION); - // 判断Nacos服务是否有版本标签 - if (StrUtil.isBlank(version)) { - log.debug("nacos server tag is blank ,GrayMetadataAwarePredicate return true"); - return true; - } - - // 判断请求中是否有版本 - String target = headers.getFirst(CommonConstants.VERSION); - if (StrUtil.isBlank(target)) { - log.debug("request headers version is blank,GrayMetadataAwarePredicate return true"); - return true; - } - - log.debug("请求版本:{} ,当前服务版本:{}", target, version); - return target.equals(version); - } - -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/AbstractDiscoveryEnabledRule.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/AbstractDiscoveryEnabledRule.java deleted file mode 100755 index 2d0a762f7..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/AbstractDiscoveryEnabledRule.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.rule; - -import com.google.common.base.Optional; -import com.netflix.loadbalancer.*; -import com.pig4cloud.pigx.common.gateway.predicate.AbstractDiscoveryEnabledPredicate; -import org.springframework.util.Assert; - -import java.util.List; - -/** - * ribbon 路由规则 - * - * @author L.cm - */ -public abstract class AbstractDiscoveryEnabledRule extends PredicateBasedRule { - private final CompositePredicate predicate; - - public AbstractDiscoveryEnabledRule(AbstractDiscoveryEnabledPredicate discoveryEnabledPredicate) { - Assert.notNull(discoveryEnabledPredicate, "Parameter 'discoveryEnabledPredicate' can't be null"); - this.predicate = createCompositePredicate(discoveryEnabledPredicate, new AvailabilityPredicate(this, null)); - } - - /** - * {@inheritDoc} - */ - @Override - public AbstractServerPredicate getPredicate() { - return predicate; - } - - @Override - public Server choose(Object key) { - ILoadBalancer lb = getLoadBalancer(); - - List allServers = lb.getAllServers(); - // 过滤服务列表 - List serverList = filterServers(allServers); - - Optional server = getPredicate().chooseRoundRobinAfterFiltering(serverList, key); - if (server.isPresent()) { - return server.get(); - } else { - return null; - } - } - - /** - * 过滤服务 - * - * @param serverList 服务列表 - * @return 服务列表 - */ - public abstract List filterServers(List serverList); - - private CompositePredicate createCompositePredicate(AbstractDiscoveryEnabledPredicate discoveryEnabledPredicate, AvailabilityPredicate availabilityPredicate) { - return CompositePredicate.withPredicates(discoveryEnabledPredicate, availabilityPredicate) - .build(); - } -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/GrayLoadBalancer.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/GrayLoadBalancer.java new file mode 100644 index 000000000..ad2efe0eb --- /dev/null +++ b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/GrayLoadBalancer.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gateway.rule; + +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.http.server.reactive.ServerHttpRequest; + +/** + * @author lengleng + * @date 2020/1/12 + *

+ * 灰度路由 + */ +public interface GrayLoadBalancer { + + /** + * 根据serviceId 筛选可用服务 + * + * @param serviceId 服务ID + * @param request 当前请求 + * @return + */ + ServiceInstance choose(String serviceId, ServerHttpRequest request); +} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/MetadataAwareRule.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/MetadataAwareRule.java deleted file mode 100755 index 92eea034e..000000000 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/MetadataAwareRule.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.common.gateway.rule; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.system.HostInfo; -import cn.hutool.system.SystemUtil; -import com.netflix.loadbalancer.Server; -import com.pig4cloud.pigx.common.core.util.SpringContextHolder; -import com.pig4cloud.pigx.common.gateway.predicate.AbstractDiscoveryEnabledPredicate; -import com.pig4cloud.pigx.common.gateway.predicate.GrayMetadataAwarePredicate; -import com.pig4cloud.pigx.common.gateway.support.PigxRibbonRuleProperties; -import lombok.extern.slf4j.Slf4j; -import org.springframework.util.PatternMatchUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * ribbon 路由规则器 - * - * @author dream.lu - */ -@Slf4j -public class MetadataAwareRule extends AbstractDiscoveryEnabledRule { - - public MetadataAwareRule() { - this(new GrayMetadataAwarePredicate()); - } - - public MetadataAwareRule(AbstractDiscoveryEnabledPredicate predicate) { - super(predicate); - } - - @Override - public List filterServers(List serverList) { - PigxRibbonRuleProperties ribbonProperties = SpringContextHolder.getBean(PigxRibbonRuleProperties.class); - List priorIpPattern = ribbonProperties.getPriorIpPattern(); - - if (ribbonProperties.isGrayEnabled()) { - return serverList; - } - - // 1. 查找是否有本机 ip - HostInfo hostInfo = SystemUtil.getHostInfo(); - String hostIp = hostInfo.getAddress(); - - // 优先的 ip 规则 - boolean hasPriorIpPattern = !priorIpPattern.isEmpty(); - String[] priorIpPatterns = priorIpPattern.toArray(new String[0]); - - List priorServerList = new ArrayList<>(); - for (Server server : serverList) { - String host = server.getHost(); - // 2. 优先本地 ip 的服务 - if (!hasPriorIpPattern && ObjectUtil.equal(hostIp, host)) { - log.debug("{} 不存在优先配置,本地路由条件", hostIp); - return Collections.singletonList(server); - } - // 3. 优先的 ip 服务 - if (hasPriorIpPattern && PatternMatchUtils.simpleMatch(priorIpPatterns, host)) { - log.debug("{} 存在优先配置,ribbon 强制路由", priorIpPatterns); - priorServerList.add(server); - } - } - - // 4. 如果优先的有数据直接返回 - if (!priorServerList.isEmpty()) { - return priorServerList; - } - - return Collections.unmodifiableList(serverList); - } - -} diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/VersionGrayLoadBalancer.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/VersionGrayLoadBalancer.java new file mode 100644 index 000000000..07c69a1e9 --- /dev/null +++ b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/rule/VersionGrayLoadBalancer.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gateway.rule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.common.core.constant.CommonConstants; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.cloud.gateway.support.NotFoundException; +import org.springframework.http.server.reactive.ServerHttpRequest; + +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2020/1/12 + *

+ * 基于客户端版本号灰度路由 + */ +@Slf4j +@AllArgsConstructor +public class VersionGrayLoadBalancer implements GrayLoadBalancer { + private DiscoveryClient discoveryClient; + + + /** + * 根据serviceId 筛选可用服务 + * + * @param serviceId 服务ID + * @param request 当前请求 + * @return + */ + @Override + public ServiceInstance choose(String serviceId, ServerHttpRequest request) { + List instances = discoveryClient.getInstances(serviceId); + + //注册中心无实例 抛出异常 + if (CollUtil.isEmpty(instances)) { + log.warn("No instance available for {}", serviceId); + throw new NotFoundException("No instance available for " + serviceId); + } + + // 获取请求version,无则随机返回可用实例 + String reqVersion = request.getHeaders().getFirst(CommonConstants.VERSION); + if (StrUtil.isBlank(reqVersion)) { + return instances.get(RandomUtil.randomInt(instances.size())); + } + + // 遍历可以实例元数据,若匹配则返回此实例 + for (ServiceInstance instance : instances) { + Map metadata = instance.getMetadata(); + String targetVersion = MapUtil.getStr(metadata, CommonConstants.VERSION); + if (reqVersion.equalsIgnoreCase(targetVersion)) { + log.debug("gray requst match success :{} {}", reqVersion, instance); + return instance; + } + } + return instances.get(RandomUtil.randomInt(instances.size())); + } +} diff --git a/pigx-common/pigx-common-gray/pom.xml b/pigx-common/pigx-common-gray/pom.xml new file mode 100644 index 000000000..343520e64 --- /dev/null +++ b/pigx-common/pigx-common-gray/pom.xml @@ -0,0 +1,49 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-common + 3.6.0 + + + pigx-common-gray + jar + + pigx 灰度路由 + + + + com.pig4cloud + pigx-common-core + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + io.github.openfeign + feign-core + + + diff --git a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java new file mode 100644 index 000000000..bae8ca647 --- /dev/null +++ b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gray; + +import com.pig4cloud.pigx.common.gray.feign.GrayFeignRequestInterceptor; +import com.pig4cloud.pigx.common.gray.rule.GrayRibbonLoadBalancerRule; +import feign.RequestInterceptor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author lengleng + * @date 2020/1/12 + */ +@Configuration +@ConditionalOnProperty(value = "gray.rule.enabled", havingValue = "true") +public class GrayRibbonLoadBalancerConfiguration { + @Bean + public GrayRibbonLoadBalancerRule ribbonLoadBalancerRule() { + return new GrayRibbonLoadBalancerRule(); + } + + @Bean + public RequestInterceptor pigxFeignTenantInterceptor() { + return new GrayFeignRequestInterceptor(); + } +} diff --git a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/feign/GrayFeignRequestInterceptor.java b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/feign/GrayFeignRequestInterceptor.java new file mode 100644 index 000000000..1d261750f --- /dev/null +++ b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/feign/GrayFeignRequestInterceptor.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gray.feign; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.common.core.constant.CommonConstants; +import com.pig4cloud.pigx.common.core.util.WebUtils; +import feign.RequestInterceptor; +import feign.RequestTemplate; +import lombok.extern.slf4j.Slf4j; + +/** + * @author lengleng + * @date 2020/1/12 + *

+ * feign 请求VERSION 传递 + */ +@Slf4j +public class GrayFeignRequestInterceptor implements RequestInterceptor { + /** + * Called for every request. Add data using methods on the supplied {@link RequestTemplate}. + * + * @param template + */ + @Override + public void apply(RequestTemplate template) { + String reqVersion = WebUtils.getRequest() != null + ? WebUtils.getRequest().getHeader(CommonConstants.VERSION) : null; + + if (StrUtil.isNotBlank(reqVersion)) { + log.debug("feign gray add header version :{}", reqVersion); + template.header(CommonConstants.VERSION, reqVersion); + } + } +} diff --git a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java new file mode 100644 index 000000000..5d71c22fc --- /dev/null +++ b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.gray.rule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.cloud.nacos.ribbon.NacosServer; +import com.netflix.client.config.IClientConfig; +import com.netflix.loadbalancer.AbstractLoadBalancerRule; +import com.netflix.loadbalancer.ILoadBalancer; +import com.netflix.loadbalancer.Server; +import com.pig4cloud.pigx.common.core.constant.CommonConstants; +import com.pig4cloud.pigx.common.core.util.WebUtils; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2020/1/12 + */ +@Slf4j +public class GrayRibbonLoadBalancerRule extends AbstractLoadBalancerRule { + @Override + public void initWithNiwsConfig(IClientConfig iClientConfig) { + + } + + @Override + public Server choose(Object key) { + return choose(getLoadBalancer(), key); + } + + + public Server choose(ILoadBalancer lb, Object key) { + List reachableServers = lb.getReachableServers(); + + //注册中心无可用实例 抛出异常 + if (CollUtil.isEmpty(reachableServers)) { + log.warn("No instance available for {}", key); + return null; + } + + // 获取请求version,无则随机返回可用实例 + String reqVersion = WebUtils.getRequest() != null + ? WebUtils.getRequest().getHeader(CommonConstants.VERSION) : null; + if (StrUtil.isBlank(reqVersion)) { + return reachableServers.get(RandomUtil.randomInt(reachableServers.size())); + } + + // 遍历可以实例元数据,若匹配则返回此实例 + for (Server server : reachableServers) { + NacosServer nacosServer = (NacosServer) server; + Map metadata = nacosServer.getMetadata(); + String targetVersion = MapUtil.getStr(metadata, CommonConstants.VERSION); + if (reqVersion.equalsIgnoreCase(targetVersion)) { + log.debug("gray requst match success :{} {}", reqVersion, nacosServer); + return nacosServer; + } + } + return reachableServers.get(RandomUtil.randomInt(reachableServers.size())); + } + +} diff --git a/pigx-common/pigx-common-gray/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-gray/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..0dc0c1d27 --- /dev/null +++ b/pigx-common/pigx-common-gray/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.common.gray.GrayRibbonLoadBalancerConfiguration \ No newline at end of file diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/ElasticJobAutoConfiguration.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/ElasticJobAutoConfiguration.java similarity index 91% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/ElasticJobAutoConfiguration.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/ElasticJobAutoConfiguration.java index 97afd9bb7..903ceca42 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/ElasticJobAutoConfiguration.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/ElasticJobAutoConfiguration.java @@ -15,14 +15,14 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job; +package com.pig4cloud.pigx.common.gray; import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration; import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter; -import com.pig4cloud.pigx.common.job.jobinit.DataflowJobInitialization; -import com.pig4cloud.pigx.common.job.jobinit.ScriptJobInitialization; -import com.pig4cloud.pigx.common.job.jobinit.SimpleJobInitialization; -import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties; +import com.pig4cloud.pigx.common.gray.jobinit.DataflowJobInitialization; +import com.pig4cloud.pigx.common.gray.jobinit.ScriptJobInitialization; +import com.pig4cloud.pigx.common.gray.jobinit.SimpleJobInitialization; +import com.pig4cloud.pigx.common.gray.properties.ElasticJobProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/XxlJobAutoConfiguration.java similarity index 92% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/XxlJobAutoConfiguration.java index 7e81e44bd..b24fb5d79 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/XxlJobAutoConfiguration.java @@ -15,9 +15,9 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job; +package com.pig4cloud.pigx.common.gray; -import com.pig4cloud.pigx.common.job.properties.XxlJobProperties; +import com.pig4cloud.pigx.common.gray.properties.XxlJobProperties; import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; @@ -32,7 +32,7 @@ import org.springframework.context.annotation.Configuration; */ @Configuration @EnableAutoConfiguration -@ComponentScan("com.pig4cloud.pigx.common.job.properties") +@ComponentScan("com.pig4cloud.pigx.common.gray.properties") public class XxlJobAutoConfiguration { @Bean(initMethod = "start", destroyMethod = "destroy") diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxElasticJob.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxElasticJob.java similarity index 90% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxElasticJob.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxElasticJob.java index bd1d92460..da37b80fd 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxElasticJob.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxElasticJob.java @@ -15,9 +15,9 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.annotation; +package com.pig4cloud.pigx.common.gray.annotation; -import com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration; +import com.pig4cloud.pigx.common.gray.ElasticJobAutoConfiguration; import org.springframework.context.annotation.Import; import java.lang.annotation.*; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxXxlJob.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxXxlJob.java similarity index 90% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxXxlJob.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxXxlJob.java index aa40052aa..b57b7c5a9 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/annotation/EnablePigxXxlJob.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/annotation/EnablePigxXxlJob.java @@ -15,9 +15,9 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.annotation; +package com.pig4cloud.pigx.common.gray.annotation; -import com.pig4cloud.pigx.common.job.XxlJobAutoConfiguration; +import com.pig4cloud.pigx.common.gray.XxlJobAutoConfiguration; import org.springframework.context.annotation.Import; import java.lang.annotation.*; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/AbstractJobInitialization.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/AbstractJobInitialization.java similarity index 98% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/AbstractJobInitialization.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/AbstractJobInitialization.java index b9b81b5d8..9f0e2b014 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/AbstractJobInitialization.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/AbstractJobInitialization.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.jobinit; +package com.pig4cloud.pigx.common.gray.jobinit; import com.dangdang.ddframe.job.api.ElasticJob; import com.dangdang.ddframe.job.api.JobType; @@ -30,7 +30,7 @@ import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener; import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration; import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler; import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter; -import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties; +import com.pig4cloud.pigx.common.gray.properties.ElasticJobProperties; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.config.BeanDefinition; @@ -46,7 +46,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import static com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME; +import static com.pig4cloud.pigx.common.gray.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME; /** diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/DataflowJobInitialization.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/DataflowJobInitialization.java similarity index 94% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/DataflowJobInitialization.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/DataflowJobInitialization.java index 66af592bb..989710152 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/DataflowJobInitialization.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/DataflowJobInitialization.java @@ -15,12 +15,12 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.jobinit; +package com.pig4cloud.pigx.common.gray.jobinit; import com.dangdang.ddframe.job.config.JobCoreConfiguration; import com.dangdang.ddframe.job.config.JobTypeConfiguration; import com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration; -import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties; +import com.pig4cloud.pigx.common.gray.properties.ElasticJobProperties; import java.util.Map; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/ScriptJobInitialization.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/ScriptJobInitialization.java similarity index 94% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/ScriptJobInitialization.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/ScriptJobInitialization.java index c7cbd5890..bded1fb30 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/ScriptJobInitialization.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/ScriptJobInitialization.java @@ -15,12 +15,12 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.jobinit; +package com.pig4cloud.pigx.common.gray.jobinit; import com.dangdang.ddframe.job.config.JobCoreConfiguration; import com.dangdang.ddframe.job.config.JobTypeConfiguration; import com.dangdang.ddframe.job.config.script.ScriptJobConfiguration; -import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties; +import com.pig4cloud.pigx.common.gray.properties.ElasticJobProperties; import java.util.Map; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/SimpleJobInitialization.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/SimpleJobInitialization.java similarity index 94% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/SimpleJobInitialization.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/SimpleJobInitialization.java index fbbead7cb..551e6ba85 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/jobinit/SimpleJobInitialization.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/jobinit/SimpleJobInitialization.java @@ -15,12 +15,12 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.jobinit; +package com.pig4cloud.pigx.common.gray.jobinit; import com.dangdang.ddframe.job.config.JobCoreConfiguration; import com.dangdang.ddframe.job.config.JobTypeConfiguration; import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration; -import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties; +import com.pig4cloud.pigx.common.gray.properties.ElasticJobProperties; import java.util.Map; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/ElasticJobProperties.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/ElasticJobProperties.java similarity index 98% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/ElasticJobProperties.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/ElasticJobProperties.java index 7dbbab4d7..12d63de13 100755 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/ElasticJobProperties.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/ElasticJobProperties.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.properties; +package com.pig4cloud.pigx.common.gray.properties; import com.dangdang.ddframe.job.api.JobType; import lombok.Getter; @@ -25,7 +25,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.LinkedHashMap; import java.util.Map; -import static com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME; +import static com.pig4cloud.pigx.common.gray.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME; /** diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlAdminProperties.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlAdminProperties.java similarity index 96% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlAdminProperties.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlAdminProperties.java index eda15b774..29d2ad359 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlAdminProperties.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlAdminProperties.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.properties; +package com.pig4cloud.pigx.common.gray.properties; import lombok.Data; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlExecutorProperties.java similarity index 97% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlExecutorProperties.java index 09f56cec7..24d14d906 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlExecutorProperties.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.properties; +package com.pig4cloud.pigx.common.gray.properties; import lombok.Data; diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlJobProperties.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlJobProperties.java similarity index 95% rename from pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlJobProperties.java rename to pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlJobProperties.java index a45e0a475..15e8050a9 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlJobProperties.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/gray/properties/XxlJobProperties.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.job.properties; +package com.pig4cloud.pigx.common.gray.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java index 819269f59..0f1029b48 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java @@ -22,14 +22,12 @@ import cn.hutool.core.util.StrUtil; import com.pig4cloud.pigx.admin.api.dto.UserInfo; import com.pig4cloud.pigx.admin.api.entity.SysUser; import com.pig4cloud.pigx.admin.api.feign.RemoteUserService; -import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.constant.CommonConstants; import com.pig4cloud.pigx.common.core.constant.SecurityConstants; import com.pig4cloud.pigx.common.core.util.R; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; @@ -62,14 +60,8 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService { @Override @SneakyThrows public UserDetails loadUserByUsername(String username) { - Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS); - if (cache != null && cache.get(username) != null) { - return (PigxUser) cache.get(username).get(); - } - R result = remoteUserService.info(username, SecurityConstants.FROM_IN); UserDetails userDetails = getUserDetails(result); - cache.put(username, userDetails); return userDetails; } diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml index 46a7edf89..7d2bcbf31 100644 --- a/pigx-common/pom.xml +++ b/pigx-common/pom.xml @@ -38,6 +38,7 @@ pigx-common-data pigx-common-datasource pigx-common-gateway + pigx-common-gray pigx-common-job pigx-common-log pigx-common-minio diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml index c97f8f620..20110e78a 100644 --- a/pigx-gateway/pom.xml +++ b/pigx-gateway/pom.xml @@ -47,6 +47,10 @@ com.pig4cloud pigx-common-gateway + + com.pig4cloud + pigx-common-gray + com.alibaba.cloud diff --git a/pigx-gateway/src/main/resources/bootstrap.yml b/pigx-gateway/src/main/resources/bootstrap.yml index 7f9f41e22..bdbe859da 100644 --- a/pigx-gateway/src/main/resources/bootstrap.yml +++ b/pigx-gateway/src/main/resources/bootstrap.yml @@ -5,6 +5,9 @@ spring: application: name: @artifactId@ cloud: + loadbalancer: + ribbon: + enabled: false nacos: discovery: server-addr: ${NACOS-HOST:pigx-register}:${NACOS-PORT:8848} @@ -13,4 +16,4 @@ spring: file-extension: yml shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} profiles: - active: @profiles.active@ + active: @profiles.active@ \ No newline at end of file diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java index d31f9fe51..55fc6f750 100644 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java +++ b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.daemon.elastic; -import com.pig4cloud.pigx.common.job.annotation.EnablePigxXxlJob; +import com.pig4cloud.pigx.common.gray.annotation.EnablePigxXxlJob; import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; From ca455ceade22e137ff866084e5b8b9e10c6b171b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 12 Jan 2020 16:26:06 +0800 Subject: [PATCH 010/130] =?UTF-8?q?:arrow=5Fup:=20Upgrading=20dependencies?= =?UTF-8?q?.=20=E6=B7=BB=E5=8A=A0=E7=81=B0=E5=BA=A6=20pigx-common-gray=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :bug: Fixing a bug. gray feign request :bug: Fixing a bug. gray feign request --- .../com/pig4cloud/pigx/common/core/util/WebUtils.java | 4 +++- .../GrayLoadBalancerClientConfiguration.java | 2 ++ .../common/gray/GrayRibbonLoadBalancerConfiguration.java | 8 +++++++- .../pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java | 1 - pigx-gateway/pom.xml | 4 ---- pigx-upms/pigx-upms-biz/pom.xml | 5 +++++ pigx-visual/pigx-codegen/pom.xml | 5 +++++ pigx-visual/pigx-daemon-elastic-job/pom.xml | 5 +++++ pigx-visual/pigx-daemon-quartz/pom.xml | 5 +++++ pigx-visual/pigx-mp-platform/pom.xml | 5 +++++ pigx-visual/pigx-oa-platform/pom.xml | 5 +++++ pigx-visual/pigx-pay-platform/pom.xml | 5 +++++ 12 files changed, 47 insertions(+), 7 deletions(-) diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java index ba927567e..7b6817a83 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java @@ -31,6 +31,7 @@ import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.method.HandlerMethod; @@ -123,7 +124,8 @@ public class WebUtils extends org.springframework.web.util.WebUtils { */ public HttpServletRequest getRequest() { try { - return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); + return ((ServletRequestAttributes) requestAttributes).getRequest(); } catch (IllegalStateException e) { return null; } diff --git a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java index c160cfc82..93c68f69d 100755 --- a/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java +++ b/pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/configuration/GrayLoadBalancerClientConfiguration.java @@ -22,6 +22,7 @@ import com.pig4cloud.pigx.common.gateway.rule.VersionGrayLoadBalancer; import com.pig4cloud.pigx.common.gateway.filter.GrayReactiveLoadBalancerClientFilter; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.gateway.config.GatewayReactiveLoadBalancerClientAutoConfiguration; @@ -40,6 +41,7 @@ import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties(LoadBalancerProperties.class) @ConditionalOnProperty(value = "gray.rule.enabled", havingValue = "true") @AutoConfigureBefore(GatewayReactiveLoadBalancerClientAutoConfiguration.class) +@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) public class GrayLoadBalancerClientConfiguration { @Bean diff --git a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java index bae8ca647..5d686f858 100644 --- a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java +++ b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/GrayRibbonLoadBalancerConfiguration.java @@ -20,9 +20,12 @@ package com.pig4cloud.pigx.common.gray; import com.pig4cloud.pigx.common.gray.feign.GrayFeignRequestInterceptor; import com.pig4cloud.pigx.common.gray.rule.GrayRibbonLoadBalancerRule; import feign.RequestInterceptor; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; /** * @author lengleng @@ -31,13 +34,16 @@ import org.springframework.context.annotation.Configuration; @Configuration @ConditionalOnProperty(value = "gray.rule.enabled", havingValue = "true") public class GrayRibbonLoadBalancerConfiguration { + @Bean + @ConditionalOnMissingBean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public GrayRibbonLoadBalancerRule ribbonLoadBalancerRule() { return new GrayRibbonLoadBalancerRule(); } @Bean - public RequestInterceptor pigxFeignTenantInterceptor() { + public RequestInterceptor grayFeignRequestInterceptor() { return new GrayFeignRequestInterceptor(); } } diff --git a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java index 5d71c22fc..a4c553515 100644 --- a/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java +++ b/pigx-common/pigx-common-gray/src/main/java/com/pig4cloud/pigx/common/gray/rule/GrayRibbonLoadBalancerRule.java @@ -41,7 +41,6 @@ import java.util.Map; public class GrayRibbonLoadBalancerRule extends AbstractLoadBalancerRule { @Override public void initWithNiwsConfig(IClientConfig iClientConfig) { - } @Override diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml index 20110e78a..c97f8f620 100644 --- a/pigx-gateway/pom.xml +++ b/pigx-gateway/pom.xml @@ -47,10 +47,6 @@ com.pig4cloud pigx-common-gateway - - com.pig4cloud - pigx-common-gray - com.alibaba.cloud diff --git a/pigx-upms/pigx-upms-biz/pom.xml b/pigx-upms/pigx-upms-biz/pom.xml index 1c2ef5853..431898c68 100644 --- a/pigx-upms/pigx-upms-biz/pom.xml +++ b/pigx-upms/pigx-upms-biz/pom.xml @@ -82,6 +82,11 @@ com.pig4cloud pigx-common-sentinel + + + com.pig4cloud + pigx-common-gray + com.baomidou diff --git a/pigx-visual/pigx-codegen/pom.xml b/pigx-visual/pigx-codegen/pom.xml index bf3b97f7d..923e0850b 100755 --- a/pigx-visual/pigx-codegen/pom.xml +++ b/pigx-visual/pigx-codegen/pom.xml @@ -63,6 +63,11 @@ com.pig4cloud pigx-common-log + + + com.pig4cloud + pigx-common-gray + velocity diff --git a/pigx-visual/pigx-daemon-elastic-job/pom.xml b/pigx-visual/pigx-daemon-elastic-job/pom.xml index 8770bd1d6..054d7e5f4 100644 --- a/pigx-visual/pigx-daemon-elastic-job/pom.xml +++ b/pigx-visual/pigx-daemon-elastic-job/pom.xml @@ -86,6 +86,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-gray + org.springframework.boot diff --git a/pigx-visual/pigx-daemon-quartz/pom.xml b/pigx-visual/pigx-daemon-quartz/pom.xml index b892ca3d4..d04cce9ee 100644 --- a/pigx-visual/pigx-daemon-quartz/pom.xml +++ b/pigx-visual/pigx-daemon-quartz/pom.xml @@ -59,6 +59,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-gray + org.springframework.boot diff --git a/pigx-visual/pigx-mp-platform/pom.xml b/pigx-visual/pigx-mp-platform/pom.xml index f0bb1e35f..16d92498a 100755 --- a/pigx-visual/pigx-mp-platform/pom.xml +++ b/pigx-visual/pigx-mp-platform/pom.xml @@ -63,6 +63,11 @@ com.pig4cloud pigx-common-log + + + com.pig4cloud + pigx-common-gray + com.github.binarywang diff --git a/pigx-visual/pigx-oa-platform/pom.xml b/pigx-visual/pigx-oa-platform/pom.xml index d678e33f5..89c02b71f 100644 --- a/pigx-visual/pigx-oa-platform/pom.xml +++ b/pigx-visual/pigx-oa-platform/pom.xml @@ -56,6 +56,11 @@ com.pig4cloud pigx-upms-api + + + com.pig4cloud + pigx-common-gray + com.baomidou diff --git a/pigx-visual/pigx-pay-platform/pom.xml b/pigx-visual/pigx-pay-platform/pom.xml index 05b9d3479..9f80dafe9 100755 --- a/pigx-visual/pigx-pay-platform/pom.xml +++ b/pigx-visual/pigx-pay-platform/pom.xml @@ -48,6 +48,11 @@ com.pig4cloud pigx-common-sequence + + + com.pig4cloud + pigx-common-gray + com.pig4cloud From 1d1232721923cdb7caf0e09e4ce5f62ab67aa452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 12 Jan 2020 20:16:07 +0800 Subject: [PATCH 011/130] :rewind: Reverting changes. cache revert --- .../security/service/PigxUserDetailsServiceImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java index 0f1029b48..819269f59 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java @@ -22,12 +22,14 @@ import cn.hutool.core.util.StrUtil; import com.pig4cloud.pigx.admin.api.dto.UserInfo; import com.pig4cloud.pigx.admin.api.entity.SysUser; import com.pig4cloud.pigx.admin.api.feign.RemoteUserService; +import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.constant.CommonConstants; import com.pig4cloud.pigx.common.core.constant.SecurityConstants; import com.pig4cloud.pigx.common.core.util.R; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; @@ -60,8 +62,14 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService { @Override @SneakyThrows public UserDetails loadUserByUsername(String username) { + Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS); + if (cache != null && cache.get(username) != null) { + return (PigxUser) cache.get(username).get(); + } + R result = remoteUserService.info(username, SecurityConstants.FROM_IN); UserDetails userDetails = getUserDetails(result); + cache.put(username, userDetails); return userDetails; } From ec6abd4eac2340044d73372ddfa5bc8b1340d9ea Mon Sep 17 00:00:00 2001 From: chenjun Date: Thu, 16 Jan 2020 20:58:54 +0800 Subject: [PATCH 012/130] speed up maven plugin download --- pigx-common/pigx-common-bom/pom.xml | 13 +++++++++++++ pom.xml | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index a912c9bbb..8582885f3 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -159,4 +159,17 @@ + + + + aliyun-plugin + https://maven.aliyun.com/repository/public + + true + + + false + + + diff --git a/pom.xml b/pom.xml index 990127bac..520e17b22 100644 --- a/pom.xml +++ b/pom.xml @@ -229,6 +229,19 @@ + + + aliyun-plugin + https://maven.aliyun.com/repository/public + + true + + + false + + + + From 619f5ffab459ef9f4c8900f763258a8550f53af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sat, 18 Jan 2020 16:42:40 +0800 Subject: [PATCH 013/130] =?UTF-8?q?:whale:=20Work=20about=20Docker.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9docker=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/Dockerfile | 16 +++---- docker-compose.yml | 42 ++++++------------ pigx-auth/Dockerfile | 2 +- pigx-auth/pom.xml | 4 +- pigx-common/pigx-common-bom/pom.xml | 6 +-- pigx-common/pigx-common-core/pom.xml | 2 +- pigx-common/pigx-common-data/pom.xml | 2 +- pigx-common/pigx-common-datasource/pom.xml | 2 +- pigx-common/pigx-common-gateway/pom.xml | 2 +- pigx-common/pigx-common-gray/pom.xml | 2 +- pigx-common/pigx-common-job/pom.xml | 2 +- pigx-common/pigx-common-log/pom.xml | 2 +- pigx-common/pigx-common-minio/pom.xml | 2 +- pigx-common/pigx-common-security/pom.xml | 2 +- pigx-common/pigx-common-sentinel/pom.xml | 2 +- pigx-common/pigx-common-sequence/pom.xml | 2 +- pigx-common/pigx-common-swagger/pom.xml | 2 +- pigx-common/pigx-common-transaction/pom.xml | 2 +- pigx-common/pom.xml | 2 +- pigx-gateway/Dockerfile | 2 +- pigx-gateway/pom.xml | 4 +- .../config/RouterFunctionConfiguration.java | 6 +-- pigx-register/Dockerfile | 2 +- pigx-register/pom.xml | 4 +- pigx-upms/pigx-upms-api/pom.xml | 2 +- .../api/entity/SysOauthClientDetails.java | 4 +- pigx-upms/pigx-upms-biz/Dockerfile | 2 +- pigx-upms/pigx-upms-biz/pom.xml | 4 +- pigx-upms/pom.xml | 2 +- pigx-visual/pigx-codegen/Dockerfile | 2 +- pigx-visual/pigx-codegen/pom.xml | 4 +- .../pigx-daemon-elastic-job/Dockerfile | 2 +- pigx-visual/pigx-daemon-elastic-job/pom.xml | 4 +- pigx-visual/pigx-daemon-quartz/Dockerfile | 2 +- pigx-visual/pigx-daemon-quartz/pom.xml | 4 +- pigx-visual/pigx-monitor/Dockerfile | 2 +- pigx-visual/pigx-monitor/pom.xml | 4 +- pigx-visual/pigx-mp-platform/.rebel.xml.bak | 14 ------ pigx-visual/pigx-mp-platform/Dockerfile | 2 +- pigx-visual/pigx-mp-platform/pom.xml | 4 +- pigx-visual/pigx-oa-platform/Dockerfile | 2 +- pigx-visual/pigx-oa-platform/pom.xml | 4 +- pigx-visual/pigx-pay-platform/Dockerfile | 2 +- pigx-visual/pigx-pay-platform/pom.xml | 4 +- .../pigx-sentinel-dashboard/Dockerfile | 2 +- pigx-visual/pigx-sentinel-dashboard/pom.xml | 4 +- .../src/main/resources/application.yml | 3 +- pigx-visual/pigx-sso-client-demo/pom.xml | 2 +- pigx-visual/pigx-tx-manager/Dockerfile | 2 +- pigx-visual/pigx-tx-manager/pom.xml | 2 +- pigx-visual/pom.xml | 2 +- pom.xml | 43 +++++++++++-------- 52 files changed, 113 insertions(+), 133 deletions(-) delete mode 100644 pigx-visual/pigx-mp-platform/.rebel.xml.bak diff --git a/db/Dockerfile b/db/Dockerfile index d37855415..93b66c750 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -4,18 +4,18 @@ MAINTAINER lengleng(wangiegie@gmail.com) RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -COPY ./db/1schema.sql /docker-entrypoint-initdb.d +COPY ./1schema.sql /docker-entrypoint-initdb.d -COPY ./db/2pigxx.sql /docker-entrypoint-initdb.d +COPY ./2pigxx.sql /docker-entrypoint-initdb.d -COPY ./db/3pigxx_ac.sql /docker-entrypoint-initdb.d +COPY ./3pigxx_ac.sql /docker-entrypoint-initdb.d -COPY ./db/4pigxx_job.sql /docker-entrypoint-initdb.d +COPY ./4pigxx_job.sql /docker-entrypoint-initdb.d -COPY ./db/5pigxx_mp.sql /docker-entrypoint-initdb.d +COPY ./5pigxx_mp.sql /docker-entrypoint-initdb.d -COPY ./db/6pigxx_config.sql /docker-entrypoint-initdb.d +COPY ./6pigxx_config.sql /docker-entrypoint-initdb.d -COPY ./db/7pigxx_pay.sql /docker-entrypoint-initdb.d +COPY ./7pigxx_pay.sql /docker-entrypoint-initdb.d -COPY ./db/8pigxx_codegen.sql /docker-entrypoint-initdb.d \ No newline at end of file +COPY ./8pigxx_codegen.sql /docker-entrypoint-initdb.d \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9331f1fb4..18f524e01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,7 @@ version: '2' services: pigx-mysql: build: - context: ./ - dockerfile: ./db/Dockerfile + context: ./db environment: MYSQL_ROOT_PASSWORD: root restart: always @@ -57,8 +56,7 @@ services: pigx-register: build: - context: ./ - dockerfile: ./pigx-register/Dockerfile + context: ./pigx-register restart: always container_name: pigx-register image: pigx-register @@ -67,8 +65,7 @@ services: pigx-gateway: build: - context: ./ - dockerfile: ./pigx-gateway/Dockerfile + context: ./pigx-gateway restart: always container_name: pigx-gateway image: pigx-gateway @@ -77,24 +74,21 @@ services: pigx-auth: build: - context: ./ - dockerfile: ./pigx-auth/Dockerfile + context: ./pigx-auth restart: always container_name: pigx-auth image: pigx-auth pigx-upms: build: - context: ./ - dockerfile: ./pigx-upms/pigx-upms-biz/Dockerfile + context: ./pigx-upms/pigx-upms-biz restart: always container_name: pigx-upms image: pigx-upms pigx-monitor: build: - context: ./ - dockerfile: ./pigx-visual/pigx-monitor/Dockerfile + context: ./pigx-visual/pigx-monitor restart: always image: pigx-monitor container_name: pigx-monitor @@ -103,56 +97,49 @@ services: pigx-daemon-quartz: build: - context: ./ - dockerfile: ./pigx-visual/pigx-daemon-quartz/Dockerfile + context: ./pigx-visual/pigx-daemon-quartz restart: always image: pigx-daemon-quartz container_name: pigx-daemon-quartz pigx-daemon-elastic-job: build: - context: ./ - dockerfile: ./pigx-visual/pigx-daemon-elastic-job/Dockerfile + context: ./pigx-visual/pigx-daemon-elastic-job restart: always image: pigx-daemon-elastic-job container_name: pigx-daemon-elastic-job pigx-codegen: build: - context: ./ - dockerfile: ./pigx-visual/pigx-codegen/Dockerfile + context: ./pigx-visual/pigx-codegen restart: always image: pigx-codegen container_name: pigx-codegen pigx-mp-platform: build: - context: ./ - dockerfile: ./pigx-visual/pigx-mp-platform/Dockerfile + context: ./pigx-visual/pigx-mp-platform restart: always image: pigx-mp-platform container_name: pigx-mp-platform pigx-pay-platform: build: - context: ./ - dockerfile: ./pigx-visual/pigx-pay-platform/Dockerfile + context: ./pigx-visual/pigx-pay-platform restart: always image: pigx-pay-platform container_name: pigx-pay-platform pigx-oa-platform: build: - context: ./ - dockerfile: ./pigx-visual/pigx-oa-platform/Dockerfile + context: ./pigx-visual/pigx-oa-platform restart: always image: pigx-oa-platform container_name: pigx-oa-platform pigx-tx-manager: build: - context: ./ - dockerfile: ./pigx-visual/pigx-tx-manager/Dockerfile + context: ./pigx-visual/pigx-tx-manager restart: always image: pigx-tx-manager container_name: pigx-tx-manager @@ -162,8 +149,7 @@ services: pigx-sentinel: build: - context: ./ - dockerfile: ./pigx-visual/pigx-sentinel-dashboard/Dockerfile + context: ./pigx-visual/pigx-sentinel-dashboard restart: always image: pigx-sentinel container_name: pigx-sentinel diff --git a/pigx-auth/Dockerfile b/pigx-auth/Dockerfile index 0d3b938e0..29eb6d65f 100644 --- a/pigx-auth/Dockerfile +++ b/pigx-auth/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-auth EXPOSE 3000 -ADD ./pigx-auth/target/pigx-auth.jar ./ +ADD ./target/pigx-auth.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-auth.jar diff --git a/pigx-auth/pom.xml b/pigx-auth/pom.xml index 0adc34f60..fbb50c7a2 100644 --- a/pigx-auth/pom.xml +++ b/pigx-auth/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-auth @@ -107,7 +107,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index 73e9930db..40bba17ee 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -17,8 +17,8 @@ pigx 公共版本控制 - 3.6.0 - 3.3.0 + 3.7.0 + 3.3.1 1.1.21 8.0.18 1.5.22 @@ -152,7 +152,7 @@ com.pig4cloud.plugin spring-cloud-maven-plugin - 1.0.0 + 1.0.1 package diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml index e5127da49..73df2e903 100644 --- a/pigx-common/pigx-common-core/pom.xml +++ b/pigx-common/pigx-common-core/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-core diff --git a/pigx-common/pigx-common-data/pom.xml b/pigx-common/pigx-common-data/pom.xml index 6159ce3ce..e66a9f2f3 100644 --- a/pigx-common/pigx-common-data/pom.xml +++ b/pigx-common/pigx-common-data/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-data diff --git a/pigx-common/pigx-common-datasource/pom.xml b/pigx-common/pigx-common-datasource/pom.xml index 0725599d5..d8703af69 100644 --- a/pigx-common/pigx-common-datasource/pom.xml +++ b/pigx-common/pigx-common-datasource/pom.xml @@ -5,7 +5,7 @@ pigx-common com.pig4cloud - 3.6.0 + 3.7.0 4.0.0 diff --git a/pigx-common/pigx-common-gateway/pom.xml b/pigx-common/pigx-common-gateway/pom.xml index c97fff40c..5688cdff9 100644 --- a/pigx-common/pigx-common-gateway/pom.xml +++ b/pigx-common/pigx-common-gateway/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-gateway diff --git a/pigx-common/pigx-common-gray/pom.xml b/pigx-common/pigx-common-gray/pom.xml index 343520e64..ffa07c47e 100644 --- a/pigx-common/pigx-common-gray/pom.xml +++ b/pigx-common/pigx-common-gray/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-gray diff --git a/pigx-common/pigx-common-job/pom.xml b/pigx-common/pigx-common-job/pom.xml index 2db6a36fd..d78d7d9a6 100644 --- a/pigx-common/pigx-common-job/pom.xml +++ b/pigx-common/pigx-common-job/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-job diff --git a/pigx-common/pigx-common-log/pom.xml b/pigx-common/pigx-common-log/pom.xml index b73fb8640..26d0deb9a 100644 --- a/pigx-common/pigx-common-log/pom.xml +++ b/pigx-common/pigx-common-log/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-log diff --git a/pigx-common/pigx-common-minio/pom.xml b/pigx-common/pigx-common-minio/pom.xml index 7f14d1a01..d0c0e2104 100755 --- a/pigx-common/pigx-common-minio/pom.xml +++ b/pigx-common/pigx-common-minio/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-minio diff --git a/pigx-common/pigx-common-security/pom.xml b/pigx-common/pigx-common-security/pom.xml index 2521e7fab..2fc4ac855 100644 --- a/pigx-common/pigx-common-security/pom.xml +++ b/pigx-common/pigx-common-security/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-security diff --git a/pigx-common/pigx-common-sentinel/pom.xml b/pigx-common/pigx-common-sentinel/pom.xml index 349b437e4..bf214eac4 100755 --- a/pigx-common/pigx-common-sentinel/pom.xml +++ b/pigx-common/pigx-common-sentinel/pom.xml @@ -5,7 +5,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 4.0.0 diff --git a/pigx-common/pigx-common-sequence/pom.xml b/pigx-common/pigx-common-sequence/pom.xml index f33ab5f03..4cd443a51 100755 --- a/pigx-common/pigx-common-sequence/pom.xml +++ b/pigx-common/pigx-common-sequence/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-sequence diff --git a/pigx-common/pigx-common-swagger/pom.xml b/pigx-common/pigx-common-swagger/pom.xml index 0b122d958..76c21e5db 100644 --- a/pigx-common/pigx-common-swagger/pom.xml +++ b/pigx-common/pigx-common-swagger/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-swagger diff --git a/pigx-common/pigx-common-transaction/pom.xml b/pigx-common/pigx-common-transaction/pom.xml index 3d70feadc..88f21b515 100644 --- a/pigx-common/pigx-common-transaction/pom.xml +++ b/pigx-common/pigx-common-transaction/pom.xml @@ -5,7 +5,7 @@ com.pig4cloud pigx-common - 3.6.0 + 3.7.0 pigx-common-transaction diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml index 7d2bcbf31..fbea41d91 100644 --- a/pigx-common/pom.xml +++ b/pigx-common/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-common diff --git a/pigx-gateway/Dockerfile b/pigx-gateway/Dockerfile index 8333b52c2..43b1df2d7 100644 --- a/pigx-gateway/Dockerfile +++ b/pigx-gateway/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-gateway EXPOSE 9999 -ADD ./pigx-gateway/target/pigx-gateway.jar ./ +ADD ./target/pigx-gateway.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-gateway.jar diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml index c97f8f620..b6120b475 100644 --- a/pigx-gateway/pom.xml +++ b/pigx-gateway/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-gateway @@ -103,7 +103,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java index 2b46c6c55..df089e42f 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java @@ -21,7 +21,7 @@ import com.pig4cloud.pigx.gateway.handler.ImageCodeHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerResourceHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerSecurityHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerUiHandler; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,12 +37,12 @@ import org.springframework.web.reactive.function.server.RouterFunctions; */ @Slf4j @Configuration -@AllArgsConstructor +@RequiredArgsConstructor public class RouterFunctionConfiguration { private final SwaggerResourceHandler swaggerResourceHandler; private final SwaggerSecurityHandler swaggerSecurityHandler; private final SwaggerUiHandler swaggerUiHandler; - private final ImageCodeHandler imageCodeHandler; + private ImageCodeHandler imageCodeHandler; @Bean public RouterFunction routerFunction() { diff --git a/pigx-register/Dockerfile b/pigx-register/Dockerfile index 00e73b26e..e34b0f879 100644 --- a/pigx-register/Dockerfile +++ b/pigx-register/Dockerfile @@ -10,7 +10,7 @@ WORKDIR /pigx-register EXPOSE 8848 -ADD ./pigx-register/target/pigx-register.jar ./ +ADD ./target/pigx-register.jar ./ CMD sleep 60;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-register.jar diff --git a/pigx-register/pom.xml b/pigx-register/pom.xml index 11ca0bcfb..44c4c339e 100755 --- a/pigx-register/pom.xml +++ b/pigx-register/pom.xml @@ -18,7 +18,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-register @@ -71,7 +71,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml index 8374f78af..8ac0af4ea 100644 --- a/pigx-upms/pigx-upms-api/pom.xml +++ b/pigx-upms/pigx-upms-api/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-upms - 3.6.0 + 3.7.0 pigx-upms-api diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java index ee50284cf..99d67b30a 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java @@ -68,10 +68,10 @@ public class SysOauthClientDetails extends Model { @ApiModelProperty(value = "作用域") private String scope; /** - * 授权方式(A,B,C) + * 授权方式[A,B,C] */ @ApiModelProperty(value = "授权方式") - private String authorizedGrantTypes; + private String[] authorizedGrantTypes; /** * 回调地址 */ diff --git a/pigx-upms/pigx-upms-biz/Dockerfile b/pigx-upms/pigx-upms-biz/Dockerfile index a5cab04bc..1662f32c2 100644 --- a/pigx-upms/pigx-upms-biz/Dockerfile +++ b/pigx-upms/pigx-upms-biz/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-upms EXPOSE 4000 -ADD ./pigx-upms/pigx-upms-biz/target/pigx-upms-biz.jar ./ +ADD ./target/pigx-upms-biz.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-upms-biz.jar diff --git a/pigx-upms/pigx-upms-biz/pom.xml b/pigx-upms/pigx-upms-biz/pom.xml index 431898c68..c4e4f9888 100644 --- a/pigx-upms/pigx-upms-biz/pom.xml +++ b/pigx-upms/pigx-upms-biz/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-upms - 3.6.0 + 3.7.0 pigx-upms-biz @@ -121,7 +121,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-upms/pom.xml b/pigx-upms/pom.xml index 62547ba5a..0296cdf6b 100644 --- a/pigx-upms/pom.xml +++ b/pigx-upms/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-upms diff --git a/pigx-visual/pigx-codegen/Dockerfile b/pigx-visual/pigx-codegen/Dockerfile index cd8188629..0fa2f9a56 100644 --- a/pigx-visual/pigx-codegen/Dockerfile +++ b/pigx-visual/pigx-codegen/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-codegen EXPOSE 5003 -ADD ./pigx-visual/pigx-codegen/target/pigx-codegen.jar ./ +ADD ./target/pigx-codegen.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-codegen.jar diff --git a/pigx-visual/pigx-codegen/pom.xml b/pigx-visual/pigx-codegen/pom.xml index 923e0850b..559d0fce8 100755 --- a/pigx-visual/pigx-codegen/pom.xml +++ b/pigx-visual/pigx-codegen/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-codegen @@ -93,7 +93,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-daemon-elastic-job/Dockerfile b/pigx-visual/pigx-daemon-elastic-job/Dockerfile index 47419db58..9926c1653 100644 --- a/pigx-visual/pigx-daemon-elastic-job/Dockerfile +++ b/pigx-visual/pigx-daemon-elastic-job/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-daemon-elastic-job EXPOSE 5002 -ADD ./pigx-visual/pigx-daemon-elastic-job/target/pigx-daemon-elastic-job.jar ./ +ADD ./target/pigx-daemon-elastic-job.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-daemon-elastic-job.jar diff --git a/pigx-visual/pigx-daemon-elastic-job/pom.xml b/pigx-visual/pigx-daemon-elastic-job/pom.xml index 054d7e5f4..1f6c3b236 100644 --- a/pigx-visual/pigx-daemon-elastic-job/pom.xml +++ b/pigx-visual/pigx-daemon-elastic-job/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-daemon-elastic-job @@ -110,7 +110,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-daemon-quartz/Dockerfile b/pigx-visual/pigx-daemon-quartz/Dockerfile index 3305ac04b..c5f86e69f 100644 --- a/pigx-visual/pigx-daemon-quartz/Dockerfile +++ b/pigx-visual/pigx-daemon-quartz/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-daemon-quartz EXPOSE 5007 -ADD ./pigx-visual/pigx-daemon-quartz/target/pigx-daemon-quartz.jar ./ +ADD ./target/pigx-daemon-quartz.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-daemon-quartz.jar diff --git a/pigx-visual/pigx-daemon-quartz/pom.xml b/pigx-visual/pigx-daemon-quartz/pom.xml index d04cce9ee..1fef99056 100644 --- a/pigx-visual/pigx-daemon-quartz/pom.xml +++ b/pigx-visual/pigx-daemon-quartz/pom.xml @@ -5,7 +5,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 4.0.0 @@ -88,7 +88,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-monitor/Dockerfile b/pigx-visual/pigx-monitor/Dockerfile index 3ebf8dbb2..09f633248 100644 --- a/pigx-visual/pigx-monitor/Dockerfile +++ b/pigx-visual/pigx-monitor/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-monitor EXPOSE 5001 -ADD ./pigx-visual/pigx-monitor/target/pigx-monitor.jar ./ +ADD ./target/pigx-monitor.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-monitor.jar diff --git a/pigx-visual/pigx-monitor/pom.xml b/pigx-visual/pigx-monitor/pom.xml index 5f7497b17..40dfb2d73 100644 --- a/pigx-visual/pigx-monitor/pom.xml +++ b/pigx-visual/pigx-monitor/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-monitor @@ -91,7 +91,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-mp-platform/.rebel.xml.bak b/pigx-visual/pigx-mp-platform/.rebel.xml.bak deleted file mode 100644 index d9e3a84dc..000000000 --- a/pigx-visual/pigx-mp-platform/.rebel.xml.bak +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - -

- - - - diff --git a/pigx-visual/pigx-mp-platform/Dockerfile b/pigx-visual/pigx-mp-platform/Dockerfile index e8f380a59..c3fb3eff4 100644 --- a/pigx-visual/pigx-mp-platform/Dockerfile +++ b/pigx-visual/pigx-mp-platform/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-mp-platform EXPOSE 6000 -ADD ./pigx-visual/pigx-mp-platform/target/pigx-mp-platform.jar ./ +ADD ./target/pigx-mp-platform.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-mp-platform.jar diff --git a/pigx-visual/pigx-mp-platform/pom.xml b/pigx-visual/pigx-mp-platform/pom.xml index 16d92498a..b8ab54fcd 100755 --- a/pigx-visual/pigx-mp-platform/pom.xml +++ b/pigx-visual/pigx-mp-platform/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-mp-platform @@ -92,7 +92,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-oa-platform/Dockerfile b/pigx-visual/pigx-oa-platform/Dockerfile index 34bcfe2e2..e1808e710 100644 --- a/pigx-visual/pigx-oa-platform/Dockerfile +++ b/pigx-visual/pigx-oa-platform/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-oa-platform EXPOSE 5005 -ADD ./pigx-visual/pigx-oa-platform/target/pigx-oa-platform.jar ./ +ADD ./target/pigx-oa-platform.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-oa-platform.jar diff --git a/pigx-visual/pigx-oa-platform/pom.xml b/pigx-visual/pigx-oa-platform/pom.xml index 89c02b71f..6b6b52d3b 100644 --- a/pigx-visual/pigx-oa-platform/pom.xml +++ b/pigx-visual/pigx-oa-platform/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-oa-platform @@ -150,7 +150,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-pay-platform/Dockerfile b/pigx-visual/pigx-pay-platform/Dockerfile index 255ac7f48..84b81bda9 100644 --- a/pigx-visual/pigx-pay-platform/Dockerfile +++ b/pigx-visual/pigx-pay-platform/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-pay-platform EXPOSE 5010 -ADD ./pigx-visual/pigx-pay-platform/target/pigx-pay-platform.jar ./ +ADD ./target/pigx-pay-platform.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-pay-platform.jar diff --git a/pigx-visual/pigx-pay-platform/pom.xml b/pigx-visual/pigx-pay-platform/pom.xml index 9f80dafe9..8320800f7 100755 --- a/pigx-visual/pigx-pay-platform/pom.xml +++ b/pigx-visual/pigx-pay-platform/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-pay-platform @@ -110,7 +110,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-sentinel-dashboard/Dockerfile b/pigx-visual/pigx-sentinel-dashboard/Dockerfile index 89f3ae7d5..f92f55c59 100644 --- a/pigx-visual/pigx-sentinel-dashboard/Dockerfile +++ b/pigx-visual/pigx-sentinel-dashboard/Dockerfile @@ -10,6 +10,6 @@ WORKDIR /pigx-sentinel-dashboard EXPOSE 5020 -ADD ./pigx-visual/pigx-sentinel-dashboard/target/pigx-sentinel-dashboard.jar ./ +ADD ./target/pigx-sentinel-dashboard.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-sentinel-dashboard.jar diff --git a/pigx-visual/pigx-sentinel-dashboard/pom.xml b/pigx-visual/pigx-sentinel-dashboard/pom.xml index 4cbccc614..bdcff7a92 100755 --- a/pigx-visual/pigx-sentinel-dashboard/pom.xml +++ b/pigx-visual/pigx-sentinel-dashboard/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-sentinel-dashboard @@ -109,7 +109,7 @@ spring-boot-maven-plugin - com.spotify + io.fabric8 docker-maven-plugin diff --git a/pigx-visual/pigx-sentinel-dashboard/src/main/resources/application.yml b/pigx-visual/pigx-sentinel-dashboard/src/main/resources/application.yml index ed72d6d2c..d87941658 100755 --- a/pigx-visual/pigx-sentinel-dashboard/src/main/resources/application.yml +++ b/pigx-visual/pigx-sentinel-dashboard/src/main/resources/application.yml @@ -10,7 +10,8 @@ logging: org: springframework: web: info - file: ${user.home}/logs/csp/sentinel-dashboard.log + file: + name: ${user.home}/logs/csp/sentinel-dashboard.log pattern: file: '%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n' diff --git a/pigx-visual/pigx-sso-client-demo/pom.xml b/pigx-visual/pigx-sso-client-demo/pom.xml index 801b54a80..34fac1a40 100644 --- a/pigx-visual/pigx-sso-client-demo/pom.xml +++ b/pigx-visual/pigx-sso-client-demo/pom.xml @@ -29,7 +29,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 diff --git a/pigx-visual/pigx-tx-manager/Dockerfile b/pigx-visual/pigx-tx-manager/Dockerfile index 6b80fa3a9..beddc57dc 100644 --- a/pigx-visual/pigx-tx-manager/Dockerfile +++ b/pigx-visual/pigx-tx-manager/Dockerfile @@ -11,6 +11,6 @@ WORKDIR /pigx-tx-manager EXPOSE 5004 EXPOSE 9998 -ADD ./pigx-visual/pigx-tx-manager/target/pigx-tx-manager.jar ./ +ADD ./target/pigx-tx-manager.jar ./ CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-tx-manager.jar diff --git a/pigx-visual/pigx-tx-manager/pom.xml b/pigx-visual/pigx-tx-manager/pom.xml index eb38c7007..a3dd26431 100644 --- a/pigx-visual/pigx-tx-manager/pom.xml +++ b/pigx-visual/pigx-tx-manager/pom.xml @@ -5,7 +5,7 @@ com.pig4cloud pigx-visual - 3.6.0 + 3.7.0 pigx-tx-manager diff --git a/pigx-visual/pom.xml b/pigx-visual/pom.xml index a8ea3b63e..f111e637c 100644 --- a/pigx-visual/pom.xml +++ b/pigx-visual/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 pigx-visual diff --git a/pom.xml b/pom.xml index 990127bac..6f4ce2d79 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pigx - 3.6.0 + 3.7.0 ${project.artifactId} pom @@ -33,7 +33,7 @@ - 2.2.2.RELEASE + 2.2.3.RELEASE Hoxton.SR1 2.1.1.RELEASE Cairo-SR8 @@ -55,9 +55,12 @@ 2.1.1 2.3.6.RELEASE 5.22.0 - http://192.168.0.13:4243 - 0.4.12 - 192.168.0.13:5000 + http://172.17.0.111:2375 + 172.17.0.111 + library + admin + Harbor12345 + 0.32.0 @@ -190,22 +193,26 @@ - com.spotify + io.fabric8 docker-maven-plugin ${docker.plugin.version} - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ + ${docker.host} + ${docker.registry} + + + ${docker.username} + ${docker.password} + + + + + ${docker.host}/${docker.namespace}/${project.name}:${project.version} + + ${project.basedir}/Dockerfile + + + From 7a815e6d4ca9f09782eddf730c54e039fbfa2c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 30 Jan 2020 12:38:26 +0800 Subject: [PATCH 014/130] =?UTF-8?q?:whale:=20Work=20about=20Docker.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9docker=20=E6=97=B6=E5=8C=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/Dockerfile | 4 +++- pigx-auth/Dockerfile | 4 +++- pigx-gateway/Dockerfile | 4 +++- pigx-register/Dockerfile | 4 +++- pigx-upms/pigx-upms-biz/Dockerfile | 4 +++- pigx-visual/pigx-codegen/Dockerfile | 4 +++- pigx-visual/pigx-daemon-elastic-job/Dockerfile | 4 +++- pigx-visual/pigx-daemon-quartz/Dockerfile | 4 +++- pigx-visual/pigx-monitor/Dockerfile | 4 +++- pigx-visual/pigx-mp-platform/Dockerfile | 4 +++- pigx-visual/pigx-oa-platform/Dockerfile | 4 +++- pigx-visual/pigx-pay-platform/Dockerfile | 6 ++++-- pigx-visual/pigx-sentinel-dashboard/Dockerfile | 4 +++- pigx-visual/pigx-tx-manager/Dockerfile | 4 +++- 14 files changed, 43 insertions(+), 15 deletions(-) diff --git a/db/Dockerfile b/db/Dockerfile index 93b66c750..6faa763fc 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -2,7 +2,9 @@ FROM mysql:8.0.18 MAINTAINER lengleng(wangiegie@gmail.com) -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone COPY ./1schema.sql /docker-entrypoint-initdb.d diff --git a/pigx-auth/Dockerfile b/pigx-auth/Dockerfile index 29eb6d65f..c570176d3 100644 --- a/pigx-auth/Dockerfile +++ b/pigx-auth/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-auth diff --git a/pigx-gateway/Dockerfile b/pigx-gateway/Dockerfile index 43b1df2d7..63aa59b15 100644 --- a/pigx-gateway/Dockerfile +++ b/pigx-gateway/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-gateway diff --git a/pigx-register/Dockerfile b/pigx-register/Dockerfile index e34b0f879..91bc34faa 100644 --- a/pigx-register/Dockerfile +++ b/pigx-register/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-register diff --git a/pigx-upms/pigx-upms-biz/Dockerfile b/pigx-upms/pigx-upms-biz/Dockerfile index 1662f32c2..7a20fc804 100644 --- a/pigx-upms/pigx-upms-biz/Dockerfile +++ b/pigx-upms/pigx-upms-biz/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-upms diff --git a/pigx-visual/pigx-codegen/Dockerfile b/pigx-visual/pigx-codegen/Dockerfile index 0fa2f9a56..0c7b4da73 100644 --- a/pigx-visual/pigx-codegen/Dockerfile +++ b/pigx-visual/pigx-codegen/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-codegen diff --git a/pigx-visual/pigx-daemon-elastic-job/Dockerfile b/pigx-visual/pigx-daemon-elastic-job/Dockerfile index 9926c1653..a07f1eeb2 100644 --- a/pigx-visual/pigx-daemon-elastic-job/Dockerfile +++ b/pigx-visual/pigx-daemon-elastic-job/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-daemon-elastic-job diff --git a/pigx-visual/pigx-daemon-quartz/Dockerfile b/pigx-visual/pigx-daemon-quartz/Dockerfile index c5f86e69f..e114f60de 100644 --- a/pigx-visual/pigx-daemon-quartz/Dockerfile +++ b/pigx-visual/pigx-daemon-quartz/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-daemon-quartz diff --git a/pigx-visual/pigx-monitor/Dockerfile b/pigx-visual/pigx-monitor/Dockerfile index 09f633248..b59f6f983 100644 --- a/pigx-visual/pigx-monitor/Dockerfile +++ b/pigx-visual/pigx-monitor/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-monitor diff --git a/pigx-visual/pigx-mp-platform/Dockerfile b/pigx-visual/pigx-mp-platform/Dockerfile index c3fb3eff4..24d3921ad 100644 --- a/pigx-visual/pigx-mp-platform/Dockerfile +++ b/pigx-visual/pigx-mp-platform/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-pay-platform diff --git a/pigx-visual/pigx-oa-platform/Dockerfile b/pigx-visual/pigx-oa-platform/Dockerfile index e1808e710..e2b3b538c 100644 --- a/pigx-visual/pigx-oa-platform/Dockerfile +++ b/pigx-visual/pigx-oa-platform/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-oa-platform diff --git a/pigx-visual/pigx-pay-platform/Dockerfile b/pigx-visual/pigx-pay-platform/Dockerfile index 84b81bda9..b1ccc45a8 100644 --- a/pigx-visual/pigx-pay-platform/Dockerfile +++ b/pigx-visual/pigx-pay-platform/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-pay-platform @@ -12,4 +14,4 @@ EXPOSE 5010 ADD ./target/pigx-pay-platform.jar ./ -CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-pay-platform.jar +CMD sleep 180;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-pay-platform.jar diff --git a/pigx-visual/pigx-sentinel-dashboard/Dockerfile b/pigx-visual/pigx-sentinel-dashboard/Dockerfile index f92f55c59..9cf73c1cd 100644 --- a/pigx-visual/pigx-sentinel-dashboard/Dockerfile +++ b/pigx-visual/pigx-sentinel-dashboard/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-sentinel-dashboard diff --git a/pigx-visual/pigx-tx-manager/Dockerfile b/pigx-visual/pigx-tx-manager/Dockerfile index beddc57dc..af7dc41b5 100644 --- a/pigx-visual/pigx-tx-manager/Dockerfile +++ b/pigx-visual/pigx-tx-manager/Dockerfile @@ -2,7 +2,9 @@ FROM java:8-jre MAINTAINER wangiegie@gmail.com -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENV TZ=Asia/Shanghai + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN mkdir -p /pigx-tx-manager From 2a839a56f0cc8185d43dad79b193150b54182cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 30 Jan 2020 12:39:17 +0800 Subject: [PATCH 015/130] =?UTF-8?q?:sparkles:=20Introducing=20new=20featur?= =?UTF-8?q?es.=20=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=94=AF=E6=8C=81=20?= =?UTF-8?q?element=20=E5=8E=9F=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/constant/enums/StyleTypeEnum.java | 33 +++++ .../pigx/codegen/entity/GenConfig.java | 7 + .../service/impl/GenFormConfServiceImpl.java | 2 +- .../pig4cloud/pigx/codegen/util/GenUtils.java | 44 ++++-- .../resources/template/{ => avue}/api.js.vm | 0 .../resources/template/{ => avue}/crud.js.vm | 0 .../template/{ => avue}/index.vue.vm | 0 .../template/element/add-or-update.vue.vm | 86 ++++++++++++ .../resources/template/element/index.vue.vm | 126 ++++++++++++++++++ 9 files changed, 285 insertions(+), 13 deletions(-) create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java rename pigx-visual/pigx-codegen/src/main/resources/template/{ => avue}/api.js.vm (100%) rename pigx-visual/pigx-codegen/src/main/resources/template/{ => avue}/crud.js.vm (100%) rename pigx-visual/pigx-codegen/src/main/resources/template/{ => avue}/index.vue.vm (100%) create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/element/add-or-update.vue.vm create mode 100644 pigx-visual/pigx-codegen/src/main/resources/template/element/index.vue.vm 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 new file mode 100644 index 000000000..0e776f828 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/StyleTypeEnum.java @@ -0,0 +1,33 @@ +package com.pig4cloud.pigx.common.core.constant.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author lengleng + * @date 2020-01-19 + *

+ * 前端类型类型 + */ +@Getter +@AllArgsConstructor +public enum StyleTypeEnum { + /** + * 前端类型-avue 风格 + */ + AVUE("0", "avue 风格"), + + /** + * 前端类型-element 风格 + */ + ELEMENT("1", "element 风格"); + + /** + * 类型 + */ + private String style; + /** + * 描述 + */ + private String description; +} 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 cb270c897..579c45730 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 @@ -56,4 +56,11 @@ public class GenConfig { * 表备注 */ private String comments; + + /** + * 代码风格 + * 0 - avue + * 1 - element + */ + private String style; } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java index 690c4c465..ef7df6c9a 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java @@ -78,7 +78,7 @@ public class GenFormConfServiceImpl extends ServiceImpl columnList = new ArrayList<>(); 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 26a55a4bf..73e03c9ac 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 @@ -26,6 +26,7 @@ import com.pig4cloud.pigx.codegen.entity.GenConfig; import com.pig4cloud.pigx.codegen.entity.GenFormConf; import com.pig4cloud.pigx.codegen.entity.TableEntity; import com.pig4cloud.pigx.common.core.constant.CommonConstants; +import com.pig4cloud.pigx.common.core.constant.enums.StyleTypeEnum; import com.pig4cloud.pigx.common.core.exception.CheckedException; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; @@ -63,11 +64,19 @@ public class GenUtils { private final String CONTROLLER_JAVA_VM = "Controller.java.vm"; private final String MAPPER_XML_VM = "Mapper.xml.vm"; private final String MENU_SQL_VM = "menu.sql.vm"; - private final String INDEX_VUE_VM = "index.vue.vm"; - private final String API_JS_VM = "api.js.vm"; - private final String CRUD_JS_VM = "crud.js.vm"; + private final String AVUE_INDEX_VUE_VM = "avue/index.vue.vm"; + private final String ELE_INDEX_VUE_VM = "element/index.vue.vm"; + private final String ELE_ADD_UPDATE_VUE_VM = "element/add-or-update.vue.vm"; + private final String AVUE_API_JS_VM = "avue/api.js.vm"; + private final String AVUE_CRUD_JS_VM = "avue/crud.js.vm"; - private List getTemplates() { + /** + * 配置 + * + * @param config + * @return + */ + private List getTemplates(GenConfig config) { List templates = new ArrayList<>(); templates.add("template/Entity.java.vm"); templates.add("template/Mapper.java.vm"); @@ -76,10 +85,16 @@ 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.ELEMENT.getStyle().equals(config.getStyle())) { + templates.add("template/element/index.vue.vm"); + templates.add("template/element/add-or-update.vue.vm"); + } else { + templates.add("template/avue/index.vue.vm"); + templates.add("template/avue/crud.js.vm"); + } - templates.add("template/index.vue.vm"); - templates.add("template/api.js.vm"); - templates.add("template/crud.js.vm"); return templates; } @@ -199,10 +214,10 @@ public class GenUtils { VelocityContext context = new VelocityContext(map); //获取模板列表 - List templates = getTemplates(); + List templates = getTemplates(genConfig); for (String template : templates) { // 如果是crud - if (template.contains(CRUD_JS_VM) && formConf != null) { + if (template.contains(AVUE_CRUD_JS_VM) && formConf != null) { zip.putNextEntry(new ZipEntry(Objects .requireNonNull(getFileName(template, tableEntity.getCaseClassName() , map.get("package").toString(), map.get("moduleName").toString())))); @@ -293,20 +308,25 @@ public class GenUtils { return className.toLowerCase() + "_menu.sql"; } - if (template.contains(INDEX_VUE_VM)) { + if (template.contains(AVUE_INDEX_VUE_VM) || template.contains(ELE_INDEX_VUE_VM)) { return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + "index.vue"; } - if (template.contains(API_JS_VM)) { + if (template.contains(AVUE_API_JS_VM)) { return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js"; } - if (template.contains(CRUD_JS_VM)) { + if (template.contains(AVUE_CRUD_JS_VM)) { return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" + File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; } + if (template.contains(ELE_ADD_UPDATE_VUE_VM)) { + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + moduleName + "-add-or-update.vue"; + } + return null; } } diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/api.js.vm b/pigx-visual/pigx-codegen/src/main/resources/template/avue/api.js.vm similarity index 100% rename from pigx-visual/pigx-codegen/src/main/resources/template/api.js.vm rename to pigx-visual/pigx-codegen/src/main/resources/template/avue/api.js.vm diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm b/pigx-visual/pigx-codegen/src/main/resources/template/avue/crud.js.vm similarity index 100% rename from pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm rename to pigx-visual/pigx-codegen/src/main/resources/template/avue/crud.js.vm diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm similarity index 100% rename from pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm rename to pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/element/add-or-update.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/element/add-or-update.vue.vm new file mode 100644 index 000000000..bef510cdb --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/element/add-or-update.vue.vm @@ -0,0 +1,86 @@ + + + diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/element/index.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/element/index.vue.vm new file mode 100644 index 000000000..ed318be3a --- /dev/null +++ b/pigx-visual/pigx-codegen/src/main/resources/template/element/index.vue.vm @@ -0,0 +1,126 @@ + + + From 6bb7aff4ad575e5c01759afbd8199b521c57eb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 30 Jan 2020 12:39:56 +0800 Subject: [PATCH 016/130] :arrow_up: Upgrading dependencies. spring boot 2.2.4 & mybatis-plus 3.3.1 --- pigx-common/pigx-common-bom/pom.xml | 2 +- pom.xml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index 40bba17ee..8e8a7fe38 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -18,7 +18,7 @@ 3.7.0 - 3.3.1 + 3.3.0 1.1.21 8.0.18 1.5.22 diff --git a/pom.xml b/pom.xml index 6f4ce2d79..2d40a64a5 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ - 2.2.3.RELEASE + 2.2.4.RELEASE Hoxton.SR1 2.1.1.RELEASE Cairo-SR8 @@ -41,7 +41,7 @@ 1.8 1.8 2.2.1 - 5.1.0 + 5.1.1 1.6.2 2.9.2 2.0.1 @@ -55,8 +55,8 @@ 2.1.1 2.3.6.RELEASE 5.22.0 - http://172.17.0.111:2375 - 172.17.0.111 + 172.17.0.111 + http://172.17.0.111:2375 library admin Harbor12345 @@ -207,7 +207,7 @@ - ${docker.host}/${docker.namespace}/${project.name}:${project.version} + ${docker.registry}/${docker.namespace}/${project.name}:${project.version} ${project.basedir}/Dockerfile From 65604d745a5e583cb9f34790fed16fc33bda310a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 30 Jan 2020 12:40:15 +0800 Subject: [PATCH 017/130] =?UTF-8?q?:recycle:=20Refactoring=20code.=20?= =?UTF-8?q?=E9=80=80=E5=87=BA=E4=BB=A4=E7=89=8C=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pigx/auth/endpoint/PigxTokenEndpoint.java | 32 +++++++++---------- .../core/exception/ValidateCodeException.java | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java index 4b087f0e2..148f5103d 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java @@ -124,7 +124,19 @@ public class PigxTokenEndpoint { } String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim(); - OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); + return delToken(tokenValue); + } + + /** + * 令牌管理调用 + * + * @param token token + * @return + */ + @Inner + @DeleteMapping("/{token}") + public R delToken(@PathVariable("token") String token) { + OAuth2AccessToken accessToken = tokenStore.readAccessToken(token); if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) { return R.ok(Boolean.TRUE, "退出失败,token 无效"); } @@ -140,21 +152,7 @@ public class PigxTokenEndpoint { // 清空 refresh token OAuth2RefreshToken refreshToken = accessToken.getRefreshToken(); tokenStore.removeRefreshToken(refreshToken); - return R.ok(Boolean.TRUE); - } - - /** - * 令牌管理调用 - * - * @param token token - * @return - */ - @Inner - @DeleteMapping("/{token}") - public R delToken(@PathVariable("token") String token) { - OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token); - tokenStore.removeAccessToken(oAuth2AccessToken); - return new R<>(); + return R.ok(); } @@ -176,7 +174,7 @@ public class PigxTokenEndpoint { redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); Page result = new Page(MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE)); result.setRecords(redisTemplate.opsForValue().multiGet(pages)); - result.setTotal((long) redisTemplate.keys(key).size()); + result.setTotal(redisTemplate.keys(key).size()); return R.ok(result); } diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java index ea5767f43..896878ea8 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java @@ -23,7 +23,7 @@ package com.pig4cloud.pigx.common.core.exception; * @author lengleng * @date 2018年06月22日16:22:15 */ -public class ValidateCodeException extends Exception { +public class ValidateCodeException extends RuntimeException { private static final long serialVersionUID = -7285211528095468156L; public ValidateCodeException() { From 28e390975e8055017b0b2078ea292e2ef924fc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 6 Feb 2020 16:15:03 +0800 Subject: [PATCH 018/130] =?UTF-8?q?=E6=96=B0=E7=89=B9=E6=80=A7=EF=BC=9A=20?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=A0=91=E5=A2=9E=E5=8A=A0=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java | 10 ++++++++++ .../pigx/admin/service/impl/SysDeptServiceImpl.java | 3 ++- .../src/main/resources/mapper/SysDeptMapper.xml | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java index aeb1e4ae5..e83f7335e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java @@ -21,6 +21,9 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysDept; +import com.pig4cloud.pigx.common.data.datascope.DataScope; + +import java.util.List; /** *

@@ -32,4 +35,11 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept; */ public interface SysDeptMapper extends BaseMapper { + /** + * 根据数据权限查询部门 + * + * @param dataScope + * @return + */ + List listDepts(DataScope dataScope); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java index c0bc0e291..345ebca05 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java @@ -29,6 +29,7 @@ import com.pig4cloud.pigx.admin.api.vo.TreeUtil; import com.pig4cloud.pigx.admin.mapper.SysDeptMapper; import com.pig4cloud.pigx.admin.service.SysDeptRelationService; import com.pig4cloud.pigx.admin.service.SysDeptService; +import com.pig4cloud.pigx.common.data.datascope.DataScope; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -120,7 +121,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl */ @Override public List selectTree() { - return getDeptTree(this.list(Wrappers.emptyWrapper())); + return getDeptTree(baseMapper.listDepts(new DataScope())); } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml index 7f0befa96..013ef26d3 100644 --- a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml @@ -21,4 +21,7 @@ + From d2db31e9bed5c418d70559752d6741fd1f49dd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 6 Feb 2020 16:15:56 +0800 Subject: [PATCH 019/130] =?UTF-8?q?sql:=20=E4=BF=AE=E6=94=B9=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=A7=92=E8=89=B2=E7=9A=84=E6=95=B0=E6=8D=AE=E6=9D=83?= =?UTF-8?q?=E9=99=90an?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 2 +- .../pigx/gateway/config/RouterFunctionConfiguration.java | 6 +++--- pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/2pigxx.sql b/db/2pigxx.sql index cb57a502d..c510277da 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -522,7 +522,7 @@ CREATE TABLE `sys_role` ( -- Records of sys_role -- ---------------------------- BEGIN; -INSERT INTO `sys_role` VALUES (1, '管理员', 'ROLE_ADMIN', '管理员', '3', '2', '2017-10-29 15:45:51', '2018-12-26 14:09:11', '0', 1); +INSERT INTO `sys_role` VALUES (1, '管理员', 'ROLE_ADMIN', '管理员', '0', '2', '2017-10-29 15:45:51', '2018-12-26 14:09:11', '0', 1); COMMIT; -- ---------------------------- diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java index df089e42f..2b46c6c55 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java @@ -21,7 +21,7 @@ import com.pig4cloud.pigx.gateway.handler.ImageCodeHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerResourceHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerSecurityHandler; import com.pig4cloud.pigx.gateway.handler.SwaggerUiHandler; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,12 +37,12 @@ import org.springframework.web.reactive.function.server.RouterFunctions; */ @Slf4j @Configuration -@RequiredArgsConstructor +@AllArgsConstructor public class RouterFunctionConfiguration { private final SwaggerResourceHandler swaggerResourceHandler; private final SwaggerSecurityHandler swaggerSecurityHandler; private final SwaggerUiHandler swaggerUiHandler; - private ImageCodeHandler imageCodeHandler; + private final ImageCodeHandler imageCodeHandler; @Bean public RouterFunction routerFunction() { diff --git a/pom.xml b/pom.xml index 2d40a64a5..7eca5634a 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 1.8 1.8 2.2.1 - 5.1.1 + 5.1.2 1.6.2 2.9.2 2.0.1 From 432335d17ea091b89875ab72b757f13c54276f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 6 Feb 2020 16:30:58 +0800 Subject: [PATCH 020/130] up: spring-cloud-maven-plugin version 1.1.1 --- pigx-common/pigx-common-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index 8e8a7fe38..003fdee7f 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -152,7 +152,7 @@ com.pig4cloud.plugin spring-cloud-maven-plugin - 1.0.1 + 1.1.1 package From 029b90b237994a6a842bafbcfcca4851bafe9ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Fri, 7 Feb 2020 13:03:59 +0800 Subject: [PATCH 021/130] =?UTF-8?q?:sparkles:=20Introducing=20new=20featur?= =?UTF-8?q?es.=20=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=E7=94=9F=E4=BA=A7=20?= =?UTF-8?q?=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-common/pigx-common-bom/pom.xml | 8 +- .../pig4cloud/pigx/common/core/util/R.java | 1 + pigx-common/pigx-common-datasource/pom.xml | 10 +- .../DataSourceAutoConfiguration.java | 16 - .../DynamicDataSourceAutoConfiguration.java | 56 ++++ .../annotation/EnableDynamicDataSource.java | 7 +- .../config/DruidDataSourceProperties.java | 5 + .../datasource/config/DynamicDataSource.java | 25 -- .../config/DynamicDataSourceConfig.java | 104 ------ .../config/DynamicDatasourceInterceptor.java | 44 --- .../config/JdbcDynamicDataSourceProvider.java | 75 +++++ .../config/LastParamDsProcessor.java | 57 ++++ .../support/DataSourceConstants.java | 5 - .../DynamicDataSourceContextHolder.java | 40 --- .../main/resources/META-INF/spring.factories | 2 - pigx-visual/pigx-code/Dockerfile | 15 - pigx-visual/pigx-code/README.md | 90 ----- pigx-visual/pigx-code/pom.xml | 107 ------ .../pigx/code/PigxCodeApplication.java | 44 --- .../JdbcDynamicDataSourceProperties.java | 21 -- .../config/JdbcDynamicDataSourceProvider.java | 47 --- .../code/controller/GenDsConfController.java | 141 -------- .../controller/GenFormConfController.java | 127 ------- .../code/controller/GeneratorController.java | 74 ----- .../pigx/code/entity/ColumnEntity.java | 70 ---- .../pig4cloud/pigx/code/entity/GenConfig.java | 59 ---- .../pigx/code/entity/GenDatasourceConf.java | 79 ----- .../pigx/code/entity/GenFormConf.java | 79 ----- .../pigx/code/entity/TableEntity.java | 55 --- .../code/mapper/GenDatasourceConfMapper.java | 30 -- .../pigx/code/mapper/GenFormConfMapper.java | 33 -- .../pigx/code/mapper/GeneratorMapper.java | 59 ---- .../service/GenDatasourceConfService.java | 44 --- .../pigx/code/service/GenFormConfService.java | 40 --- .../pigx/code/service/GeneratorService.java | 48 --- .../impl/GenDatasourceConfServiceImpl.java | 68 ---- .../service/impl/GenFormConfServiceImpl.java | 98 ------ .../service/impl/GeneratorServiceImpl.java | 106 ------ .../pig4cloud/pigx/code/util/GenUtils.java | 312 ------------------ .../src/main/resources/bootstrap.yml | 16 - .../src/main/resources/generator.properties | 37 --- .../resources/mapper/GenFormConfMapper.xml | 33 -- .../main/resources/mapper/GeneratorMapper.xml | 23 -- .../resources/template/Controller.java.vm | 110 ------ .../main/resources/template/Entity.java.vm | 56 ---- .../main/resources/template/Mapper.java.vm | 31 -- .../src/main/resources/template/Mapper.xml.vm | 35 -- .../main/resources/template/Service.java.vm | 31 -- .../resources/template/ServiceImpl.java.vm | 34 -- .../src/main/resources/template/api.js.vm | 56 ---- .../src/main/resources/template/crud.js.vm | 17 - .../src/main/resources/template/index.vue.vm | 121 ------- .../src/main/resources/template/menu.sql.vm | 16 - pigx-visual/pigx-codegen/pom.xml | 5 + .../pigx/codegen/PigxCodeGenApplication.java | 1 + .../controller/GenDsConfController.java | 10 +- .../controller/GenFormConfController.java | 6 +- .../controller/GeneratorController.java | 6 +- .../pigx/codegen/entity/GenConfig.java | 4 +- .../pigx/codegen/mapper/GeneratorMapper.java | 7 +- .../service/GenDatasourceConfService.java | 25 ++ .../codegen/service/GenFormConfService.java | 4 +- .../codegen/service/GeneratorService.java | 32 +- .../impl/GenDatasourceConfServiceImpl.java | 103 +++++- .../service/impl/GenFormConfServiceImpl.java | 8 +- .../service/impl/GeneratorServiceImpl.java | 23 +- pigx-visual/pigx-dynamic-datasource/README.md | 94 ------ .../pigx-dynamic-datasource-api/pom.xml | 27 -- .../pigx/dynamic/feign/packge-info.java | 6 - .../pigx-dynamic-datasource-biz/pom.xml | 99 ------ .../PigxDynamicDatasourceApplication.java | 25 -- .../dynamic/controller/TestController.java | 96 ------ .../pigx/dynamic/mapper/TestMapper.java | 50 --- .../com/pig4cloud/pigx/dynamic/vo/UserVO.java | 10 - .../src/main/resources/bootstrap.yml | 16 - .../src/main/resources/logback-spring.xml | 70 ---- .../src/main/resources/mapper/TestMapper.xml | 13 - pigx-visual/pigx-dynamic-datasource/pom.xml | 179 ---------- pigx-visual/pom.xml | 2 - 79 files changed, 378 insertions(+), 3460 deletions(-) delete mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DataSourceAutoConfiguration.java create mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DynamicDataSourceAutoConfiguration.java delete mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSource.java delete mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSourceConfig.java delete mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java create mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java create mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/LastParamDsProcessor.java delete mode 100644 pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DynamicDataSourceContextHolder.java delete mode 100644 pigx-common/pigx-common-datasource/src/main/resources/META-INF/spring.factories delete mode 100644 pigx-visual/pigx-code/Dockerfile delete mode 100644 pigx-visual/pigx-code/README.md delete mode 100644 pigx-visual/pigx-code/pom.xml delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java delete mode 100644 pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java delete mode 100644 pigx-visual/pigx-code/src/main/resources/bootstrap.yml delete mode 100644 pigx-visual/pigx-code/src/main/resources/generator.properties delete mode 100644 pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml delete mode 100644 pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/Service.java.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/api.js.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/crud.js.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/index.vue.vm delete mode 100644 pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm delete mode 100644 pigx-visual/pigx-dynamic-datasource/README.md delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml delete mode 100644 pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml delete mode 100644 pigx-visual/pigx-dynamic-datasource/pom.xml diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index 003fdee7f..107d1081f 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -18,7 +18,8 @@ 3.7.0 - 3.3.0 + 3.3.1 + 3.0.0 1.1.21 8.0.18 1.5.22 @@ -143,6 +144,11 @@ weixin-java-common ${mp.weixin.version} + + com.baomidou + dynamic-datasource-spring-boot-starter + ${dynamic-ds.version} + diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java index 09b511c19..82fe04b54 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java @@ -33,6 +33,7 @@ import java.io.Serializable; * @param * @author lengleng */ +@Builder @ToString @NoArgsConstructor @AllArgsConstructor diff --git a/pigx-common/pigx-common-datasource/pom.xml b/pigx-common/pigx-common-datasource/pom.xml index d8703af69..3b1f1d2e4 100644 --- a/pigx-common/pigx-common-datasource/pom.xml +++ b/pigx-common/pigx-common-datasource/pom.xml @@ -34,13 +34,11 @@ com.pig4cloud pigx-common-core - - - - com.pig4cloud - pigx-common-data - + + com.baomidou + dynamic-datasource-spring-boot-starter + com.baomidou mybatis-plus-boot-starter diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DataSourceAutoConfiguration.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DataSourceAutoConfiguration.java deleted file mode 100644 index 011876df7..000000000 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DataSourceAutoConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.pig4cloud.pigx.common.datasource; - -import com.pig4cloud.pigx.common.datasource.config.DruidDataSourceProperties; -import lombok.AllArgsConstructor; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -/** - * @author Lucky - * @date 2019-05-18 - *

- * 自动配置类 - */ -@AllArgsConstructor -@EnableConfigurationProperties({DruidDataSourceProperties.class}) -public class DataSourceAutoConfiguration { -} diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DynamicDataSourceAutoConfiguration.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DynamicDataSourceAutoConfiguration.java new file mode 100644 index 000000000..0e7dbd146 --- /dev/null +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/DynamicDataSourceAutoConfiguration.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.datasource; + +import com.baomidou.dynamic.datasource.processor.DsProcessor; +import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.pig4cloud.pigx.common.datasource.config.DruidDataSourceProperties; +import com.pig4cloud.pigx.common.datasource.config.JdbcDynamicDataSourceProvider; +import com.pig4cloud.pigx.common.datasource.config.LastParamDsProcessor; +import lombok.AllArgsConstructor; +import org.jasypt.encryption.StringEncryptor; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author lengleng + * @date 2020-02-06 + *

+ * 动态数据源切换配置 + */ +@Configuration +@AllArgsConstructor +@AutoConfigureAfter(DataSourceAutoConfiguration.class) +@EnableConfigurationProperties(DruidDataSourceProperties.class) +public class DynamicDataSourceAutoConfiguration { + private final StringEncryptor stringEncryptor; + private final DruidDataSourceProperties properties; + + @Bean + public DynamicDataSourceProvider dynamicDataSourceProvider() { + return new JdbcDynamicDataSourceProvider(stringEncryptor, properties); + } + + @Bean + public DsProcessor dsProcessor() { + return new LastParamDsProcessor(); + } +} diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/annotation/EnableDynamicDataSource.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/annotation/EnableDynamicDataSource.java index 99ebdbd6d..c04d6a105 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/annotation/EnableDynamicDataSource.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/annotation/EnableDynamicDataSource.java @@ -1,6 +1,8 @@ package com.pig4cloud.pigx.common.datasource.annotation; -import com.pig4cloud.pigx.common.datasource.config.DynamicDataSourceConfig; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.pig4cloud.pigx.common.datasource.DynamicDataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Import; import java.lang.annotation.*; @@ -15,6 +17,7 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Import({DynamicDataSourceConfig.class}) +@EnableAutoConfiguration(exclude = {DruidDataSourceAutoConfigure.class}) +@Import(DynamicDataSourceAutoConfiguration.class) public @interface EnableDynamicDataSource { } diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DruidDataSourceProperties.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DruidDataSourceProperties.java index efb00821c..08a8ba6d3 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DruidDataSourceProperties.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DruidDataSourceProperties.java @@ -18,4 +18,9 @@ public class DruidDataSourceProperties { private String password; private String url; private String driverClassName; + + /** + * 查询数据源的SQL + */ + private String queryDsSql; } diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSource.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSource.java deleted file mode 100644 index 557b5d236..000000000 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.pig4cloud.pigx.common.datasource.config; - -import com.pig4cloud.pigx.common.datasource.support.DynamicDataSourceContextHolder; -import lombok.extern.slf4j.Slf4j; -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; - -/** - * @author lengleng - * @date 2019-03-31 - *

- * 动态数据源类 - */ -@Slf4j -public class DynamicDataSource extends AbstractRoutingDataSource { - - /** - * 指定路由Key - * - * @return - */ - @Override - protected Object determineCurrentLookupKey() { - return DynamicDataSourceContextHolder.getDataSourceType(); - } -} \ No newline at end of file diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSourceConfig.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSourceConfig.java deleted file mode 100644 index 56a0b870b..000000000 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDataSourceConfig.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.pig4cloud.pigx.common.datasource.config; - -import com.alibaba.druid.pool.DruidDataSource; -import com.mysql.cj.jdbc.Driver; -import com.pig4cloud.pigx.common.datasource.support.DataSourceConstants; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.jasypt.encryption.StringEncryptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.transaction.ChainedTransactionManager; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.TransactionManagementConfigurer; - -import javax.annotation.PostConstruct; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * @author lengleng - * @date 2019-03-31 - *

- * 动态数据源切换配置 - */ -@Slf4j -@Configuration -@AllArgsConstructor -public class DynamicDataSourceConfig implements TransactionManagementConfigurer { - private final Map dataSourceMap = new HashMap<>(8); - private final DruidDataSourceProperties dataSourceProperties; - private final StringEncryptor stringEncryptor; - - @Bean("dynamicDataSource") - public DynamicDataSource dataSource() { - DynamicDataSource ds = new DynamicDataSource(); - DruidDataSource cads = new DruidDataSource(); - cads.setUrl(dataSourceProperties.getUrl()); - cads.setDriverClassName(dataSourceProperties.getDriverClassName()); - cads.setUsername(dataSourceProperties.getUsername()); - cads.setPassword(dataSourceProperties.getPassword()); - ds.setDefaultTargetDataSource(cads); - dataSourceMap.put(0, cads); - ds.setTargetDataSources(dataSourceMap); - return ds; - } - - /** - * 组装默认配置的数据源,查询数据库配置 - */ - @PostConstruct - public void init() { - DriverManagerDataSource dds = new DriverManagerDataSource(); - dds.setUrl(dataSourceProperties.getUrl()); - dds.setDriverClassName(dataSourceProperties.getDriverClassName()); - dds.setUsername(dataSourceProperties.getUsername()); - dds.setPassword(dataSourceProperties.getPassword()); - - List> dbList = new JdbcTemplate(dds).queryForList(DataSourceConstants.QUERY_DS_SQL); - log.info("开始 -> 初始化动态数据源"); - Optional.of(dbList).ifPresent(list -> list.forEach(db -> { - log.info("数据源:{}", db.get(DataSourceConstants.DS_NAME)); - DruidDataSource ds = new DruidDataSource(); - ds.setUrl(String.valueOf(db.get(DataSourceConstants.DS_JDBC_URL))); - ds.setDriverClassName(Driver.class.getName()); - ds.setUsername((String) db.get(DataSourceConstants.DS_USER_NAME)); - - String decPwd = stringEncryptor.decrypt((String) db.get(DataSourceConstants.DS_USER_PWD)); - ds.setPassword(decPwd); - dataSourceMap.put(db.get(DataSourceConstants.DS_ROUTE_KEY), ds); - })); - - log.info("完毕 -> 初始化动态数据源,共计 {} 条", dataSourceMap.size()); - } - - /** - * 重新加载数据源配置 - */ - public Boolean reload() { - init(); - DynamicDataSource dataSource = dataSource(); - dataSource.setTargetDataSources(dataSourceMap); - dataSource.afterPropertiesSet(); - return Boolean.FALSE; - } - - - @Bean - public PlatformTransactionManager txManager() { - DataSourceTransactionManager transactionManager - = new DataSourceTransactionManager(dataSource()); - return new ChainedTransactionManager(transactionManager); - } - - @Override - public PlatformTransactionManager annotationDrivenTransactionManager() { - return txManager(); - } - -} \ No newline at end of file diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java deleted file mode 100644 index d10d0fac5..000000000 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.pig4cloud.pigx.common.datasource.config; - -import com.pig4cloud.pigx.common.datasource.support.DynamicDataSourceContextHolder; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.HandlerInterceptor; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author lengleng - * @date 2019-05-18 - *

- * 动态数据源拦截器 - */ -@Slf4j -@Component -@AllArgsConstructor -public class DynamicDatasourceInterceptor implements HandlerInterceptor { - - /** - * TODO 根据上下文判断路由哪个数据库 - * - * @param request - * @param response - * @param handler - * @return - */ - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - DynamicDataSourceContextHolder.setDataSourceType(1); - return true; - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, - @Nullable Exception ex) { - DynamicDataSourceContextHolder.clearDataSourceType(); - } - -} diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java new file mode 100644 index 000000000..b8706e57e --- /dev/null +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.datasource.config; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.pig4cloud.pigx.common.datasource.support.DataSourceConstants; +import org.jasypt.encryption.StringEncryptor; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; + +/** + * @author lengleng + * @date 2020/2/6 + *

+ * 从数据源中获取 配置信息 + */ +public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvider { + private final DruidDataSourceProperties properties; + private final StringEncryptor stringEncryptor; + + public JdbcDynamicDataSourceProvider(StringEncryptor stringEncryptor, DruidDataSourceProperties properties) { + super(properties.getDriverClassName(), properties.getUrl(), properties.getUsername(), properties.getPassword()); + this.stringEncryptor = stringEncryptor; + this.properties = properties; + } + + /** + * 执行语句获得数据源参数 + * + * @param statement 语句 + * @return 数据源参数 + * @throws SQLException sql异常 + */ + @Override + protected Map executeStmt(Statement statement) throws SQLException { + ResultSet rs = statement.executeQuery(StrUtil.isBlank(properties.getQueryDsSql()) + ? DataSourceConstants.QUERY_DS_SQL + : properties.getQueryDsSql()); + + Map map = new HashMap<>(8); + while (rs.next()) { + String name = rs.getString(DataSourceConstants.DS_NAME); + String username = rs.getString(DataSourceConstants.DS_USER_NAME); + String password = rs.getString(DataSourceConstants.DS_USER_PWD); + String url = rs.getString(DataSourceConstants.DS_JDBC_URL); + DataSourceProperty property = new DataSourceProperty(); + property.setUsername(username); + property.setPassword(stringEncryptor.decrypt(password)); + property.setUrl(url); + map.put(name, property); + } + return map; + } +} diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/LastParamDsProcessor.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/LastParamDsProcessor.java new file mode 100644 index 000000000..10953abc9 --- /dev/null +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/LastParamDsProcessor.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.datasource.config; + +import com.baomidou.dynamic.datasource.processor.DsProcessor; +import org.aopalliance.intercept.MethodInvocation; + +/** + * @author lengleng + * @date 2020/2/6 + *

+ * 参数数据源解析 @DS("#last) + */ +public class LastParamDsProcessor extends DsProcessor { + + private static final String LAST_PREFIX = "#last"; + + + /** + * 抽象匹配条件 匹配才会走当前执行器否则走下一级执行器 + * + * @param key DS注解里的内容 + * @return 是否匹配 + */ + @Override + public boolean matches(String key) { + return key.startsWith(LAST_PREFIX); + } + + /** + * 抽象最终决定数据源 + * + * @param invocation 方法执行信息 + * @param key DS注解里的内容 + * @return 数据源名称 + */ + @Override + public String doDetermineDatasource(MethodInvocation invocation, String key) { + Object[] arguments = invocation.getArguments(); + return String.valueOf(arguments[arguments.length - 1]); + } +} diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java index af57b82fc..3d23df3e8 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java @@ -12,11 +12,6 @@ public interface DataSourceConstants { */ String QUERY_DS_SQL = "select * from gen_datasource_conf where del_flag = 0"; - /** - * 动态路由KEY - */ - String DS_ROUTE_KEY = "id"; - /** * 数据源名称 */ diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DynamicDataSourceContextHolder.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DynamicDataSourceContextHolder.java deleted file mode 100644 index d082585d4..000000000 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DynamicDataSourceContextHolder.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.pig4cloud.pigx.common.datasource.support; - -import lombok.experimental.UtilityClass; - -/** - * @author lengleng - * @date 2019-05-18 - *

- * 根据当前线程来选择具体的数据源 - */ -@UtilityClass -public class DynamicDataSourceContextHolder { - private final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); - - /** - * 提供给AOP去设置当前的线程的数据源的信息 - * - * @param dataSourceType - */ - public void setDataSourceType(Integer dataSourceType) { - CONTEXT_HOLDER.set(dataSourceType); - } - - /** - * 提供给AbstractRoutingDataSource的实现类,通过key选择数据源 - * - * @return - */ - public Integer getDataSourceType() { - return CONTEXT_HOLDER.get(); - } - - /** - * 使用默认的数据源 - * - */ - public void clearDataSourceType() { - CONTEXT_HOLDER.remove(); - } -} \ No newline at end of file diff --git a/pigx-common/pigx-common-datasource/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-datasource/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 15efe41d9..000000000 --- a/pigx-common/pigx-common-datasource/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.pig4cloud.pigx.common.datasource.DataSourceAutoConfiguration \ No newline at end of file diff --git a/pigx-visual/pigx-code/Dockerfile b/pigx-visual/pigx-code/Dockerfile deleted file mode 100644 index fed99aa53..000000000 --- a/pigx-visual/pigx-code/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM anapsix/alpine-java:8_server-jre_unlimited - -MAINTAINER wangiegie@gmail.com - -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime - -RUN mkdir -p /pigx-code - -WORKDIR /pigx-code - -EXPOSE 5003 - -ADD ./pigx-visual/pigx-code/target/pigx-code.jar ./ - -CMD sleep 120;java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar pigx-code.jar diff --git a/pigx-visual/pigx-code/README.md b/pigx-visual/pigx-code/README.md deleted file mode 100644 index fc2b73f3a..000000000 --- a/pigx-visual/pigx-code/README.md +++ /dev/null @@ -1,90 +0,0 @@ -## 使用说明 -``` -本模块是pigx-codegen的重写版本,使用dynamic-datasource实现,去除pigx-common-datasource依赖,功能未做扩展。 -``` -### pigx-code-dev.yml -``` -## spring security 配置 -security: - oauth2: - client: - client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==) - client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==) - scope: server - resources: - static-locations: classpath:/static/,classpath:/views/ - -# 数据源 -spring: - datasource: - dynamic: - username: ${MYSQL-USER:root} - password: ${MYSQL-USER:root} - url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true - driverClassName: com.mysql.cj.jdbc.Driver - sql: select * from gen_datasource_conf - - -pigx: - tenant: - column: tenant_id - tables: - - sys_datasource_conf -``` -### 示例中的pigxx_codegen数据库及sql说明 -``` -pigxx_codegen数据库中gen_datasource_conf表必须存在一个name为master的数据库连接配置 - -INSERT INTO `gen_datasource_conf` VALUES ('8', 'master', 'jdbc:mysql://pigx-mysql:3306/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'ZkxR9PxP6sWvasdc9CG9Ww==', '2019-09-18 09:44:55', '2019-12-17 17:07:17', '0', null); -``` -### 修改菜单的url -``` -开发平台菜单下的/gen全部改为/code -如 /gen/datasource 改为 /code/datasource -``` -### 修改动态路由 -``` -{ - "routeId": "pigx-codegen", - "routeName": "代码生成模块", - "predicates": [ - { - "args": { - "_genkey_0": "/gen/**" - }, - "name": "Path" - } - ], - "filters": [], - "uri": "lb://pigx-codegen", - "order": 0, - "createTime": "2019-10-16 16:44:41", - "updateTime": "2019-11-05 22:36:58", - "delFlag": "0" - }, -改为 -{ - "routeId": "pigx-code", - "routeName": "多数据源代码生成模块", - "predicates": [ - { - "args": { - "_genkey_0": "/code/**" - }, - "name": "Path" - } - ], - "filters": [], - "uri": "lb://pigx-code", - "order": 0, - "createTime": "2019-10-16 16:44:41", - "updateTime": "2019-11-05 22:36:58", - "delFlag": "0" - }, -``` -### yml配置文件切换数据源 -``` -请参考:https://git.pig4cloud.com/pigx/pigx/src/liuyes_dev/pigx-visual/pigx-dynamic-datasource -``` -### 联系我 -QQ:55215085 \ No newline at end of file diff --git a/pigx-visual/pigx-code/pom.xml b/pigx-visual/pigx-code/pom.xml deleted file mode 100644 index 1ffaa6de9..000000000 --- a/pigx-visual/pigx-code/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - 4.0.0 - - - com.pig4cloud - pigx-visual - 3.5.0 - - - pigx-code - jar - - 多数据源代码生成模块 - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - com.pig4cloud - pigx-common-data - - - - com.baomidou - dynamic-datasource-spring-boot-starter - 2.5.6 - - - - com.baomidou - mybatis-plus-boot-starter - - - mysql - mysql-connector-java - - - - com.alibaba - druid-spring-boot-starter - - - - com.pig4cloud - pigx-common-core - - - - com.pig4cloud - pigx-common-swagger - - - - com.pig4cloud - pigx-common-security - - - - com.pig4cloud - pigx-common-sentinel - - - com.pig4cloud - pigx-common-log - - - - velocity - org.apache.velocity - ${velocity.version} - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-undertow - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - com.spotify - docker-maven-plugin - - - - diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java deleted file mode 100644 index 18def63af..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/PigxCodeApplication.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code; - -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; -import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.client.SpringCloudApplication; - -/** - * @author lengleng - * @date 2018/07/29 - * 代码生成模块 - */ -@EnablePigxSwagger2 -@SpringCloudApplication -@EnablePigxFeignClients -@EnablePigxResourceServer -@EnableAutoConfiguration(exclude={DruidDataSourceAutoConfigure.class}) -public class PigxCodeApplication { - - public static void main(String[] args) { - SpringApplication.run(PigxCodeApplication.class, args); - } - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java deleted file mode 100644 index 20b157fd6..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProperties.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.pig4cloud.pigx.code.config; - -import lombok.AllArgsConstructor; -import lombok.Data; -import org.jasypt.encryption.StringEncryptor; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -@Data -@Component -@ConfigurationProperties("spring.datasource.dynamic") -public class JdbcDynamicDataSourceProperties { - private final StringEncryptor stringEncryptor; - private String username; - private String password; - private String url; - private String driverClassName; - private String sql; - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java deleted file mode 100644 index 198a10ae9..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/config/JdbcDynamicDataSourceProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.pig4cloud.pigx.code.config; - -import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider; -import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; -import lombok.AllArgsConstructor; -import org.jasypt.encryption.StringEncryptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashMap; -import java.util.Map; - -@Configuration -@AllArgsConstructor -public class JdbcDynamicDataSourceProvider { - private final StringEncryptor stringEncryptor; - private final JdbcDynamicDataSourceProperties properties; - - @Bean - public DynamicDataSourceProvider dynamicDataSourceProvider() { - return new AbstractJdbcDataSourceProvider(properties.getDriverClassName(), properties.getUrl(), properties.getUsername(), properties.getPassword()) { - @Override - protected Map executeStmt(Statement statement) throws SQLException { - Map map = new HashMap<>(); - ResultSet rs = statement.executeQuery(properties.getSql()); - while (rs.next()) { - String name = rs.getString("name"); - String username = rs.getString("username"); - String password = rs.getString("password"); - String url = rs.getString("url"); -// String driver = rs.getString("driver"); - DataSourceProperty property = new DataSourceProperty(); - property.setUsername(username); - property.setPassword(stringEncryptor.decrypt(password)); - property.setUrl(url); -// property.setDriverClassName(driver); - map.put(name, property); - } - return map; - } - }; - } -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java deleted file mode 100644 index a43ad053c..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenDsConfController.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.controller; - -import com.baomidou.dynamic.datasource.DynamicDataSourceCreator; -import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.code.entity.GenDatasourceConf; -import com.pig4cloud.pigx.code.service.GenDatasourceConfService; -import com.pig4cloud.pigx.common.core.util.R; -import com.pig4cloud.pigx.common.log.annotation.SysLog; -import lombok.AllArgsConstructor; -import org.jasypt.encryption.StringEncryptor; -import org.springframework.web.bind.annotation.*; - -import javax.sql.DataSource; - - -/** - * 数据源管理 - * - * @author lengleng - * @date 2019-03-31 16:00:20 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/dsconf") -public class GenDsConfController { - private final GenDatasourceConfService datasourceConfService; - private final StringEncryptor stringEncryptor; - private DataSource dataSource; - private DynamicDataSourceCreator dataSourceCreator; - - /** - * 分页查询 - * - * @param page 分页对象 - * @param datasourceConf 数据源表 - * @return - */ - @GetMapping("/page") - public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { - return R.ok(datasourceConfService.page(page, Wrappers.query(datasourceConf))); - } - - /** - * 查询全部数据源 - * - * @return - */ - @GetMapping("/list") - public R list() { - return R.ok(datasourceConfService.list()); - } - - - /** - * 通过id查询数据源表 - * - * @param id id - * @return R - */ - @GetMapping("/{id}") - public R getById(@PathVariable("id") Integer id) { - return R.ok(datasourceConfService.getById(id)); - } - - /** - * 新增数据源表 - * - * @param datasourceConf 数据源表 - * @return R - */ - @SysLog("新增数据源表") - @PostMapping - public R save(@RequestBody GenDatasourceConf datasourceConf) { - DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; - DataSourceProperty dataSourceProperty = new DataSourceProperty(); - dataSourceProperty.setPollName(datasourceConf.getName()); - dataSourceProperty.setUrl(datasourceConf.getUrl()); - dataSourceProperty.setUsername(datasourceConf.getUsername()); - dataSourceProperty.setPassword(datasourceConf.getPassword()); - DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty); - ds.addDataSource(dataSourceProperty.getPollName(), dataSource); - return R.ok(datasourceConfService.saveDsByEnc(datasourceConf)); - } - - /** - * 修改数据源表 - * - * @param sysDatasourceConf 数据源表 - * @return R - */ - @SysLog("修改数据源表") - @PutMapping - public R updateById(@RequestBody GenDatasourceConf sysDatasourceConf) { - DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; - //先移除 - ds.removeDataSource(datasourceConfService.getById(sysDatasourceConf.getId()).getName()); - //再添加 - DataSourceProperty dataSourceProperty = new DataSourceProperty(); - dataSourceProperty.setPollName(sysDatasourceConf.getName()); - dataSourceProperty.setUrl(sysDatasourceConf.getUrl()); - dataSourceProperty.setUsername(sysDatasourceConf.getUsername()); - dataSourceProperty.setPassword(sysDatasourceConf.getPassword()); - DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty); - ds.addDataSource(dataSourceProperty.getPollName(), dataSource); - return R.ok(datasourceConfService.updateDsByEnc(sysDatasourceConf)); - } - - /** - * 通过id删除数据源表 - * - * @param id id - * @return R - */ - @SysLog("删除数据源表") - @DeleteMapping("/{id}") - public R removeById(@PathVariable Integer id) { - DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource; - ds.removeDataSource(datasourceConfService.getById(id).getName()); - return R.ok(datasourceConfService.removeById(id)); - } - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java deleted file mode 100644 index a2243bf2b..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GenFormConfController.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.controller; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.code.entity.GenFormConf; -import com.pig4cloud.pigx.code.service.GenFormConfService; -import com.pig4cloud.pigx.common.core.util.R; -import com.pig4cloud.pigx.common.log.annotation.SysLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/form") -@Api(value = "form", tags = "表单管理") -public class GenFormConfController { - private final GenFormConfService genRecordService; - - /** - * 分页查询 - * - * @param page 分页对象 - * @param formConf 生成记录 - * @return - */ - @ApiOperation(value = "分页查询", notes = "分页查询") - @GetMapping("/page") - public R getGenFormConfPage(Page page, GenFormConf formConf) { - return R.ok(genRecordService.page(page, Wrappers.query(formConf))); - } - - - /** - * 通过id查询生成记录 - * - * @param id id - * @return R - */ - @ApiOperation(value = "通过id查询", notes = "通过id查询") - @GetMapping("/{id}") - public R getById(@PathVariable("id") Integer id) { - return R.ok(genRecordService.getById(id)); - } - - /** - * 通过id查询生成记录 - * - * @param dsId 数据源ID - * @param tableName tableName - * @return R - */ - @ApiOperation(value = "通过tableName查询表单信息") - @GetMapping("/info") - public R form(Integer dsId, String tableName) { - return R.ok(genRecordService.getForm(dsId, tableName)); - } - - /** - * 新增生成记录 - * - * @param formConf 生成记录 - * @return R - */ - @ApiOperation(value = "新增生成记录", notes = "新增生成记录") - @SysLog("新增生成记录") - @PostMapping - @PreAuthorize("@pms.hasPermission('gen_form_add')") - public R save(@RequestBody GenFormConf formConf) { - return R.ok(genRecordService.save(formConf)); - } - - /** - * 修改生成记录 - * - * @param formConf 生成记录 - * @return R - */ - @ApiOperation(value = "修改生成记录", notes = "修改生成记录") - @SysLog("修改生成记录") - @PutMapping - @PreAuthorize("@pms.hasPermission('gen_form_edit')") - public R updateById(@RequestBody GenFormConf formConf) { - return R.ok(genRecordService.updateById(formConf)); - } - - /** - * 通过id删除生成记录 - * - * @param id id - * @return R - */ - @ApiOperation(value = "通过id删除生成记录", notes = "通过id删除生成记录") - @SysLog("通过id删除生成记录") - @DeleteMapping("/{id}") - @PreAuthorize("@pms.hasPermission('gen_form_del')") - public R removeById(@PathVariable Integer id) { - return R.ok(genRecordService.removeById(id)); - } - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java deleted file mode 100644 index be97fa249..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/controller/GeneratorController.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.controller; - -import cn.hutool.core.io.IoUtil; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.code.entity.GenConfig; -import com.pig4cloud.pigx.code.service.GeneratorService; -import com.pig4cloud.pigx.common.core.util.R; -import lombok.AllArgsConstructor; -import lombok.SneakyThrows; -import org.apache.commons.lang3.StringUtils; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * 代码生成器 - * - * @author lengleng - * @date 2018-07-30 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/generator") -public class GeneratorController { - private final GeneratorService generatorService; - - /** - * 列表 - * - * @param tableName 参数集 - * @param id 数据源编号 - * @return 数据库表 - */ - @GetMapping("/page") - public R getPage(Page page, String tableName, String name, HttpServletRequest request) { - name = StringUtils.isEmpty(name) ? "master" : name; - request.getSession().setAttribute("dataSourceName", name); - return R.ok(generatorService.getPage(page, tableName)); - } - - /** - * 生成代码 - */ - @SneakyThrows - @PostMapping("/code") - public void generatorCode(@RequestBody GenConfig genConfig, HttpServletResponse response) { - byte[] data = generatorService.generatorCode(genConfig); - response.reset(); - response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", genConfig.getTableName())); - response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); - response.setContentType("application/octet-stream; charset=UTF-8"); - - IoUtil.write(response.getOutputStream(), Boolean.TRUE, data); - } -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java deleted file mode 100644 index 92b0854a5..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/ColumnEntity.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.entity; - -import lombok.Data; - -/** - * @author lengleng - * @date 2018/07/29 - * 列属性: https://blog.csdn.net/lkforce/article/details/79557482 - */ -@Data -public class ColumnEntity { - /** - * 列表 - */ - private String columnName; - /** - * 数据类型 - */ - private String dataType; - /** - * 备注 - */ - private String comments; - - /** - * 驼峰属性 - */ - private String caseAttrName; - /** - * 普通属性 - */ - private String lowerAttrName; - /** - * 属性类型 - */ - private String attrType; - /** - * 其他信息 - */ - private String extra; - /** - * 字段类型 - */ - private String columnType; - /** - * 是否可以为空 - */ - private Boolean nullable; - /** - * 是否隐藏 - */ - private Boolean hidden; -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java deleted file mode 100644 index c23aa006c..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.entity; - -import lombok.Data; - -/** - * @author lengleng - * @date 2018/8/2 - * 生成配置 - */ -@Data -public class GenConfig { - /** - * 数据源ID - */ - private Integer id; - /** - * 包名 - */ - private String packageName; - /** - * 作者 - */ - private String author; - /** - * 模块名称 - */ - private String moduleName; - /** - * 表前缀 - */ - private String tablePrefix; - - /** - * 表名称 - */ - private String tableName; - - /** - * 表备注 - */ - private String comments; -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java deleted file mode 100644 index d2965821f..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenDatasourceConf.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 数据源表 - * - * @author lengleng - * @date 2019-03-31 16:00:20 - */ -@Data -@TableName("gen_datasource_conf") -@EqualsAndHashCode(callSuper = true) -public class GenDatasourceConf extends Model { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId - private Integer id; - /** - * 名称 - */ - private String name; - /** - * jdbcurl - */ - private String url; - /** - * 用户名 - */ - private String username; - /** - * 密码 - */ - private String password; - /** - * 创建时间 - */ - private LocalDateTime createDate; - /** - * 更新 - */ - private LocalDateTime updateDate; - /** - * 删除标记 - */ - @TableLogic - private String delFlag; - /** - * 租户ID - */ - private Integer tenantId; - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java deleted file mode 100644 index 4c6ae7d56..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/GenFormConf.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 生成记录 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@Data -@TableName("gen_form_conf") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "生成记录") -public class GenFormConf extends Model { - private static final long serialVersionUID = 1L; - - /** - * ID - */ - @TableId - @ApiModelProperty(value = "ID") - private Integer id; - /** - * 表名称 - */ - @ApiModelProperty(value = "表名称") - private String tableName; - /** - * 表单信息 - */ - @ApiModelProperty(value = "表单信息") - private String formInfo; - /** - * 创建时间 - */ - @ApiModelProperty(value = "创建时间") - private LocalDateTime createTime; - /** - * 修改时间 - */ - @ApiModelProperty(value = "修改时间") - private LocalDateTime updateTime; - /** - * 删除标记 - */ - @ApiModelProperty(value = "删除标记") - private String delFlag; - /** - * 所属租户 - */ - @ApiModelProperty(value = "所属租户", hidden = true) - private Integer tenantId; -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java deleted file mode 100644 index 4f0cf207c..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/entity/TableEntity.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.entity; - -import lombok.Data; - -import java.util.List; - -/** - * @author lengleng - * @date 2018/07/29 - * 表属性: https://blog.csdn.net/lkforce/article/details/79557482 - */ -@Data -public class TableEntity { - /** - * 名称 - */ - private String tableName; - /** - * 备注 - */ - private String comments; - /** - * 主键 - */ - private ColumnEntity pk; - /** - * 列名 - */ - private List columns; - /** - * 驼峰类型 - */ - private String caseClassName; - /** - * 普通类型 - */ - private String lowerClassName; -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java deleted file mode 100644 index c761e1cbc..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenDatasourceConfMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.pig4cloud.pigx.code.entity.GenDatasourceConf; - -/** - * 数据源表 - * - * @author lengleng - * @date 2019-03-31 16:00:20 - */ -public interface GenDatasourceConfMapper extends BaseMapper { - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java deleted file mode 100644 index 145faf1a1..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GenFormConfMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.mapper; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.pig4cloud.pigx.code.entity.GenFormConf; - -/** - * 生成记录 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@DS("master") -public interface GenFormConfMapper extends BaseMapper { - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java deleted file mode 100644 index 975b08d16..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/mapper/GeneratorMapper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.mapper; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Map; - -/** - * 代码生成器 - * - * @author lengleng - * @date 2018-07-30 - */ -public interface GeneratorMapper { - - /** - * 分页查询表格 - * - * @param page - * @param tableName - * @return - */ - IPage>> queryList(Page page, @Param("tableName") String tableName); - - /** - * 查询表信息 - * - * @param tableName 表名称 - * @return - */ - Map queryTable(String tableName); - - /** - * 查询表列信息 - * - * @param tableName 表名称 - * @return - */ - List> queryColumns(String tableName); -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java deleted file mode 100644 index c441b5cec..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenDatasourceConfService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.pig4cloud.pigx.code.entity.GenDatasourceConf; - -/** - * 数据源表 - * - * @author lengleng - * @date 2019-03-31 16:00:20 - */ -public interface GenDatasourceConfService extends IService { - /** - * 保存数据源并且加密 - * - * @param genDatasourceConf - * @return - */ - Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf); - - /** - * 更新数据源 - * - * @param genDatasourceConf - * @return - */ - Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf); -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java deleted file mode 100644 index c6468db33..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GenFormConfService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.pig4cloud.pigx.code.entity.GenFormConf; - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -public interface GenFormConfService extends IService { - - /** - * 获取表单信息 - * - * @param dsId 数据源ID - * @param tableName 表名称 - * @return - */ - String getForm(Integer dsId, String tableName); - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java deleted file mode 100644 index 5186eb6cc..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/GeneratorService.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.code.entity.GenConfig; - -import java.util.List; -import java.util.Map; - -/** - * @author lengleng - * @date 2018/7/29 - */ -public interface GeneratorService { - /** - * 生成代码 - * - * @param tableNames 表名称 - * @return - */ - byte[] generatorCode(GenConfig tableNames); - - /** - * 分页查询表 - * - * @param page 分页信息 - * @param tableName 表名 - * @return - */ - IPage>> getPage(Page page, String tableName); -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java deleted file mode 100644 index 49b6deea1..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenDatasourceConfServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.pig4cloud.pigx.code.entity.GenDatasourceConf; -import com.pig4cloud.pigx.code.mapper.GenDatasourceConfMapper; -import com.pig4cloud.pigx.code.service.GenDatasourceConfService; -import lombok.AllArgsConstructor; -import org.jasypt.encryption.StringEncryptor; -import org.springframework.stereotype.Service; - -/** - * 数据源表 - * - * @author lengleng - * @date 2019-03-31 16:00:20 - */ -@Service -@AllArgsConstructor -public class GenDatasourceConfServiceImpl extends ServiceImpl implements GenDatasourceConfService { - private final StringEncryptor stringEncryptor; - - /** - * 保存数据源并且加密 - * - * @param genDatasourceConf - * @return - */ - @Override - public Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf) { - genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); - this.baseMapper.insert(genDatasourceConf); - return true; -// return dynamicDataSourceConfig.reload(); - } - - /** - * 更新数据源 - * - * @param genDatasourceConf - * @return - */ - @Override - public Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf) { - if (StrUtil.isNotBlank(genDatasourceConf.getPassword())) { - genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); - } - this.baseMapper.updateById(genDatasourceConf); - return true; -// return dynamicDataSourceConfig.reload(); - } -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java deleted file mode 100644 index 7c033efd3..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GenFormConfServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package com.pig4cloud.pigx.code.service.impl; - -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.pig4cloud.pigx.code.entity.ColumnEntity; -import com.pig4cloud.pigx.code.entity.GenFormConf; -import com.pig4cloud.pigx.code.mapper.GenFormConfMapper; -import com.pig4cloud.pigx.code.mapper.GeneratorMapper; -import com.pig4cloud.pigx.code.service.GenFormConfService; -import com.pig4cloud.pigx.code.util.GenUtils; -import lombok.AllArgsConstructor; -import lombok.SneakyThrows; -import org.apache.commons.lang.StringUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; -import org.springframework.stereotype.Service; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@Service -@AllArgsConstructor -public class GenFormConfServiceImpl extends ServiceImpl implements GenFormConfService { - private final GeneratorMapper generatorMapper; - - /** - * 1. 根据数据源、表名称,查询已配置表单信息 - * 2. 不存在调用模板生成 - * - * @param dsId 数据源ID - * @param tableName 表名称 - * @return - */ - @DS("pigxx") - @Override - @SneakyThrows - public String getForm(Integer dsId, String tableName) { - GenFormConf form = getOne(Wrappers.lambdaQuery() - .eq(GenFormConf::getTableName, tableName) - .orderByDesc(GenFormConf::getCreateTime), false); - - if (form != null) { - return form.getFormInfo(); - } - -// DynamicDataSourceContextHolder.setDataSourceType(dsId); - List> columns = generatorMapper.queryColumns(tableName); - //设置velocity资源加载器 - Properties prop = new Properties(); - prop.put("file.resource.loader.class", ClasspathResourceLoader.class.getName()); - Velocity.init(prop); - Template template = Velocity.getTemplate("template/crud.js.vm", CharsetUtil.UTF_8); - VelocityContext context = new VelocityContext(); - - List columnList = new ArrayList<>(); - for (Map column : columns) { - ColumnEntity columnEntity = new ColumnEntity(); - columnEntity.setComments(column.get("columnComment")); - columnEntity.setLowerAttrName(StringUtils.uncapitalize(GenUtils.columnToJava(column.get("columnName")))); - columnList.add(columnEntity); - } - context.put("columns", columnList); - StringWriter writer = new StringWriter(); - template.merge(context, writer); - return StrUtil.trim(StrUtil.removePrefix(writer.toString(), GenUtils.CRUD_PREFIX)); - } - -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java deleted file mode 100644 index 72e94731f..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.code.entity.GenConfig; -import com.pig4cloud.pigx.code.entity.GenFormConf; -import com.pig4cloud.pigx.code.mapper.GenFormConfMapper; -import com.pig4cloud.pigx.code.mapper.GeneratorMapper; -import com.pig4cloud.pigx.code.service.GeneratorService; -import com.pig4cloud.pigx.code.util.GenUtils; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; - -import java.io.ByteArrayOutputStream; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipOutputStream; - -/** - * @author lengleng - * @date 2018-07-30 - *

- * 代码生成器 - */ -@Service -@AllArgsConstructor -public class GeneratorServiceImpl implements GeneratorService { - private final GeneratorMapper generatorMapper; - private final GenFormConfMapper genFormConfMapper; - - /** - * 分页查询表 - * - * @param tableName 查询条件 - * @return - */ - @DS("#session.dataSourceName") - @Override - public IPage>> getPage(Page page, String tableName) { - return generatorMapper.queryList(page, tableName); - } - - /** - * 生成代码 - * - * @param genConfig 生成配置 - * @return - */ - @DS("#session.dataSourceName") - @Override - public byte[] generatorCode(GenConfig genConfig) { - //根据tableName 查询最新的表单配置 - List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery() - .eq(GenFormConf::getTableName, genConfig.getTableName()) - .orderByDesc(GenFormConf::getCreateTime)); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(outputStream); - - String tableNames = genConfig.getTableName(); - for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) { - //查询表信息 - Map table = queryTable(tableName); - //查询列信息 - List> columns = queryColumns(tableName); - //生成代码 - if (CollUtil.isNotEmpty(formConfList)) { - GenUtils.generatorCode(genConfig, table, columns, zip, formConfList.get(0)); - } else { - GenUtils.generatorCode(genConfig, table, columns, zip, null); - } - } - IoUtil.close(zip); - return outputStream.toByteArray(); - } - - private Map queryTable(String tableName) { - return generatorMapper.queryTable(tableName); - } - - private List> queryColumns(String tableName) { - return generatorMapper.queryColumns(tableName); - } -} diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java deleted file mode 100644 index 8907bdc96..000000000 --- a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/util/GenUtils.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.code.util; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.StrUtil; -import com.pig4cloud.pigx.code.entity.ColumnEntity; -import com.pig4cloud.pigx.code.entity.GenConfig; -import com.pig4cloud.pigx.code.entity.GenFormConf; -import com.pig4cloud.pigx.code.entity.TableEntity; -import com.pig4cloud.pigx.common.core.constant.CommonConstants; -import com.pig4cloud.pigx.common.core.exception.CheckedException; -import lombok.SneakyThrows; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.WordUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - -import java.io.File; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** - * 代码生成器 工具类 - * - * @author lengleng - * @date 2018-07-30 - */ -@Slf4j -@UtilityClass -public class GenUtils { - public final String CRUD_PREFIX = "export const tableOption ="; - private final String ENTITY_JAVA_VM = "Entity.java.vm"; - private final String MAPPER_JAVA_VM = "Mapper.java.vm"; - private final String SERVICE_JAVA_VM = "Service.java.vm"; - private final String SERVICE_IMPL_JAVA_VM = "ServiceImpl.java.vm"; - private final String CONTROLLER_JAVA_VM = "Controller.java.vm"; - private final String MAPPER_XML_VM = "Mapper.xml.vm"; - private final String MENU_SQL_VM = "menu.sql.vm"; - private final String INDEX_VUE_VM = "index.vue.vm"; - private final String API_JS_VM = "api.js.vm"; - private final String CRUD_JS_VM = "crud.js.vm"; - - private List getTemplates() { - List templates = new ArrayList<>(); - templates.add("template/Entity.java.vm"); - templates.add("template/Mapper.java.vm"); - templates.add("template/Mapper.xml.vm"); - templates.add("template/Service.java.vm"); - templates.add("template/ServiceImpl.java.vm"); - templates.add("template/Controller.java.vm"); - templates.add("template/menu.sql.vm"); - - templates.add("template/index.vue.vm"); - templates.add("template/api.js.vm"); - templates.add("template/crud.js.vm"); - return templates; - } - - /** - * 生成代码 - */ - @SneakyThrows - public void generatorCode(GenConfig genConfig, Map table, - List> columns, ZipOutputStream zip, GenFormConf formConf) { - //配置信息 - Configuration config = getConfig(); - boolean hasBigDecimal = false; - //表信息 - TableEntity tableEntity = new TableEntity(); - tableEntity.setTableName(table.get("tableName")); - - if (StrUtil.isNotBlank(genConfig.getComments())) { - tableEntity.setComments(genConfig.getComments()); - } else { - tableEntity.setComments(table.get("tableComment")); - } - - String tablePrefix; - if (StrUtil.isNotBlank(genConfig.getTablePrefix())) { - tablePrefix = genConfig.getTablePrefix(); - } else { - tablePrefix = config.getString("tablePrefix"); - } - - //表名转换成Java类名 - String className = tableToJava(tableEntity.getTableName(), tablePrefix); - tableEntity.setCaseClassName(className); - tableEntity.setLowerClassName(StringUtils.uncapitalize(className)); - //获取需要在swagger文档中隐藏的属性字段 - List hiddenColumns = config.getList("hiddenColumn"); - //列信息 - List columnList = new ArrayList<>(); - for (Map column : columns) { - ColumnEntity columnEntity = new ColumnEntity(); - columnEntity.setColumnName(column.get("columnName")); - columnEntity.setDataType(column.get("dataType")); - columnEntity.setComments(column.get("columnComment")); - columnEntity.setExtra(column.get("extra")); - columnEntity.setNullable("NO".equals(column.get("isNullable"))); - columnEntity.setColumnType(column.get("columnType")); - //隐藏不需要的在接口文档中展示的字段 - if (hiddenColumns.contains(column.get("columnName"))) { - columnEntity.setHidden(Boolean.TRUE); - } else { - columnEntity.setHidden(Boolean.FALSE); - } - //列名转换成Java属性名 - String attrName = columnToJava(columnEntity.getColumnName()); - columnEntity.setCaseAttrName(attrName); - columnEntity.setLowerAttrName(StringUtils.uncapitalize(attrName)); - - //列的数据类型,转换成Java类型 - String attrType = config.getString(columnEntity.getDataType(), "unknowType"); - columnEntity.setAttrType(attrType); - if (!hasBigDecimal && "BigDecimal".equals(attrType)) { - hasBigDecimal = true; - } - //是否主键 - if ("PRI".equalsIgnoreCase(column.get("columnKey")) && tableEntity.getPk() == null) { - tableEntity.setPk(columnEntity); - } - - columnList.add(columnEntity); - } - tableEntity.setColumns(columnList); - - //没主键,则第一个字段为主键 - if (tableEntity.getPk() == null) { - tableEntity.setPk(tableEntity.getColumns().get(0)); - } - - //设置velocity资源加载器 - Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - Velocity.init(prop); - //封装模板数据 - Map map = new HashMap<>(16); - map.put("tableName", tableEntity.getTableName()); - map.put("pk", tableEntity.getPk()); - map.put("className", tableEntity.getCaseClassName()); - map.put("classname", tableEntity.getLowerClassName()); - map.put("pathName", tableEntity.getLowerClassName().toLowerCase()); - map.put("columns", tableEntity.getColumns()); - map.put("hasBigDecimal", hasBigDecimal); - map.put("datetime", DateUtil.now()); - - if (StrUtil.isNotBlank(genConfig.getComments())) { - map.put("comments", genConfig.getComments()); - } else { - map.put("comments", tableEntity.getComments()); - } - - if (StrUtil.isNotBlank(genConfig.getAuthor())) { - map.put("author", genConfig.getAuthor()); - } else { - map.put("author", config.getString("author")); - } - - if (StrUtil.isNotBlank(genConfig.getModuleName())) { - map.put("moduleName", genConfig.getModuleName()); - } else { - map.put("moduleName", config.getString("moduleName")); - } - - if (StrUtil.isNotBlank(genConfig.getPackageName())) { - map.put("package", genConfig.getPackageName()); - map.put("mainPath", genConfig.getPackageName()); - } else { - map.put("package", config.getString("package")); - map.put("mainPath", config.getString("mainPath")); - } - VelocityContext context = new VelocityContext(map); - - //获取模板列表 - List templates = getTemplates(); - for (String template : templates) { - // 如果是crud - if (template.contains(CRUD_JS_VM) && formConf != null) { - zip.putNextEntry(new ZipEntry(Objects - .requireNonNull(getFileName(template, tableEntity.getCaseClassName() - , map.get("package").toString(), map.get("moduleName").toString())))); - IoUtil.write(zip, StandardCharsets.UTF_8, false, CRUD_PREFIX + formConf.getFormInfo()); - zip.closeEntry(); - continue; - } - - - //渲染模板 - StringWriter sw = new StringWriter(); - Template tpl = Velocity.getTemplate(template, CharsetUtil.UTF_8); - tpl.merge(context, sw); - - //添加到zip - zip.putNextEntry(new ZipEntry(Objects - .requireNonNull(getFileName(template, tableEntity.getCaseClassName() - , map.get("package").toString(), map.get("moduleName").toString())))); - IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); - IoUtil.close(sw); - zip.closeEntry(); - } - } - - - /** - * 列名转换成Java属性名 - */ - public String columnToJava(String columnName) { - return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", ""); - } - - /** - * 表名转换成Java类名 - */ - private String tableToJava(String tableName, String tablePrefix) { - if (StringUtils.isNotBlank(tablePrefix)) { - tableName = tableName.replaceFirst(tablePrefix, ""); - } - return columnToJava(tableName); - } - - /** - * 获取配置信息 - */ - private Configuration getConfig() { - try { - return new PropertiesConfiguration("generator.properties"); - } catch (ConfigurationException e) { - throw new CheckedException("获取配置文件失败,", e); - } - } - - /** - * 获取文件名 - */ - private String getFileName(String template, String className, String packageName, String moduleName) { - String packagePath = CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator; - if (StringUtils.isNotBlank(packageName)) { - packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; - } - - if (template.contains(ENTITY_JAVA_VM)) { - return packagePath + "entity" + File.separator + className + ".java"; - } - - if (template.contains(MAPPER_JAVA_VM)) { - return packagePath + "mapper" + File.separator + className + "Mapper.java"; - } - - if (template.contains(SERVICE_JAVA_VM)) { - return packagePath + "service" + File.separator + className + "Service.java"; - } - - if (template.contains(SERVICE_IMPL_JAVA_VM)) { - return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java"; - } - - if (template.contains(CONTROLLER_JAVA_VM)) { - return packagePath + "controller" + File.separator + className + "Controller.java"; - } - - if (template.contains(MAPPER_XML_VM)) { - return CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml"; - } - - if (template.contains(MENU_SQL_VM)) { - return className.toLowerCase() + "_menu.sql"; - } - - if (template.contains(INDEX_VUE_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + - File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + "index.vue"; - } - - if (template.contains(API_JS_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js"; - } - - if (template.contains(CRUD_JS_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" + - File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; - } - - return null; - } -} diff --git a/pigx-visual/pigx-code/src/main/resources/bootstrap.yml b/pigx-visual/pigx-code/src/main/resources/bootstrap.yml deleted file mode 100644 index 370893775..000000000 --- a/pigx-visual/pigx-code/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,16 +0,0 @@ -server: - port: 5003 - -spring: - application: - name: @artifactId@ - cloud: - nacos: - discovery: - server-addr: ${NACOS-HOST:pigx-register}:${NACOS-PORT:8848} - config: - server-addr: ${spring.cloud.nacos.discovery.server-addr} - file-extension: yml - shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - profiles: - active: @profiles.active@ \ No newline at end of file diff --git a/pigx-visual/pigx-code/src/main/resources/generator.properties b/pigx-visual/pigx-code/src/main/resources/generator.properties deleted file mode 100644 index dfe6d305a..000000000 --- a/pigx-visual/pigx-code/src/main/resources/generator.properties +++ /dev/null @@ -1,37 +0,0 @@ -#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F - -mainPath=com.pig4cloud.pigx -#\u5305\u540D -package=com.pig4cloud.pigx -moduleName=generator -#\u4F5C\u8005 -author=pigx code generator - -#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) -tablePrefix=tb_ - -#\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F -tinyint=Integer -smallint=Integer -mediumint=Integer -int=Integer -integer=Integer -bigint=Long -float=Float -double=Double -decimal=BigDecimal -bit=Boolean - -char=String -varchar=String -tinytext=String -text=String -mediumtext=String -longtext=String - -date=LocalDateTime -datetime=LocalDateTime -timestamp=LocalDateTime - -# hidden columns in Swagger Models -hiddenColumn=tenant_id diff --git a/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml b/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml deleted file mode 100644 index 22270ac54..000000000 --- a/pigx-visual/pigx-code/src/main/resources/mapper/GenFormConfMapper.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml b/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml deleted file mode 100644 index 7ef05fc4d..000000000 --- a/pigx-visual/pigx-code/src/main/resources/mapper/GeneratorMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - diff --git a/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm deleted file mode 100644 index 9eb5102e8..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/Controller.java.vm +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package ${package}.${moduleName}.controller; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.common.core.util.R; -import com.pig4cloud.pigx.common.log.annotation.SysLog; -import ${package}.${moduleName}.entity.${className}; -import ${package}.${moduleName}.service.${className}Service; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.*; - - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -@RestController -@AllArgsConstructor -@RequestMapping("/${pathName}" ) -@Api(value = "${pathName}", tags = "${comments}管理") -public class ${className}Controller { - - private final ${className}Service ${classname}Service; - - /** - * 分页查询 - * @param page 分页对象 - * @param ${classname} ${comments} - * @return - */ - @ApiOperation(value = "分页查询", notes = "分页查询") - @GetMapping("/page" ) - public R get${className}Page(Page page, ${className} ${classname}) { - return R.ok(${classname}Service.page(page, Wrappers.query(${classname}))); - } - - - /** - * 通过id查询${comments} - * @param ${pk.lowerAttrName} id - * @return R - */ - @ApiOperation(value = "通过id查询", notes = "通过id查询") - @GetMapping("/{${pk.lowerAttrName}}" ) - public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) { - return R.ok(${classname}Service.getById(${pk.lowerAttrName})); - } - - /** - * 新增${comments} - * @param ${classname} ${comments} - * @return R - */ - @ApiOperation(value = "新增${comments}", notes = "新增${comments}") - @SysLog("新增${comments}" ) - @PostMapping - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" ) - public R save(@RequestBody ${className} ${classname}) { - return R.ok(${classname}Service.save(${classname})); - } - - /** - * 修改${comments} - * @param ${classname} ${comments} - * @return R - */ - @ApiOperation(value = "修改${comments}", notes = "修改${comments}") - @SysLog("修改${comments}" ) - @PutMapping - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" ) - public R updateById(@RequestBody ${className} ${classname}) { - return R.ok(${classname}Service.updateById(${classname})); - } - - /** - * 通过id删除${comments} - * @param ${pk.lowerAttrName} id - * @return R - */ - @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}") - @SysLog("通过id删除${comments}" ) - @DeleteMapping("/{${pk.lowerAttrName}}" ) - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" ) - public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) { - return R.ok(${classname}Service.removeById(${pk.lowerAttrName})); - } - -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm deleted file mode 100644 index eb9a71379..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/Entity.java.vm +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package ${package}.${moduleName}.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -#if(${hasBigDecimal}) -import java.math.BigDecimal; -#end -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -@Data -@TableName("${tableName}") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "${comments}") -public class ${className} extends Model<${className}> { -private static final long serialVersionUID = 1L; - - #foreach ($column in $columns) -/** - * $column.comments - */ - #if($column.columnName == $pk.columnName) -@TableId - #end -@ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end) - private $column.attrType $column.lowerAttrName; - #end -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm deleted file mode 100644 index 867859b51..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/Mapper.java.vm +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package ${package}.${moduleName}.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import ${package}.${moduleName}.entity.${className}; - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -public interface ${className}Mapper extends BaseMapper<${className}> { - -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm b/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm deleted file mode 100644 index 864e3d9ea..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/Mapper.xml.vm +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - #foreach($column in $columns) - #if($column.lowerAttrName==$pk.lowerAttrName) - - #else - - #end - #end - - diff --git a/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm b/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm deleted file mode 100644 index 5d808ef57..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/Service.java.vm +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package ${package}.${moduleName}.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import ${package}.${moduleName}.entity.${className}; - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -public interface ${className}Service extends IService<${className}> { - -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm b/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm deleted file mode 100644 index bce38eeea..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/ServiceImpl.java.vm +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ -package ${package}.${moduleName}.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import ${package}.${moduleName}.entity.${className}; -import ${package}.${moduleName}.mapper.${className}Mapper; -import ${package}.${moduleName}.service.${className}Service; -import org.springframework.stereotype.Service; - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -@Service -public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service { - -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/api.js.vm b/pigx-visual/pigx-code/src/main/resources/template/api.js.vm deleted file mode 100644 index e257ce767..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/api.js.vm +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -import request from '@/router/axios' - -export function fetchList(query) { - return request({ - url: '/${moduleName}/${pathName}/page', - method: 'get', - params: query - }) -} - -export function addObj(obj) { - return request({ - url: '/${moduleName}/${pathName}', - method: 'post', - data: obj - }) -} - -export function getObj(id) { - return request({ - url: '/${moduleName}/${pathName}/' + id, - method: 'get' - }) -} - -export function delObj(id) { - return request({ - url: '/${moduleName}/${pathName}/' + id, - method: 'delete' - }) -} - -export function putObj(obj) { - return request({ - url: '/${moduleName}/${pathName}', - method: 'put', - data: obj - }) -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm b/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm deleted file mode 100644 index 0c9e51fa2..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/crud.js.vm +++ /dev/null @@ -1,17 +0,0 @@ -export const tableOption = { - "border": true, - "index": true, - "indexLabel": "序号", - "stripe": true, - "menuAlign": "center", - "align": "center", - "column": [ -#foreach ($column in $columns) - { - "type": "input", - "label": "$column.comments", - "prop": "$column.lowerAttrName" - }#if($foreach.hasNext),#end -#end - ] -} diff --git a/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm b/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm deleted file mode 100644 index 47fd26051..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/index.vue.vm +++ /dev/null @@ -1,121 +0,0 @@ - - - - \ No newline at end of file diff --git a/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm b/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm deleted file mode 100644 index c8a353d2a..000000000 --- a/pigx-visual/pigx-code/src/main/resources/template/menu.sql.vm +++ /dev/null @@ -1,16 +0,0 @@ --- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点1000 - --- 菜单SQL -insert into `sys_menu` ( `parent_id`, `path`, `permission`, `type`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) - values ( '1000', '/${moduleName}/${pathName}/index', '', '0', 'icon-bangzhushouji', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理'); - --- 按钮父菜单ID -set @parentId = @@identity; - --- 菜单对应按钮SQL -insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) - SELECT @parentId, '${moduleName}_${pathName}_add', '1', null, '1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增'; -insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) - SELECT @parentId, '${moduleName}_${pathName}_edit', '1', null, '1', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改'; -insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`) - SELECT @parentId, '${moduleName}_${pathName}_del', '1', null, '1', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除'; diff --git a/pigx-visual/pigx-codegen/pom.xml b/pigx-visual/pigx-codegen/pom.xml index 559d0fce8..780b84407 100755 --- a/pigx-visual/pigx-codegen/pom.xml +++ b/pigx-visual/pigx-codegen/pom.xml @@ -25,6 +25,11 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pigx-common-data + com.pig4cloud diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java index e500c0028..f37a655fc 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java @@ -36,6 +36,7 @@ import org.springframework.cloud.client.SpringCloudApplication; @EnablePigxResourceServer public class PigxCodeGenApplication { + public static void main(String[] args) { SpringApplication.run(PigxCodeGenApplication.class, args); } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java index 8a76b1b80..9cc3e6f80 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java @@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.*; public class GenDsConfController { private final GenDatasourceConfService datasourceConfService; + /** * 分页查询 * @@ -87,13 +88,13 @@ public class GenDsConfController { /** * 修改数据源表 * - * @param sysDatasourceConf 数据源表 + * @param conf 数据源表 * @return R */ @SysLog("修改数据源表") @PutMapping - public R updateById(@RequestBody GenDatasourceConf sysDatasourceConf) { - return R.ok(datasourceConfService.updateDsByEnc(sysDatasourceConf)); + public R updateById(@RequestBody GenDatasourceConf conf) { + return R.ok(datasourceConfService.updateDsByEnc(conf)); } /** @@ -105,7 +106,6 @@ public class GenDsConfController { @SysLog("删除数据源表") @DeleteMapping("/{id}") public R removeById(@PathVariable Integer id) { - return R.ok(datasourceConfService.removeById(id)); + return R.ok(datasourceConfService.removeByDsId(id)); } - } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenFormConfController.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenFormConfController.java index a06b04e4e..2ad1077d3 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenFormConfController.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenFormConfController.java @@ -72,14 +72,14 @@ public class GenFormConfController { /** * 通过id查询生成记录 * - * @param dsId 数据源ID + * @param dsName 数据源ID * @param tableName tableName * @return R */ @ApiOperation(value = "通过tableName查询表单信息") @GetMapping("/info") - public R form(Integer dsId, String tableName) { - return R.ok(genRecordService.getForm(dsId, tableName)); + public R form(String dsName, String tableName) { + return R.ok(genRecordService.getForm(dsName, tableName)); } /** diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GeneratorController.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GeneratorController.java index debc95f5c..8cddc4419 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GeneratorController.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GeneratorController.java @@ -45,12 +45,12 @@ public class GeneratorController { * 列表 * * @param tableName 参数集 - * @param id 数据源编号 + * @param dsName 数据源编号 * @return 数据库表 */ @GetMapping("/page") - public R getPage(Page page, String tableName, Integer id) { - return R.ok(generatorService.getPage(page, tableName, id)); + public R getPage(Page page, String tableName, String dsName) { + return R.ok(generatorService.getPage(page, tableName, dsName)); } /** 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 579c45730..6fafa2f1c 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 @@ -27,9 +27,9 @@ import lombok.Data; @Data public class GenConfig { /** - * 数据源ID + * 数据源name */ - private Integer id; + private String dsName; /** * 包名 */ diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java index 2476633de..d93819311 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java @@ -17,6 +17,7 @@ package com.pig4cloud.pigx.codegen.mapper; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; @@ -47,7 +48,8 @@ public interface GeneratorMapper { * @param tableName 表名称 * @return */ - Map queryTable(String tableName); + @DS("#last") + Map queryTable(@Param("tableName") String tableName, String dsName); /** * 查询表列信息 @@ -55,5 +57,6 @@ public interface GeneratorMapper { * @param tableName 表名称 * @return */ - List> queryColumns(String tableName); + @DS("#last") + List> queryColumns(@Param("tableName") String tableName, String dsName); } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenDatasourceConfService.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenDatasourceConfService.java index c5e7e63a9..3b842f18f 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenDatasourceConfService.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenDatasourceConfService.java @@ -41,4 +41,29 @@ public interface GenDatasourceConfService extends IService { * @return */ Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf); + + /** + * 更新动态数据的数据源列表 + * + * @param datasourceConf + * @return + */ + void addDynamicDataSource(GenDatasourceConf datasourceConf); + + + /** + * 校验数据源配置是否有效 + * + * @param datasourceConf 数据源信息 + * @return 有效/无效 + */ + Boolean checkDataSource(GenDatasourceConf datasourceConf); + + /** + * 通过数据源名称删除 + * + * @param dsId 数据源ID + * @return + */ + Boolean removeByDsId(Integer dsId); } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenFormConfService.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenFormConfService.java index a26d1f951..695830b3d 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenFormConfService.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenFormConfService.java @@ -31,10 +31,10 @@ public interface GenFormConfService extends IService { /** * 获取表单信息 * - * @param dsId 数据源ID + * @param dsName 数据源ID * @param tableName 表名称 * @return */ - String getForm(Integer dsId, String tableName); + String getForm(String dsName, String tableName); } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GeneratorService.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GeneratorService.java index 9cc6df264..52c038cb1 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GeneratorService.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GeneratorService.java @@ -29,21 +29,21 @@ import java.util.Map; * @date 2018/7/29 */ public interface GeneratorService { - /** - * 生成代码 - * - * @param tableNames 表名称 - * @return - */ - byte[] generatorCode(GenConfig tableNames); + /** + * 生成代码 + * + * @param tableNames 表名称 + * @return + */ + byte[] generatorCode(GenConfig tableNames); - /** - * 分页查询表 - * - * @param page 分页信息 - * @param tableName 表名 - * @param id 数据源ID - * @return - */ - IPage>> getPage(Page page, String tableName, Integer id); + /** + * 分页查询表 + * + * @param page 分页信息 + * @param tableName 表名 + * @param name 数据源ID + * @return + */ + IPage>> getPage(Page page, String tableName, String name); } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenDatasourceConfServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenDatasourceConfServiceImpl.java index 1a5a2969d..3eae2701c 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenDatasourceConfServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenDatasourceConfServiceImpl.java @@ -17,52 +17,129 @@ package com.pig4cloud.pigx.codegen.service.impl; import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.baomidou.dynamic.datasource.creator.DataSourceCreator; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pigx.codegen.entity.GenDatasourceConf; import com.pig4cloud.pigx.codegen.mapper.GenDatasourceConfMapper; import com.pig4cloud.pigx.codegen.service.GenDatasourceConfService; -import com.pig4cloud.pigx.common.datasource.config.DynamicDataSourceConfig; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.jasypt.encryption.StringEncryptor; import org.springframework.stereotype.Service; +import javax.sql.DataSource; +import java.sql.DriverManager; +import java.sql.SQLException; + /** * 数据源表 * * @author lengleng * @date 2019-03-31 16:00:20 */ +@Slf4j @Service @AllArgsConstructor public class GenDatasourceConfServiceImpl extends ServiceImpl implements GenDatasourceConfService { - private final DynamicDataSourceConfig dynamicDataSourceConfig; + private DynamicRoutingDataSource dynamicRoutingDataSource; private final StringEncryptor stringEncryptor; + private DataSourceCreator dataSourceCreator; /** * 保存数据源并且加密 * - * @param genDatasourceConf + * @param conf * @return */ @Override - public Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf) { - genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); - this.baseMapper.insert(genDatasourceConf); - return dynamicDataSourceConfig.reload(); + public Boolean saveDsByEnc(GenDatasourceConf conf) { + // 校验配置合法性 + if (!checkDataSource(conf)) { + return Boolean.FALSE; + } + + //添加动态数据源 + addDynamicDataSource(conf); + + // 更新数据库配置 + conf.setPassword(stringEncryptor.encrypt(conf.getPassword())); + this.baseMapper.insert(conf); + return Boolean.TRUE; } /** * 更新数据源 * - * @param genDatasourceConf + * @param conf 数据源信息 * @return */ @Override - public Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf) { - if (StrUtil.isNotBlank(genDatasourceConf.getPassword())) { - genDatasourceConf.setPassword(stringEncryptor.encrypt(genDatasourceConf.getPassword())); + public Boolean updateDsByEnc(GenDatasourceConf conf) { + if (!checkDataSource(conf)) { + return Boolean.FALSE; } - this.baseMapper.updateById(genDatasourceConf); - return dynamicDataSourceConfig.reload(); + //先移除 + dynamicRoutingDataSource.removeDataSource( + baseMapper.selectById(conf.getId()).getName()); + + //再添加 + addDynamicDataSource(conf); + + // 更新数据库配置 + if (StrUtil.isNotBlank(conf.getPassword())) { + conf.setPassword(stringEncryptor.encrypt(conf.getPassword())); + } + this.baseMapper.updateById(conf); + return Boolean.TRUE; + } + + + /** + * 通过数据源名称删除 + * + * @param dsId 数据源ID + * @return + */ + @Override + public Boolean removeByDsId(Integer dsId) { + dynamicRoutingDataSource.removeDataSource( + baseMapper.selectById(dsId).getName()); + this.baseMapper.deleteById(dsId); + return Boolean.TRUE; + } + + /** + * 添加动态数据源 + * + * @param conf 数据源信息 + */ + @Override + public void addDynamicDataSource(GenDatasourceConf conf) { + DataSourceProperty dataSourceProperty = new DataSourceProperty(); + dataSourceProperty.setPollName(conf.getName()); + dataSourceProperty.setUrl(conf.getUrl()); + dataSourceProperty.setUsername(conf.getUsername()); + dataSourceProperty.setPassword(conf.getPassword()); + DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty); + dynamicRoutingDataSource.addDataSource(dataSourceProperty.getPollName(), dataSource); + } + + /** + * 校验数据源配置是否有效 + * + * @param conf 数据源信息 + * @return 有效/无效 + */ + @Override + public Boolean checkDataSource(GenDatasourceConf conf) { + try { + DriverManager.getConnection(conf.getUrl(),conf.getUsername(),conf.getPassword()); + } catch (SQLException e) { + log.error("数据源配置 {} , 获取链接失败", conf.getName(), e); + return Boolean.FALSE; + } + return Boolean.TRUE; } } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java index ef7df6c9a..29a5d7a10 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenFormConfServiceImpl.java @@ -26,7 +26,6 @@ import com.pig4cloud.pigx.codegen.mapper.GenFormConfMapper; import com.pig4cloud.pigx.codegen.mapper.GeneratorMapper; import com.pig4cloud.pigx.codegen.service.GenFormConfService; import com.pig4cloud.pigx.codegen.util.GenUtils; -import com.pig4cloud.pigx.common.datasource.support.DynamicDataSourceContextHolder; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.apache.commons.lang.StringUtils; @@ -57,13 +56,13 @@ public class GenFormConfServiceImpl extends ServiceImpllambdaQuery() .eq(GenFormConf::getTableName, tableName) .orderByDesc(GenFormConf::getCreateTime), false); @@ -72,8 +71,7 @@ public class GenFormConfServiceImpl extends ServiceImpl> columns = generatorMapper.queryColumns(tableName); + List> columns = generatorMapper.queryColumns(tableName,dsName); //设置velocity资源加载器 Properties prop = new Properties(); prop.put("file.resource.loader.class", ClasspathResourceLoader.class.getName()); diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java index 581b1b10c..ed5e11d9c 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java @@ -20,6 +20,8 @@ package com.pig4cloud.pigx.codegen.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -29,7 +31,6 @@ import com.pig4cloud.pigx.codegen.mapper.GenFormConfMapper; import com.pig4cloud.pigx.codegen.mapper.GeneratorMapper; import com.pig4cloud.pigx.codegen.service.GeneratorService; import com.pig4cloud.pigx.codegen.util.GenUtils; -import com.pig4cloud.pigx.common.datasource.support.DynamicDataSourceContextHolder; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -54,12 +55,12 @@ public class GeneratorServiceImpl implements GeneratorService { * 分页查询表 * * @param tableName 查询条件 - * @param id + * @param dsName * @return */ @Override - public IPage>> getPage(Page page, String tableName, Integer id) { - DynamicDataSourceContextHolder.setDataSourceType(id); + @DS("#last") + public IPage>> getPage(Page page, String tableName, String dsName) { return generatorMapper.queryList(page, tableName); } @@ -76,16 +77,16 @@ public class GeneratorServiceImpl implements GeneratorService { .eq(GenFormConf::getTableName, genConfig.getTableName()) .orderByDesc(GenFormConf::getCreateTime)); - DynamicDataSourceContextHolder.setDataSourceType(genConfig.getId()); + DynamicDataSourceContextHolder.push(genConfig.getDsName()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); String tableNames = genConfig.getTableName(); for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) { //查询表信息 - Map table = queryTable(tableName); + Map table = generatorMapper.queryTable(tableName,genConfig.getDsName()); //查询列信息 - List> columns = queryColumns(tableName); + List> columns = generatorMapper.queryColumns(tableName, genConfig.getDsName()); //生成代码 if (CollUtil.isNotEmpty(formConfList)) { GenUtils.generatorCode(genConfig, table, columns, zip, formConfList.get(0)); @@ -96,12 +97,4 @@ public class GeneratorServiceImpl implements GeneratorService { IoUtil.close(zip); return outputStream.toByteArray(); } - - private Map queryTable(String tableName) { - return generatorMapper.queryTable(tableName); - } - - private List> queryColumns(String tableName) { - return generatorMapper.queryColumns(tableName); - } } diff --git a/pigx-visual/pigx-dynamic-datasource/README.md b/pigx-visual/pigx-dynamic-datasource/README.md deleted file mode 100644 index 4ac44ffb0..000000000 --- a/pigx-visual/pigx-dynamic-datasource/README.md +++ /dev/null @@ -1,94 +0,0 @@ -## 快速入门 -### 创建测试数据库 -``` -create database `test1` default character set utf8mb4 collate utf8mb4_general_ci; -create database `test2` default character set utf8mb4 collate utf8mb4_general_ci; -create database `test3` default character set utf8mb4 collate utf8mb4_general_ci; -``` -### 创建测试表 -``` - CREATE TABLE `user` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `username` varchar(255) DEFAULT NULL COMMENT '用户名', - `password` varchar(255) DEFAULT NULL COMMENT '密码', - PRIMARY KEY (`id`) USING BTREE - ) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COMMENT='用户测试表'; -``` -### 插入测试数据 -``` -use test1; -BEGIN; -INSERT INTO `user` VALUES (1, 'test1测试一', '123'); -INSERT INTO `user` VALUES (2, 'test1测试二', '123'); -INSERT INTO `user` VALUES (3, 'test1测试三', '123'); -COMMIT; -use test2; -BEGIN; -INSERT INTO `user` VALUES (1, 'test2测试一', '123'); -INSERT INTO `user` VALUES (2, 'test2测试二', '123'); -INSERT INTO `user` VALUES (3, 'test2测试三', '123'); -COMMIT; -use test3; -BEGIN; -INSERT INTO `user` VALUES (1, 'test3测试一', '123'); -INSERT INTO `user` VALUES (2, 'test3测试二', '123'); -INSERT INTO `user` VALUES (3, 'test3测试三', '123'); -COMMIT; -``` -### Nocas新增配置 -``` -## pigx-dynamic-datasource-biz.yml -## spring security 配置 -security: - oauth2: - client: - client-id: ENC(ltJPpR50wT0oIY9kfOe1Iw==) - client-secret: ENC(ltJPpR50wT0oIY9kfOe1Iw==) - scope: server - -# 数据源 -spring: - datasource: - dynamic: - primary: test1 #设置默认的数据源 - druid: - filters: stat - datasource: - test1: - username: ${MYSQL-USER:root} - password: ${MYSQL-USER:root} - url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true - driver-class-name: com.mysql.cj.jdbc.Driver - test2: - username: ${MYSQL-USER:root} - password: ${MYSQL-USER:root} - url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test2?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true - driver-class-name: com.mysql.cj.jdbc.Driver - test3: - username: ${MYSQL-USER:root} - password: ${MYSQL-USER:root} - url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/test3?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true - driver-class-name: com.mysql.cj.jdbc.Driver -``` -### 启动以下应用 -+ PigxNacosApplication -+ PigxSentinelApplication -+ PigxAuthApplication -+ PigxAdminApplication -+ PigxGatewayApplication -+ PigxDynamicDatasourceApplication -### Postman看效果 -``` -http://localhost:6060/test/getTest1 -http://localhost:6060/test/getTest2?current=1&size=5 -http://localhost:6060/test/getTest3?current=1&size=5 -``` -![test1数据库](http://i1.fuimg.com/704023/83e168e45242e135.png "test1数据库") -![test2数据库](http://i1.fuimg.com/704023/cf8c42fbc3512c32.png "test2数据库") -![test3数据库](http://i1.fuimg.com/704023/534483515e3f7cd0.png "test3数据库") -### 切换数据源 -``` -请参考:com/pig4cloud/pigx/dynamic/mapper/TestMapper.java -``` -### 联系我 -QQ:55215085 \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml deleted file mode 100644 index d44172a36..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - com.pig4cloud - pigx-dynamic-datasource - 3.5.0 - - - pigx-dynamic-datasource-api - - - - - com.pig4cloud - pigx-common-core - - - - com.baomidou - mybatis-plus-extension - - - \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java deleted file mode 100644 index b497b9232..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-api/src/main/java/com/pig4cloud/pigx/dynamic/feign/packge-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/* - @author pigx archetype - *

- * feign client 存放目录,注意 @EnablePigxFeignClients 的扫描范围 - */ -package com.pig4cloud.pigx.dynamic.feign; \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml deleted file mode 100644 index 481d203cd..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - 4.0.0 - - com.pig4cloud - pigx-dynamic-datasource - 3.5.0 - - - pigx-dynamic-datasource-biz - - - - - org.springframework.boot - spring-boot-starter-undertow - - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - com.pig4cloud - pigx-common-data - - - com.baomidou - mybatis-plus-boot-starter - - - druid-spring-boot-starter - com.alibaba - 1.1.20 - - - - com.baomidou - dynamic-datasource-spring-boot-starter - 2.5.6 - - - mysql - mysql-connector-java - - - com.pig4cloud - pigx-common-log - - - - com.pig4cloud - pigx-common-security - - - - com.pig4cloud - pigx-common-sentinel - - - - com.pig4cloud - pigx-dynamic-datasource-api - 3.5.0 - - - - com.pig4cloud - pigx-common-swagger - - - - org.springframework.boot - spring-boot-starter-test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java deleted file mode 100644 index e572a2d4e..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/PigxDynamicDatasourceApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.pig4cloud.pigx.dynamic; - -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; -import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.client.SpringCloudApplication; - -/** - * @author pigx archetype - *

- * 项目启动类 - */ -@EnablePigxSwagger2 -@SpringCloudApplication -@EnablePigxFeignClients -@EnablePigxResourceServer -@EnableAutoConfiguration(exclude={DruidDataSourceAutoConfigure.class}) -public class PigxDynamicDatasourceApplication { - public static void main(String[] args) { - SpringApplication.run(PigxDynamicDatasourceApplication.class, args); - } -} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java deleted file mode 100644 index 8f6208e7d..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/controller/TestController.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - * - */ - -package com.pig4cloud.pigx.dynamic.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.common.core.util.R; -import com.pig4cloud.pigx.common.log.annotation.SysLog; -import com.pig4cloud.pigx.dynamic.mapper.TestMapper; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Map; - -/** - * @author liuyes - * @date 2019/11/19 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/test") -@Api(value = "test", tags = "动态多数据源示例模块") -public class TestController { - - private TestMapper testMapper; - - /** - * 获取test1数据库用户信息 - * - * @return 用户信息 - */ - @ApiOperation(value = "查询test1数据库用户信息", notes = "查询test1数据库用户信息") - @SysLog("查询test1数据库用户信息" ) - @PostMapping("/getTest1") - public R getTest1() { - List> list = testMapper.getTest1(); - if (list == null) { - return R.failed(null, "查询失败!"); - } - return R.ok(list,"操作成功!"); - } - - /** - * 获取test2数据库用户信息 - * - * @return 用户信息 - */ - @ApiOperation(value = "查询test2数据库用户信息", notes = "查询test2数据库用户信息") - @SysLog("查询test2数据库用户信息" ) - @PostMapping("/getTest2") - public R getTest2(Page page) { - IPage>> list = testMapper.getTest2(page); - if (list == null) { - return R.failed(null, "查询失败!"); - } - return R.ok(list,"操作成功!"); - } - /** - * 获取test3数据库用户信息 - * - * @return 用户信息 - */ - @ApiOperation(value = "查询test3数据库用户信息", notes = "查询test3数据库用户信息") - @SysLog("查询test3数据库用户信息" ) - @PostMapping("/getTest3") - public R getTest3(Page page) { - IPage>> list = testMapper.getTest3(page); - if (list == null) { - return R.failed(null, "查询失败!"); - } - return R.ok(list,"操作成功!"); - } - -} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java deleted file mode 100644 index 4a4bbfa3d..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/mapper/TestMapper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - * - */ - -package com.pig4cloud.pigx.dynamic.mapper; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Select; - -import java.util.List; -import java.util.Map; - -/** - *

- * test Mapper 接口 - *

- * - * @author liuyes - * @date 2019/11/19 - */ -public interface TestMapper { - - @Select("SELECT * FROM user") - @DS("test1") - List> getTest1(); - - @DS("test2") - IPage>> getTest2(Page page); - - @DS("test3") - IPage>> getTest3(Page page); - -} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java deleted file mode 100644 index 0950a4b28..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/java/com/pig4cloud/pigx/dynamic/vo/UserVO.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pig4cloud.pigx.dynamic.vo; - -import lombok.Data; - -@Data -public class UserVO { - private Integer id; - private String username; - private String password; -} diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml deleted file mode 100644 index 05389d5f5..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,16 +0,0 @@ -server: - port: 6060 - -spring: - application: - name: @artifactId@ - cloud: - nacos: - discovery: - server-addr: ${NACOS-HOST:pigx-register}:${NACOS-PORT:8848} - config: - server-addr: ${spring.cloud.nacos.discovery.server-addr} - file-extension: yml - shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - profiles: - active: dev diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index 964ca8735..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - ${CONSOLE_LOG_PATTERN} - - - - - - ${log.path}/debug.log - - ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz - 50MB - 30 - - - %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n - - - - - - ${log.path}/error.log - - ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz - 50MB - 30 - - - %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n - - - ERROR - - - - - - - - - - - - - - - - - diff --git a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml b/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml deleted file mode 100644 index fcbe041f9..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pigx-dynamic-datasource-biz/src/main/resources/mapper/TestMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/pigx-visual/pigx-dynamic-datasource/pom.xml b/pigx-visual/pigx-dynamic-datasource/pom.xml deleted file mode 100644 index bbb59f65c..000000000 --- a/pigx-visual/pigx-dynamic-datasource/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - pigx-visual - com.pig4cloud - 3.5.0 - - - 4.0.0 - - pigx-dynamic-datasource - pom - pigx-dynamic-datasource - - - 2.1.10.RELEASE - Greenwich.SR3 - 2.1.0.RELEASE - Cairo-SR8 - UTF-8 - 1.8 - 1.8 - 5.0.5 - 3.5.0 - 0.0.9 - 2.1.1 - 2.10.2 - 2.1.6 - 2.3.6.RELEASE - - - - - pigx-dynamic-datasource-api - pigx-dynamic-datasource-biz - - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - com.github.ulisesbocchio - jasypt-spring-boot-starter - ${jasypt.version} - - - - org.springframework.boot - spring-boot-starter-actuator - - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin.version} - - - - org.projectlombok - lombok - provided - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - io.spring.platform - platform-bom - ${spring-platform.version} - pom - import - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - com.pig4cloud - pigx-common-bom - ${pigx.bom.version} - pom - import - - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${spring-cloud-alibaba.version} - pom - import - - - - org.springframework.security.oauth - spring-security-oauth2 - ${security.oauth.version} - - - - org.springframework.boot - spring-boot-starter-web - ${spring-boot.version} - - - - spring-boot-starter-tomcat - org.springframework.boot - - - - - - - - ${project.name} - - - src/main/resources - true - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - - - - - maven-compiler-plugin - 3.8.0 - - ${maven.compiler.target} - ${maven.compiler.source} - UTF-8 - true - - - - pl.project13.maven - git-commit-id-plugin - 2.2.5 - - - - diff --git a/pigx-visual/pom.xml b/pigx-visual/pom.xml index 3d8ff74ad..f111e637c 100644 --- a/pigx-visual/pom.xml +++ b/pigx-visual/pom.xml @@ -42,7 +42,5 @@ pigx-sso-client-demo pigx-sentinel-dashboard pigx-tx-manager - pigx-dynamic-datasource - pigx-code From 100289dc2bd02c98dc0c1dc0c071449ddca6d877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sat, 8 Feb 2020 17:32:23 +0800 Subject: [PATCH 022/130] =?UTF-8?q?:recycle:=20Refactoring=20code.=20#743?= =?UTF-8?q?=20=E3=80=90=E9=87=8D=E6=9E=84=E3=80=91Mapper=20=E5=8E=BB?= =?UTF-8?q?=E6=8E=89@MapperScan=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E5=A2=9E=E5=8A=A0@Mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java | 2 -- pigx-upms/pigx-upms-api/pom.xml | 2 +- .../java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java | 2 ++ .../com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysDictItemMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysFileMapper.java | 2 ++ .../main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java | 2 ++ .../pigx/admin/mapper/SysOauthClientDetailsMapper.java | 2 ++ .../com/pig4cloud/pigx/admin/mapper/SysPublicParamMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java | 2 ++ .../com/pig4cloud/pigx/admin/mapper/SysRouteConfMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysTenantMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java | 2 ++ .../java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java | 2 ++ .../pig4cloud/pigx/codegen/mapper/GenDatasourceConfMapper.java | 2 ++ .../com/pig4cloud/pigx/codegen/mapper/GenFormConfMapper.java | 2 ++ .../java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java | 2 ++ .../pigx-codegen/src/main/resources/template/Mapper.java.vm | 2 ++ .../pigx/daemon/elastic/mapper/ExecutionLogMapper.java | 2 ++ .../pigx/daemon/elastic/mapper/StatusTraceLogMapper.java | 2 ++ .../pig4cloud/pigx/daemon/quartz/config/PigxInitQuartzJob.java | 2 +- .../pig4cloud/pigx/daemon/quartz/config/PigxQuartzFactory.java | 2 +- .../quartz/{constant/enums => constants}/JobTypeQuartzEnum.java | 2 +- .../quartz/{constant/enums => constants}/PigxQuartzEnum.java | 2 +- .../pigx/daemon/quartz/controller/SysJobController.java | 2 +- .../pig4cloud/pigx/daemon/quartz/mapper/SysJobLogMapper.java | 2 ++ .../com/pig4cloud/pigx/daemon/quartz/mapper/SysJobMapper.java | 2 ++ .../pig4cloud/pigx/daemon/quartz/task/SpringBeanTaskDemo.java | 2 +- .../pig4cloud/pigx/daemon/quartz/util/JavaClassTaskInvok.java | 2 +- .../pig4cloud/pigx/daemon/quartz/util/SpringBeanTaskInvok.java | 2 +- .../com/pig4cloud/pigx/daemon/quartz/util/TaskInvokFactory.java | 2 +- .../com/pig4cloud/pigx/daemon/quartz/util/TaskInvokUtil.java | 2 +- .../java/com/pig4cloud/pigx/daemon/quartz/util/TaskUtil.java | 2 +- .../java/com/pig4cloud/pigx/mp/mapper/WxAccountFansMapper.java | 2 ++ .../main/java/com/pig4cloud/pigx/mp/mapper/WxAccountMapper.java | 2 ++ .../main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgMapper.java | 2 ++ .../java/com/pig4cloud/pigx/mp/mapper/WxFansMsgResMapper.java | 2 ++ .../main/java/com/pig4cloud/pigx/mp/mapper/WxMenuMapper.java | 2 ++ .../java/com/pig4cloud/pigx/pay/mapper/PayChannelMapper.java | 2 ++ .../java/com/pig4cloud/pigx/pay/mapper/PayGoodsOrderMapper.java | 2 ++ .../com/pig4cloud/pigx/pay/mapper/PayNotifyRecordMapper.java | 2 ++ .../com/pig4cloud/pigx/pay/mapper/PayRefundOrderMapper.java | 2 ++ .../java/com/pig4cloud/pigx/pay/mapper/PayTradeOrderMapper.java | 2 ++ 46 files changed, 78 insertions(+), 14 deletions(-) rename pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/{constant/enums => constants}/JobTypeQuartzEnum.java (95%) rename pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/{constant/enums => constants}/PigxQuartzEnum.java (97%) diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java index 0d64acaa9..7c50d9292 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java @@ -24,7 +24,6 @@ import com.pig4cloud.pigx.common.data.datascope.DataScopeHandle; import com.pig4cloud.pigx.common.data.datascope.DataScopeInterceptor; import com.pig4cloud.pigx.common.data.datascope.PigxDefaultDatascopeHandle; import com.pig4cloud.pigx.common.data.tenant.PigxTenantHandler; -import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -44,7 +43,6 @@ import java.util.List; @Configuration @ConditionalOnBean(DataSource.class) @AutoConfigureAfter(DataSourceAutoConfiguration.class) -@MapperScan("com.pig4cloud.pigx.**.mapper") public class MybatisPlusConfig { /** diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml index 8ac0af4ea..96717d305 100644 --- a/pigx-upms/pigx-upms-api/pom.xml +++ b/pigx-upms/pigx-upms-api/pom.xml @@ -44,7 +44,7 @@ com.baomidou mybatis-plus-extension
- + com.pig4cloud pigx-common-sentinel diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java index e83f7335e..738274b24 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysDept; import com.pig4cloud.pigx.common.data.datascope.DataScope; +import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -33,6 +34,7 @@ import java.util.List; * @author lengleng * @since 2018-01-20 */ +@Mapper public interface SysDeptMapper extends BaseMapper { /** diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java index 874c96756..823279ce2 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java @@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -30,6 +31,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; * @author lengleng * @since 2018-02-12 */ +@Mapper public interface SysDeptRelationMapper extends BaseMapper { /** * 删除部门关系表数据 diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictItemMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictItemMapper.java index ffe5e4967..5b942a6ce 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictItemMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictItemMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysDictItem; +import org.apache.ibatis.annotations.Mapper; /** * 字典项 @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDictItem; * @author lengleng * @date 2019/03/19 */ +@Mapper public interface SysDictItemMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java index 684da122c..318460179 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java @@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysDict; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -30,6 +31,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDict; * @author lengleng * @since 2017-11-19 */ +@Mapper public interface SysDictMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysFileMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysFileMapper.java index 3516b06ba..d8f4140aa 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysFileMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysFileMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysFile; +import org.apache.ibatis.annotations.Mapper; /** * 文件管理 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysFile; * @author Luckly * @date 2019-06-18 17:18:42 */ +@Mapper public interface SysFileMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java index cdcc9235e..f33f904cc 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java @@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysLog; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -30,5 +31,6 @@ import com.pig4cloud.pigx.admin.api.entity.SysLog; * @author lengleng * @since 2017-11-20 */ +@Mapper public interface SysLogMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java index 6117d82ed..75d752ca6 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysMenu; import com.pig4cloud.pigx.admin.api.vo.MenuVO; +import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -33,6 +34,7 @@ import java.util.List; * @author lengleng * @since 2017-10-29 */ +@Mapper public interface SysMenuMapper extends BaseMapper { /** diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java index f0e058d95..c5184776e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -31,6 +32,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; * @author lengleng * @since 2018-05-15 */ +@Mapper public interface SysOauthClientDetailsMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPublicParamMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPublicParamMapper.java index 542590821..8fce8c9aa 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPublicParamMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPublicParamMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysPublicParam; +import org.apache.ibatis.annotations.Mapper; /** * 公共参数配置 @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysPublicParam; * @author Lucky * @date 2019-04-29 */ +@Mapper public interface SysPublicParamMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java index f9a6dd4dd..730ae8002 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java @@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysRole; +import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -32,6 +33,7 @@ import java.util.List; * @author lengleng * @since 2017-10-29 */ +@Mapper public interface SysRoleMapper extends BaseMapper { /** * 通过用户ID,查询角色信息 diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java index 0183fda50..e853335f0 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -31,6 +32,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; * @author lengleng * @since 2017-10-29 */ +@Mapper public interface SysRoleMenuMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRouteConfMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRouteConfMapper.java index 576d5f0a7..73527d2c0 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRouteConfMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRouteConfMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysRouteConf; +import org.apache.ibatis.annotations.Mapper; /** * 路由 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysRouteConf; * @author lengleng * @date 2018-11-06 10:17:18 */ +@Mapper public interface SysRouteConfMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysTenantMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysTenantMapper.java index 5f49f77f4..e8ef8af7e 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysTenantMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysTenantMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysTenant; +import org.apache.ibatis.annotations.Mapper; /** * 租户 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysTenant; * @author lengleng * @date 2019-05-15 15:55:41 */ +@Mapper public interface SysTenantMapper extends BaseMapper { } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java index 16cd4ad83..4a311b8ef 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java @@ -26,6 +26,7 @@ import com.pig4cloud.pigx.admin.api.dto.UserDTO; import com.pig4cloud.pigx.admin.api.entity.SysUser; import com.pig4cloud.pigx.admin.api.vo.UserVO; import com.pig4cloud.pigx.common.data.datascope.DataScope; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -38,6 +39,7 @@ import java.util.List; * @author lengleng * @since 2017-10-29 */ +@Mapper public interface SysUserMapper extends BaseMapper { /** * 通过用户名查询用户信息(含有角色信息) diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java index 4029bf69a..a419f769f 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.admin.api.entity.SysUserRole; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; /** @@ -32,6 +33,7 @@ import org.apache.ibatis.annotations.Param; * @author lengleng * @since 2017-10-29 */ +@Mapper public interface SysUserRoleMapper extends BaseMapper { /** * 根据用户Id删除该用户的角色关系 diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenDatasourceConfMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenDatasourceConfMapper.java index acc2e8586..d5ce7707e 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenDatasourceConfMapper.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenDatasourceConfMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.codegen.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.codegen.entity.GenDatasourceConf; +import org.apache.ibatis.annotations.Mapper; /** * 数据源表 @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.codegen.entity.GenDatasourceConf; * @author lengleng * @date 2019-03-31 16:00:20 */ +@Mapper public interface GenDatasourceConfMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenFormConfMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenFormConfMapper.java index 74fa89326..d9e0d1b57 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenFormConfMapper.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GenFormConfMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.codegen.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.codegen.entity.GenFormConf; +import org.apache.ibatis.annotations.Mapper; /** * 生成记录 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.codegen.entity.GenFormConf; * @author lengleng * @date 2019-08-12 15:55:35 */ +@Mapper public interface GenFormConfMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java index d93819311..5af04db55 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java @@ -20,6 +20,7 @@ package com.pig4cloud.pigx.codegen.mapper; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -31,6 +32,7 @@ import java.util.Map; * @author lengleng * @date 2018-07-30 */ +@Mapper public interface GeneratorMapper { /** diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm b/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm index 867859b51..d5f3d3937 100755 --- a/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm +++ b/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm @@ -19,6 +19,7 @@ package ${package}.${moduleName}.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import ${package}.${moduleName}.entity.${className}; +import org.apache.ibatis.annotations.Mapper; /** * ${comments} @@ -26,6 +27,7 @@ import ${package}.${moduleName}.entity.${className}; * @author ${author} * @date ${datetime} */ +@Mapper public interface ${className}Mapper extends BaseMapper<${className}> { } diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/ExecutionLogMapper.java b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/ExecutionLogMapper.java index ad7cc8279..f0d19fc20 100644 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/ExecutionLogMapper.java +++ b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/ExecutionLogMapper.java @@ -2,6 +2,7 @@ package com.pig4cloud.pigx.daemon.elastic.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.daemon.elastic.entity.ExecutionLog; +import org.apache.ibatis.annotations.Mapper; /** * 任务日志处理 @@ -9,6 +10,7 @@ import com.pig4cloud.pigx.daemon.elastic.entity.ExecutionLog; * @author lishangbu * @date 2018/11/22 */ +@Mapper public interface ExecutionLogMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/StatusTraceLogMapper.java b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/StatusTraceLogMapper.java index 1efdd443c..f301fe207 100644 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/StatusTraceLogMapper.java +++ b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/mapper/StatusTraceLogMapper.java @@ -2,6 +2,7 @@ package com.pig4cloud.pigx.daemon.elastic.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.daemon.elastic.entity.StatusTraceLog; +import org.apache.ibatis.annotations.Mapper; /** * 任务轨迹处理 @@ -9,6 +10,7 @@ import com.pig4cloud.pigx.daemon.elastic.entity.StatusTraceLog; * @author lishangbu * @date 2018/11/22 */ +@Mapper public interface StatusTraceLogMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxInitQuartzJob.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxInitQuartzJob.java index d3e89ad83..7c75af8d9 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxInitQuartzJob.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxInitQuartzJob.java @@ -18,7 +18,7 @@ package com.pig4cloud.pigx.daemon.quartz.config; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.service.SysJobService; import com.pig4cloud.pigx.daemon.quartz.util.TaskUtil; import lombok.AllArgsConstructor; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxQuartzFactory.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxQuartzFactory.java index 9a3ff1f23..afd545bda 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxQuartzFactory.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/config/PigxQuartzFactory.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.daemon.quartz.config; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/JobTypeQuartzEnum.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/JobTypeQuartzEnum.java similarity index 95% rename from pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/JobTypeQuartzEnum.java rename to pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/JobTypeQuartzEnum.java index 54fdcfb91..abad19731 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/JobTypeQuartzEnum.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/JobTypeQuartzEnum.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.daemon.quartz.constant.enums; +package com.pig4cloud.pigx.daemon.quartz.constants; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/PigxQuartzEnum.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/PigxQuartzEnum.java similarity index 97% rename from pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/PigxQuartzEnum.java rename to pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/PigxQuartzEnum.java index 2d72f4405..77e1c53fb 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constant/enums/PigxQuartzEnum.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/constants/PigxQuartzEnum.java @@ -15,7 +15,7 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.daemon.quartz.constant.enums; +package com.pig4cloud.pigx.daemon.quartz.constants; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/controller/SysJobController.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/controller/SysJobController.java index 9a39c0616..f7c778a88 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/controller/SysJobController.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/controller/SysJobController.java @@ -36,7 +36,7 @@ import org.quartz.Scheduler; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; -import static com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum.*; +import static com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum.*; /** diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobLogMapper.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobLogMapper.java index 970b940f6..ea9181c1b 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobLogMapper.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobLogMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.daemon.quartz.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.daemon.quartz.entity.SysJobLog; +import org.apache.ibatis.annotations.Mapper; /** * 定时任务执行日志表 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.daemon.quartz.entity.SysJobLog; * @author frwcloud * @date 2019-01-27 13:40:20 */ +@Mapper public interface SysJobLogMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobMapper.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobMapper.java index a777f003b..475edc918 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobMapper.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/mapper/SysJobMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.daemon.quartz.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; +import org.apache.ibatis.annotations.Mapper; /** * 定时任务调度表 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; * @author frwcloud * @date 2019-01-27 10:04:42 */ +@Mapper public interface SysJobMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/task/SpringBeanTaskDemo.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/task/SpringBeanTaskDemo.java index c4151cd69..0338b5c89 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/task/SpringBeanTaskDemo.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/task/SpringBeanTaskDemo.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.daemon.quartz.task; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/JavaClassTaskInvok.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/JavaClassTaskInvok.java index dbae08bb3..0ddc6e26f 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/JavaClassTaskInvok.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/JavaClassTaskInvok.java @@ -18,7 +18,7 @@ package com.pig4cloud.pigx.daemon.quartz.util; import cn.hutool.core.util.StrUtil; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; import com.pig4cloud.pigx.daemon.quartz.exception.TaskException; import lombok.extern.slf4j.Slf4j; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/SpringBeanTaskInvok.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/SpringBeanTaskInvok.java index 00491ebe2..7712a2bd3 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/SpringBeanTaskInvok.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/SpringBeanTaskInvok.java @@ -19,7 +19,7 @@ package com.pig4cloud.pigx.daemon.quartz.util; import cn.hutool.core.util.StrUtil; import com.pig4cloud.pigx.common.core.util.SpringContextHolder; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; import com.pig4cloud.pigx.daemon.quartz.exception.TaskException; import lombok.extern.slf4j.Slf4j; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokFactory.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokFactory.java index 741a47943..825dca5c5 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokFactory.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokFactory.java @@ -2,7 +2,7 @@ package com.pig4cloud.pigx.daemon.quartz.util; import cn.hutool.core.util.StrUtil; import com.pig4cloud.pigx.common.core.util.SpringContextHolder; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.JobTypeQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.JobTypeQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.exception.TaskException; import lombok.extern.slf4j.Slf4j; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokUtil.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokUtil.java index af01248fd..fa5fbc890 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokUtil.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskInvokUtil.java @@ -19,7 +19,7 @@ package com.pig4cloud.pigx.daemon.quartz.util; import cn.hutool.core.util.StrUtil; -import com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum; +import com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum; import com.pig4cloud.pigx.daemon.quartz.entity.SysJob; import com.pig4cloud.pigx.daemon.quartz.entity.SysJobLog; import com.pig4cloud.pigx.daemon.quartz.event.SysJobLogEvent; diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskUtil.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskUtil.java index 6b65eb664..256ccd324 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskUtil.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/util/TaskUtil.java @@ -23,7 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.quartz.*; import org.springframework.stereotype.Component; -import static com.pig4cloud.pigx.daemon.quartz.constant.enums.PigxQuartzEnum.*; +import static com.pig4cloud.pigx.daemon.quartz.constants.PigxQuartzEnum.*; /** * 定时任务的工具类 diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountFansMapper.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountFansMapper.java index 010329ea7..723072783 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountFansMapper.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountFansMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.mp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.mp.entity.WxAccountFans; +import org.apache.ibatis.annotations.Mapper; /** * 微信公众号粉丝 @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.mp.entity.WxAccountFans; * @author lengleng * @date 2019-03-26 22:08:08 */ +@Mapper public interface WxAccountFansMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountMapper.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountMapper.java index 899c95124..011dd1cc4 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountMapper.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxAccountMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.mp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.mp.entity.WxAccount; +import org.apache.ibatis.annotations.Mapper; /** * 公众号账户 @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.mp.entity.WxAccount; * @author lengleng * @date 2019-03-26 22:07:53 */ +@Mapper public interface WxAccountMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgMapper.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgMapper.java index d09c9ef25..8472adcd8 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgMapper.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.mp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.mp.entity.WxFansMsg; +import org.apache.ibatis.annotations.Mapper; /** * lengleng @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.mp.entity.WxFansMsg; * @author lengleng * @date 2019-03-27 20:45:27 */ +@Mapper public interface WxFansMsgMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgResMapper.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgResMapper.java index 876c5ff60..8a21ccfe5 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgResMapper.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxFansMsgResMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.mp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.mp.entity.WxFansMsgRes; +import org.apache.ibatis.annotations.Mapper; /** * lengleng @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.mp.entity.WxFansMsgRes; * @author lengleng * @date 2019-03-27 20:45:48 */ +@Mapper public interface WxFansMsgResMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxMenuMapper.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxMenuMapper.java index 1d219c9b0..facf5174d 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxMenuMapper.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/mapper/WxMenuMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.mp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.mp.entity.WxMpMenu; +import org.apache.ibatis.annotations.Mapper; /** * lengleng @@ -25,6 +26,7 @@ import com.pig4cloud.pigx.mp.entity.WxMpMenu; * @author lengleng * @date 2019-03-27 20:45:18 */ +@Mapper public interface WxMenuMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayChannelMapper.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayChannelMapper.java index 50a1889f2..8886d65b4 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayChannelMapper.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayChannelMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.pay.entity.PayChannel; +import org.apache.ibatis.annotations.Mapper; /** * 渠道 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.pay.entity.PayChannel; * @author lengleng * @date 2019-05-28 23:57:58 */ +@Mapper public interface PayChannelMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayGoodsOrderMapper.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayGoodsOrderMapper.java index fa337a084..9e9a2c500 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayGoodsOrderMapper.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayGoodsOrderMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.pay.entity.PayGoodsOrder; +import org.apache.ibatis.annotations.Mapper; /** * 商品 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.pay.entity.PayGoodsOrder; * @author lengleng * @date 2019-05-28 23:58:27 */ +@Mapper public interface PayGoodsOrderMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayNotifyRecordMapper.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayNotifyRecordMapper.java index e064f34fa..d803b2755 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayNotifyRecordMapper.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayNotifyRecordMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.pay.entity.PayNotifyRecord; +import org.apache.ibatis.annotations.Mapper; /** * 异步通知记录 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.pay.entity.PayNotifyRecord; * @author lengleng * @date 2019-05-28 23:57:23 */ +@Mapper public interface PayNotifyRecordMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayRefundOrderMapper.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayRefundOrderMapper.java index 1030a66cc..b7f66688c 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayRefundOrderMapper.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayRefundOrderMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.pay.entity.PayRefundOrder; +import org.apache.ibatis.annotations.Mapper; /** * 退款 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.pay.entity.PayRefundOrder; * @author lengleng * @date 2019-05-28 23:58:11 */ +@Mapper public interface PayRefundOrderMapper extends BaseMapper { } diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayTradeOrderMapper.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayTradeOrderMapper.java index 5e676eca6..38cb16782 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayTradeOrderMapper.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/mapper/PayTradeOrderMapper.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pigx.pay.entity.PayTradeOrder; +import org.apache.ibatis.annotations.Mapper; /** * 支付 @@ -26,6 +27,7 @@ import com.pig4cloud.pigx.pay.entity.PayTradeOrder; * @author lengleng * @date 2019-05-28 23:58:18 */ +@Mapper public interface PayTradeOrderMapper extends BaseMapper { } From 9f22f3e9997a679f062a359be540c071d9d04662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 9 Feb 2020 21:17:43 +0800 Subject: [PATCH 023/130] =?UTF-8?q?=20#743=20=E3=80=90=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E3=80=91Mapper=20=E5=8E=BB=E6=8E=89@MapperScan=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E6=89=8B=E5=8A=A8=E5=A2=9E=E5=8A=A0@Mapper?= =?UTF-8?q?=20=E6=96=B0=E7=89=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java | 4 +++- .../pig4cloud/pigx/admin/controller/SysMenuController.java | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java index cab02e059..4bdf85fbd 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java @@ -30,7 +30,7 @@ import java.util.List; /** * @author lengleng - * @date 2017年11月9日23:34:11 + * @date 2020-02-09 */ @UtilityClass public class TreeUtil { @@ -115,6 +115,8 @@ public class TreeUtil { node.setCode(menu.getPermission()); node.setLabel(menu.getName()); node.setIcon(menu.getIcon()); + node.setType(menu.getType()); + node.setSort(menu.getSort()); node.setKeepAlive(menu.getKeepAlive()); trees.add(node); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysMenuController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysMenuController.java index 71612375e..ebcb46bcb 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysMenuController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysMenuController.java @@ -70,7 +70,6 @@ public class SysMenuController { .sorted(Comparator.comparingInt(MenuTree::getSort)) .collect(Collectors.toList()); - return R.ok(TreeUtil.build(menuTreeList, parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId)); } From f0d18f82d5d20faf82b8502fe64c942fa5b439b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 9 Feb 2020 21:18:37 +0800 Subject: [PATCH 024/130] =?UTF-8?q?:sparkles:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E7=89=B9=E6=80=A7.=20=20pigx-common-feing=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81META-INF=20=E8=87=AA=E5=8A=A8=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-auth/pom.xml | 5 + .../pigx/auth/PigxAuthApplication.java | 4 +- pigx-common/pigx-common-bom/pom.xml | 17 ++ .../data/mybatis/MybatisPlusConfig.java | 5 +- pigx-common/pigx-common-feign/pom.xml | 22 ++ .../feign/PigxFeignAutoConfiguration.java | 40 +++ .../annotation/EnablePigxFeignClients.java | 7 +- .../openfeign/PigxFeignClientsRegistrar.java | 231 ++++++++++++++++++ .../main/resources/META-INF/spring.factories | 2 + pigx-common/pigx-common-security/pom.xml | 5 + ...re.java => SentinelAutoConfiguration.java} | 2 +- .../main/resources/META-INF/spring.factories | 2 +- pigx-common/pom.xml | 1 + pigx-upms/pigx-upms-api/pom.xml | 4 +- .../main/resources/META-INF/spring.factories | 7 + .../pigx/admin/PigxAdminApplication.java | 2 +- pigx-visual/pigx-codegen/pom.xml | 5 + .../pigx/codegen/PigxCodeGenApplication.java | 4 +- pigx-visual/pigx-daemon-elastic-job/pom.xml | 5 + .../PigxDaemonElasticJobApplication.java | 2 +- pigx-visual/pigx-daemon-quartz/pom.xml | 5 + .../quartz/PigxDaemonQuartzApplication.java | 4 +- pigx-visual/pigx-mp-platform/pom.xml | 5 + .../pigx/mp/PigxMpPlatformApplication.java | 4 +- pigx-visual/pigx-oa-platform/pom.xml | 9 + .../pigx/act/PigxActivitiApplication.java | 2 +- pigx-visual/pigx-pay-platform/pom.xml | 7 +- .../pigx/pay/PigxPayPlatformApplication.java | 2 +- 28 files changed, 389 insertions(+), 21 deletions(-) create mode 100755 pigx-common/pigx-common-feign/pom.xml create mode 100644 pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/PigxFeignAutoConfiguration.java rename pigx-common/{pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security => pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign}/annotation/EnablePigxFeignClients.java (91%) create mode 100644 pigx-common/pigx-common-feign/src/main/java/org/springframework/cloud/openfeign/PigxFeignClientsRegistrar.java create mode 100755 pigx-common/pigx-common-feign/src/main/resources/META-INF/spring.factories rename pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/{SentinelAutoConfigure.java => SentinelAutoConfiguration.java} (97%) create mode 100755 pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories diff --git a/pigx-auth/pom.xml b/pigx-auth/pom.xml index fbb50c7a2..ad373932e 100644 --- a/pigx-auth/pom.xml +++ b/pigx-auth/pom.xml @@ -53,6 +53,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-feign + mysql diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java index bd492f999..2e41ffa7c 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java @@ -20,13 +20,13 @@ package com.pig4cloud.pigx.auth; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import org.springframework.boot.SpringApplication; import org.springframework.cloud.client.SpringCloudApplication; /** * @author lengleng - * @date 2018年06月21日 + * @date 2020-02-08 * 认证授权中心 */ @SpringCloudApplication diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml index 107d1081f..31738e563 100644 --- a/pigx-common/pigx-common-bom/pom.xml +++ b/pigx-common/pigx-common-bom/pom.xml @@ -24,6 +24,8 @@ 8.0.18 1.5.22 3.6.0 + 1.2.0 + 3.0.52.ALL @@ -78,6 +80,11 @@ pigx-common-sentinel ${pigx.version} + + com.pig4cloud + pigx-common-feign + ${pigx.version} + com.pig4cloud pigx-common-sequence @@ -144,6 +151,16 @@ weixin-java-common ${mp.weixin.version} + + com.github.javen205 + IJPay + ${ijpay.version} + + + com.alipay.sdk + alipay-sdk-java + ${aliyun.version} + com.baomidou dynamic-datasource-spring-boot-starter diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java index 7c50d9292..f57a5e08d 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java @@ -20,6 +20,7 @@ package com.pig4cloud.pigx.common.data.mybatis; import com.baomidou.mybatisplus.core.parser.ISqlParser; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser; +import com.pig4cloud.pigx.admin.api.feign.RemoteDataScopeService; import com.pig4cloud.pigx.common.data.datascope.DataScopeHandle; import com.pig4cloud.pigx.common.data.datascope.DataScopeInterceptor; import com.pig4cloud.pigx.common.data.datascope.PigxDefaultDatascopeHandle; @@ -38,7 +39,7 @@ import java.util.List; /** * @author lengleng - * @date 2017/10/29 + * @date 2020-02-08 */ @Configuration @ConditionalOnBean(DataSource.class) @@ -82,6 +83,7 @@ public class MybatisPlusConfig { */ @Bean @ConditionalOnMissingBean + @ConditionalOnBean(RemoteDataScopeService.class) public DataScopeHandle dataScopeHandle() { return new PigxDefaultDatascopeHandle(); } @@ -93,6 +95,7 @@ public class MybatisPlusConfig { */ @Bean @ConditionalOnMissingBean + @ConditionalOnBean(DataScopeHandle.class) public DataScopeInterceptor dataScopeInterceptor() { return new DataScopeInterceptor(dataScopeHandle()); } diff --git a/pigx-common/pigx-common-feign/pom.xml b/pigx-common/pigx-common-feign/pom.xml new file mode 100755 index 000000000..6bacaf1d9 --- /dev/null +++ b/pigx-common/pigx-common-feign/pom.xml @@ -0,0 +1,22 @@ + + + + com.pig4cloud + pigx-common + 3.7.0 + + + 4.0.0 + jar + pigx-common-feign + feign 通用组件 + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + diff --git a/pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/PigxFeignAutoConfiguration.java b/pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/PigxFeignAutoConfiguration.java new file mode 100644 index 000000000..46ec3b360 --- /dev/null +++ b/pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/PigxFeignAutoConfiguration.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.feign; + +import feign.Feign; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.cloud.openfeign.PigxFeignClientsRegistrar; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * @author lengleng + * @date 2020/2/8 + *

+ * feign 自动化配置 + */ +@Configuration +@ConditionalOnClass(Feign.class) +@Import(PigxFeignClientsRegistrar.class) +@AutoConfigureAfter(EnableFeignClients.class) +public class PigxFeignAutoConfiguration { + +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/annotation/EnablePigxFeignClients.java b/pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/annotation/EnablePigxFeignClients.java similarity index 91% rename from pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/annotation/EnablePigxFeignClients.java rename to pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/annotation/EnablePigxFeignClients.java index f6fc388a3..9075c216b 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/annotation/EnablePigxFeignClients.java +++ b/pigx-common/pigx-common-feign/src/main/java/com/pig4cloud/pigx/common/feign/annotation/EnablePigxFeignClients.java @@ -15,20 +15,23 @@ * Author: lengleng (wangiegie@gmail.com) */ -package com.pig4cloud.pigx.common.security.annotation; +package com.pig4cloud.pigx.common.feign.annotation; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.cloud.openfeign.PigxFeignClientsRegistrar; +import org.springframework.context.annotation.Import; import java.lang.annotation.*; /** * @author lengleng - * @date 2018/9/5 + * @date 2020-02-08 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @EnableFeignClients +@Import(PigxFeignClientsRegistrar.class) public @interface EnablePigxFeignClients { /** * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation diff --git a/pigx-common/pigx-common-feign/src/main/java/org/springframework/cloud/openfeign/PigxFeignClientsRegistrar.java b/pigx-common/pigx-common-feign/src/main/java/org/springframework/cloud/openfeign/PigxFeignClientsRegistrar.java new file mode 100644 index 000000000..5585de580 --- /dev/null +++ b/pigx-common/pigx-common-feign/src/main/java/org/springframework/cloud/openfeign/PigxFeignClientsRegistrar.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package org.springframework.cloud.openfeign; + +import com.pig4cloud.pigx.common.feign.PigxFeignAutoConfiguration; +import lombok.Getter; +import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.beans.factory.config.BeanDefinitionHolder; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; +import org.springframework.core.annotation.AnnotatedElementUtils; +import org.springframework.core.annotation.AnnotationAttributes; +import org.springframework.core.env.Environment; +import org.springframework.core.io.support.SpringFactoriesLoader; +import org.springframework.core.type.AnnotationMetadata; +import org.springframework.lang.Nullable; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Map; + +/** + * @author L.cm + * @date 2020/2/8 + *

+ * feign 自动配置功能 from mica + */ +public class PigxFeignClientsRegistrar implements ImportBeanDefinitionRegistrar, BeanClassLoaderAware, EnvironmentAware { + @Getter + private ClassLoader beanClassLoader; + @Getter + private Environment environment; + + @Override + public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { + registerFeignClients(registry); + } + + @Override + public void setBeanClassLoader(ClassLoader classLoader) { + this.beanClassLoader = classLoader; + } + + private void registerFeignClients(BeanDefinitionRegistry registry) { + List feignClients = SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()); + // 如果 spring.factories 里为空 + if (feignClients.isEmpty()) { + return; + } + for (String className : feignClients) { + try { + Class clazz = beanClassLoader.loadClass(className); + AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz, FeignClient.class); + if (attributes == null) { + continue; + } + // 如果已经存在该 bean,支持原生的 Feign + if (registry.containsBeanDefinition(className)) { + continue; + } + registerClientConfiguration(registry, getClientName(attributes), attributes.get("configuration")); + + validate(attributes); + BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(FeignClientFactoryBean.class); + definition.addPropertyValue("url", getUrl(attributes)); + definition.addPropertyValue("path", getPath(attributes)); + String name = getName(attributes); + definition.addPropertyValue("name", name); + + // 兼容最新版本的 spring-cloud-openfeign,尚未发布 + StringBuilder aliasBuilder = new StringBuilder(18); + if (attributes.containsKey("contextId")) { + String contextId = getContextId(attributes); + aliasBuilder.append(contextId); + definition.addPropertyValue("contextId", contextId); + } else { + aliasBuilder.append(name); + } + + definition.addPropertyValue("type", className); + definition.addPropertyValue("decode404", attributes.get("decode404")); + definition.addPropertyValue("fallback", attributes.get("fallback")); + definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory")); + definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); + + AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); + + // alias + String alias = aliasBuilder.append("FeignClient").toString(); + + // has a default, won't be null + boolean primary = (Boolean) attributes.get("primary"); + + beanDefinition.setPrimary(primary); + + String qualifier = getQualifier(attributes); + if (StringUtils.hasText(qualifier)) { + alias = qualifier; + } + + BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, new String[]{alias}); + BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + } + + /** + * Return the class used by {@link SpringFactoriesLoader} to load configuration + * candidates. + * + * @return the factory class + */ + private Class getSpringFactoriesLoaderFactoryClass() { + return PigxFeignAutoConfiguration.class; + } + + private void validate(Map attributes) { + AnnotationAttributes annotation = AnnotationAttributes.fromMap(attributes); + // This blows up if an aliased property is overspecified + FeignClientsRegistrar.validateFallback(annotation.getClass("fallback")); + FeignClientsRegistrar.validateFallbackFactory(annotation.getClass("fallbackFactory")); + } + + private String getName(Map attributes) { + String name = (String) attributes.get("serviceId"); + if (!StringUtils.hasText(name)) { + name = (String) attributes.get("name"); + } + if (!StringUtils.hasText(name)) { + name = (String) attributes.get("value"); + } + name = resolve(name); + return FeignClientsRegistrar.getName(name); + } + + private String getContextId(Map attributes) { + String contextId = (String) attributes.get("contextId"); + if (!StringUtils.hasText(contextId)) { + return getName(attributes); + } + + contextId = resolve(contextId); + return FeignClientsRegistrar.getName(contextId); + } + + private String resolve(String value) { + if (StringUtils.hasText(value)) { + return this.environment.resolvePlaceholders(value); + } + return value; + } + + private String getUrl(Map attributes) { + String url = resolve((String) attributes.get("url")); + return FeignClientsRegistrar.getUrl(url); + } + + private String getPath(Map attributes) { + String path = resolve((String) attributes.get("path")); + return FeignClientsRegistrar.getPath(path); + } + + @Nullable + private String getQualifier(@Nullable Map client) { + if (client == null) { + return null; + } + String qualifier = (String) client.get("qualifier"); + if (StringUtils.hasText(qualifier)) { + return qualifier; + } + return null; + } + + @Nullable + private String getClientName(@Nullable Map client) { + if (client == null) { + return null; + } + String value = (String) client.get("contextId"); + if (!StringUtils.hasText(value)) { + value = (String) client.get("value"); + } + if (!StringUtils.hasText(value)) { + value = (String) client.get("name"); + } + if (!StringUtils.hasText(value)) { + value = (String) client.get("serviceId"); + } + if (StringUtils.hasText(value)) { + return value; + } + + throw new IllegalStateException("Either 'name' or 'value' must be provided in @" + FeignClient.class.getSimpleName()); + } + + private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object configuration) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class); + builder.addConstructorArgValue(name); + builder.addConstructorArgValue(configuration); + registry.registerBeanDefinition(name + "." + FeignClientSpecification.class.getSimpleName(), builder.getBeanDefinition()); + } + + @Override + public void setEnvironment(Environment environment) { + this.environment = environment; + } + +} \ No newline at end of file diff --git a/pigx-common/pigx-common-feign/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-feign/src/main/resources/META-INF/spring.factories new file mode 100755 index 000000000..d078c185f --- /dev/null +++ b/pigx-common/pigx-common-feign/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.common.feign.PigxFeignAutoConfiguration diff --git a/pigx-common/pigx-common-security/pom.xml b/pigx-common/pigx-common-security/pom.xml index 2fc4ac855..3548858dd 100644 --- a/pigx-common/pigx-common-security/pom.xml +++ b/pigx-common/pigx-common-security/pom.xml @@ -43,6 +43,11 @@ org.springframework.cloud spring-cloud-starter-oauth2 + + + io.github.openfeign + feign-core + com.pig4cloud diff --git a/pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfigure.java b/pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfiguration.java similarity index 97% rename from pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfigure.java rename to pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfiguration.java index 29a4919e9..609f7076d 100755 --- a/pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfigure.java +++ b/pigx-common/pigx-common-sentinel/src/main/java/com/pig4cloud/pigx/common/sentinel/SentinelAutoConfiguration.java @@ -30,7 +30,7 @@ import javax.annotation.PostConstruct; * sentinel 配置 */ @Configuration -public class SentinelAutoConfigure { +public class SentinelAutoConfiguration { @PostConstruct public void initWebCallbackManager() { diff --git a/pigx-common/pigx-common-sentinel/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-sentinel/src/main/resources/META-INF/spring.factories index c396f293f..550a79f02 100755 --- a/pigx-common/pigx-common-sentinel/src/main/resources/META-INF/spring.factories +++ b/pigx-common/pigx-common-sentinel/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.pig4cloud.pigx.common.sentinel.SentinelAutoConfigure + com.pig4cloud.pigx.common.sentinel.SentinelAutoConfiguration diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml index fbea41d91..11c55843e 100644 --- a/pigx-common/pom.xml +++ b/pigx-common/pom.xml @@ -37,6 +37,7 @@ pigx-common-core pigx-common-data pigx-common-datasource + pigx-common-feign pigx-common-gateway pigx-common-gray pigx-common-job diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml index 96717d305..4185cfb97 100644 --- a/pigx-upms/pigx-upms-api/pom.xml +++ b/pigx-upms/pigx-upms-api/pom.xml @@ -44,10 +44,10 @@ com.baomidou mybatis-plus-extension - + com.pig4cloud - pigx-common-sentinel + pigx-common-feign diff --git a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories new file mode 100755 index 000000000..7f1ffd042 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories @@ -0,0 +1,7 @@ +# 配置 feignclient 的全类名路径, 避免包名不规范无法扫描问题 +com.pig4cloud.pigx.common.feign.PigxFeignAutoConfiguration=\ + com.pig4cloud.pigx.admin.api.feign.RemoteDataScopeService,\ + com.pig4cloud.pigx.admin.api.feign.RemoteLogService,\ + com.pig4cloud.pigx.admin.api.feign.RemoteTenantService,\ + com.pig4cloud.pigx.admin.api.feign.RemoteTokenService,\ + com.pig4cloud.pigx.admin.api.feign.RemoteUserService \ No newline at end of file diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java index 0c4518277..99affce47 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java @@ -20,7 +20,7 @@ package com.pig4cloud.pigx.admin; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; diff --git a/pigx-visual/pigx-codegen/pom.xml b/pigx-visual/pigx-codegen/pom.xml index 780b84407..ccd616140 100755 --- a/pigx-visual/pigx-codegen/pom.xml +++ b/pigx-visual/pigx-codegen/pom.xml @@ -64,6 +64,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud pigx-common-log diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java index f37a655fc..ccd8bb432 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java @@ -18,7 +18,7 @@ package com.pig4cloud.pigx.codegen; import com.pig4cloud.pigx.common.datasource.annotation.EnableDynamicDataSource; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; @@ -31,8 +31,8 @@ import org.springframework.cloud.client.SpringCloudApplication; */ @EnableDynamicDataSource @EnablePigxSwagger2 -@SpringCloudApplication @EnablePigxFeignClients +@SpringCloudApplication @EnablePigxResourceServer public class PigxCodeGenApplication { diff --git a/pigx-visual/pigx-daemon-elastic-job/pom.xml b/pigx-visual/pigx-daemon-elastic-job/pom.xml index 1f6c3b236..f5f3fa867 100644 --- a/pigx-visual/pigx-daemon-elastic-job/pom.xml +++ b/pigx-visual/pigx-daemon-elastic-job/pom.xml @@ -86,6 +86,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java index 55fc6f750..f01188317 100644 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java +++ b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/PigxDaemonElasticJobApplication.java @@ -17,8 +17,8 @@ package com.pig4cloud.pigx.daemon.elastic; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.gray.annotation.EnablePigxXxlJob; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; diff --git a/pigx-visual/pigx-daemon-quartz/pom.xml b/pigx-visual/pigx-daemon-quartz/pom.xml index 1fef99056..6035f7864 100644 --- a/pigx-visual/pigx-daemon-quartz/pom.xml +++ b/pigx-visual/pigx-daemon-quartz/pom.xml @@ -59,6 +59,11 @@ com.pig4cloud pigx-common-security + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud diff --git a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/PigxDaemonQuartzApplication.java b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/PigxDaemonQuartzApplication.java index efd0b722c..7c2d03d6e 100644 --- a/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/PigxDaemonQuartzApplication.java +++ b/pigx-visual/pigx-daemon-quartz/src/main/java/com/pig4cloud/pigx/daemon/quartz/PigxDaemonQuartzApplication.java @@ -1,6 +1,6 @@ package com.pig4cloud.pigx.daemon.quartz; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; @@ -12,8 +12,8 @@ import org.springframework.cloud.client.SpringCloudApplication; * 定时任务模块 */ @EnablePigxSwagger2 -@SpringCloudApplication @EnablePigxFeignClients +@SpringCloudApplication @EnablePigxResourceServer public class PigxDaemonQuartzApplication { diff --git a/pigx-visual/pigx-mp-platform/pom.xml b/pigx-visual/pigx-mp-platform/pom.xml index b8ab54fcd..0f3eeca58 100755 --- a/pigx-visual/pigx-mp-platform/pom.xml +++ b/pigx-visual/pigx-mp-platform/pom.xml @@ -63,6 +63,11 @@ com.pig4cloud pigx-common-log + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud diff --git a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/PigxMpPlatformApplication.java b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/PigxMpPlatformApplication.java index 883009d00..f43c3df59 100755 --- a/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/PigxMpPlatformApplication.java +++ b/pigx-visual/pigx-mp-platform/src/main/java/com/pig4cloud/pigx/mp/PigxMpPlatformApplication.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.mp; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; @@ -29,8 +29,8 @@ import org.springframework.cloud.client.SpringCloudApplication; * 微信公众号管理模块 */ @EnablePigxSwagger2 -@SpringCloudApplication @EnablePigxFeignClients +@SpringCloudApplication @EnablePigxResourceServer public class PigxMpPlatformApplication { diff --git a/pigx-visual/pigx-oa-platform/pom.xml b/pigx-visual/pigx-oa-platform/pom.xml index 6b6b52d3b..2334ca523 100644 --- a/pigx-visual/pigx-oa-platform/pom.xml +++ b/pigx-visual/pigx-oa-platform/pom.xml @@ -56,6 +56,11 @@ com.pig4cloud pigx-upms-api + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud @@ -136,6 +141,10 @@ com.pig4cloud pigx-common-security + + com.pig4cloud + pigx-common-feign + org.springframework.boot diff --git a/pigx-visual/pigx-oa-platform/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java b/pigx-visual/pigx-oa-platform/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java index 17977746f..e7af829dc 100644 --- a/pigx-visual/pigx-oa-platform/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java +++ b/pigx-visual/pigx-oa-platform/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.act; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; diff --git a/pigx-visual/pigx-pay-platform/pom.xml b/pigx-visual/pigx-pay-platform/pom.xml index 8320800f7..8e66a679e 100755 --- a/pigx-visual/pigx-pay-platform/pom.xml +++ b/pigx-visual/pigx-pay-platform/pom.xml @@ -53,6 +53,11 @@ com.pig4cloud pigx-common-gray + + + com.pig4cloud + pigx-common-sentinel + com.pig4cloud @@ -76,12 +81,10 @@ com.github.javen205 IJPay - 1.2.0 com.alipay.sdk alipay-sdk-java - 3.0.52.ALL com.github.binarywang diff --git a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/PigxPayPlatformApplication.java b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/PigxPayPlatformApplication.java index a441f8370..cf7a6a08c 100755 --- a/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/PigxPayPlatformApplication.java +++ b/pigx-visual/pigx-pay-platform/src/main/java/com/pig4cloud/pigx/pay/PigxPayPlatformApplication.java @@ -17,7 +17,7 @@ package com.pig4cloud.pigx.pay; -import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients; +import com.pig4cloud.pigx.common.feign.annotation.EnablePigxFeignClients; import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; From 934f2ec36161e221c7c95ddf62a462ed78fb8d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Mon, 10 Feb 2020 22:29:27 +0800 Subject: [PATCH 025/130] :bug: Fixing a bug. #753 413 (Request Entity Too Large) --- .../pig4cloud/pigx/admin/api/vo/RoleVo.java | 39 +++++++++++++++++++ .../admin/controller/SysRoleController.java | 13 ++++--- 2 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleVo.java diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleVo.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleVo.java new file mode 100644 index 000000000..29bb17952 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleVo.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @author lengleng + * @date 2020/2/10 + */ +@Data +@ApiModel(value = "前端角色展示对象") +public class RoleVo { + /** + * 角色id + */ + private Integer roleId; + + /** + * 菜单列表 + */ + private String menuIds; +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java index db9ad7ff8..2fef70850 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.controller; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.api.vo.RoleVo; import com.pig4cloud.pigx.admin.service.SysRoleMenuService; import com.pig4cloud.pigx.admin.service.SysRoleService; import com.pig4cloud.pigx.common.core.util.R; @@ -36,7 +37,7 @@ import java.util.List; /** * @author lengleng - * @date 2017/11/5 + * @date 2020-02-10 */ @RestController @AllArgsConstructor @@ -120,16 +121,16 @@ public class SysRoleController { /** * 更新角色菜单 * - * @param roleId 角色ID - * @param menuIds 菜单ID拼成的字符串,每个id之间根据逗号分隔 + * @param roleVo 角色对象 * @return success、false */ @SysLog("更新角色菜单") @PutMapping("/menu") @PreAuthorize("@pms.hasPermission('sys_role_perm')") - public R saveRoleMenus(Integer roleId, @RequestParam(value = "menuIds", required = false) String menuIds) { - SysRole sysRole = sysRoleService.getById(roleId); - return R.ok(sysRoleMenuService.saveRoleMenus(sysRole.getRoleCode(), roleId, menuIds)); + public R saveRoleMenus(@RequestBody RoleVo roleVo) { + SysRole sysRole = sysRoleService.getById(roleVo.getRoleId()); + return R.ok(sysRoleMenuService.saveRoleMenus(sysRole.getRoleCode() + , roleVo.getRoleId(), roleVo.getMenuIds())); } /** From 49966b1096a537d608d9d890de2022f9b35e9f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Wed, 12 Feb 2020 13:26:26 +0800 Subject: [PATCH 026/130] =?UTF-8?q?:recycle:=20Refactoring=20code.=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=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 --- ...fig.java => MybatisPlusConfiguration.java} | 2 +- .../main/resources/META-INF/spring.factories | 2 +- .../pig4cloud/pigx/codegen/util/GenUtils.java | 23 +++++++++++-------- .../main/resources/mapper/GeneratorMapper.xml | 2 +- .../element/{add-or-update.vue.vm => form.vm} | 0 .../resources/template/element/index.vue.vm | 6 ++--- 6 files changed, 20 insertions(+), 15 deletions(-) rename pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/{MybatisPlusConfig.java => MybatisPlusConfiguration.java} (98%) rename pigx-visual/pigx-codegen/src/main/resources/template/element/{add-or-update.vue.vm => form.vm} (100%) diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfiguration.java similarity index 98% rename from pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java rename to pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfiguration.java index f57a5e08d..c6c6fbc81 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfig.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/mybatis/MybatisPlusConfiguration.java @@ -44,7 +44,7 @@ import java.util.List; @Configuration @ConditionalOnBean(DataSource.class) @AutoConfigureAfter(DataSourceAutoConfiguration.class) -public class MybatisPlusConfig { +public class MybatisPlusConfiguration { /** * 创建租户维护处理器对象 diff --git a/pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories index 8bc3f62f8..fd3942d5c 100644 --- a/pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories +++ b/pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories @@ -5,5 +5,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.pig4cloud.pigx.common.data.tenant.PigxTenantConfigProperties,\ com.pig4cloud.pigx.common.data.tenant.TenantContextHolderFilter,\ com.pig4cloud.pigx.common.data.tenant.PigxFeignTenantConfiguration,\ - com.pig4cloud.pigx.common.data.mybatis.MybatisPlusConfig,\ + com.pig4cloud.pigx.common.data.mybatis.MybatisPlusConfiguration,\ com.pig4cloud.pigx.common.data.resolver.WebMvcConfig \ No newline at end of file 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 73e03c9ac..ac7c00cbe 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 @@ -66,7 +66,7 @@ public class GenUtils { private final String MENU_SQL_VM = "menu.sql.vm"; private final String AVUE_INDEX_VUE_VM = "avue/index.vue.vm"; private final String ELE_INDEX_VUE_VM = "element/index.vue.vm"; - private final String ELE_ADD_UPDATE_VUE_VM = "element/add-or-update.vue.vm"; + private final String ELE_ADD_UPDATE_VUE_VM = "element/form.vue.vm"; private final String AVUE_API_JS_VM = "avue/api.js.vm"; private final String AVUE_CRUD_JS_VM = "avue/crud.js.vm"; @@ -89,7 +89,7 @@ public class GenUtils { if (StyleTypeEnum.ELEMENT.getStyle().equals(config.getStyle())) { templates.add("template/element/index.vue.vm"); - templates.add("template/element/add-or-update.vue.vm"); + templates.add("template/element/form.vue.vm"); } else { templates.add("template/avue/index.vue.vm"); templates.add("template/avue/crud.js.vm"); @@ -275,7 +275,9 @@ public class GenUtils { * 获取文件名 */ private String getFileName(String template, String className, String packageName, String moduleName) { - String packagePath = CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator; + String packagePath = CommonConstants.BACK_END_PROJECT + File.separator + "src" + + File.separator + "main" + File.separator + "java" + File.separator; + if (StringUtils.isNotBlank(packageName)) { packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; } @@ -301,7 +303,8 @@ public class GenUtils { } if (template.contains(MAPPER_XML_VM)) { - return CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml"; + return CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml"; } if (template.contains(MENU_SQL_VM)) { @@ -314,17 +317,19 @@ public class GenUtils { } if (template.contains(AVUE_API_JS_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js"; + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + + File.separator + className.toLowerCase() + ".js"; } if (template.contains(AVUE_CRUD_JS_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" + - File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" + + File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; } if (template.contains(ELE_ADD_UPDATE_VUE_VM)) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + - File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + moduleName + "-add-or-update.vue"; + return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" + + File.separator + moduleName + File.separator + className.toLowerCase() + + File.separator + moduleName + "-form.vue.vm"; } return null; diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMapper.xml index 58c36ecbf..372e0931a 100755 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMapper.xml +++ b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMapper.xml @@ -3,7 +3,7 @@