diff --git a/.editorconfig b/.editorconfig index 48a40c43..0144009d 100755 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -root=true +root = true [*.{groovy,java,kt,xml}] indent_style = tab diff --git a/README.md b/README.md index 08583b7f..14039a02 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ | Spring Cloud Alibaba | 2021.1 | | Spring Security OAuth2 | 2.3.6 | | Mybatis Plus | 3.4.3.2 | -| hutool | 5.7.9 | +| hutool | 5.7.12 | | Avue | 2.6.18 | ### 模块说明 @@ -71,6 +71,11 @@ pig 提供了详细的[部署文档 wiki.pig4cloud.com](https://www.yuque.com/pi 请务必**完全按照**文档部署运行章节 进行操作,减少踩坑弯路!! +### 定制自己微服务 + +[PIG DIY](https://diy.pig4cloud.com) +[PIG ARCHETYPE](https://archetype.pig4cloud.com) + ### Docker 运行 ``` @@ -87,22 +92,6 @@ cd pig-ui && npm install -g cnpm --registry=https://registry.npm.taobao.org npm run build:docker && docker-compose up -d ``` -### 快速构架微服务 - -```bash - -# 在空文件夹执行以下命令,注意 windows 下 \ 修改成 ^ -mvn archetype:generate \ - -DgroupId=com.pig4cloud \ - -DartifactId=demo \ - -Dversion=1.0.0-SNAPSHOT \ - -Dpackage=com.pig4cloud.pig.demo \ - -DarchetypeGroupId=com.pig4cloud.archetype \ - -DarchetypeArtifactId=pig-gen \ - -DarchetypeVersion=3.3.2 \ - -DarchetypeCatalog=local -``` - ## 免费公开课 @@ -132,7 +121,7 @@ pig 开源软件遵循 [Apache 2.0 协议](https://www.apache.org/licenses/LICEN ### 其他说明 -1. 欢迎提交 [PR](https://dwz.cn/2KURd5Vf),注意对应提交对应 `dev` 分支 +1. 欢迎提交 [PR](https://dwz.cn/2KURd5Vf),注意对应提交对应 `dev` 分支 代码规范 [spring-javaformat](https://github.com/spring-io/spring-javaformat) 2. 欢迎提交 [issue](https://gitee.com/log4j/pig/issues),请写清楚遇到问题的原因、开发环境、复显步骤。 diff --git a/db/pig.sql b/db/pig.sql index f5eeeb8d..3b22ea1a 100644 --- a/db/pig.sql +++ b/db/pig.sql @@ -227,6 +227,10 @@ INSERT INTO `sys_menu` VALUES (2401, '客户端新增', 'sys_client_add', NULL, INSERT INTO `sys_menu` VALUES (2402, '客户端修改', 'sys_client_edit', NULL, 2400, NULL, NULL, 1, '0', '1', '0', NULL, '2018-05-15 21:37:06', NULL, '2021-05-25 06:48:34'); INSERT INTO `sys_menu` VALUES (2403, '客户端删除', 'sys_client_del', NULL, 2400, NULL, NULL, 1, '0', '1', '0', NULL, '2018-05-15 21:39:16', NULL, '2021-05-25 06:48:34'); INSERT INTO `sys_menu` VALUES (2500, '服务监控', NULL, 'http://localhost:5001', 2000, 'icon-server', NULL, 10, '0', '0', '0', NULL, '2018-06-26 10:50:32', NULL, '2019-02-01 20:41:30'); +INSERT INTO `sys_menu` VALUES (2600, '文件管理', NULL, '/admin/file/index', 2000, 'icon-wenjianguanli', NULL, 10, '0', '0', '0', NULL, '2018-06-26 10:50:32', NULL, '2019-02-01 20:41:30'); +INSERT INTO `sys_menu` VALUES (2601, '文件删除', 'sys_file_del', NULL, 2600, NULL, NULL, 1, '0', '1', '0', NULL, '2017-11-29 11:30:11', NULL, '2021-05-25 06:48:34'); +INSERT INTO `sys_menu` VALUES (2602, '文件新增', 'sys_file_add', NULL, 2600, NULL, NULL, 1, '0', '1', '0', NULL, '2018-05-11 22:34:55', NULL, '2021-05-25 06:48:34'); +INSERT INTO `sys_menu` VALUES (2603, '文件修改', 'sys_file_edit', NULL, 2600, NULL, NULL, 1, '0', '1', '0', NULL, '2018-05-11 22:36:03', NULL, '2021-05-25 06:48:34'); INSERT INTO `sys_menu` VALUES (3000, '开发平台', NULL, '/gen', -1, 'icon-shejiyukaifa-', NULL, 3, '1', '0', '0', NULL, '2020-03-11 22:15:40', NULL, '2020-03-11 23:52:54'); INSERT INTO `sys_menu` VALUES (3100, '数据源管理', NULL, '/gen/datasource', 3000, 'icon-mysql', NULL, 1, '1', '0', '0', NULL, '2020-03-11 22:17:05', NULL, '2020-03-12 00:16:09'); INSERT INTO `sys_menu` VALUES (3200, '代码生成', NULL, '/gen/index', 3000, 'icon-weibiaoti46', NULL, 2, '0', '0', '0', NULL, '2020-03-11 22:23:42', NULL, '2020-03-12 00:16:14'); @@ -346,7 +350,10 @@ INSERT INTO `sys_role_menu` VALUES (1, 2400); INSERT INTO `sys_role_menu` VALUES (1, 2401); INSERT INTO `sys_role_menu` VALUES (1, 2402); INSERT INTO `sys_role_menu` VALUES (1, 2403); -INSERT INTO `sys_role_menu` VALUES (1, 2500); +INSERT INTO `sys_role_menu` VALUES (1, 2600); +INSERT INTO `sys_role_menu` VALUES (1, 2601); +INSERT INTO `sys_role_menu` VALUES (1, 2602); +INSERT INTO `sys_role_menu` VALUES (1, 2603); INSERT INTO `sys_role_menu` VALUES (1, 3000); INSERT INTO `sys_role_menu` VALUES (1, 3100); INSERT INTO `sys_role_menu` VALUES (1, 3200); @@ -404,4 +411,20 @@ BEGIN; INSERT INTO `sys_user_role` VALUES (1, 1); COMMIT; +DROP TABLE IF EXISTS `sys_file`; +CREATE TABLE `sys_file` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', + `file_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `bucket_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `original` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `file_size` bigint DEFAULT NULL COMMENT '文件大小', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '0-正常,1-删除', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建者', + `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='文件管理表'; + SET FOREIGN_KEY_CHECKS = 1; diff --git a/db/pig_config.sql b/db/pig_config.sql index e773ef19..3a98c92c 100644 --- a/db/pig_config.sql +++ b/db/pig_config.sql @@ -41,7 +41,7 @@ INSERT INTO `config_info` VALUES (2, 'pig-auth-dev.yml', 'DEFAULT_GROUP', '# 数 INSERT INTO `config_info` VALUES (3, 'pig-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(27v1agvAug87ANOVnbKdsw==)\n client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)\n scope: server\n\n# 数据源配置\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\n# 直接放行URL\nignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n', 'abc702838b34d11b46e96143ccd9f367', '2019-11-29 16:32:12', '2019-11-29 16:32:12', NULL, '127.0.0.1', '', '', '代码生成配置', NULL, NULL, 'yaml', NULL); INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 100\n redis-rate-limiter.burstCapacity: 200\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n\n\ngateway:\n encode-key: \'thanks,pig4cloud\'\n ignore-clients:\n - test\n\nswagger:\n ignore-providers:\n - pig-auth\n - pig-codegen\n', '5cd71b235930c78e700819b944a14446', '2019-11-29 16:32:42', '2020-10-09 17:10:45', NULL, '0:0:0:0:0:0:0:1', '', '', '网关配置', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (5, 'pig-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n # 安全配置\n security:\n user:\n name: ENC(8Hk2ILNJM8UTOuW/Xi75qg==) # pig\n password: ENC(o6cuPFfUevmTbkmBnE67Ow====) # pig\n', '85509c6f8c67c364dc78301896274f26', '2019-11-29 16:33:05', '2019-11-29 16:33:05', NULL, '127.0.0.1', '', '', '监控配置', NULL, NULL, 'yaml', NULL); -INSERT INTO `config_info` VALUES (6, 'pig-upms-biz-dev.yml', 'DEFAULT_GROUP', 'security:\n oauth2:\n client:\n client-id: ENC(imENTO7M8bLO38LFSIxnzw==)\n client-secret: ENC(i3cDFhs26sa2Ucrfz2hnQw==)\n scope: server\n\n# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai\n', '3248f7cf9ea2ce40cd41cd664ec32ae0', '2019-11-29 16:52:32', '2020-03-14 16:24:24', NULL, '172.17.0.125', '', '', '统一权限', 'null', 'null', 'yaml', 'null'); +INSERT INTO `config_info` VALUES (6, 'pig-upms-biz-dev.yml', 'DEFAULT_GROUP', 'security:\n oauth2:\n client:\n client-id: ENC(imENTO7M8bLO38LFSIxnzw==)\n client-secret: ENC(i3cDFhs26sa2Ucrfz2hnQw==)\n scope: server\n\n# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai\n\n# 文件上传相关 支持阿里云、华为云、腾讯、minio\noss:\n endpoint: https://play.min.io:9000\n access-key: Q3AM3UQ867SPQQA43P2F\n secret-key: zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG\n bucket-name: test-oss', '5041ac486e18aa0dd0bf624bb83806de', '2019-11-29 16:52:32', '2021-09-11 14:19:55', '', '127.0.0.1', '', '', '统一权限', 'null', 'null', 'yaml', 'null'); COMMIT; -- ---------------------------- diff --git a/pig-auth/pom.xml b/pig-auth/pom.xml index 60d590dd..f75b25f9 100755 --- a/pig-auth/pom.xml +++ b/pig-auth/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-auth @@ -44,19 +44,19 @@ com.pig4cloud pig-common-feign - 3.3.3 + 3.3.4 com.pig4cloud pig-upms-api - 3.3.3 + 3.3.4 com.pig4cloud pig-common-security - 3.3.3 + 3.3.4 diff --git a/pig-common/pig-common-bom/pom.xml b/pig-common/pig-common-bom/pom.xml index 54cad8b5..9aa82976 100644 --- a/pig-common/pig-common-bom/pom.xml +++ b/pig-common/pig-common-bom/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-common-bom - 3.3.3 + 3.3.4 pom pig-common-bom @@ -24,12 +24,13 @@ 0.0.28 1.2.75 1.5.24 - 3.4.3.2 + 3.4.3.3 3.5.7 4.1 5.18.3 2.0.3 1.0.0 + 1.0.1 @@ -113,12 +114,6 @@ fastjson ${fastjson.version} - - - org.rocksdb - rocksdbjni - ${rocksdbjni.version} - com.alibaba.nacos nacos-client @@ -130,7 +125,13 @@ excel-spring-boot-starter ${excel.version} - + + + com.pig4cloud.plugin + oss-spring-boot-starter + ${oss.version} + + com.baomidou mybatis-plus-boot-starter diff --git a/pig-common/pig-common-core/pom.xml b/pig-common/pig-common-core/pom.xml index 0d821013..6e92240d 100755 --- a/pig-common/pig-common-core/pom.xml +++ b/pig-common/pig-common-core/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-core diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/jackson/PigJavaTimeModule.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/jackson/PigJavaTimeModule.java index 33a63026..d36a0b15 100644 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/jackson/PigJavaTimeModule.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/jackson/PigJavaTimeModule.java @@ -50,12 +50,9 @@ public class PigJavaTimeModule extends SimpleModule { this.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); // yyyy-MM-dd - this.addSerializer(LocalDate.class, - new LocalDateSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN))); + this.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE)); // HH:mm:ss - this.addSerializer(LocalTime.class, - new LocalTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN))); - + this.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME)); // Instant 类型序列化 this.addSerializer(Instant.class, InstantSerializer.INSTANCE); @@ -64,11 +61,9 @@ public class PigJavaTimeModule extends SimpleModule { this.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); // yyyy-MM-dd - this.addDeserializer(LocalDate.class, - new LocalDateDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN))); + this.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_LOCAL_DATE)); // HH:mm:ss - this.addDeserializer(LocalTime.class, - new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN))); + this.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ISO_LOCAL_TIME)); // Instant 反序列化 this.addDeserializer(Instant.class, InstantDeserializer.INSTANT); } diff --git a/pig-common/pig-common-datasource/pom.xml b/pig-common/pig-common-datasource/pom.xml index 7e533d7c..bc0bfa56 100644 --- a/pig-common/pig-common-datasource/pom.xml +++ b/pig-common/pig-common-datasource/pom.xml @@ -21,7 +21,7 @@ pig-common com.pig4cloud - 3.3.3 + 3.3.4 4.0.0 diff --git a/pig-common/pig-common-feign/pom.xml b/pig-common/pig-common-feign/pom.xml index 821e1c06..4bf1f729 100755 --- a/pig-common/pig-common-feign/pom.xml +++ b/pig-common/pig-common-feign/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 4.0.0 @@ -33,7 +33,7 @@ com.pig4cloud pig-common-core - 3.3.3 + 3.3.4 com.alibaba.cloud diff --git a/pig-common/pig-common-job/pom.xml b/pig-common/pig-common-job/pom.xml index fa7db5dc..09251273 100755 --- a/pig-common/pig-common-job/pom.xml +++ b/pig-common/pig-common-job/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-job diff --git a/pig-common/pig-common-log/pom.xml b/pig-common/pig-common-log/pom.xml index c31d3b75..bdda50d2 100755 --- a/pig-common/pig-common-log/pom.xml +++ b/pig-common/pig-common-log/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-log @@ -35,13 +35,13 @@ com.pig4cloud pig-common-core - 3.3.3 + 3.3.4 com.pig4cloud pig-upms-api - 3.3.3 + 3.3.4 diff --git a/pig-common/pig-common-mybatis/pom.xml b/pig-common/pig-common-mybatis/pom.xml index dc75ddd5..b0f1cc86 100755 --- a/pig-common/pig-common-mybatis/pom.xml +++ b/pig-common/pig-common-mybatis/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-mybatis diff --git a/pig-common/pig-common-security/pom.xml b/pig-common/pig-common-security/pom.xml index 96bd06ef..3e35a521 100755 --- a/pig-common/pig-common-security/pom.xml +++ b/pig-common/pig-common-security/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-security @@ -35,7 +35,7 @@ com.pig4cloud pig-common-core - 3.3.3 + 3.3.4 @@ -46,7 +46,7 @@ com.pig4cloud pig-upms-api - 3.3.3 + 3.3.4 diff --git a/pig-common/pig-common-swagger/pom.xml b/pig-common/pig-common-swagger/pom.xml index fd92fd98..a12419cb 100644 --- a/pig-common/pig-common-swagger/pom.xml +++ b/pig-common/pig-common-swagger/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-swagger diff --git a/pig-common/pig-common-test/pom.xml b/pig-common/pig-common-test/pom.xml index 27c64bba..019e2649 100755 --- a/pig-common/pig-common-test/pom.xml +++ b/pig-common/pig-common-test/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-common - 3.3.3 + 3.3.4 pig-common-test @@ -18,7 +18,7 @@ com.pig4cloud pig-common-security - 3.3.3 + 3.3.4 org.springframework.security diff --git a/pig-common/pom.xml b/pig-common/pom.xml index edabd645..62ae451e 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-common diff --git a/pig-gateway/pom.xml b/pig-gateway/pom.xml index 18e9d35b..d6f22253 100755 --- a/pig-gateway/pom.xml +++ b/pig-gateway/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-gateway diff --git a/pig-register/pom.xml b/pig-register/pom.xml index 06266cef..a82ba8bd 100755 --- a/pig-register/pom.xml +++ b/pig-register/pom.xml @@ -18,7 +18,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-register @@ -27,7 +27,7 @@ nacos 注册配置中心 - 2.0.3 + 2.0.3.1 diff --git a/pig-register/src/main/java/com/alibaba/nacos/PigNacosApplication.java b/pig-register/src/main/java/com/alibaba/nacos/PigNacosApplication.java index 782c98f3..c22741c0 100755 --- a/pig-register/src/main/java/com/alibaba/nacos/PigNacosApplication.java +++ b/pig-register/src/main/java/com/alibaba/nacos/PigNacosApplication.java @@ -16,8 +16,6 @@ package com.alibaba.nacos; -import cn.hutool.core.lang.Validator; -import cn.hutool.system.SystemUtil; import com.alibaba.nacos.config.ConfigConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; @@ -27,7 +25,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; /** * @author nacos *

- * nacos console 源码运行,方便开发 生产建议从官网下载最新版配置运行 + * nacos console 源码运行,方便开发 生产从官网下载zip最新版集群配置运行 */ @Slf4j @EnableScheduling @@ -44,13 +42,6 @@ public class PigNacosApplication { * 初始化运行环境 */ private static boolean initEnv() { - // 特殊处理 window 且用户名包含中文的用户,避免RocksDB 初始化失败 - // System.setProperty(SystemUtil.USER_HOME, "/nacos-path/"); - if (SystemUtil.getOsInfo().isWindows() && Validator.hasChinese(SystemUtil.getUserInfo().getHomeDir())) { - log.error("路径包含中文,需要打开以上注释配置指定不包含中文目录"); - return false; - } - System.setProperty(ConfigConstants.STANDALONE_MODE, "true"); System.setProperty(ConfigConstants.AUTH_ENABLED, "false"); System.setProperty(ConfigConstants.LOG_BASEDIR, "logs"); diff --git a/pig-upms/pig-upms-api/pom.xml b/pig-upms/pig-upms-api/pom.xml index ca24096b..fa1b35c7 100755 --- a/pig-upms/pig-upms-api/pom.xml +++ b/pig-upms/pig-upms-api/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 3.3.3 + 3.3.4 pig-upms-api diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java new file mode 100644 index 00000000..d712ee15 --- /dev/null +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java @@ -0,0 +1,76 @@ +/* + * 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.pig.admin.api.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 文件管理 + * + * @author Luckly + * @date 2019-06-18 17:18:42 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class SysFile extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 编号 + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 文件名 + */ + private String fileName; + + /** + * 原文件名 + */ + private String original; + + /** + * 容器名称 + */ + private String bucketName; + + /** + * 文件类型 + */ + private String type; + + /** + * 文件大小 + */ + private Long fileSize; + + /** + * 删除标识:1-删除,0-正常 + */ + @TableLogic + private Integer delFlag; + +} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java index 100224bd..5f8ca7a8 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; @@ -38,6 +39,7 @@ import javax.validation.constraints.NotBlank; * @since 2019/2/1 */ @Data +@EqualsAndHashCode(callSuper = true) public class SysLog extends BaseEntity { private static final long serialVersionUID = 1L; diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java index 6fb2dd7f..b9b22508 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; /** *

@@ -33,6 +34,7 @@ import lombok.Data; * @since 2019/2/1 */ @Data +@EqualsAndHashCode(callSuper = true) public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; diff --git a/pig-upms/pig-upms-biz/pom.xml b/pig-upms/pig-upms-biz/pom.xml index b4d967c0..ccc15614 100644 --- a/pig-upms/pig-upms-biz/pom.xml +++ b/pig-upms/pig-upms-biz/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 3.3.3 + 3.3.4 pig-upms-biz @@ -35,6 +35,11 @@ com.pig4cloud pig-upms-api + + + com.pig4cloud.plugin + oss-spring-boot-starter + com.pig4cloud diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java index 2b594947..78fe64ae 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java @@ -1,36 +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.pig.admin.controller; -import cn.hutool.core.io.IoUtil; -import lombok.SneakyThrows; -import org.springframework.core.io.ClassPathResource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.entity.SysFile; +import com.pig4cloud.pig.admin.service.SysFileService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.pig.common.security.annotation.Inner; +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.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; /** * 文件管理 * - * @author lengleng - * @date 2021/8/23 + * @author Luckly + * @date 2021-09-11 */ @RestController -@RequestMapping("/file") +@AllArgsConstructor +@RequestMapping("/sys-file") +@Api(value = "sys-file", tags = "文件管理") public class FileController { + private final SysFileService sysFileService; + /** - * 获取本地文件 - * @param fileName 文件名称 - * @param response 本地文件 + * 分页查询 + * @param page 分页对象 + * @param sysFile 文件管理 + * @return */ - @SneakyThrows - @GetMapping("/local-file/{fileName}") - public void localFile(@PathVariable String fileName, HttpServletResponse response) { - ClassPathResource resource = new ClassPathResource("file/" + fileName); - response.setContentType("application/octet-stream; charset=UTF-8"); - IoUtil.copy(resource.getInputStream(), response.getOutputStream()); + @ApiOperation(value = "分页查询", notes = "分页查询") + @GetMapping("/page") + public R getSysFilePage(Page page, SysFile sysFile) { + return R.ok(sysFileService.page(page, Wrappers.query(sysFile))); + } + + /** + * 通过id删除文件管理 + * @param id id + * @return R + */ + @ApiOperation(value = "通过id删除文件管理", notes = "通过id删除文件管理") + @SysLog("删除文件管理") + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_file_del')") + public R removeById(@PathVariable Long id) { + return R.ok(sysFileService.deleteFile(id)); + } + + /** + * 上传文件 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常 + * @param file 资源 + * @return R(/ admin / bucketName / filename) + */ + @PostMapping(value = "/upload") + public R upload(@RequestPart("file") MultipartFile file) { + return sysFileService.uploadFile(file); + } + + /** + * 获取文件 + * @param bucket 桶名称 + * @param fileName 文件空间/名称 + * @param response + * @return + */ + @Inner(false) + @GetMapping("/{bucket}/{fileName}") + public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) { + sysFileService.getFile(bucket, fileName, response); } } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java new file mode 100644 index 00000000..0c80a771 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.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.pig.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.admin.api.entity.SysFile; +import org.apache.ibatis.annotations.Mapper; + +/** + * 文件管理 + * + * @author Luckly + * @date 2019-06-18 17:18:42 + */ +@Mapper +public interface SysFileMapper extends BaseMapper { + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java new file mode 100644 index 00000000..6d7baabf --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.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.pig.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.admin.api.entity.SysFile; +import com.pig4cloud.pig.common.core.util.R; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; + +/** + * 文件管理 + * + * @author Luckly + * @date 2019-06-18 17:18:42 + */ +public interface SysFileService extends IService { + + /** + * 上传文件 + * @param file + * @return + */ + R uploadFile(MultipartFile file); + + /** + * 读取文件 + * @param bucket 桶名称 + * @param fileName 文件名称 + * @param response 输出流 + */ + void getFile(String bucket, String fileName, HttpServletResponse response); + + /** + * 删除文件 + * @param id + * @return + */ + Boolean deleteFile(Long id); + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java new file mode 100644 index 00000000..6bc8e377 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java @@ -0,0 +1,128 @@ +/* + * 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.pig.admin.service.impl; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.amazonaws.services.s3.model.S3Object; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.admin.api.entity.SysFile; +import com.pig4cloud.pig.admin.mapper.SysFileMapper; +import com.pig4cloud.pig.admin.service.SysFileService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.plugin.oss.OssProperties; +import com.pig4cloud.plugin.oss.service.OssTemplate; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; + +/** + * 文件管理 + * + * @author Luckly + * @date 2019-06-18 17:18:42 + */ +@Slf4j +@Service +@AllArgsConstructor +public class SysFileServiceImpl extends ServiceImpl implements SysFileService { + + private final OssProperties ossProperties; + + private final OssTemplate minioTemplate; + + /** + * 上传文件 + * @param file + * @return + */ + @Override + public R uploadFile(MultipartFile file) { + String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename()); + Map resultMap = new HashMap<>(4); + resultMap.put("bucketName", ossProperties.getBucketName()); + resultMap.put("fileName", fileName); + resultMap.put("url", String.format("/admin/sys-file/%s/%s", ossProperties.getBucketName(), fileName)); + + try { + minioTemplate.putObject(ossProperties.getBucketName(), fileName, file.getInputStream()); + // 文件管理数据记录,收集管理追踪文件 + fileLog(file, fileName); + } + catch (Exception e) { + log.error("上传失败", e); + return R.failed(e.getLocalizedMessage()); + } + return R.ok(resultMap); + } + + /** + * 读取文件 + * @param bucket + * @param fileName + * @param response + */ + @Override + public void getFile(String bucket, String fileName, HttpServletResponse response) { + try (S3Object s3Object = minioTemplate.getObject(bucket, fileName)) { + response.setContentType("application/octet-stream; charset=UTF-8"); + IoUtil.copy(s3Object.getObjectContent(), response.getOutputStream()); + } + catch (Exception e) { + log.error("文件读取异常: {}", e.getLocalizedMessage()); + } + } + + /** + * 删除文件 + * @param id + * @return + */ + @Override + @SneakyThrows + @Transactional(rollbackFor = Exception.class) + public Boolean deleteFile(Long id) { + SysFile file = this.getById(id); + minioTemplate.removeObject(ossProperties.getBucketName(), file.getFileName()); + return this.removeById(id); + } + + /** + * 文件管理数据记录,收集管理追踪文件 + * @param file 上传文件格式 + * @param fileName 文件名 + */ + private void fileLog(MultipartFile file, String fileName) { + SysFile sysFile = new SysFile(); + sysFile.setFileName(fileName); + sysFile.setOriginal(file.getOriginalFilename()); + sysFile.setFileSize(file.getSize()); + sysFile.setType(FileUtil.extName(file.getOriginalFilename())); + sysFile.setBucketName(ossProperties.getBucketName()); + this.save(sysFile); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysFileMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysFileMapper.xml new file mode 100644 index 00000000..12ddfa42 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysFileMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/pig-upms/pom.xml b/pig-upms/pom.xml index bf60a9fd..09bf75b1 100755 --- a/pig-upms/pom.xml +++ b/pig-upms/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-upms diff --git a/pig-visual/pig-codegen/pom.xml b/pig-visual/pig-codegen/pom.xml index 2cffd5b5..626774ce 100755 --- a/pig-visual/pig-codegen/pom.xml +++ b/pig-visual/pig-codegen/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig-visual - 3.3.3 + 3.3.4 pig-codegen diff --git a/pig-visual/pig-monitor/pom.xml b/pig-visual/pig-monitor/pom.xml index 90638c4a..0a0524d1 100755 --- a/pig-visual/pig-monitor/pom.xml +++ b/pig-visual/pig-monitor/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-visual - 3.3.3 + 3.3.4 pig-monitor diff --git a/pig-visual/pig-sentinel-dashboard/pom.xml b/pig-visual/pig-sentinel-dashboard/pom.xml index 18b4f7bf..5bfafa87 100755 --- a/pig-visual/pig-sentinel-dashboard/pom.xml +++ b/pig-visual/pig-sentinel-dashboard/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-visual - 3.3.3 + 3.3.4 pig-sentinel-dashboard diff --git a/pig-visual/pig-xxl-job-admin/pom.xml b/pig-visual/pig-xxl-job-admin/pom.xml index 68f19f08..92afeea0 100644 --- a/pig-visual/pig-xxl-job-admin/pom.xml +++ b/pig-visual/pig-xxl-job-admin/pom.xml @@ -4,7 +4,7 @@ com.pig4cloud pig-visual - 3.3.3 + 3.3.4 pig-xxl-job-admin diff --git a/pig-visual/pom.xml b/pig-visual/pom.xml index cf09152f..fbcf1b07 100755 --- a/pig-visual/pom.xml +++ b/pig-visual/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.3.3 + 3.3.4 pig-visual diff --git a/pom.xml b/pom.xml index 59dbe438..ab829866 100755 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig ${project.artifactId} - 3.3.3 + 3.3.4 pom https://www.pig4cloud.com @@ -34,7 +34,7 @@ 1.8 1.8 2.5.1 - 5.7.9 + 5.7.12 3.4.1 2.2.0 1.7