diff --git a/README.md b/README.md index 47bdea4a0..6d77216a8 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,9 @@ pigX并非一个开源软件,作者保留全部的权利。 擅自窃用,即属严重侵权行为,与盗窃无异。产生的一切任何后果责任由侵权者自负。 -### 🌹权益 - -1. 个人使用 -2. 允许用于学习、毕设等。 - ### 🚫禁止 -1. 将本项目的部分或全部代码和资源进行任何形式的再发行(尤其上传GitHub、Gitee ) -2. 利用本项目的部分或全部代码和资源进行`任何商业行为` - -### 免责声明 - -PigX 未对任何组织、团队,书面授权商业使用。如若出现任何商业后果、纠纷和本人无关,特此声明 +将本项目的部分或全部代码和资源进行任何形式的再发行(上传GitHub、Gitee ) ## 贡献代码 diff --git a/db/6pigxx_config.sql b/db/6pigxx_config.sql index fbef2bd09..ab96a0913 100644 --- a/db/6pigxx_config.sql +++ b/db/6pigxx_config.sql @@ -34,7 +34,7 @@ CREATE TABLE `config_info` ( BEGIN; INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', 'jasypt:\n encryptor:\n password: pigx\n \nspring:\n redis:\n host: pigx-redis\n servlet:\n multipart:\n max-file-size: 100MB\n max-request-size: 100MB\n cloud:\n sentinel:\n eager: true\n filter:\n url-patterns: /** \n transport:\n dashboard: pigx-sentinel:5020\n \nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n#开启灰度\ngray:\n rule:\n enabled: true\n\nmybatis-plus:\n tenant-enable: ture\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n field-strategy: NOT_EMPTY\n type-handlers-package: com.pig4cloud.pigx.common.data.handler\n\nswagger:\n title: PigX Swagger API\n license: Powered By PigX\n licenseUrl: https://pig4cloud.com/\n terms-of-service-url: https://pig4cloud.com/\n contact:\n email: wangiegie@gmail.com\n url: https://pig4cloud.com/about.html\n authorization:\n name: pigX OAuth\n auth-regex: ^.*$\n authorization-scope-list:\n - scope: server\n description: server all\n token-url-list:\n - http://${GATEWAY-HOST:pigx-gateway}:${GATEWAY-PORT:9999}/auth/oauth/token\n\nsecurity:\n oauth2:\n client:\n ignore-urls:\n - /actuator/**\n - /v2/api-docs\n resource:\n loadBalanced: true\n token-info-uri: http://pigx-auth/oauth/check_token', '954b56ac77f2691529aad5c497591b28', '2019-04-18 02:10:20', '2020-02-24 13:58:21', NULL, '172.17.0.125', '', '', '通用配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (2, 'pigx-auth-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL-USER:root}\n password: ${MYSQL-PWD:root}\n url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/', 'a6674e6747c1a0bb6c6d78e13706f8f0', '2019-04-18 02:11:32', '2019-08-27 18:24:04', NULL, '127.0.0.1', '', '', '认证中心配置文件', 'null', 'null', 'yaml', 'null'); -INSERT INTO `config_info` VALUES (3, 'pigx-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n scope: server\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL-USER:root}\n password: ${MYSQL-PWD:root}\n url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_codegen}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\npigx:\n tenant:\n column: tenant_id\n tables:\n - sys_datasource_conf', 'b7d132a3ecdfac4252c994adbb65b23a', '2019-04-18 02:12:10', '2019-08-27 18:24:18', NULL, '127.0.0.1', '', '', '代码生成', 'null', 'null', 'yaml', 'null'); +INSERT INTO `config_info` VALUES (3, 'pigx-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n scope: server\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL-USER:root}\n password: ${MYSQL-PWD:root}\n url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_codegen}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\npigx:\n tenant:\n column: tenant_id\n tables:\n - gen_datasource_conf', 'b7d132a3ecdfac4252c994adbb65b23a', '2019-04-18 02:12:10', '2019-08-27 18:24:18', NULL, '127.0.0.1', '', '', '代码生成', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (4, 'pigx-daemon-elastic-job-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n scope: server\n## 定时任务\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL-USER:root}\n password: ${MYSQL-PWD:root}\n url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n elasticjob:\n # 分布式任务协调依赖zookeeper\n zookeeper:\n server-lists: ${ZOOKEEPER-HOST:pigx-zookeeper}:${ZOOKEEPER-PORT:2181}\n namespace: pigx-daemon\n # 普通任务\n simples:\n spring-simple-job:\n job-class: com.pig4cloud.pigx.daemon.elastic.job.PigxSimpleJob\n cron: 0 0 0/1 * * ?\n sharding-total-count: 3\n sharding-item-parameters: 0=service1,1=service2,2=service3\n eventTraceRdbDataSource: \'dataSource\'\n listener:\n listener-class: com.pig4cloud.pigx.daemon.elastic.listener.PigxElasticJobListener\n spring-simple-job2:\n job-class: com.pig4cloud.pigx.daemon.elastic.job.PigxSimpleJob2\n cron: 0 0 0/1 * * ?\n sharding-total-count: 3\n sharding-item-parameters: 0=service1,1=service2,2=service3\n eventTraceRdbDataSource: \'dataSource\'\n listener:\n listener-class: com.pig4cloud.pigx.daemon.elastic.listener.PigxElasticJobListener\n # 简单任务\n dataflows:\n spring-dataflow-job:\n job-class: com.pig4cloud.pigx.daemon.elastic.job.PigxDataflowJob\n cron: 0 0 0/1 * * ?\n sharding-total-count: 3\n sharding-item-parameters: 0=service1,1=service2,2=service3\n streaming-process: true\n eventTraceRdbDataSource: \'dataSource\'\n listener:\n distributed-listener-class: com.pig4cloud.pigx.daemon.elastic.listener.PigxDistributeElasticJobListener\n started-timeout-milliseconds: 5000\n completed-timeout-milliseconds: 10000\n\nxxl:\n job:\n admin:\n addresses: http://${XXL-HOST:pigx-xxl}:${XXL-HOST:9080}/xxl-job-admin\n executor:\n port: 9988\n appName: test-xxl', '9ce58242d57b57f737dcb59a41ee6e55', '2019-04-18 02:12:57', '2019-10-04 11:22:56', NULL, '127.0.0.1', '', '', '定时任务-elastic-job配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (5, 'pigx-gateway-dev.yml', 'DEFAULT_GROUP', 'security:\n encode:\n key: \'pigxpigxpigxpigx\'\n\nignore:\n clients:\n - test\n swagger-providers:\n - pigx-auth\n - pigx-tx-manager\n\nribbon:\n rule:\n gray-enabled: true', '24403a5b205b1e9d320078e309584bbc', '2019-04-18 02:13:52', '2019-10-20 17:07:42', NULL, '127.0.0.1', '', '', '网关配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (6, 'pigx-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n # 安全配置\n security:\n user:\n name: ENC(rZHA4LW5hHmhLAAzJoFNag==) # pigx\n password: ENC(bjeyh+Aeii3kHXkoo00ZUw==) # pigx\n boot:\n admin:\n ui:\n title: \'pigx 服务状态监控\'\n brand: \'pigx 服务状态监控\'\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n endpoint:\n health:\n show-details: ALWAYS #显示详细信息', '7925a0c734460526262319b6a189e39d', '2019-04-18 02:14:17', '2019-12-31 19:04:00', NULL, '172.17.0.157', '', '', '监控配置文件', 'null', 'null', 'yaml', 'null'); diff --git a/db/8pigxx_codegen.sql b/db/8pigxx_codegen.sql index 86a79313e..47da6fc18 100644 --- a/db/8pigxx_codegen.sql +++ b/db/8pigxx_codegen.sql @@ -20,17 +20,6 @@ CREATE TABLE `gen_datasource_conf` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='数据源表'; --- ---------------------------- --- Records of gen_datasource_conf --- ---------------------------- -BEGIN; -INSERT INTO `gen_datasource_conf` VALUES (1, 'master', 'jdbc:mysql://pigx-mysql:3306/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'hyxlg2iaqpDLOe9qEcv2xQ==', '2019-08-12 15:47:39', '2019-08-12 15:47:39', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (2, 'pigxx_core', 'jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 16:40:43', '2019-06-13 03:07:24', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (3, 'pigxx_ac', 'jdbc:mysql://pigx-mysql:3306/pigxx_ac?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:25', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (4, 'pigxx_job', 'jdbc:mysql://pigx-mysql:3306/pigxx_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:26', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (5, 'pigxx_mp', 'jdbc:mysql://pigx-mysql:3306/pigxx_mp?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:28', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (6, 'pigxx_pay', 'jdbc:mysql://pigx-mysql:3306/pigxx_pay?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:30', '0', 1); -COMMIT; -- ---------------------------- -- Table structure for gen_form_conf diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/cache/RedisTemplateConfig.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/cache/RedisTemplateConfig.java index d2bf27e95..d89791f6a 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/cache/RedisTemplateConfig.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/cache/RedisTemplateConfig.java @@ -78,7 +78,7 @@ public class RedisTemplateConfig { // https://github.com/lettuce-io/lettuce-core/wiki/ReadFrom-Settings LettuceClientConfiguration lettuceClientConfiguration = LettuceClientConfiguration.builder() - .readFrom(ReadFrom.SLAVE_PREFERRED) + .readFrom(ReadFrom.REPLICA_PREFERRED) .clientOptions(clusterClientOptions).build(); return new LettuceConnectionFactory(redisClusterConfiguration, lettuceClientConfiguration); diff --git a/pigx-common/pigx-common-datasource/pom.xml b/pigx-common/pigx-common-datasource/pom.xml index 6f586e0ee..9939cfb2a 100644 --- a/pigx-common/pigx-common-datasource/pom.xml +++ b/pigx-common/pigx-common-datasource/pom.xml @@ -17,70 +17,16 @@ pigx 动态切换数据源 - - org.springframework.boot - spring-boot-starter-jdbc - - - javax.servlet - javax.servlet-api - - - org.springframework - spring-webmvc - - - - com.pig4cloud - pigx-common-core - com.baomidou dynamic-datasource-spring-boot-starter - - com.baomidou - mybatis-plus-boot-starter - - - mysql - mysql-connector-java - com.alibaba druid-spring-boot-starter - - - - com.pig4cloud - pigx-common-swagger - - - - com.pig4cloud - pigx-common-security - - - 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 + provided \ No newline at end of file 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 08a8ba6d3..5c9164b7f 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 @@ -14,13 +14,29 @@ import org.springframework.stereotype.Component; @Component @ConfigurationProperties("spring.datasource.druid") public class DruidDataSourceProperties { + + /** + * 数据源用户名 + */ private String username; + + /** + * 数据源密码 + */ private String password; + + /** + * jdbcurl + */ private String url; + + /** + * 数据源驱动 + */ private String driverClassName; /** * 查询数据源的SQL */ - private String queryDsSql; + private String queryDsSql = "select * from gen_datasource_conf where del_flag = 0"; } 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 index b8706e57e..3881d21ef 100644 --- 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 @@ -17,7 +17,6 @@ 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; @@ -54,9 +53,7 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide */ @Override protected Map executeStmt(Statement statement) throws SQLException { - ResultSet rs = statement.executeQuery(StrUtil.isBlank(properties.getQueryDsSql()) - ? DataSourceConstants.QUERY_DS_SQL - : properties.getQueryDsSql()); + ResultSet rs = statement.executeQuery(properties.getQueryDsSql()); Map map = new HashMap<>(8); while (rs.next()) { @@ -70,6 +67,13 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide property.setUrl(url); map.put(name, property); } + + // 添加默认主数据源 + DataSourceProperty property = new DataSourceProperty(); + property.setUsername(properties.getUsername()); + property.setPassword(properties.getPassword()); + property.setUrl(properties.getUrl()); + map.put(DataSourceConstants.DS_MASTER, property); return map; } } 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 3d23df3e8..07a34ea62 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 @@ -7,16 +7,17 @@ package com.pig4cloud.pigx.common.datasource.support; * 数据源相关常量 */ public interface DataSourceConstants { - /** - * 查询数据源的SQL - */ - String QUERY_DS_SQL = "select * from gen_datasource_conf where del_flag = 0"; /** * 数据源名称 */ String DS_NAME = "name"; + /** + * 默认数据源(master) + */ + String DS_MASTER = "master"; + /** * jdbcurl */ 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/job/XxlJobAutoConfiguration.java index 7e81e44bd..443b22b73 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/job/XxlJobAutoConfiguration.java @@ -20,7 +20,6 @@ package com.pig4cloud.pigx.common.job; import com.pig4cloud.pigx.common.job.properties.XxlJobProperties; import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -35,7 +34,6 @@ import org.springframework.context.annotation.Configuration; @ComponentScan("com.pig4cloud.pigx.common.job.properties") public class XxlJobAutoConfiguration { - @Bean(initMethod = "start", destroyMethod = "destroy") public XxlJobSpringExecutor xxlJobSpringExecutor(XxlJobProperties xxlJobProperties) { XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses()); diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/ConcurrentDateFormat.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/ConcurrentDateFormat.java deleted file mode 100644 index b0063b674..000000000 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/ConcurrentDateFormat.java +++ /dev/null @@ -1,87 +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.security.util; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.Queue; -import java.util.TimeZone; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * 参考tomcat8中的并发DateFormat - *

- * {@link SimpleDateFormat}的线程安全包装器。 - * 不使用ThreadLocal,创建足够的SimpleDateFormat对象来满足并发性要求。 - * - * @author L.cm - */ -public class ConcurrentDateFormat { - private final String format; - private final Locale locale; - private final TimeZone timezone; - private final Queue queue = new ConcurrentLinkedQueue<>(); - - private ConcurrentDateFormat(String format, Locale locale, TimeZone timezone) { - this.format = format; - this.locale = locale; - this.timezone = timezone; - SimpleDateFormat initial = createInstance(); - queue.add(initial); - } - - public static ConcurrentDateFormat of(String format) { - return new ConcurrentDateFormat(format, Locale.getDefault(), TimeZone.getDefault()); - } - - public static ConcurrentDateFormat of(String format, TimeZone timezone) { - return new ConcurrentDateFormat(format, Locale.getDefault(), timezone); - } - - public static ConcurrentDateFormat of(String format, Locale locale, TimeZone timezone) { - return new ConcurrentDateFormat(format, locale, timezone); - } - - public String format(Date date) { - SimpleDateFormat sdf = queue.poll(); - if (sdf == null) { - sdf = createInstance(); - } - String result = sdf.format(date); - queue.add(sdf); - return result; - } - - public Date parse(String source) throws ParseException { - SimpleDateFormat sdf = queue.poll(); - if (sdf == null) { - sdf = createInstance(); - } - Date result = sdf.parse(source); - queue.add(sdf); - return result; - } - - private SimpleDateFormat createInstance() { - SimpleDateFormat sdf = new SimpleDateFormat(format, locale); - sdf.setTimeZone(timezone); - return sdf; - } -} diff --git a/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/BizName.java b/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/BizName.java index 93ef9ec9b..04d0ba57a 100644 --- a/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/BizName.java +++ b/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/BizName.java @@ -9,6 +9,8 @@ package com.pig4cloud.pigx.common.sequence.range; public interface BizName { /** * 生成名称 + * + * @return 返回文本序号 */ String create(); diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java index e715ffdde..a07a1c2c3 100644 --- a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java @@ -25,8 +25,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; @@ -49,9 +51,9 @@ import java.util.List; public class SwaggerAutoConfiguration { /** - * 默认的排除路径,排除Spring Boot默认的错误处理路径和端点 + * 默认的排除路径,排除Spring Boot默认的错误处理路径和端点 */ - private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error","/actuator/**"); + private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**"); private static final String BASE_PATH = "/**"; @Bean @@ -77,16 +79,26 @@ public class SwaggerAutoConfiguration { List> excludePath = new ArrayList<>(); swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); + // 版本请求头处理 + ParameterBuilder versionPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + versionPar.name("VERSION").description("灰度路由版本信息") + .modelRef(new ModelRef("string")).parameterType("header") + .required(false).build(); + pars.add(versionPar.build()); + //noinspection Guava return new Docket(DocumentationType.SWAGGER_2) - .host(swaggerProperties.getHost()) - .apiInfo(apiInfo(swaggerProperties)).select() - .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) - .paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath))) - .build() - .securitySchemes(Collections.singletonList(securitySchema())) - .securityContexts(Collections.singletonList(securityContext())) - .pathMapping("/"); + .host(swaggerProperties.getHost()) + .apiInfo(apiInfo(swaggerProperties)) + .globalOperationParameters(pars) + .select() + .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) + .paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath))) + .build() + .securitySchemes(Collections.singletonList(securitySchema())) + .securityContexts(Collections.singletonList(securityContext())) + .pathMapping("/"); } /** @@ -96,9 +108,9 @@ public class SwaggerAutoConfiguration { */ private SecurityContext securityContext() { return SecurityContext.builder() - .securityReferences(defaultAuth()) - .forPaths(PathSelectors.regex(swaggerProperties().getAuthorization().getAuthRegex())) - .build(); + .securityReferences(defaultAuth()) + .forPaths(PathSelectors.regex(swaggerProperties().getAuthorization().getAuthRegex())) + .build(); } /** @@ -111,9 +123,9 @@ public class SwaggerAutoConfiguration { swaggerProperties().getAuthorization().getAuthorizationScopeList().forEach(authorizationScope -> authorizationScopeList.add(new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription()))); AuthorizationScope[] authorizationScopes = new AuthorizationScope[authorizationScopeList.size()]; return Collections.singletonList(SecurityReference.builder() - .reference(swaggerProperties().getAuthorization().getName()) - .scopes(authorizationScopeList.toArray(authorizationScopes)) - .build()); + .reference(swaggerProperties().getAuthorization().getName()) + .scopes(authorizationScopeList.toArray(authorizationScopes)) + .build()); } @@ -127,14 +139,14 @@ public class SwaggerAutoConfiguration { private ApiInfo apiInfo(SwaggerProperties swaggerProperties) { return new ApiInfoBuilder() - .title(swaggerProperties.getTitle()) - .description(swaggerProperties.getDescription()) - .license(swaggerProperties.getLicense()) - .licenseUrl(swaggerProperties.getLicenseUrl()) - .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) - .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) - .version(swaggerProperties.getVersion()) - .build(); + .title(swaggerProperties.getTitle()) + .description(swaggerProperties.getDescription()) + .license(swaggerProperties.getLicense()) + .licenseUrl(swaggerProperties.getLicenseUrl()) + .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) + .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) + .version(swaggerProperties.getVersion()) + .build(); } } diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java index 1bb3d0e23..f85261485 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java @@ -87,6 +87,20 @@ public class MenuTree extends TreeNode implements Serializable { public MenuTree() { } + public MenuTree(int id, String name, int parentId) { + this.id = id; + this.parentId = parentId; + this.name = name; + this.label = name; + } + + public MenuTree(int id, String name, MenuTree parent) { + this.id = id; + this.parentId = parent.getId(); + this.name = name; + this.label = name; + } + public MenuTree(MenuVO menuVo) { this.id = menuVo.getMenuId(); this.parentId = menuVo.getParentId(); @@ -94,9 +108,9 @@ public class MenuTree extends TreeNode implements Serializable { this.name = menuVo.getName(); this.path = menuVo.getPath(); this.type = menuVo.getType(); + this.permission = menuVo.getPermission(); this.label = menuVo.getName(); this.sort = menuVo.getSort(); - this.permission = menuVo.getPermission(); this.keepAlive = menuVo.getKeepAlive(); } } 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 28e65cd0b..8f6ad7d08 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 @@ -112,13 +112,13 @@ public class TreeUtil { node.setParentId(menu.getParentId()); node.setName(menu.getName()); node.setPath(menu.getPath()); + node.setPermission(menu.getPermission()); node.setLabel(menu.getName()); node.setIcon(menu.getIcon()); node.setType(menu.getType()); node.setSort(menu.getSort()); node.setHasChildren(true); node.setKeepAlive(menu.getKeepAlive()); - node.setPermission(menu.getPermission()); trees.add(node); } return TreeUtil.build(trees, root); 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 5af04db55..6e5639d82 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 @@ -48,6 +48,7 @@ public interface GeneratorMapper { * 查询表信息 * * @param tableName 表名称 + * @param dsName 数据源名称 * @return */ @DS("#last") @@ -57,6 +58,7 @@ public interface GeneratorMapper { * 查询表列信息 * * @param tableName 表名称 + * @param dsName 数据源名称 * @return */ @DS("#last") 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 d5622a555..f1dae2987 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 @@ -329,7 +329,7 @@ public class GenUtils { 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 + "-form.vue"; + + File.separator + className.toLowerCase() + "-form.vue"; } return null; diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm b/pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm index 4272691ff..6c46c9ab1 100755 --- a/pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm +++ b/pigx-visual/pigx-codegen/src/main/resources/template/avue/index.vue.vm @@ -118,6 +118,7 @@ }, searchChange(form, done) { this.searchForm = form + this.page.currentPage = 1 this.getList(this.page, form) done() },