添加文件服务

This commit is contained in:
2025-11-04 16:13:28 +08:00
parent 6a59e27ebb
commit fd5a68c27e
112 changed files with 1245 additions and 741 deletions

View File

@@ -50,13 +50,13 @@ CREATE TABLE `tz_trade_order`
`after_sale_status` tinyint DEFAULT NULL COMMENT '售后状态 (枚举 TradeOrderItemAfterSaleStatusEnum)',
`finance_id` bigint DEFAULT NULL COMMENT '财务单编号',
`finance_status` tinyint DEFAULT NULL COMMENT '财务状态 (枚举 TradeOrderItemFinanceEnum)',
`tenant_id` bigint NOT NULL DEFAULT '1' COMMENT '租户编号',
`version` int NOT NULL DEFAULT '0' COMMENT '版本号(乐观锁)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '最后更新时间',
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT '1' COMMENT '租户编号',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_order_num` (`order_num`),
KEY `idx_user_id` (`user_id`),
@@ -71,43 +71,56 @@ CREATE TABLE `tz_trade_order`
-- 交易订单项表 (trade_order_item)
CREATE TABLE `tz_trade_order_item`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` bigint(20) NOT NULL COMMENT '用户编号',
`order_id` bigint(20) NOT NULL COMMENT '订单编号',
`cart_id` bigint(20) DEFAULT NULL COMMENT '购物车项编号',
`spu_id` bigint(20) NOT NULL COMMENT '商品 SPU 编号',
`spu_name` varchar(256) NOT NULL COMMENT '商品 SPU 名称',
`spu_type` tinyint(1) NOT NULL COMMENT '商品类型1商品 2服务',
`sku_id` bigint(20) NOT NULL COMMENT '商品 SKU 编号',
`sku_name` bigint(20) NOT NULL COMMENT '商品 SKU 名称',
`pic_url` varchar(512) NOT NULL COMMENT '商品图片',
`count` int(11) NOT NULL COMMENT '购买数量',
`unit` varchar(16) NOT NULL COMMENT '商品单位',
`expense_price` int(11) NOT NULL COMMENT '商品成本(单),单位:分',
`price` int(11) NOT NULL COMMENT '商品原价(单),单位:分',
`discount_price` int(11) NOT NULL COMMENT '优惠金额(总),单位:分',
`delivery_price` int(11) NOT NULL COMMENT '运费金额(总),单位:分',
`adjust_price` int(11) NOT NULL COMMENT '订单调价(总),单位:分',
`pay_price` int(11) NOT NULL COMMENT '应付金额(总),单位:分',
`live_price` int(11) NOT NULL COMMENT '实收金额(总),单位:分',
`serve_address` datetime NOT NULL COMMENT '服务地址',
`properties` json DEFAULT NULL COMMENT '属性数组',
`serve_info` json DEFAULT NULL COMMENT '服务信息',
`serve_ext_info` json DEFAULT NULL COMMENT '扩展服务信息,存储额外的服务相关数据',
`price_ext_info` json DEFAULT NULL COMMENT '附加费信息',
`version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL COMMENT '最后更新时间',
`creator` varchar(64) NOT NULL COMMENT '创建者',
`updater` varchar(64) NOT NULL COMMENT '更新者',
`deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` bigint NOT NULL COMMENT '用户编号',
`order_id` bigint NOT NULL COMMENT '订单编号',
`cart_id` bigint DEFAULT NULL COMMENT '购物车项编号',
`spu_id` bigint NOT NULL COMMENT '商品 SPU 编号',
`spu_name` varchar(256) NOT NULL COMMENT '商品 SPU 名称',
`spu_type` tinyint(1) NOT NULL COMMENT '商品类型1商品 2服务',
`sku_id` bigint NOT NULL COMMENT '商品 SKU 编号',
`sku_name` varchar(255) NOT NULL COMMENT '商品 SKU 名称',
`shop_id` bigint DEFAULT NULL COMMENT '店铺id',
`shop_name` varchar(64) DEFAULT NULL COMMENT '店铺名称',
`shop_logo` varchar(255) DEFAULT NULL COMMENT '店铺logo',
`order_category_name` varchar(64) NOT NULL COMMENT '订单类目名称',
`order_category_id` bigint NOT NULL COMMENT '订单类目id',
`pic_url` varchar(512) NOT NULL COMMENT '商品图片',
`count` int NOT NULL COMMENT '购买数量',
`unit` varchar(16) DEFAULT NULL COMMENT '商品单位',
`expense_price` int DEFAULT NULL COMMENT '商品成本(单),单位:分',
`price` int DEFAULT NULL COMMENT '商品原价(单),单位:分',
`discount_price` int DEFAULT NULL COMMENT '优惠金额(总),单位:分',
`delivery_price` int DEFAULT NULL COMMENT '运费金额(总),单位:分',
`adjust_price` int DEFAULT NULL COMMENT '订单调价(总),单位:分',
`pay_price` int DEFAULT NULL COMMENT '应付金额(总),单位:分',
`live_price` int DEFAULT NULL COMMENT '实收金额(总),单位:分',
`refund_status` tinyint DEFAULT NULL COMMENT '退款状态 (枚举 TradeOrderRefundStatusEnum)',
`refund_price` int DEFAULT NULL COMMENT '退款金额,单位:分',
`refund_time` datetime DEFAULT NULL COMMENT '退款时间',
`sub_type` tinyint(1) DEFAULT '1' COMMENT '预约类型1预约 2 加急)',
`sub_time` datetime DEFAULT NULL COMMENT '预约时间',
`serve_address` varchar(255) DEFAULT NULL COMMENT '服务地址',
`serve_content` varchar(255) DEFAULT NULL COMMENT '服务内容',
`properties` json DEFAULT NULL COMMENT '属性数组',
`serve_info` json DEFAULT NULL COMMENT '服务信息',
`serve_ext_info` json DEFAULT NULL COMMENT '扩展服务信息,存储额外的服务相关数据',
`price_ext_info` json DEFAULT NULL COMMENT '附加费信息',
`version` int NOT NULL DEFAULT '0' COMMENT '版本号(乐观锁)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '最后更新时间',
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT '1' COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_order_id` (`order_id`),
KEY `idx_sku_id` (`sku_id`),
KEY `idx_user_id` (`user_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='交易订单项表';
AUTO_INCREMENT = 2
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci COMMENT ='交易订单项表';
-- 订单日志表 (trade_order_log)
@@ -126,6 +139,7 @@ CREATE TABLE `tz_trade_order_log`
`creator` varchar(64) NOT NULL COMMENT '创建者',
`updater` varchar(64) NOT NULL COMMENT '更新者',
`deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT '1' COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_order_id` (`order_id`),
KEY `idx_user_id` (`user_id`)

View File

@@ -163,6 +163,16 @@
<artifactId>tashow-trade-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-module-file</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-file-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-module-trade</artifactId>

View File

@@ -17,6 +17,7 @@
<module>tashow-trade-api</module>
<module>tashow-pay-api</module>
<module>tashow-user-api</module>
<module>tashow-file-api</module>
</modules>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-feign</artifactId>
<version>${revision}</version>
</parent>
<artifactId>tashow-file-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
infra 模块 API暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,18 @@
package com.tashow.cloud.fileapi.api.config;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.fileapi.enums.ApiConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
/** RPC 服务 - 参数配置 */
public interface ConfigApi {
String PREFIX = ApiConstants.PREFIX + "/config";
/** 根据参数键查询参数值 */
@GetMapping(PREFIX + "/get-value-by-key")
CommonResult<String> getConfigValueByKey(@RequestParam("key") String key);
}

View File

@@ -0,0 +1,62 @@
package com.tashow.cloud.fileapi.api.file;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.fileapi.api.file.dto.FileCreateReqDTO;
import com.tashow.cloud.fileapi.enums.ApiConstants;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* RPC 服务 - 文件
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
public interface FileApi {
String PREFIX = ApiConstants.PREFIX + "/file";
/**
* 保存文件,并返回文件的访问路径
*
* @param content 文件内容
* @return 文件路径
*/
default String createFile(byte[] content) {
return createFile(null, null, content);
}
/**
* 保存文件,并返回文件的访问路径
*
* @param path 文件路径
* @param content 文件内容
* @return 文件路径
*/
default String createFile(String path, byte[] content) {
return createFile(null, path, content);
}
/**
* 保存文件,并返回文件的访问路径
*
* @param name 原文件名称
* @param path 文件路径
* @param content 文件内容
* @return 文件路径
*/
default String createFile(
@RequestParam("name") String name,
@RequestParam("path") String path,
@RequestParam("content") byte[] content) {
return createFile(new FileCreateReqDTO().setName(name).setPath(path).setContent(content))
.getCheckedData();
}
/**
* 保存文件,并返回文件的访问路径
*/
@PostMapping(PREFIX + "/create")
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
}

View File

@@ -0,0 +1,21 @@
package com.tashow.cloud.fileapi.api.file.dto;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
/** RPC 服务 - 文件创建 Request DTO */
@Data
public class FileCreateReqDTO {
/** 原文件名称 */
private String name;
/** 文件路径 */
private String path;
/**
* 文件内容
*/
@NotEmpty(message = "文件内容不能为空")
private byte[] content;
}

View File

@@ -0,0 +1,4 @@
/**
* infra API 包,定义暴露给其它模块的 API
*/
package com.tashow.cloud.fileapi.api;

View File

@@ -0,0 +1,24 @@
package com.tashow.cloud.fileapi.enums;
import com.tashow.cloud.common.enums.RpcConstants;
/**
* API 相关的枚举
*
* @author 芋道源码
*/
public class ApiConstants {
/**
* 服务名
*
* 注意,需要保证和 spring.application.name 保持一致
*/
public static final String NAME = "file-server";
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/file";
public static final String VERSION = "1.0.0";
}

View File

@@ -0,0 +1,72 @@
package com.tashow.cloud.fileapi.enums;
import com.tashow.cloud.common.exception.ErrorCode;
/**
* Infra 错误码枚举类
*
* infra 系统,使用 1-001-000-000 段
*/
public interface ErrorCodeConstants {
// ========== 参数配置 1-001-000-000 ==========
ErrorCode CONFIG_NOT_EXISTS = new ErrorCode(1_001_000_001, "参数配置不存在");
ErrorCode CONFIG_KEY_DUPLICATE = new ErrorCode(1_001_000_002, "参数配置 key 重复");
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1_001_000_003, "不能删除类型为系统内置的参数配置");
ErrorCode CONFIG_GET_VALUE_ERROR_IF_VISIBLE = new ErrorCode(1_001_000_004, "获取参数配置失败,原因:不允许获取不可见配置");
// ========== 定时任务 1-001-001-000 ==========
ErrorCode JOB_NOT_EXISTS = new ErrorCode(1_001_001_000, "定时任务不存在");
ErrorCode JOB_HANDLER_EXISTS = new ErrorCode(1_001_001_001, "定时任务的处理器已经存在");
ErrorCode JOB_CHANGE_STATUS_INVALID = new ErrorCode(1_001_001_002, "只允许修改为开启或者关闭状态");
ErrorCode JOB_CHANGE_STATUS_EQUALS = new ErrorCode(1_001_001_003, "定时任务已经处于该状态,无需修改");
ErrorCode JOB_UPDATE_ONLY_NORMAL_STATUS = new ErrorCode(1_001_001_004, "只有开启状态的任务,才可以修改");
ErrorCode JOB_CRON_EXPRESSION_VALID = new ErrorCode(1_001_001_005, "CRON 表达式不正确");
ErrorCode JOB_HANDLER_BEAN_NOT_EXISTS = new ErrorCode(1_001_001_006, "定时任务的处理器 Bean 不存在,注意 Bean 默认首字母小写");
ErrorCode JOB_HANDLER_BEAN_TYPE_ERROR = new ErrorCode(1_001_001_007, "定时任务的处理器 Bean 类型不正确,未实现 JobHandler 接口");
// ========== API 错误日志 1-001-002-000 ==========
ErrorCode API_ERROR_LOG_NOT_FOUND = new ErrorCode(1_001_002_000, "API 错误日志不存在");
ErrorCode API_ERROR_LOG_PROCESSED = new ErrorCode(1_001_002_001, "API 错误日志已处理");
// ========= 文件相关 1-001-003-000 =================
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1_001_003_000, "文件路径已存在");
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1_001_003_001, "文件不存在");
ErrorCode FILE_IS_EMPTY = new ErrorCode(1_001_003_002, "文件为空");
// ========== 代码生成器 1-001-004-000 ==========
ErrorCode CODEGEN_TABLE_EXISTS = new ErrorCode(1_001_004_002, "表定义已经存在");
ErrorCode CODEGEN_IMPORT_TABLE_NULL = new ErrorCode(1_001_004_001, "导入的表不存在");
ErrorCode CODEGEN_IMPORT_COLUMNS_NULL = new ErrorCode(1_001_004_002, "导入的字段不存在");
ErrorCode CODEGEN_TABLE_NOT_EXISTS = new ErrorCode(1_001_004_004, "表定义不存在");
ErrorCode CODEGEN_COLUMN_NOT_EXISTS = new ErrorCode(1_001_004_005, "字段义不存在");
ErrorCode CODEGEN_SYNC_COLUMNS_NULL = new ErrorCode(1_001_004_006, "同步的字段不存在");
ErrorCode CODEGEN_SYNC_NONE_CHANGE = new ErrorCode(1_001_004_007, "同步失败,不存在改变");
ErrorCode CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL = new ErrorCode(1_001_004_008, "数据库的表注释未填写");
ErrorCode CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL = new ErrorCode(1_001_004_009, "数据库的表字段({})注释未填写");
ErrorCode CODEGEN_MASTER_TABLE_NOT_EXISTS = new ErrorCode(1_001_004_010, "主表(id={})定义不存在,请检查");
ErrorCode CODEGEN_SUB_COLUMN_NOT_EXISTS = new ErrorCode(1_001_004_011, "子表的字段(id={})不存在,请检查");
ErrorCode CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE = new ErrorCode(1_001_004_012, "主表生成代码失败,原因:它没有子表");
// ========== 文件配置 1-001-006-000 ==========
ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_006_000, "文件配置不存在");
ErrorCode FILE_CONFIG_DELETE_FAIL_MASTER = new ErrorCode(1_001_006_001, "该文件配置不允许删除,原因:它是主配置,删除会导致无法上传文件");
// ========== 数据源配置 1-001-007-000 ==========
ErrorCode DATA_SOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_007_000, "数据源配置不存在");
ErrorCode DATA_SOURCE_CONFIG_NOT_OK = new ErrorCode(1_001_007_001, "数据源配置不正确,无法进行连接");
// ========== 学生 1-001-201-000 ==========
ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在");
ErrorCode DEMO02_CATEGORY_NOT_EXISTS = new ErrorCode(1_001_201_001, "示例分类不存在");
ErrorCode DEMO02_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_001_201_002, "存在存在子示例分类,无法删除");
ErrorCode DEMO02_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_001_201_003,"父级示例分类不存在");
ErrorCode DEMO02_CATEGORY_PARENT_ERROR = new ErrorCode(1_001_201_004, "不能设置自己为父示例分类");
ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
ErrorCode DEMO03_STUDENT_NOT_EXISTS = new ErrorCode(1_001_201_007, "学生不存在");
ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生班级不存在");
ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_009, "学生班级已存在");
}

View File

@@ -15,6 +15,8 @@ public class UserMemberRespDTO {
//昵称
private String nickname;
//姓名
private String name;
//帐号状态
private Integer status; // 参见 CommonStatusEnum 枚举

View File

@@ -126,6 +126,10 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 -->
</dependency>
<dependency>

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.framework.file.core.utils;
package com.tashow.cloud.common.util.io;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
@@ -6,20 +6,8 @@ import com.alibaba.ttl.TransmittableThreadLocal;
import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;
import org.apache.tika.Tika;
import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.CannotWriteException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
/**
@@ -84,22 +72,4 @@ public class FileTypeUtils {
// 输出附件
IoUtil.write(response.getOutputStream(), false, content);
}
public static void main(String[] args) throws CannotReadException, TagException, InvalidAudioFrameException, ReadOnlyFileException, IOException, CannotWriteException, URISyntaxException {
URL url = new URL("https://petshy.tashowz.com/admin-api/infra/file/29/get/jna2-雪球-难过焦虑.wav");
File file = new File(url.getFile());
System.out.println(file.exists());
AudioFile audioFile = AudioFileIO.read(file);
Tag tag = audioFile.getTag();
if (tag instanceof AbstractID3v2Tag) {
AbstractID3v2Tag id3v2Tag = (AbstractID3v2Tag) tag;
// id3v2Tag.delete(); // 删除所有ID3标签
} else {
System.out.println("The file does not contain ID3v2 tags.");
}
AudioFileIO.write(audioFile); // 保存更改
System.out.println("ID3 tags removed successfully.");
}
}

View File

@@ -19,6 +19,7 @@
<module>tashow-module-pay</module>
<module>tashow-module-trade</module>
<module>tashow-module-user</module>
<module>tashow-module-file</module>
</modules>
</project>

View File

@@ -0,0 +1,19 @@
## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性
## 感谢复旦核博士的建议!灰子哥,牛皮!
FROM eclipse-temurin:21-jre
## 创建目录,并使用它作为工作目录
RUN mkdir -p /yudao-module-member-biz
WORKDIR /yudao-module-member-biz
## 将后端项目的 Jar 文件,复制到镜像中
COPY ./target/yudao-module-member-biz.jar app.jar
## 设置 TZ 时区
## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m"
## 暴露后端项目的 48080 端口
EXPOSE 48087
## 启动后端项目
CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-module</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tashow-module-file</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
member 模块,我们放会员业务。
例如说:会员中心等等
</description>
<dependencies>
<!-- Spring Cloud 基础 -->
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-framework-env</artifactId>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-framework-monitor</artifactId>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-framework-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-data-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-file-api</artifactId>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>com.tashow.cloud</groupId>
<artifactId>tashow-framework-rpc</artifactId>
</dependency>
<!-- Registry 注册中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Config 配置中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- 三方云服务相关 -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <!-- 文件客户端:解决 ftp 连接 -->
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId> <!-- 文件客户端:解决 sftp 连接 -->
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId><!-- 文件客户端解决阿里云、腾讯云、minio 等 S3 连接 -->
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,16 @@
package com.tashow.cloud.file;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 项目的启动类
*/
@SpringBootApplication
public class FileServerApplication {
public static void main(String[] args) {
SpringApplication.run(FileServerApplication.class, args);
}
}

View File

@@ -1,9 +1,9 @@
package com.tashow.cloud.infra.api.config;
package com.tashow.cloud.file.api.config;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.infra.service.config.ConfigService;
import com.tashow.cloud.infraapi.api.config.ConfigApi;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.service.config.ConfigService;
import com.tashow.cloud.fileapi.api.config.ConfigApi;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

View File

@@ -1,14 +1,13 @@
package com.tashow.cloud.infra.api.file;
package com.tashow.cloud.file.api.file;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.infra.service.file.FileService;
import com.tashow.cloud.infraapi.api.file.FileApi;
import com.tashow.cloud.infraapi.api.file.dto.FileCreateReqDTO;
import com.tashow.cloud.file.service.file.FileService;
import com.tashow.cloud.fileapi.api.file.FileApi;
import com.tashow.cloud.fileapi.api.file.dto.FileCreateReqDTO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import static com.tashow.cloud.common.pojo.CommonResult.success;

View File

@@ -0,0 +1 @@
package com.tashow.cloud.user.api;

View File

@@ -0,0 +1,101 @@
package com.tashow.cloud.file.controller.admin.config;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigRespVO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.file.convert.config.ConfigConvert;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.service.config.ConfigService;
import com.tashow.cloud.fileapi.enums.ErrorCodeConstants;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
import static com.tashow.cloud.common.pojo.CommonResult.success;
/**
* 管理后台 - 参数配置
*/
@RestController
@RequestMapping("/infra/config")
@Validated
public class ConfigController {
@Resource
private ConfigService configService;
/**
* 创建参数配置
* @param createReqVO
* @return
*/
@PostMapping("/create")
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
return success(configService.createConfig(createReqVO));
}
/**
* 修改参数配置
* @param updateReqVO
* @return
*/
@PutMapping("/update")
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
configService.updateConfig(updateReqVO);
return success(true);
}
/**
* 删除参数配置
* @param id
* @return
*/
@DeleteMapping("/delete")
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
configService.deleteConfig(id);
return success(true);
}
/**
* 获得参数配置
* @param id
* @return
*/
@GetMapping(value = "/get")
public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) {
return success(ConfigConvert.INSTANCE.convert(configService.getConfig(id)));
}
/**
* 根据参数键名查询参数值
* @param key
* @return
*/
@GetMapping(value = "/get-value-by-key")
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
ConfigDO config = configService.getConfigByKey(key);
if (config == null) {
return success(null);
}
if (!config.getVisible()) {
throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
}
return success(config.getValue());
}
/**
* 获取参数配置分页
* @param pageReqVO
* @return
*/
@GetMapping("/page")
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) {
PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO);
return success(ConfigConvert.INSTANCE.convertPage(page));
}
}

View File

@@ -0,0 +1,35 @@
package com.tashow.cloud.file.controller.admin.config.vo;
import com.tashow.cloud.common.pojo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 管理后台 - 参数配置分页 Request VO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ConfigPageReqVO extends PageParam {
// 数据源名称,模糊匹配
private String name;
//参数键名,模糊匹配
private String key;
//参数类型,参见 SysConfigTypeEnum 枚举
private Integer type;
//创建时间
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,40 @@
package com.tashow.cloud.file.controller.admin.config.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 管理后台 - 参数配置信息 Response VO
*/
@Data
public class ConfigRespVO {
//参数配置序号
private Long id;
//参数分类
private String category;
//参数名称
private String name;
//参数键名
private String key;
//参数键值
private String value;
//参数类型,参见 SysConfigTypeEnum 枚举
private Integer type;
//是否可见
private Boolean visible;
//备注
private String remark;
//创建时间
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,45 @@
package com.tashow.cloud.file.controller.admin.config.vo;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
/**
* 管理后台 - 参数配置创建/修改 Request VO
*/
@Data
public class ConfigSaveReqVO {
//参数配置序号
private Long id;
//参数分组
@NotEmpty(message = "参数分组不能为空")
@Size(max = 50, message = "参数名称不能超过 50 个字符")
private String category;
//参数名称
@NotBlank(message = "参数名称不能为空")
@Size(max = 100, message = "参数名称不能超过 100 个字符")
private String name;
//参数键名
@NotBlank(message = "参数键名长度不能为空")
@Size(max = 100, message = "参数键名长度不能超过 100 个字符")
private String key;
//参数键值
@NotBlank(message = "参数键值不能为空")
@Size(max = 500, message = "参数键值长度不能超过 500 个字符")
private String value;
//是否可见
@NotNull(message = "是否可见不能为空")
private Boolean visible;
//备注
private String remark;
}

View File

@@ -1,21 +1,20 @@
package com.tashow.cloud.infra.controller.admin.file;
import static com.tashow.cloud.common.pojo.CommonResult.success;
package com.tashow.cloud.file.controller.admin.file;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.util.object.BeanUtils;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigRespVO;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.infra.service.file.FileConfigService;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigRespVO;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.file.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.file.service.file.FileConfigService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static com.tashow.cloud.common.pojo.CommonResult.success;
/** 管理后台 - 文件配置 */
@RestController
@RequestMapping("/infra/file-config")
@@ -26,14 +25,12 @@ public class FileConfigController {
/** 创建文件配置 */
@PostMapping("/create")
@PreAuthorize("@ss.hasPermission('infra:file-config:create')")
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigSaveReqVO createReqVO) {
return success(fileConfigService.createFileConfig(createReqVO));
}
/** 更新文件配置 */
@PutMapping("/update")
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
public CommonResult<Boolean> updateFileConfig(
@Valid @RequestBody FileConfigSaveReqVO updateReqVO) {
fileConfigService.updateFileConfig(updateReqVO);
@@ -42,7 +39,6 @@ public class FileConfigController {
/** 更新文件配置为 Master */
@PutMapping("/update-master")
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
public CommonResult<Boolean> updateFileConfigMaster(@RequestParam("id") Long id) {
fileConfigService.updateFileConfigMaster(id);
return success(true);
@@ -50,7 +46,6 @@ public class FileConfigController {
/** 删除文件配置 */
@DeleteMapping("/delete")
@PreAuthorize("@ss.hasPermission('infra:file-config:delete')")
public CommonResult<Boolean> deleteFileConfig(@RequestParam("id") Long id) {
fileConfigService.deleteFileConfig(id);
return success(true);
@@ -58,7 +53,6 @@ public class FileConfigController {
/** 获得文件配置 */
@GetMapping("/get")
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
public CommonResult<FileConfigRespVO> getFileConfig(@RequestParam("id") Long id) {
FileConfigDO config = fileConfigService.getFileConfig(id);
return success(BeanUtils.toBean(config, FileConfigRespVO.class));
@@ -66,7 +60,6 @@ public class FileConfigController {
/** 获得文件配置分页 */
@GetMapping("/page")
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
public CommonResult<PageResult<FileConfigRespVO>> getFileConfigPage(
@Valid FileConfigPageReqVO pageVO) {
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(pageVO);
@@ -75,7 +68,6 @@ public class FileConfigController {
/** 测试文件配置是否正确 */
@GetMapping("/test")
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
public CommonResult<String> testFileConfig(@RequestParam("id") Long id) throws Exception {
String url = fileConfigService.testFileConfig(id);
return success(url);

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.controller.admin.file;
package com.tashow.cloud.file.controller.admin.file;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
@@ -6,23 +6,21 @@ import cn.hutool.core.util.URLUtil;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.util.object.BeanUtils;
import com.tashow.cloud.infra.controller.admin.file.vo.file.*;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import com.tashow.cloud.infra.service.file.FileService;
import com.tashow.cloud.file.controller.admin.file.vo.file.*;
import com.tashow.cloud.file.dal.dataobject.file.FileDO;
import com.tashow.cloud.file.service.file.FileService;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.tashow.cloud.common.pojo.CommonResult.success;
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
import static com.tashow.cloud.file.framework.file.core.utils.FileTypeUtils.writeAttachment;
/** 管理后台 - 文件存储 */
@RestController
@@ -58,7 +56,6 @@ public class FileController {
/** 删除文件 */
@DeleteMapping("/delete")
@PreAuthorize("@ss.hasPermission('infra:file:delete')")
public CommonResult<Boolean> deleteFile(@RequestParam("id") Long id) throws Exception {
fileService.deleteFile(id);
return success(true);
@@ -66,7 +63,6 @@ public class FileController {
/** 下载文件 */
@GetMapping("/{configId}/get/**")
@PermitAll
public void getFileContent(
HttpServletRequest request,
HttpServletResponse response,
@@ -92,7 +88,6 @@ public class FileController {
/** 获得文件分页 */
@GetMapping("/page")
@PreAuthorize("@ss.hasPermission('infra:file:query')")
public CommonResult<PageResult<FileRespVO>> getFilePage(@Valid FilePageReqVO pageVO) {
PageResult<FileDO> pageResult = fileService.getFilePage(pageVO);
return success(BeanUtils.toBean(pageResult, FileRespVO.class));

View File

@@ -1,14 +1,15 @@
package com.tashow.cloud.infra.controller.admin.file.vo.config;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
package com.tashow.cloud.file.controller.admin.file.vo.config;
import com.tashow.cloud.common.pojo.PageParam;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/** 管理后台 - 文件配置分页 Request VO */
@Data
@EqualsAndHashCode(callSuper = true)

View File

@@ -1,9 +1,10 @@
package com.tashow.cloud.infra.controller.admin.file.vo.config;
package com.tashow.cloud.file.controller.admin.file.vo.config;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import java.time.LocalDateTime;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import lombok.Data;
import java.time.LocalDateTime;
/** 管理后台 - 文件配置 Response VO */
@Data
public class FileConfigRespVO {

View File

@@ -1,9 +1,10 @@
package com.tashow.cloud.infra.controller.admin.file.vo.config;
package com.tashow.cloud.file.controller.admin.file.vo.config;
import jakarta.validation.constraints.NotNull;
import java.util.Map;
import lombok.Data;
import java.util.Map;
/** 管理后台 - 文件配置创建/修改 Request VO */
@Data
public class FileConfigSaveReqVO {

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.controller.admin.file.vo.file;
package com.tashow.cloud.file.controller.admin.file.vo.file;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -1,14 +1,15 @@
package com.tashow.cloud.infra.controller.admin.file.vo.file;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
package com.tashow.cloud.file.controller.admin.file.vo.file;
import com.tashow.cloud.common.pojo.PageParam;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/** 管理后台 - 文件分页 Request VO */
@Data
@EqualsAndHashCode(callSuper = true)

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.controller.admin.file.vo.file;
package com.tashow.cloud.file.controller.admin.file.vo.file;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@@ -1,7 +1,8 @@
package com.tashow.cloud.infra.controller.admin.file.vo.file;
package com.tashow.cloud.file.controller.admin.file.vo.file;
import lombok.Data;
import java.time.LocalDateTime;
import lombok.Data;
/** 管理后台 - 文件 Response VO,不返回 content 字段,太大 */
@Data

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.controller.admin.file.vo.file;
package com.tashow.cloud.file.controller.admin.file.vo.file;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -0,0 +1 @@
package com.tashow.cloud.user.controller.admin;

View File

@@ -1,21 +1,20 @@
package com.tashow.cloud.infra.controller.app.file;
import static com.tashow.cloud.common.pojo.CommonResult.success;
package com.tashow.cloud.file.controller.app.file;
import cn.hutool.core.io.IoUtil;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.infra.controller.app.file.vo.AppFileUploadReqVO;
import com.tashow.cloud.infra.service.file.FileService;
import com.tashow.cloud.file.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.file.controller.app.file.vo.AppFileUploadReqVO;
import com.tashow.cloud.file.service.file.FileService;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.tashow.cloud.common.pojo.CommonResult.success;
/** 用户 App - 文件存储 */
@RestController
@RequestMapping("/infra/file")
@@ -27,7 +26,6 @@ public class AppFileController {
/** 上传文件 */
@PostMapping("/upload")
@PermitAll
public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
MultipartFile file = uploadReqVO.getFile();
String path = uploadReqVO.getPath();
@@ -38,7 +36,6 @@ public class AppFileController {
/** 获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器 */
@GetMapping("/presigned-url")
@PermitAll
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path)
throws Exception {
return success(fileService.getFilePresignedUrl(path));
@@ -46,7 +43,6 @@ public class AppFileController {
/** 创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件 */
@PostMapping("/create")
@PermitAll
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
return success(fileService.createFile(createReqVO));
}

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.controller.app.file.vo;
package com.tashow.cloud.file.controller.app.file.vo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -0,0 +1 @@
package com.tashow.cloud.file.controller.app;

View File

@@ -0,0 +1,6 @@
/**
* 提供 RESTful API 给前端:
* 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目
* 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分
*/
package com.tashow.cloud.user.controller;

View File

@@ -1,9 +1,9 @@
package com.tashow.cloud.infra.convert.config;
package com.tashow.cloud.file.convert.config;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigRespVO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigRespVO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

View File

@@ -1,7 +1,7 @@
package com.tashow.cloud.infra.convert.file;
package com.tashow.cloud.file.convert.file;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.file.dal.dataobject.file.FileConfigDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

View File

@@ -0,0 +1,6 @@
/**
* 提供 POJO 类的实体转换
*
* 目前使用 MapStruct 框架
*/
package com.tashow.cloud.user.convert;

View File

@@ -1,12 +1,10 @@
package com.tashow.cloud.infra.dal.dataobject.config;
package com.tashow.cloud.file.dal.dataobject.config;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import com.tashow.cloud.infra.enums.config.ConfigTypeEnum;
import com.tashow.cloud.infra.enums.config.ConfigTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tashow.cloud.infra.enums.config.ConfigTypeEnum;
import com.tashow.cloud.file.enums.config.ConfigTypeEnum;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

View File

@@ -1,20 +1,20 @@
package com.tashow.cloud.infra.dal.dataobject.file;
package com.tashow.cloud.file.dal.dataobject.file;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.common.util.json.JsonUtils;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.local.LocalFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tashow.cloud.common.util.json.JsonUtils;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.local.LocalFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.sftp.SftpFileClientConfig;
import com.tashow.cloud.file.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.lang.reflect.Field;

View File

@@ -1,11 +1,10 @@
package com.tashow.cloud.infra.dal.dataobject.file;
package com.tashow.cloud.file.dal.dataobject.file;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClient;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tashow.cloud.file.framework.file.core.client.db.DBFileClient;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import lombok.*;
/**

View File

@@ -1,8 +1,8 @@
package com.tashow.cloud.infra.dal.dataobject.file;
package com.tashow.cloud.file.dal.dataobject.file;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
import lombok.*;
/**

View File

@@ -0,0 +1 @@
package com.tashow.cloud.user.dal.dataobject;

View File

@@ -1,12 +1,10 @@
package com.tashow.cloud.infra.dal.mysql.config;
package com.tashow.cloud.file.dal.mysql.config;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper

View File

@@ -1,12 +1,10 @@
package com.tashow.cloud.infra.dal.mysql.file;
package com.tashow.cloud.file.dal.mysql.file;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.file.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper

View File

@@ -1,10 +1,8 @@
package com.tashow.cloud.infra.dal.mysql.file;
package com.tashow.cloud.file.dal.mysql.file;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.file.dal.dataobject.file.FileContentDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@@ -1,12 +1,10 @@
package com.tashow.cloud.infra.dal.mysql.file;
package com.tashow.cloud.file.dal.mysql.file;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.file.dal.dataobject.file.FileDO;
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import org.apache.ibatis.annotations.Mapper;
/**

View File

@@ -0,0 +1 @@
package com.tashow.cloud.user.dal.mysql;

View File

@@ -0,0 +1,9 @@
/**
* DAL = Data Access Layer 数据访问层
* 1. data object数据对象
* 2. redisRedis 的 CRUD 操作
* 3. mysqlMySQL 的 CRUD 操作
*
* 其中MySQL 的表以 member_ 作为前缀
*/
package com.tashow.cloud.user.dal;

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.enums.config;
package com.tashow.cloud.file.enums.config;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@@ -0,0 +1,4 @@
/**
* 占位
*/
package com.tashow.cloud.file.enums;

View File

@@ -0,0 +1,21 @@
package com.tashow.cloud.file.framework.file.config;
import com.tashow.cloud.file.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.file.framework.file.core.client.FileClientFactoryImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 文件配置类
*
* @author 芋道源码
*/
@Configuration(proxyBeanMethods = false)
public class FileAutoConfiguration {
@Bean
public FileClientFactory fileClientFactory() {
return new FileClientFactoryImpl();
}
}

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.framework.file.core.client;
package com.tashow.cloud.file.framework.file.core.client;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,8 +1,7 @@
package com.tashow.cloud.infra.framework.file.core.client;
package com.tashow.cloud.file.framework.file.core.client;
import com.tashow.cloud.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import com.tashow.cloud.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import com.tashow.cloud.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import com.tashow.cloud.file.framework.file.core.client.s3.FilePresignedUrlRespDTO;
/**
* 文件客户端

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.framework.file.core.client;
package com.tashow.cloud.file.framework.file.core.client;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

View File

@@ -1,8 +1,7 @@
package com.tashow.cloud.infra.framework.file.core.client;
package com.tashow.cloud.file.framework.file.core.client;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.file.framework.file.core.enums.FileStorageEnum;
public interface FileClientFactory {

View File

@@ -1,10 +1,8 @@
package com.tashow.cloud.infra.framework.file.core.client;
package com.tashow.cloud.file.framework.file.core.client;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ReflectUtil;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.tashow.cloud.file.framework.file.core.enums.FileStorageEnum;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;

View File

@@ -1,14 +1,10 @@
package com.tashow.cloud.infra.framework.file.core.client.db;
package com.tashow.cloud.file.framework.file.core.client.db;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.infra.dal.mysql.file.FileContentMapper;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.infra.dal.mysql.file.FileContentMapper;
import com.tashow.cloud.infra.framework.file.core.client.AbstractFileClient;
import com.tashow.cloud.infra.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.infra.dal.mysql.file.FileContentMapper;
import com.tashow.cloud.file.dal.dataobject.file.FileContentDO;
import com.tashow.cloud.file.dal.mysql.file.FileContentMapper;
import com.tashow.cloud.file.framework.file.core.client.AbstractFileClient;
import java.util.Comparator;
import java.util.List;

View File

@@ -1,6 +1,6 @@
package com.tashow.cloud.infra.framework.file.core.client.db;
package com.tashow.cloud.file.framework.file.core.client.db;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.framework.file.core.client.ftp;
package com.tashow.cloud.file.framework.file.core.client.ftp;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
@@ -6,7 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.ftp.Ftp;
import cn.hutool.extra.ftp.FtpException;
import cn.hutool.extra.ftp.FtpMode;
import com.tashow.cloud.infra.framework.file.core.client.AbstractFileClient;
import com.tashow.cloud.file.framework.file.core.client.AbstractFileClient;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

View File

@@ -1,6 +1,6 @@
package com.tashow.cloud.infra.framework.file.core.client.ftp;
package com.tashow.cloud.file.framework.file.core.client.ftp;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -1,7 +1,7 @@
package com.tashow.cloud.infra.framework.file.core.client.local;
package com.tashow.cloud.file.framework.file.core.client.local;
import cn.hutool.core.io.FileUtil;
import com.tashow.cloud.infra.framework.file.core.client.AbstractFileClient;
import com.tashow.cloud.file.framework.file.core.client.AbstractFileClient;
import java.io.File;

View File

@@ -1,6 +1,6 @@
package com.tashow.cloud.infra.framework.file.core.client.local;
package com.tashow.cloud.file.framework.file.core.client.local;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

View File

@@ -1,4 +1,4 @@
package com.tashow.cloud.infra.framework.file.core.client.s3;
package com.tashow.cloud.file.framework.file.core.client.s3;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@@ -1,9 +1,8 @@
package com.tashow.cloud.infra.framework.file.core.client.s3;
package com.tashow.cloud.file.framework.file.core.client.s3;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.tashow.cloud.infra.framework.file.core.client.AbstractFileClient;
import com.amazonaws.HttpMethod;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
@@ -12,6 +11,7 @@ import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.S3Object;
import com.tashow.cloud.file.framework.file.core.client.AbstractFileClient;
import java.io.ByteArrayInputStream;
import java.util.Date;

View File

@@ -1,8 +1,8 @@
package com.tashow.cloud.infra.framework.file.core.client.s3;
package com.tashow.cloud.file.framework.file.core.client.s3;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -1,9 +1,9 @@
package com.tashow.cloud.infra.framework.file.core.client.sftp;
package com.tashow.cloud.file.framework.file.core.client.sftp;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.ssh.Sftp;
import com.tashow.cloud.common.util.io.FileUtils;
import com.tashow.cloud.infra.framework.file.core.client.AbstractFileClient;
import com.tashow.cloud.file.framework.file.core.client.AbstractFileClient;
import java.io.File;

View File

@@ -1,6 +1,6 @@
package com.tashow.cloud.infra.framework.file.core.client.sftp;
package com.tashow.cloud.file.framework.file.core.client.sftp;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@@ -0,0 +1,55 @@
package com.tashow.cloud.file.framework.file.core.enums;
import cn.hutool.core.util.ArrayUtil;
import com.tashow.cloud.file.framework.file.core.client.FileClient;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.db.DBFileClient;
import com.tashow.cloud.file.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.ftp.FtpFileClient;
import com.tashow.cloud.file.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.local.LocalFileClient;
import com.tashow.cloud.file.framework.file.core.client.local.LocalFileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.s3.S3FileClient;
import com.tashow.cloud.file.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.sftp.SftpFileClient;
import com.tashow.cloud.file.framework.file.core.client.sftp.SftpFileClientConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 文件存储器枚举
*
* @author 芋道源码
*/
@AllArgsConstructor
@Getter
public enum FileStorageEnum {
DB(1, DBFileClientConfig.class, DBFileClient.class),
LOCAL(10, LocalFileClientConfig.class, LocalFileClient.class),
FTP(11, FtpFileClientConfig.class, FtpFileClient.class),
SFTP(12, SftpFileClientConfig.class, SftpFileClient.class),
S3(20, S3FileClientConfig.class, S3FileClient.class),
;
/**
* 存储器
*/
private final Integer storage;
/**
* 配置类
*/
private final Class<? extends FileClientConfig> configClass;
/**
* 客户端类
*/
private final Class<? extends FileClient> clientClass;
public static FileStorageEnum getByStorage(Integer storage) {
return ArrayUtil.firstMatch(o -> o.getStorage().equals(storage), values());
}
}

View File

@@ -0,0 +1,75 @@
package com.tashow.cloud.file.framework.file.core.utils;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.ttl.TransmittableThreadLocal;
import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;
import org.apache.tika.Tika;
import java.io.IOException;
import java.net.URLEncoder;
/**
* 文件类型 Utils
*
* @author 芋道源码
*/
public class FileTypeUtils {
private static final ThreadLocal<Tika> TIKA = TransmittableThreadLocal.withInitial(Tika::new);
/**
* 获得文件的 mineType对于docjar等文件会有误差
*
* @param data 文件内容
* @return mineType 无法识别时会返回“application/octet-stream”
*/
@SneakyThrows
public static String getMineType(byte[] data) {
return TIKA.get().detect(data);
}
/**
* 已知文件名获取文件类型在某些情况下比通过字节数组准确例如使用jar文件时通过名字更为准确
*
* @param name 文件名
* @return mineType 无法识别时会返回“application/octet-stream”
*/
public static String getMineType(String name) {
return TIKA.get().detect(name);
}
/**
* 在拥有文件和数据的情况下,最好使用此方法,最为准确
*
* @param data 文件内容
* @param name 文件名
* @return mineType 无法识别时会返回“application/octet-stream”
*/
public static String getMineType(byte[] data, String name) {
return TIKA.get().detect(data, name);
}
/**
* 返回附件
*
* @param response 响应
* @param filename 文件名
* @param content 附件内容
*/
public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException {
// 设置 header 和 contentType
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
String contentType = getMineType(content, filename);
response.setContentType(contentType);
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
if (StrUtil.containsIgnoreCase(contentType, "video")||StrUtil.containsIgnoreCase(contentType, "audio")) {
response.setHeader("Content-Length", String.valueOf(content.length - 1));
response.setHeader("Content-Range", String.valueOf(content.length - 1));
response.setHeader("Accept-Ranges", "bytes");
}
// 输出附件
IoUtil.write(response.getOutputStream(), false, content);
}
}

View File

@@ -9,4 +9,4 @@
*
* @author 芋道源码
*/
package com.tashow.cloud.infra.framework.file;
package com.tashow.cloud.file.framework.file;

View File

@@ -0,0 +1,6 @@
/**
* 属于 member 模块的 framework 封装
*
* @author 芋道源码
*/
package com.tashow.cloud.user.framework;

View File

@@ -0,0 +1,9 @@
package com.tashow.cloud.file.framework.rpc.config;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {})
public class RpcConfiguration {
}

View File

@@ -0,0 +1,4 @@
/**
* 占位
*/
package com.tashow.cloud.user.framework.rpc;

View File

@@ -1,10 +1,9 @@
package com.tashow.cloud.infra.service.config;
package com.tashow.cloud.file.service.config;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import jakarta.validation.Valid;
/**

View File

@@ -1,21 +1,21 @@
package com.tashow.cloud.infra.service.config;
package com.tashow.cloud.file.service.config;
import com.alibaba.nacos.shaded.com.google.common.annotations.VisibleForTesting;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.infra.convert.config.ConfigConvert;
import com.tashow.cloud.infra.enums.config.ConfigTypeEnum;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.infra.dal.mysql.config.ConfigMapper;
import com.google.common.annotations.VisibleForTesting;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.file.convert.config.ConfigConvert;
import com.tashow.cloud.file.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.file.dal.mysql.config.ConfigMapper;
import com.tashow.cloud.file.enums.config.ConfigTypeEnum;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.*;
import static com.tashow.cloud.fileapi.enums.ErrorCodeConstants.*;
/**
* 参数配置 Service 实现类

View File

@@ -1,11 +1,10 @@
package com.tashow.cloud.infra.service.file;
package com.tashow.cloud.file.service.file;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.infra.framework.file.core.client.FileClient;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.file.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.file.framework.file.core.client.FileClient;
import jakarta.validation.Valid;
/**

View File

@@ -1,37 +1,31 @@
package com.tashow.cloud.infra.service.file;
package com.tashow.cloud.file.service.file;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.IdUtil;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.util.json.JsonUtils;
import com.tashow.cloud.common.util.validation.ValidationUtils;
import com.tashow.cloud.infra.convert.file.FileConfigConvert;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.infra.dal.mysql.file.FileConfigMapper;
import com.tashow.cloud.infra.framework.file.core.client.FileClient;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.infra.framework.file.core.enums.FileStorageEnum;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import lombok.Getter;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.tashow.cloud.file.convert.file.FileConfigConvert;
import com.tashow.cloud.file.dal.dataobject.file.FileConfigDO;
import com.tashow.cloud.file.dal.mysql.file.FileConfigMapper;
import com.tashow.cloud.file.framework.file.core.client.FileClient;
import com.tashow.cloud.file.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.file.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.file.framework.file.core.enums.FileStorageEnum;
import jakarta.annotation.Resource;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import jakarta.validation.Validator;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
import static com.tashow.cloud.common.util.cache.CacheUtils.buildAsyncReloadingCache;
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.FILE_CONFIG_DELETE_FAIL_MASTER;
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS;
import static com.tashow.cloud.fileapi.enums.ErrorCodeConstants.FILE_CONFIG_DELETE_FAIL_MASTER;
import static com.tashow.cloud.fileapi.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS;
/**
* 文件配置 Service 实现类
@@ -48,21 +42,21 @@ public class FileConfigServiceImpl implements FileConfigService {
/**
* {@link FileClient} 缓存通过它异步刷新 fileClientFactory
*/
@Getter
private final LoadingCache<Long, FileClient> clientCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
new CacheLoader<Long, FileClient>() {
@Override
public FileClient load(Long id) {
FileConfigDO config = Objects.equals(CACHE_MASTER_ID, id) ?
fileConfigMapper.selectByMaster() : fileConfigMapper.selectById(id);
if (config != null) {
fileClientFactory.createOrUpdateFileClient(config.getId(), config.getStorage(), config.getConfig());
}
return fileClientFactory.getFileClient(null == config ? id : config.getId());
}
});
// @Getter
// private final LoadingCache<Long, FileClient> clientCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
// new CacheLoader<Long, FileClient>() {
//
// @Override
// public FileClient load(Long id) {
// FileConfigDO config = Objects.equals(CACHE_MASTER_ID, id) ?
// fileConfigMapper.selectByMaster() : fileConfigMapper.selectById(id);
// if (config != null) {
// fileClientFactory.createOrUpdateFileClient(config.getId(), config.getStorage(), config.getConfig());
// }
// return fileClientFactory.getFileClient(null == config ? id : config.getId());
// }
//
// });
@Resource
private FileClientFactory fileClientFactory;
@@ -141,12 +135,12 @@ public class FileConfigServiceImpl implements FileConfigService {
* @param master 是否主配置
*/
private void clearCache(Long id, Boolean master) {
if (id != null) {
clientCache.invalidate(id);
}
if (Boolean.TRUE.equals(master)) {
clientCache.invalidate(CACHE_MASTER_ID);
}
// if (id != null) {
// clientCache.invalidate(id);
// }
// if (Boolean.TRUE.equals(master)) {
// clientCache.invalidate(CACHE_MASTER_ID);
// }
}
private FileConfigDO validateFileConfigExists(Long id) {
@@ -178,12 +172,12 @@ public class FileConfigServiceImpl implements FileConfigService {
@Override
public FileClient getFileClient(Long id) {
return clientCache.getUnchecked(id);
return null;// clientCache.getUnchecked(id);
}
@Override
public FileClient getMasterFileClient() {
return clientCache.getUnchecked(CACHE_MASTER_ID);
return null;// clientCache.getUnchecked(CACHE_MASTER_ID);
}
}

View File

@@ -1,10 +1,10 @@
package com.tashow.cloud.infra.service.file;
package com.tashow.cloud.file.service.file;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.file.dal.dataobject.file.FileDO;
/**
* 文件 Service 接口

View File

@@ -1,24 +1,25 @@
package com.tashow.cloud.infra.service.file;
package com.tashow.cloud.file.service.file;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.util.io.FileUtils;
import com.tashow.cloud.common.util.object.BeanUtils;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
import com.tashow.cloud.infra.dal.mysql.file.FileMapper;
import com.tashow.cloud.infra.framework.file.core.client.FileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils;
import com.tashow.cloud.file.controller.admin.file.vo.file.FileCreateReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePageReqVO;
import com.tashow.cloud.file.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.tashow.cloud.file.dal.dataobject.file.FileDO;
import com.tashow.cloud.file.dal.mysql.file.FileMapper;
import com.tashow.cloud.file.framework.file.core.client.FileClient;
import com.tashow.cloud.file.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import com.tashow.cloud.file.framework.file.core.utils.FileTypeUtils;
import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
import static com.tashow.cloud.fileapi.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
/**
* 文件 Service 实现类

View File

@@ -0,0 +1 @@
package com.tashow.cloud.file.service;

View File

@@ -0,0 +1,19 @@
--- #################### 注册中心 + 配置中心相关配置 ####################
spring:
cloud:
nacos:
server-addr: 43.139.42.137:8848 # Nacos 服务器地址
username: nacos # Nacos 账号
password: nacos # Nacos 密码
discovery: # 【配置中心】配置项
namespace: dev # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
metadata:
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
config: # 【注册中心】配置项
namespace: dev # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP

View File

@@ -0,0 +1,18 @@
server:
port: 48090
spring:
application:
name: file-server
profiles:
active: local
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务
config:
import:
- optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置
- optional:nacos:application.yaml # 加载【Nacos】的配置

View File

@@ -0,0 +1,76 @@
<configuration>
<!-- 引用 Spring Boot 的 logback 基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!-- 变量 tashow.info.base-package基础业务包 -->
<springProperty scope="context" name="tashow.info.base-package" source="tashow.info.base-package"/>
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level级别从左显示 5 个字符宽度,%msg日志消息%n是换行符 -->
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<!-- 控制台 Appender -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">     
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 文件 Appender -->
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
<!-- 日志文件名 -->
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 滚动后的日志文件名 -->
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<!-- 日志文件,到达多少容量,进行滚动 -->
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<!-- 日志文件的总大小0 表示不限制 -->
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<!-- 日志文件的保留天数 -->
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步写入日志,提升性能 -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
<queueSize>256</queueSize>
<appender-ref ref="FILE"/>
</appender>
<!-- SkyWalking GRPC 日志收集实现日志中心。注意SkyWalking 8.4.0 版本开始支持 -->
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 本地环境 -->
<springProfile name="local">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
</root>
</springProfile>
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,default">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/>
<appender-ref ref="GRPC"/>
</root>
</springProfile>
</configuration>

View File

@@ -1,9 +1,5 @@
package com.tashow.cloud.infra.controller.admin.codegen;
import static com.tashow.cloud.common.pojo.CommonResult.success;
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
import static com.tashow.cloud.security.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ZipUtil;
import com.tashow.cloud.common.pojo.CommonResult;
@@ -23,14 +19,19 @@ import com.tashow.cloud.infra.service.codegen.CodegenService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static com.tashow.cloud.common.pojo.CommonResult.success;
import static com.tashow.cloud.common.util.io.FileTypeUtils.writeAttachment;
import static com.tashow.cloud.security.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/** 管理后台 - 代码生成器 */
@RestController

View File

@@ -1,99 +0,0 @@
package com.tashow.cloud.infra.controller.admin.config;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
import static com.tashow.cloud.common.pojo.CommonResult.success;
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageParam;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigPageReqVO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigRespVO;
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
import com.tashow.cloud.infra.convert.config.ConfigConvert;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import com.tashow.cloud.infra.service.config.ConfigService;
import com.tashow.cloud.infraapi.enums.ErrorCodeConstants;
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/** 管理后台 - 参数配置 */
@RestController
@RequestMapping("/infra/config")
@Validated
public class ConfigController {
@Resource private ConfigService configService;
/** 创建参数配置 */
@PostMapping("/create")
@PreAuthorize("@ss.hasPermission('infra:config:create')")
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
return success(configService.createConfig(createReqVO));
}
/** 修改参数配置 */
@PutMapping("/update")
@PreAuthorize("@ss.hasPermission('infra:config:update')")
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
configService.updateConfig(updateReqVO);
return success(true);
}
/** 删除参数配置 */
@DeleteMapping("/delete")
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
configService.deleteConfig(id);
return success(true);
}
/** 获得参数配置 */
@GetMapping(value = "/get")
@PreAuthorize("@ss.hasPermission('infra:config:query')")
public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) {
return success(ConfigConvert.INSTANCE.convert(configService.getConfig(id)));
}
/** 根据参数键名查询参数值", description = "不可见的配置,不允许返回给前端 */
@GetMapping(value = "/get-value-by-key")
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
ConfigDO config = configService.getConfigByKey(key);
if (config == null) {
return success(null);
}
if (!config.getVisible()) {
throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
}
return success(config.getValue());
}
/** 获取参数配置分页 */
@GetMapping("/page")
@PreAuthorize("@ss.hasPermission('infra:config:query')")
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) {
PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO);
return success(ConfigConvert.INSTANCE.convertPage(page));
}
/** 导出参数配置 */
@GetMapping("/export")
@PreAuthorize("@ss.hasPermission('infra:config:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportConfig(ConfigPageReqVO exportReqVO, HttpServletResponse response)
throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ConfigDO> list = configService.getConfigPage(exportReqVO).getList();
// 输出
ExcelUtils.write(
response, "参数配置.xls", "数据", ConfigRespVO.class, ConfigConvert.INSTANCE.convertList(list));
}
}

View File

@@ -1,30 +0,0 @@
package com.tashow.cloud.infra.controller.admin.config.vo;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import com.tashow.cloud.common.pojo.PageParam;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
/** 管理后台 - 参数配置分页 Request VO */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ConfigPageReqVO extends PageParam {
/** 数据源名称,模糊匹配 */
private String name;
/** 参数键名,模糊匹配 */
private String key;
/** 参数类型,参见 SysConfigTypeEnum 枚举 */
private Integer type;
/** 创建时间 */
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,53 +0,0 @@
package com.tashow.cloud.infra.controller.admin.config.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
import com.tashow.cloud.infraapi.enums.DictTypeConstants;
import java.time.LocalDateTime;
import lombok.Data;
/** 管理后台 - 参数配置信息 Response VO */
@Data
@ExcelIgnoreUnannotated
public class ConfigRespVO {
/** 参数配置序号" */
@ExcelProperty("参数配置序号")
private Long id;
/** 参数分类" */
@ExcelProperty("参数分类")
private String category;
/** 参数名称", example = "数据库名 */
@ExcelProperty("参数名称")
private String name;
/** 参数键名" */
@ExcelProperty("参数键名")
private String key;
/** 参数键值" */
@ExcelProperty("参数键值")
private String value;
/** 参数类型,参见 SysConfigTypeEnum 枚举" */
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.CONFIG_TYPE)
private Integer type;
/** 是否可见" */
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean visible;
/** 备注 */
@ExcelProperty("备注")
private String remark;
/** 创建时间", example = "时间戳格式 */
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,42 +0,0 @@
package com.tashow.cloud.infra.controller.admin.config.vo;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
/** 管理后台 - 参数配置创建/修改 Request VO */
@Data
public class ConfigSaveReqVO {
/** 参数配置序号 */
private Long id;
/** 参数分组" */
@NotEmpty(message = "参数分组不能为空")
@Size(max = 50, message = "参数名称不能超过 50 个字符")
private String category;
/** 参数名称", example = "数据库名 */
@NotBlank(message = "参数名称不能为空")
@Size(max = 100, message = "参数名称不能超过 100 个字符")
private String name;
/** 参数键名" */
@NotBlank(message = "参数键名长度不能为空")
@Size(max = 100, message = "参数键名长度不能超过 100 个字符")
private String key;
/** 参数键值" */
@NotBlank(message = "参数键值不能为空")
@Size(max = 500, message = "参数键值长度不能超过 500 个字符")
private String value;
/** 是否可见" */
@NotNull(message = "是否可见不能为空")
private Boolean visible;
/** 备注 */
private String remark;
}

View File

@@ -1,45 +0,0 @@
### 请求 /infra/file-config/create 接口 => 成功
POST {{baseUrl}}/infra/file-config/create
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}
{
"name": "S3 - 七牛云",
"remark": "",
"storage": 20,
"config": {
"accessKey": "b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8",
"accessSecret": "kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP",
"bucket": "ruoyi-vue-pro",
"endpoint": "s3-cn-south-1.qiniucs.com",
"domain": "http://test.yudao.iocoder.cn",
"region": "oss-cn-beijing"
}
}
### 请求 /infra/file-config/update 接口 => 成功
PUT {{baseUrl}}/infra/file-config/update
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}
{
"id": 2,
"name": "S3 - 七牛云",
"remark": "",
"config": {
"accessKey": "b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8",
"accessSecret": "kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP",
"bucket": "ruoyi-vue-pro",
"endpoint": "s3-cn-south-1.qiniucs.com",
"domain": "http://test.yudao.iocoder.cn",
"region": "oss-cn-beijing"
}
}
### 请求 /infra/file-config/test 接口 => 成功
GET {{baseUrl}}/infra/file-config/test?id=2
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}

View File

@@ -1,25 +0,0 @@
package com.tashow.cloud.infra.framework.file.config;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactoryImpl;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactoryImpl;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactory;
import com.tashow.cloud.infra.framework.file.core.client.FileClientFactoryImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 文件配置类
*
* @author 芋道源码
*/
@Configuration(proxyBeanMethods = false)
public class YudaoFileAutoConfiguration {
@Bean
public FileClientFactory fileClientFactory() {
return new FileClientFactoryImpl();
}
}

View File

@@ -1,73 +0,0 @@
package com.tashow.cloud.infra.framework.file.core.enums;
import cn.hutool.core.util.ArrayUtil;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClient;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.local.LocalFileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.FileClient;
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClient;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.local.LocalFileClient;
import com.tashow.cloud.infra.framework.file.core.client.local.LocalFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClient;
import com.tashow.cloud.infra.framework.file.core.client.db.DBFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.ftp.FtpFileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.local.LocalFileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClient;
import com.tashow.cloud.infra.framework.file.core.client.s3.S3FileClientConfig;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClient;
import com.tashow.cloud.infra.framework.file.core.client.sftp.SftpFileClientConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 文件存储器枚举
*
* @author 芋道源码
*/
@AllArgsConstructor
@Getter
public enum FileStorageEnum {
DB(1, DBFileClientConfig.class, DBFileClient.class),
LOCAL(10, LocalFileClientConfig.class, LocalFileClient.class),
FTP(11, FtpFileClientConfig.class, FtpFileClient.class),
SFTP(12, SftpFileClientConfig.class, SftpFileClient.class),
S3(20, S3FileClientConfig.class, S3FileClient.class),
;
/**
* 存储器
*/
private final Integer storage;
/**
* 配置类
*/
private final Class<? extends FileClientConfig> configClass;
/**
* 客户端类
*/
private final Class<? extends FileClient> clientClass;
public static FileStorageEnum getByStorage(Integer storage) {
return ArrayUtil.firstMatch(o -> o.getStorage().equals(storage), values());
}
}

View File

@@ -2,7 +2,6 @@ package com.tashow.cloud.pay.job.notify;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.pay.service.notify.PayNotifyService;
import com.tashow.cloud.tenant.core.job.TenantJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -21,7 +20,6 @@ public class PayNotifyJob {
private PayNotifyService payNotifyService;
// @XxlJob("payNotifyJob")
@TenantJob // 多租户
public String execute() throws Exception {
int notifyCount = payNotifyService.executeNotify();
log.info("[execute][执行支付通知 ({}) 个]", notifyCount);

View File

@@ -2,7 +2,6 @@ package com.tashow.cloud.pay.job.order;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.pay.service.order.PayOrderService;
import com.tashow.cloud.tenant.core.job.TenantJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -22,7 +21,6 @@ public class PayOrderExpireJob {
private PayOrderService orderService;
// @XxlJob("payOrderExpireJob")
@TenantJob // 多租户
public String execute(String param) {
int count = orderService.expireOrder();
log.info("[execute][支付过期 ({}) 个]", count);

View File

@@ -2,7 +2,6 @@ package com.tashow.cloud.pay.job.order;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.pay.service.order.PayOrderService;
import com.tashow.cloud.tenant.core.job.TenantJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -34,7 +33,6 @@ public class PayOrderSyncJob {
private PayOrderService orderService;
// @XxlJob("payOrderSyncJob")
@TenantJob // 多租户
public String execute() {
LocalDateTime minCreateTime = LocalDateTime.now().minus(CREATE_TIME_DURATION_BEFORE);
int count = orderService.syncOrder(minCreateTime);

View File

@@ -2,7 +2,6 @@ package com.tashow.cloud.pay.job.refund;
import cn.hutool.core.util.StrUtil;
import com.tashow.cloud.pay.service.refund.PayRefundService;
import com.tashow.cloud.tenant.core.job.TenantJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -22,7 +21,6 @@ public class PayRefundSyncJob {
private PayRefundService refundService;
// @XxlJob("payRefundSyncJob")
@TenantJob // 多租户
public String execute() {
int count = refundService.syncRefund();
log.info("[execute][同步退款订单 ({}) 个]", count);

Some files were not shown because too many files have changed in this diff Show More