From c9cda12b7d54eb2cc2fa644d11738ba6a62bac87 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sat, 3 Feb 2024 21:12:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8D=87=E7=BA=A7=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=B9=B6=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.X-File-Storage 2.1.0 适配 2.Crane4j 2.5.0 不需要做任何额外的配置来引入 crane4j,crane4j 将借助 SpringBoot 的自动装配自动加载必要的组件 --- README.md | 22 +++++++------- .../common/config/Crane4jConfiguration.java | 28 ----------------- .../admin/system/config/FileRecorderImpl.java | 30 ++++++++++++------- .../system/service/impl/FileServiceImpl.java | 4 +-- .../service/impl/RoleDeptServiceImpl.java | 2 +- .../service/impl/UserRoleServiceImpl.java | 2 +- .../src/main/resources/banner.txt | 2 +- .../main/resources/config/application-dev.yml | 1 + 8 files changed, 37 insertions(+), 54 deletions(-) delete mode 100644 continew-admin-common/src/main/java/top/charles7c/continew/admin/common/config/Crane4jConfiguration.java diff --git a/README.md b/README.md index 11c866e4..4b88fbb2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ContiNew Starter -Spring Boot +Spring Boot Open JDK @@ -232,28 +232,28 @@ git clone https://github.com/Charles7c/continew-admin.git | 名称 | 版本 | 简介 | | :----------------------------------------------------------- |:---------------| :----------------------------------------------------------- | | [ContiNew Starter](https://github.com/Charles7c/continew-starter) | 1.4.0-SNAPSHOT | ContiNew Starter 包含了一系列经过企业实践优化的依赖包(如 MyBatis-Plus、SaToken),可轻松集成到应用中,为开发人员减少手动引入依赖及配置的麻烦,为 Spring Boot Web 项目的灵活快速构建提供支持。 | -| Spring Boot | 3.1.7 | 简化 Spring 应用的初始搭建和开发过程,基于“约定优于配置”的理念,使开发人员不再需要定义样板化的配置。(Spring Boot 3.0 开始,要求 Java 17 作为最低版本) | +| Spring Boot | 3.1.8 | 简化 Spring 应用的初始搭建和开发过程,基于“约定优于配置”的理念,使开发人员不再需要定义样板化的配置。(Spring Boot 3.0 开始,要求 Java 17 作为最低版本) | | Undertow | 2.3.10.Final | 采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制。 | | Sa-Token + JWT | 1.37.0 | 轻量级 Java 权限认证框架,让鉴权变得简单、优雅。 | -| MyBatis Plus | 3.5.4.1 | MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,简化开发、提高效率。 | -| dynamic-datasource-spring-boot-starter | 4.2.0 | 基于 Spring Boot 的快速集成多数据源的启动器。 | +| MyBatis Plus | 3.5.5 | MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,简化开发、提高效率。 | +| dynamic-datasource-spring-boot-starter | 4.3.0 | 基于 Spring Boot 的快速集成多数据源的启动器。 | | Hikari | 5.0.1 | JDBC 连接池,号称 “史上最快连接池”,SpringBoot 在 2.0 之后,采用的默认数据库连接池就是 Hikari。 | | MySQL | 8.0.33 | 体积小、速度快、总体拥有成本低,是最流行的关系型数据库管理系统之一。 | | mysql-connector-j | 8.0.33 | MySQL Java 驱动。 | | P6Spy | 3.9.1 | SQL 性能分析组件。 | | Liquibase | 4.20.0 | 用于管理数据库版本,跟踪、管理和应用数据库变化。 | -| [JetCache](https://github.com/alibaba/jetcache/blob/master/docs/CN/Readme.md) | 2.7.4 | 一个基于 Java 的缓存系统封装,提供统一的 API 和注解来简化缓存的使用。提供了比 SpringCache 更加强大的注解,可以原生的支持 TTL、两级缓存、分布式自动刷新,还提供了 Cache 接口用于手工缓存操作。 | -| Redisson | 3.25.2 | 不仅仅是一个 Redis Java 客户端,Redisson 充分的利用了 Redis 键值数据库提供的一系列优势,为使用者提供了一系列具有分布式特性的常用工具:分布式锁、限流器等。 | +| [JetCache](https://github.com/alibaba/jetcache/blob/master/docs/CN/Readme.md) | 2.7.5 | 一个基于 Java 的缓存系统封装,提供统一的 API 和注解来简化缓存的使用。提供了比 SpringCache 更加强大的注解,可以原生的支持 TTL、两级缓存、分布式自动刷新,还提供了 Cache 接口用于手工缓存操作。 | +| Redisson | 3.26.0 | 不仅仅是一个 Redis Java 客户端,Redisson 充分的利用了 Redis 键值数据库提供的一系列优势,为使用者提供了一系列具有分布式特性的常用工具:分布式锁、限流器等。 | | Redis | 7.2.3 | 高性能的 key-value 数据库。 | -| [X File Storage](https://x-file-storage.xuyanwu.cn/#/) | 2.0.0 | 一行代码将文件存储到本地、FTP、SFTP、WebDAV、阿里云 OSS、华为云 OBS...等其它兼容 S3 协议的存储平台。 | -| SMS4J | 3.0.4 | 短信聚合框架,轻松集成多家短信服务,解决接入多个短信 SDK 的繁琐流程。 | +| [X File Storage](https://x-file-storage.xuyanwu.cn/#/) | 2.1.0 | 一行代码将文件存储到本地、FTP、SFTP、WebDAV、阿里云 OSS、华为云 OBS...等其它兼容 S3 协议的存储平台。 | +| SMS4J | 3.1.1 | 短信聚合框架,轻松集成多家短信服务,解决接入多个短信 SDK 的繁琐流程。 | | Just Auth | 1.16.6 | 开箱即用的整合第三方登录的开源组件,脱离繁琐的第三方登录 SDK,让登录变得 So easy! | | Easy Excel | 3.3.3 | 一个基于 Java 的、快速、简洁、解决大文件内存溢出的 Excel 处理工具。 | | [AJ-Captcha](https://ajcaptcha.beliefteam.cn/captcha-doc/) | 1.3.0 | Java 行为验证码,包含滑动拼图、文字点选两种方式,UI支持弹出和嵌入两种方式。 | | Easy Captcha | 1.6.2 | Java 图形验证码,支持 gif、中文、算术等类型,可用于 Java Web、JavaSE 等项目。 | -| [Crane4j](https://createsequence.gitee.io/crane4j-doc/#/) | 2.4.0 | 一个基于注解的,用于完成一切 “根据 A 的 key 值拿到 B,再把 B 的属性映射到 A” 这类需求的字段填充框架。 | -| Knife4j | 4.4.0 | 前身是 swagger-bootstrap-ui,集 Swagger2 和 OpenAPI3 为一体的增强解决方案。 | -| Hutool | 5.8.24 | 小而全的 Java 工具类库,通过静态方法封装,降低相关 API 的学习成本,提高工作效率,使 Java 拥有函数式语言般的优雅,让 Java 语言也可以“甜甜的”。 | +| [Crane4j](https://createsequence.gitee.io/crane4j-doc/#/) | 2.5.0 | 一个基于注解的,用于完成一切 “根据 A 的 key 值拿到 B,再把 B 的属性映射到 A” 这类需求的字段填充框架。 | +| Knife4j | 4.5.0 | 前身是 swagger-bootstrap-ui,集 Swagger2 和 OpenAPI3 为一体的增强解决方案。 | +| Hutool | 5.8.25 | 小而全的 Java 工具类库,通过静态方法封装,降低相关 API 的学习成本,提高工作效率,使 Java 拥有函数式语言般的优雅,让 Java 语言也可以“甜甜的”。 | | Lombok | 1.18.30 | 在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁。 | ## 项目结构 diff --git a/continew-admin-common/src/main/java/top/charles7c/continew/admin/common/config/Crane4jConfiguration.java b/continew-admin-common/src/main/java/top/charles7c/continew/admin/common/config/Crane4jConfiguration.java deleted file mode 100644 index 1a14d78f..00000000 --- a/continew-admin-common/src/main/java/top/charles7c/continew/admin/common/config/Crane4jConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.charles7c.continew.admin.common.config; - -import org.springframework.context.annotation.Configuration; - -/** - * Crane4j 配置 - * - * @author Charles7c - * @since 2024/1/11 21:22 - */ -@Configuration -public class Crane4jConfiguration extends cn.crane4j.spring.boot.config.Crane4jAutoConfiguration {} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/config/FileRecorderImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/config/FileRecorderImpl.java index a9ccc489..8f770d35 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/config/FileRecorderImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/config/FileRecorderImpl.java @@ -16,19 +16,15 @@ package top.charles7c.continew.admin.system.config; -import java.util.Optional; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import org.dromara.x.file.storage.core.FileInfo; -import org.dromara.x.file.storage.core.recorder.FileRecorder; -import org.springframework.stereotype.Component; - import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.EscapeUtil; import cn.hutool.core.util.StrUtil; - +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.x.file.storage.core.FileInfo; +import org.dromara.x.file.storage.core.recorder.FileRecorder; +import org.dromara.x.file.storage.core.upload.FilePartInfo; +import org.springframework.stereotype.Component; import top.charles7c.continew.admin.common.util.helper.LoginHelper; import top.charles7c.continew.admin.system.enums.FileTypeEnum; import top.charles7c.continew.admin.system.mapper.FileMapper; @@ -37,6 +33,8 @@ import top.charles7c.continew.admin.system.model.entity.FileDO; import top.charles7c.continew.admin.system.model.entity.StorageDO; import top.charles7c.continew.starter.core.constant.StringConstants; +import java.util.Optional; + /** * 文件记录实现类 * @@ -100,4 +98,16 @@ public class FileRecorderImpl implements FileRecorder { .oneOpt() .orElse(null)); } + + @Override + public void update(FileInfo fileInfo) { + /* 不使用分片功能则无需重写 */ } + + @Override + public void saveFilePart(FilePartInfo filePartInfo) { + /* 不使用分片功能则无需重写 */ } + + @Override + public void deleteFilePartByUploadId(String s) { + /* 不使用分片功能则无需重写 */} } \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java index e2c4ff2c..a9cd5c00 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java @@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j; import org.dromara.x.file.storage.core.FileInfo; import org.dromara.x.file.storage.core.FileStorageService; import org.dromara.x.file.storage.core.ProgressListener; -import org.dromara.x.file.storage.core.UploadPretreatment; +import org.dromara.x.file.storage.core.upload.UploadPretreatment; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import top.charles7c.continew.admin.system.enums.StorageTypeEnum; @@ -91,7 +91,7 @@ public class FileServiceImpl extends BaseServiceImpl listDeptIdByRoleId(Long roleId) { return roleDeptMapper.selectDeptIdByRoleId(roleId); } diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/UserRoleServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/UserRoleServiceImpl.java index e92a1885..5cd3bee1 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/UserRoleServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/UserRoleServiceImpl.java @@ -69,7 +69,7 @@ public class UserRoleServiceImpl implements UserRoleService { } @Override - @ContainerMethod(namespace = ContainerConstants.USER_ROLE_ID_LIST, type = MappingType.NONE) + @ContainerMethod(namespace = ContainerConstants.USER_ROLE_ID_LIST, type = MappingType.ORDER_OF_KEYS) public List listRoleIdByUserId(Long userId) { return userRoleMapper.selectRoleIdByUserId(userId); } diff --git a/continew-admin-webapi/src/main/resources/banner.txt b/continew-admin-webapi/src/main/resources/banner.txt index 0cb71f20..22a705af 100644 --- a/continew-admin-webapi/src/main/resources/banner.txt +++ b/continew-admin-webapi/src/main/resources/banner.txt @@ -5,5 +5,5 @@ \____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_| :: ${project.name} :: v${project.version} - :: ContiNew Starter :: v1.2.1-SNAPSHOT + :: ContiNew Starter :: v1.4.0-SNAPSHOT :: Spring Boot :: v${spring-boot.version} diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index 279aff47..820c056e 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -175,6 +175,7 @@ springdoc: sms: # 从 YAML 读取配置 config-type: YAML + http-log: true is-print: false blends: cloopen: