Compare commits
13 Commits
feature/xu
...
2bd20404ba
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bd20404ba | |||
| 4fbe69062c | |||
| 5b5b827bb7 | |||
| 3438ea40a4 | |||
| 29cdf6c581 | |||
| 62b78b40be | |||
| 0c051643d5 | |||
| 793a810d65 | |||
| b4f485db09 | |||
| fd5a68c27e | |||
| 6a59e27ebb | |||
| 323cae015f | |||
| 4f9b9c29a3 |
@@ -111,3 +111,26 @@ CREATE TABLE `tz_ai_dialog_message`
|
||||
) ENGINE = InnoDB COMMENT ='ai-对话消息表';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `tz_ai_model`;
|
||||
CREATE TABLE `tz_ai_model`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`model_name` varchar(128) NOT NULL COMMENT '模型名称',
|
||||
`version` varchar(32) NOT NULL COMMENT '版本号',
|
||||
`load_percentage` decimal(5,4) NULL DEFAULT 0.0000 COMMENT '负载百分比',
|
||||
`status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0-禁用 1-启用 2-测试中 3-已废弃)',
|
||||
`description` varchar(500) NULL DEFAULT '' COMMENT '版本描述',
|
||||
`creator` varchar(64) NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_model_name` (`model_name` ASC) USING BTREE,
|
||||
INDEX `idx_version` (`version` ASC) USING BTREE,
|
||||
INDEX `idx_status` (`status` ASC) USING BTREE,
|
||||
INDEX `idx_create_time` (`create_time` ASC) USING BTREE
|
||||
) ENGINE = InnoDB COMMENT = 'AI模型版本管理表';
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ CREATE TABLE `tz_trade_order`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单编号,主键自增',
|
||||
`order_num` varchar(64) NOT NULL COMMENT '订单流水号',
|
||||
`order_category_id` bigint NOT NULL COMMENT '订单类目id',
|
||||
`order_category_name` varchar(64) NOT NULL COMMENT '订单类目名称',
|
||||
`order_type` tinyint NOT NULL COMMENT '订单类型 (枚举 TradeOrderTypeEnum)',
|
||||
`order_terminal` tinyint NOT NULL COMMENT '订单来源 (枚举 TerminalEnum)',
|
||||
`order_status` tinyint NOT NULL COMMENT '订单状态 (枚举 TradeOrderStatusEnum)',
|
||||
@@ -17,19 +15,18 @@ CREATE TABLE `tz_trade_order`
|
||||
`cancel_time` datetime DEFAULT NULL COMMENT '订单取消时间',
|
||||
`cancel_type` tinyint DEFAULT NULL COMMENT '取消类型 (枚举 TradeOrderCancelTypeEnum)',
|
||||
`cancel_reason` varchar(128) DEFAULT NULL COMMENT '取消原因',
|
||||
`cancel_remark` varchar(255) DEFAULT NULL COMMENT '取消原因备注',
|
||||
`merchant_id` bigint DEFAULT NULL COMMENT '商家编号',
|
||||
`merchant_name` varchar(64) DEFAULT NULL COMMENT '商家名称',
|
||||
`merchant_remark` varchar(512) DEFAULT NULL COMMENT '商家备注',
|
||||
`comment_status` tinyint(1) DEFAULT NULL COMMENT '是否评价 (true-已评价, false-未评价)',
|
||||
`sub_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '预约类型(1预约 2 加急)',
|
||||
`sub_time` datetime NOT NULL COMMENT '预约时间',
|
||||
`expense_price` int(11) DEFAULT NULL COMMENT '商品成本(单),单位:分',
|
||||
`price` int(11) DEFAULT NULL COMMENT '商品原价(单),单位:分',
|
||||
`discount_price` int(11) DEFAULT NULL COMMENT '优惠金额(总),单位:分',
|
||||
`delivery_price` int(11) DEFAULT NULL COMMENT '运费金额(总),单位:分',
|
||||
`adjust_price` int(11) DEFAULT NULL COMMENT '订单调价(总),单位:分',
|
||||
`pay_price` int(11) DEFAULT NULL COMMENT '应付金额(总),单位:分',
|
||||
`live_price` int(11) 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 '实收金额(总),单位:分',
|
||||
`pay_order_id` bigint DEFAULT NULL COMMENT '支付订单编号',
|
||||
`pay_status` tinyint(1) DEFAULT NULL COMMENT '是否已支付 (true-已支付, false-未支付)',
|
||||
`pay_type` tinyint DEFAULT NULL COMMENT '支付方式(PayTypeEnum)',
|
||||
@@ -59,6 +56,7 @@ CREATE TABLE `tz_trade_order`
|
||||
`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`),
|
||||
@@ -73,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 编号',
|
||||
`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(20) NOT NULL COMMENT '商品 SKU 编号',
|
||||
`sku_name` bigint(20) NOT NULL COMMENT '商品 SKU 名称',
|
||||
`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(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 '服务地址',
|
||||
`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(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 '是否删除',
|
||||
`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)
|
||||
@@ -128,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`)
|
||||
|
||||
@@ -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>
|
||||
@@ -180,7 +190,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tashow.cloud</groupId>
|
||||
<artifactId>tashow-member-api</artifactId>
|
||||
<artifactId>tashow-user-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
<module>tashow-product-api</module>
|
||||
<module>tashow-trade-api</module>
|
||||
<module>tashow-pay-api</module>
|
||||
<module>tashow-member-api</module>
|
||||
<module>tashow-user-api</module>
|
||||
<module>tashow-file-api</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
40
tashow-feign/tashow-file-api/pom.xml
Normal file
40
tashow-feign/tashow-file-api/pom.xml
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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);
|
||||
|
||||
/**
|
||||
* 分段上传文件
|
||||
*/
|
||||
@PostMapping(PREFIX + "/create-multipart")
|
||||
CommonResult<String> createFileMultipart(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tashow.cloud.fileapi.api.file.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/** RPC 服务 - 文件创建 Request DTO */
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class FileCreateReqDTO {
|
||||
|
||||
/** 原文件名称 */
|
||||
private String name;
|
||||
|
||||
/** 文件路径 */
|
||||
private String path;
|
||||
|
||||
/** 文件访问地址 */
|
||||
private String url;
|
||||
|
||||
/** 文件内容 */
|
||||
@NotEmpty(message = "文件内容不能为空")
|
||||
private byte[] content;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* infra API 包,定义暴露给其它模块的 API
|
||||
*/
|
||||
package com.tashow.cloud.fileapi.api;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.enums;
|
||||
package com.tashow.cloud.fileapi.enums;
|
||||
|
||||
|
||||
import com.tashow.cloud.common.enums.RpcConstants;
|
||||
@@ -15,9 +15,9 @@ public class ApiConstants {
|
||||
*
|
||||
* 注意,需要保证和 spring.application.name 保持一致
|
||||
*/
|
||||
public static final String NAME = "member-server";
|
||||
public static final String NAME = "file-server";
|
||||
|
||||
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/member";
|
||||
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/file";
|
||||
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
@@ -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, "学生班级已存在");
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 消息队列的消息
|
||||
*/
|
||||
package com.tashow.cloud.memberapi.message;
|
||||
@@ -10,7 +10,7 @@ import com.tashow.cloud.productapi.enums.ApiConstants;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@@ -52,15 +52,18 @@ public interface ProdApi {
|
||||
* @param skuId 单品ID
|
||||
* @param stocksNum 扣减数量
|
||||
*/
|
||||
@GetMapping(PREFIX + "/reduceStocks")
|
||||
CommonResult<Boolean> reduceStocks(Long skuId, Integer stocksNum) ;
|
||||
@PostMapping(PREFIX + "/reduceStocks")
|
||||
CommonResult<Boolean> reduceStocks(@RequestParam(value = "skuId", required = false)Long skuId
|
||||
,@RequestParam(value = "stocksNum", required = false) Integer stocksNum
|
||||
) ;
|
||||
/**
|
||||
* 增加库存
|
||||
* @param skuId 单品ID
|
||||
* @param stocksNum 增加数量
|
||||
*/
|
||||
@GetMapping(PREFIX + "/increaseStocks")
|
||||
CommonResult<Boolean> increaseStocks(Long skuId, Integer stocksNum);
|
||||
@PostMapping(PREFIX + "/increaseStocks")
|
||||
CommonResult<Boolean> increaseStocks(@RequestParam(value = "skuId", required = false)Long skuId
|
||||
,@RequestParam(value = "stocksNum", required = false) Integer stocksNum);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TradeOrderRespDTO {
|
||||
private Long id;
|
||||
|
||||
//订单流水号
|
||||
private String no;
|
||||
private String orderNum;
|
||||
|
||||
//订单类型
|
||||
private Integer type; // 参见 TradeOrderTypeEnum 枚举
|
||||
|
||||
@@ -20,40 +20,15 @@ import static cn.hutool.core.util.ArrayUtil.firstMatch;
|
||||
@Getter
|
||||
public enum AfterSaleStatusEnum implements ArrayValuable<Integer> {
|
||||
|
||||
/**
|
||||
* 【申请售后】
|
||||
*/
|
||||
APPLY(10,"申请中", "会员申请退款"), // 有赞的状态提示:退款申请待商家处理
|
||||
/**
|
||||
* 卖家通过售后;【商品待退货】
|
||||
*/
|
||||
SELLER_AGREE(20, "卖家通过", "商家同意退款"), // 有赞的状态提示:请退货并填写物流信息
|
||||
/**
|
||||
* 买家已退货,等待卖家收货;【商家待收货】
|
||||
*/
|
||||
BUYER_DELIVERY(30,"待卖家收货", "会员填写退货物流信息"), // 有赞的状态提示:退货退款申请待商家处理
|
||||
/**
|
||||
* 卖家已收货,等待平台退款;等待退款【等待退款】
|
||||
*/
|
||||
WAIT_REFUND(40, "等待平台退款", "商家收货"), // 有赞的状态提示:无(有赞无该状态)
|
||||
/**
|
||||
* 完成退款【退款成功】
|
||||
*/
|
||||
COMPLETE(50, "完成", "商家确认退款"), // 有赞的状态提示:退款成功
|
||||
/**
|
||||
* 【买家取消】
|
||||
*/
|
||||
BUYER_CANCEL(61, "买家取消售后", "会员取消退款"), // 有赞的状态提示:退款关闭
|
||||
/**
|
||||
* 卖家拒绝售后;商家拒绝【商家拒绝】
|
||||
*/
|
||||
SELLER_DISAGREE(62,"卖家拒绝", "商家拒绝退款"), // 有赞的状态提示:商家不同意退款申请
|
||||
/**
|
||||
* 卖家拒绝收货,终止售后;【商家拒收货】
|
||||
*/
|
||||
SELLER_REFUSE(63,"卖家拒绝收货", "商家拒绝收货"), // 有赞的状态提示:商家拒绝收货,不同意退款
|
||||
APPLY(10,"等待审核", ""), // 有赞的状态提示:退款申请待商家处理
|
||||
SELLER_AGREE(20, "审核通过", ""), // 有赞的状态提示:请退货并填写物流信息
|
||||
BUYER_DELIVERY(30,"已完成", ""), // 有赞的状态提示:退货退款申请待商家处理
|
||||
WAIT_REFUND(40, "已取消", ""), // 有赞的状态提示:无(有赞无该状态)
|
||||
COMPLETE(50, "已拒绝", ""), // 有赞的状态提示:退款成功
|
||||
|
||||
;
|
||||
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleStatusEnum::getStatus).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>tashow-member-api</artifactId>
|
||||
<artifactId>tashow-user-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.tashow.cloud.memberapi.api.address;
|
||||
package com.tashow.cloud.userapi.api.address;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.memberapi.api.address.dto.MemberAddressRespDTO;
|
||||
import com.tashow.cloud.memberapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.userapi.api.address.dto.MemberAddressRespDTO;
|
||||
import com.tashow.cloud.userapi.enums.ApiConstants;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.api.address.dto;
|
||||
package com.tashow.cloud.userapi.api.address.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* member API 包,定义暴露给其它模块的 API
|
||||
*/
|
||||
package com.tashow.cloud.memberapi.api;
|
||||
package com.tashow.cloud.userapi.api;
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.tashow.cloud.memberapi.api.user;
|
||||
package com.tashow.cloud.userapi.api.user;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.memberapi.api.user.dto.MemberUserRespDTO;
|
||||
import com.tashow.cloud.memberapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.userapi.api.user.dto.UserMemberRespDTO;
|
||||
import com.tashow.cloud.userapi.enums.ApiConstants;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -17,9 +17,9 @@ import static com.tashow.cloud.common.util.collection.CollectionUtils.convertMap
|
||||
* RPC 服务 - 会员用户
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
public interface MemberUserApi {
|
||||
public interface UserMemberApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/user";
|
||||
String PREFIX = ApiConstants.PREFIX + "/member";
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,9 +28,9 @@ public interface MemberUserApi {
|
||||
* @param ids 用户编号的数组
|
||||
* @return 会员用户 Map
|
||||
*/
|
||||
default Map<Long, MemberUserRespDTO> getUserMap(Collection<Long> ids) {
|
||||
List<MemberUserRespDTO> list = getUserList(ids).getCheckedData();
|
||||
return convertMap(list, MemberUserRespDTO::getId);
|
||||
default Map<Long, UserMemberRespDTO> getUserMap(Collection<Long> ids) {
|
||||
List<UserMemberRespDTO> list = getUserList(ids).getCheckedData();
|
||||
return convertMap(list, UserMemberRespDTO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ public interface MemberUserApi {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(PREFIX + "/get")
|
||||
CommonResult<MemberUserRespDTO> getUser(@RequestParam("id") Long id);
|
||||
CommonResult<UserMemberRespDTO> getUser(@RequestParam("id") Long id);
|
||||
|
||||
/**
|
||||
* 获得会员用户信息们
|
||||
@@ -47,7 +47,7 @@ public interface MemberUserApi {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(PREFIX + "/list")
|
||||
CommonResult<List<MemberUserRespDTO>> getUserList(@RequestParam("ids") Collection<Long> ids);
|
||||
CommonResult<List<UserMemberRespDTO>> getUserList(@RequestParam("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 基于用户昵称,模糊匹配用户列表
|
||||
@@ -55,7 +55,7 @@ public interface MemberUserApi {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(PREFIX + "/list-by-nickname")
|
||||
CommonResult<List<MemberUserRespDTO>> getUserListByNickname(@RequestParam("nickname") String nickname);
|
||||
CommonResult<List<UserMemberRespDTO>> getUserListByNickname(@RequestParam("nickname") String nickname);
|
||||
|
||||
/**
|
||||
* 基于手机号,精准匹配用户
|
||||
@@ -63,7 +63,7 @@ public interface MemberUserApi {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(PREFIX + "/get-by-mobile")
|
||||
CommonResult<MemberUserRespDTO> getUserByMobile(@RequestParam("mobile") String mobile);
|
||||
CommonResult<UserMemberRespDTO> getUserByMobile(@RequestParam("mobile") String mobile);
|
||||
|
||||
/**
|
||||
* 校验用户是否存在
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.api.user.dto;
|
||||
package com.tashow.cloud.userapi.api.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -8,13 +8,15 @@ import java.time.LocalDateTime;
|
||||
* RPC 服务 - 用户信息 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MemberUserRespDTO {
|
||||
public class UserMemberRespDTO {
|
||||
|
||||
//用户编号
|
||||
private Long id;
|
||||
|
||||
//昵称
|
||||
private String nickname;
|
||||
//姓名
|
||||
private String name;
|
||||
|
||||
//帐号状态
|
||||
private Integer status; // 参见 CommonStatusEnum 枚举
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tashow.cloud.userapi.enums;
|
||||
|
||||
|
||||
import com.tashow.cloud.common.enums.RpcConstants;
|
||||
|
||||
/**
|
||||
* API 相关的枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class ApiConstants {
|
||||
|
||||
/**
|
||||
* 服务名
|
||||
*
|
||||
* 注意,需要保证和 spring.application.name 保持一致
|
||||
*/
|
||||
public static final String NAME = "user-server";
|
||||
|
||||
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/user";
|
||||
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.enums;
|
||||
package com.tashow.cloud.userapi.enums;
|
||||
|
||||
/**
|
||||
* Member 字典类型的枚举类
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.enums;
|
||||
package com.tashow.cloud.userapi.enums;
|
||||
|
||||
|
||||
import com.tashow.cloud.common.exception.ErrorCode;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.enums;
|
||||
package com.tashow.cloud.userapi.enums;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.enums.point;
|
||||
package com.tashow.cloud.userapi.enums.point;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import com.tashow.cloud.common.core.ArrayValuable;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 消息队列的消息
|
||||
*/
|
||||
package com.tashow.cloud.userapi.message;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tashow.cloud.memberapi.message.user;
|
||||
package com.tashow.cloud.userapi.message.user;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -126,6 +126,10 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 -->
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.tashow.cloud.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 文档地址
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DocumentEnum {
|
||||
|
||||
REDIS_INSTALL("https://gitee.com/zhijiantianya/ruoyi-vue-pro/issues/I4VCSJ", "Redis 安装文档"),
|
||||
TENANT("https://doc.iocoder.cn", "SaaS 多租户文档");
|
||||
|
||||
private final String url;
|
||||
private final String memo;
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class PageParam implements Serializable {
|
||||
/**
|
||||
* 页码,从 1 开始", example = "1
|
||||
*/
|
||||
@NotNull(message = "页码不能为空")
|
||||
@NotNull(message = "页码不能为空" )
|
||||
@Min(value = 1, message = "页码最小值为 1")
|
||||
private Integer pageNo = 1;
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.tashow.cloud.common.serializer;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 图片URL序列化器
|
||||
* 自动为相对路径的图片添加文件服务器前缀
|
||||
*/
|
||||
@Component
|
||||
public class ImgJsonSerializer extends JsonSerializer<String> {
|
||||
|
||||
@Value("${file-server}")
|
||||
private String fileServer;
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
gen.writeString(StrUtil.EMPTY);
|
||||
return;
|
||||
}
|
||||
String[] imgs = value.split(StrUtil.COMMA);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String resourceUrl = "";
|
||||
String rule = "^((http[s]{0,1})://)";
|
||||
Pattern pattern = Pattern.compile(rule);
|
||||
|
||||
resourceUrl = fileServer;
|
||||
|
||||
for (String img : imgs) {
|
||||
Matcher matcher = pattern.matcher(img);
|
||||
//若图片以http或https开头,直接返回
|
||||
if (matcher.find()) {
|
||||
sb.append(img).append(StrUtil.COMMA);
|
||||
} else {
|
||||
sb.append(resourceUrl).append(img).append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
gen.writeString(sb.toString());
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,15 @@ public class LocalDateTimeUtils {
|
||||
public static Long between(LocalDateTime dateTime) {
|
||||
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS);
|
||||
}
|
||||
/**
|
||||
* 获取指定日期到现在过了几天,如果指定日期在当前日期之后,获取结果为负
|
||||
*
|
||||
* @param dateTime 日期
|
||||
* @return 相差天数
|
||||
*/
|
||||
public static Long betweenWithNow(LocalDateTime dateTime) {
|
||||
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今天的开始时间
|
||||
|
||||
@@ -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.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,34 +8,25 @@
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.tashow.cloud.common.util.serializer;
|
||||
package com.tashow.cloud.common.util.json.databind;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lanhai
|
||||
* 文件序列化
|
||||
*/
|
||||
@Component
|
||||
public class ImgJsonSerializer extends JsonSerializer<String> {
|
||||
|
||||
/* @Autowired
|
||||
private Qiniu qiniu;
|
||||
@Autowired
|
||||
private ImgUploadUtil imgUploadUtil;*/
|
||||
public class FileJsonSerializer extends JsonSerializer<String> {
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
/*if (StrUtil.isBlank(value)) {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
gen.writeString(StrUtil.EMPTY);
|
||||
return;
|
||||
}
|
||||
@@ -44,11 +35,11 @@ public class ImgJsonSerializer extends JsonSerializer<String> {
|
||||
String resourceUrl = "";
|
||||
String rule="^((http[s]{0,1})://)";
|
||||
Pattern pattern= Pattern.compile(rule);
|
||||
if (Objects.equals(imgUploadUtil.getUploadType(), 2)) {
|
||||
resourceUrl = qiniu.getResourcesUrl();
|
||||
} else if (Objects.equals(imgUploadUtil.getUploadType(), 1)) {
|
||||
resourceUrl = imgUploadUtil.getResourceUrl();
|
||||
}
|
||||
// if (Objects.equals(imgUploadUtil.getUploadType(), 2)) {
|
||||
// resourceUrl = qiniu.getResourcesUrl();
|
||||
// } else if (Objects.equals(imgUploadUtil.getUploadType(), 1)) {
|
||||
// resourceUrl = imgUploadUtil.getResourceUrl();
|
||||
// }
|
||||
for (String img : imgs) {
|
||||
Matcher matcher = pattern.matcher(img);
|
||||
//若图片以http或https开头,直接返回
|
||||
@@ -59,6 +50,6 @@ public class ImgJsonSerializer extends JsonSerializer<String> {
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
gen.writeString(sb.toString());*/
|
||||
gen.writeString(sb.toString());
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ConfigurationProperties(prefix = "yudao.security")
|
||||
@ConfigurationProperties(prefix = "tashow.security")
|
||||
@Validated
|
||||
@Data
|
||||
public class SecurityProperties {
|
||||
|
||||
@@ -138,7 +138,10 @@ public class WebSecurityConfigurerAdapter {
|
||||
.requestMatchers(HttpMethod.PATCH, permitAllUrls.get(HttpMethod.PATCH).toArray(new String[0])).permitAll()
|
||||
// 1.3 基于 tashow.security.permit-all-urls 无需认证
|
||||
.requestMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
|
||||
|
||||
)
|
||||
//app-api 不在security控制权限
|
||||
.authorizeHttpRequests(c->c.requestMatchers(webProperties.getAppApi().getPrefix()+"/**").permitAll())
|
||||
// ②:每个项目的自定义规则
|
||||
.authorizeHttpRequests(c -> authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(c)))
|
||||
// ③:兜底规则,必须认证
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.tashow.cloud.redis.config.TashowCacheProperties;
|
||||
import com.tashow.cloud.systemapi.api.tenant.TenantApi;
|
||||
import com.tashow.cloud.tenant.core.aop.TenantIgnoreAspect;
|
||||
import com.tashow.cloud.tenant.core.db.TenantDatabaseInterceptor;
|
||||
import com.tashow.cloud.tenant.core.job.TenantJobAspect;
|
||||
import com.tashow.cloud.tenant.core.mq.rabbitmq.TenantRabbitMQInitializer;
|
||||
import com.tashow.cloud.tenant.core.redis.TenantRedisCacheManager;
|
||||
import com.tashow.cloud.tenant.core.security.TenantSecurityWebFilter;
|
||||
@@ -86,14 +85,6 @@ public class TenantAutoConfiguration {
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
// ========== Job ==========
|
||||
|
||||
@Bean
|
||||
@ConditionalOnClass(name = "com.xxl.job.core.handler.annotation.XxlJob")
|
||||
public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) {
|
||||
return new TenantJobAspect(tenantFrameworkService);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnClass(name = "org.springframework.amqp.rabbit.core.RabbitTemplate")
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.tashow.cloud.tenant.config;
|
||||
|
||||
import com.tashow.cloud.systemapi.api.tenant.TenantApi;
|
||||
import com.tashow.cloud.tenant.core.rpc.TenantRequestInterceptor;
|
||||
import com.tashow.cloud.tenant.core.rpc.TenantRequestInterceptor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(prefix = "tashow.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户
|
||||
@ConditionalOnProperty(prefix = "tashow.tenant", value = "enable", matchIfMissing = true)
|
||||
@EnableFeignClients(clients = TenantApi.class) // 主要是引入相关的 API 服务
|
||||
public class TenantRpcAutoConfiguration {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.tashow.cloud.tenant.core.context;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import com.tashow.cloud.common.enums.DocumentEnum;
|
||||
|
||||
/**
|
||||
* 多租户上下文 Holder
|
||||
@@ -37,8 +36,7 @@ public class TenantContextHolder {
|
||||
public static Long getRequiredTenantId() {
|
||||
Long tenantId = getTenantId();
|
||||
if (tenantId == null) {
|
||||
throw new NullPointerException("TenantContextHolder 不存在租户编号!可参考文档:"
|
||||
+ DocumentEnum.TENANT.getUrl());
|
||||
throw new NullPointerException("TenantContextHolder 不存在租户编号!");
|
||||
}
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tashow.cloud.tenant.core.job;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 多租户 Job 注解
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TenantJob {
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.tashow.cloud.tenant.core.job;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tashow.cloud.common.util.json.JsonUtils;
|
||||
import com.tashow.cloud.tenant.core.service.TenantFrameworkService;
|
||||
import com.tashow.cloud.tenant.core.util.TenantUtils;
|
||||
import com.xxl.job.core.context.XxlJobContext;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* 多租户 JobHandler AOP
|
||||
* 任务执行时,会按照租户逐个执行 Job 的逻辑
|
||||
*
|
||||
* 注意,需要保证 JobHandler 的幂等性。因为 Job 因为某个租户执行失败重试时,之前执行成功的租户也会再次执行。
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Aspect
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class TenantJobAspect {
|
||||
|
||||
private final TenantFrameworkService tenantFrameworkService;
|
||||
|
||||
@Around("@annotation(tenantJob)")
|
||||
public void around(ProceedingJoinPoint joinPoint, TenantJob tenantJob) {
|
||||
// 获得租户列表
|
||||
List<Long> tenantIds = tenantFrameworkService.getTenantIds();
|
||||
if (CollUtil.isEmpty(tenantIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 逐个租户,执行 Job
|
||||
Map<Long, String> results = new ConcurrentHashMap<>();
|
||||
AtomicBoolean success = new AtomicBoolean(true); // 标记,是否存在失败的情况
|
||||
XxlJobContext xxlJobContext = XxlJobContext.getXxlJobContext(); // XXL-Job 上下文
|
||||
tenantIds.parallelStream().forEach(tenantId -> {
|
||||
// TODO 芋艿:先通过 parallel 实现并行;1)多个租户,是一条执行日志;2)异常的情况
|
||||
TenantUtils.execute(tenantId, () -> {
|
||||
try {
|
||||
XxlJobContext.setXxlJobContext(xxlJobContext);
|
||||
// 执行 Job
|
||||
Object result = joinPoint.proceed();
|
||||
results.put(tenantId, StrUtil.toStringOrEmpty(result));
|
||||
} catch (Throwable e) {
|
||||
results.put(tenantId, ExceptionUtil.getRootCauseMessage(e));
|
||||
success.set(false);
|
||||
// 打印异常
|
||||
XxlJobHelper.log(StrUtil.format("[多租户({}) 执行任务({}),发生异常:{}]",
|
||||
tenantId, joinPoint.getSignature(), ExceptionUtils.getStackTrace(e)));
|
||||
}
|
||||
});
|
||||
});
|
||||
// 记录执行结果
|
||||
if (success.get()) {
|
||||
XxlJobHelper.handleSuccess(JsonUtils.toJsonString(results));
|
||||
} else {
|
||||
XxlJobHelper.handleFail(JsonUtils.toJsonString(results));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.tashow.cloud.web.web.config;
|
||||
import com.tashow.cloud.common.enums.WebFilterOrderEnum;
|
||||
import com.tashow.cloud.infraapi.api.logger.ApiErrorLogApi;
|
||||
import com.tashow.cloud.web.web.core.filter.CacheRequestBodyFilter;
|
||||
import com.tashow.cloud.web.web.core.filter.DemoFilter;
|
||||
import com.tashow.cloud.web.web.core.handler.GlobalExceptionHandler;
|
||||
import com.tashow.cloud.web.web.core.handler.GlobalResponseBodyHandler;
|
||||
import com.tashow.cloud.web.web.core.util.WebFrameworkUtils;
|
||||
@@ -12,7 +11,6 @@ import jakarta.servlet.Filter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
@@ -53,8 +51,10 @@ public class WebAutoConfiguration implements WebMvcConfigurer {
|
||||
*/
|
||||
private void configurePathMatch(PathMatchConfigurer configurer, WebProperties.Api api) {
|
||||
AntPathMatcher antPathMatcher = new AntPathMatcher(".");
|
||||
configurer.addPathPrefix(api.getPrefix(), clazz -> clazz.isAnnotationPresent(RestController.class)
|
||||
&& antPathMatcher.match(api.getController(), clazz.getPackage().getName())); // 仅仅匹配 controller 包
|
||||
configurer.addPathPrefix(api.getPrefix(),
|
||||
clazz -> clazz.isAnnotationPresent(RestController.class)
|
||||
&& antPathMatcher.match(api.getController(), clazz.getPackage().getName())
|
||||
); // 仅仅匹配 controller 包
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -102,15 +102,6 @@ public class WebAutoConfiguration implements WebMvcConfigurer {
|
||||
return createFilterBean(new CacheRequestBodyFilter(), WebFilterOrderEnum.REQUEST_BODY_CACHE_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 DemoFilter Bean,演示模式
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "yudao.demo", havingValue = "true")
|
||||
public FilterRegistrationBean<DemoFilter> demoFilter() {
|
||||
return createFilterBean(new DemoFilter(), WebFilterOrderEnum.DEMO_FILTER);
|
||||
}
|
||||
|
||||
public static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
|
||||
FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
|
||||
bean.setOrder(order);
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.tashow.cloud.web.web.core.filter;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.util.servlet.ServletUtils;
|
||||
import com.tashow.cloud.web.web.core.util.WebFrameworkUtils;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import static com.tashow.cloud.common.exception.enums.GlobalErrorCodeConstants.DEMO_DENY;
|
||||
|
||||
|
||||
/**
|
||||
* 演示 Filter,禁止用户发起写操作,避免影响测试数据
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class DemoFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) {
|
||||
String method = request.getMethod();
|
||||
return !StrUtil.equalsAnyIgnoreCase(method, "POST", "PUT", "DELETE") // 写操作时,不进行过滤率
|
||||
|| WebFrameworkUtils.getLoginUserId(request) == null; // 非登录用户时,不进行过滤
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) {
|
||||
// 直接返回 DEMO_DENY 的结果。即,请求不继续
|
||||
ServletUtils.writeJSON(response, CommonResult.error(DEMO_DENY));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import static com.tashow.cloud.web.web.config.WebAutoConfiguration.createFilterB
|
||||
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties(XssProperties.class)
|
||||
@ConditionalOnProperty(prefix = "yudao.xss", name = "enable", havingValue = "true", matchIfMissing = true) // 设置为 false 时,禁用
|
||||
public class YudaoXssAutoConfiguration implements WebMvcConfigurer {
|
||||
@ConditionalOnProperty(prefix = "tashow.xss", name = "enable", havingValue = "true", matchIfMissing = true) // 设置为 false 时,禁用
|
||||
public class TashowXssAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* Xss 清理者
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "yudao.xss")
|
||||
@ConfigurationProperties(prefix = "tashow.xss")
|
||||
@Validated
|
||||
@Data
|
||||
public class XssProperties {
|
||||
|
||||
@@ -7,12 +7,16 @@ spring:
|
||||
username: nacos # Nacos 账号
|
||||
password: nacos # Nacos 密码
|
||||
discovery: # 【配置中心】配置项
|
||||
namespace: dev # 命名空间。这里使用 dev 开发环境
|
||||
namespace: 63caf548-313d-44bb-929c-531bf2f3b1a2 # 命名空间
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
metadata:
|
||||
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
|
||||
config: # 【注册中心】配置项
|
||||
namespace: dev # 命名空间。这里使用 dev 开发环境
|
||||
namespace: 63caf548-313d-44bb-929c-531bf2f3b1a2 # 命名空间
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
|
||||
|
||||
|
||||
# 日志文件配置
|
||||
logging:
|
||||
level:
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
<groupId>com.tashow.cloud</groupId>
|
||||
<artifactId>tashow-infra-api</artifactId>
|
||||
</dependency>
|
||||
<!--文件管理 - file-server-->
|
||||
<dependency>
|
||||
<groupId>com.tashow.cloud</groupId>
|
||||
<artifactId>tashow-file-api</artifactId>
|
||||
</dependency>
|
||||
<!-- RPC 远程调用相关 -->
|
||||
<dependency>
|
||||
<groupId>com.tashow.cloud</groupId>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.tashow.cloud.ai.controller.admin.aisample.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
import com.tashow.cloud.common.serializer.ImgJsonSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -10,6 +13,7 @@ import lombok.Data;
|
||||
public class AiSampleFileRespVO {
|
||||
|
||||
@Schema(description = "文件地址")
|
||||
@JsonSerialize(using = ImgJsonSerializer.class)
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "文件名称")
|
||||
|
||||
@@ -12,10 +12,10 @@ import lombok.ToString;
|
||||
@ToString(callSuper = true)
|
||||
public class AiSamplePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标签ids", example = "25839")
|
||||
@Schema(description = "标签ids")
|
||||
private String tagIds;
|
||||
|
||||
@Schema(description = "样本名称", example = "张三")
|
||||
@Schema(description = "样本名称")
|
||||
private String sampleName;
|
||||
|
||||
@Schema(description = "样本格式", example = "1")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.tashow.cloud.ai.controller.admin.aisample.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.tashow.cloud.ai.dal.dataobject.aisample.AiSampleTagDO;
|
||||
import com.tashow.cloud.common.serializer.ImgJsonSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class AiSampleRespVO {
|
||||
private List<AiSampleTagDO> tags;
|
||||
|
||||
@Schema(description = "样本文件地址")
|
||||
@JsonSerialize(using = ImgJsonSerializer.class)
|
||||
private String sampleFilePath;
|
||||
|
||||
@Schema(description = "样本名称", example = "张三")
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.tashow.cloud.ai.controller.admin.model;
|
||||
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelPageReqVO;
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelRespVO;
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelSaveReqVO;
|
||||
import com.tashow.cloud.ai.dal.dataobject.model.AiModelDO;
|
||||
import com.tashow.cloud.ai.service.model.AiModelService;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - AI模型管理")
|
||||
@RestController
|
||||
@RequestMapping("/ai/model")
|
||||
@Validated
|
||||
public class AiModelController {
|
||||
|
||||
@Resource
|
||||
private AiModelService modelService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模型")
|
||||
@PermitAll
|
||||
public CommonResult<Long> createModel(@Valid @RequestBody AiModelSaveReqVO createReqVO) {
|
||||
return success(modelService.createModel(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新模型")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> updateModel(@Valid @RequestBody AiModelSaveReqVO updateReqVO) {
|
||||
modelService.updateModel(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模型")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> deleteModel(@RequestParam("id") Long id) {
|
||||
modelService.deleteModel(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取所有已启用的模型")
|
||||
@PermitAll
|
||||
public CommonResult<List<AiModelRespVO>> getEnabledModels() {
|
||||
List<AiModelDO> models = modelService.getEnabledModels();
|
||||
return success(BeanUtils.toBean(models, AiModelRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得模型分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AiModelRespVO>> getModelPage(@Valid AiModelPageReqVO pageReqVO) {
|
||||
PageResult<AiModelDO> pageResult = modelService.getModelPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AiModelRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tashow.cloud.ai.controller.admin.model.vo;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AiModelPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "模型名称(模糊查询)", example = "宠物声音翻译")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "版本号(精确查询)", example = "v1.0.0")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用 2-测试中 3-已废弃)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.tashow.cloud.ai.controller.admin.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型 Response VO")
|
||||
@Data
|
||||
public class AiModelRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模型名称", example = "模型")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "版本号", example = "v1.0.0")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "负载", example = "0.75")
|
||||
private BigDecimal loadPercentage;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用 2-测试中 3-已废弃)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "版本描述", example = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.tashow.cloud.ai.controller.admin.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型新增/修改 Request VO")
|
||||
@Data
|
||||
public class AiModelSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "模型")
|
||||
@NotBlank(message = "模型名称不能为空")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "版本号", requiredMode = Schema.RequiredMode.REQUIRED, example = "v1.0.0")
|
||||
@NotBlank(message = "版本号不能为空")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "负载", example = "0.75")
|
||||
private BigDecimal loadPercentage;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "版本描述", example = "描述")
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.tashow.cloud.ai.service.dialog.AiDialogService;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
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.GetMapping;
|
||||
@@ -35,8 +35,7 @@ public class DialogController {
|
||||
* 获取对话消息列表
|
||||
*/
|
||||
@GetMapping("/getDialog")
|
||||
@PermitAll
|
||||
public CommonResult<DialogResp> msList(PageParam pageParam) {
|
||||
public CommonResult<DialogResp> msList(@Valid PageParam pageParam) {
|
||||
//获取当前登录用户
|
||||
Long userId = 1L;
|
||||
return success(aiDialogService.getDialog(userId,pageParam));
|
||||
@@ -47,7 +46,6 @@ public class DialogController {
|
||||
* 翻译
|
||||
*/
|
||||
@PostMapping("/translate")
|
||||
@PermitAll
|
||||
public CommonResult<TranslateRespVo> translate(@Validated TranslateReqVo fileReqVo) {
|
||||
return success(aiDialogService.translate(fileReqVo));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.tashow.cloud.ai.dal.dataobject.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* AI模型管理 DO
|
||||
*
|
||||
* @author tashow
|
||||
*/
|
||||
@TableName("tz_ai_model")
|
||||
@KeySequence("tz_ai_model_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AiModelDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 负载百分比(0.0-1.0)
|
||||
*/
|
||||
private BigDecimal loadPercentage;
|
||||
|
||||
/**
|
||||
* 状态(0-禁用 1-启用 2-测试中 3-已废弃)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 版本描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -28,16 +28,20 @@ public interface AiSampleMapper extends BaseMapperX<AiSampleDO> {
|
||||
",sample_mine_type sampleMineType ,sample_size sampleSize, remark,creator,updater,create_time createTime" +
|
||||
",update_time updateTime,deleted,tenant_id tenantId " +
|
||||
"FROM tz_ai_sample t " +
|
||||
"INNER JOIN tz_ai_sample_tag_relate r ON t.id = r.sample_id " +
|
||||
"LEFt JOIN tz_ai_sample_tag_relate r ON t.id = r.sample_id " +
|
||||
"<where>" +
|
||||
"AND t.deleted =0"+
|
||||
" <if test=\"pageReqVO.tagIds != null and pageReqVO.tagIds != ''\">" +
|
||||
" AND FIND_IN_SET(r.sample_tag_id,${pageReqVO.tagIds}) " +
|
||||
" </if>" +
|
||||
" <if test=\"pageReqVO.sampleName != null and pageReqVO.sampleName != ''\">" +
|
||||
" AND t.sample_name LIKE CONCAT('%',#{pageReqVO.sampleName},'%')" +
|
||||
" </if>" +
|
||||
" <if test=\"pageReqVO.sampleMineType != null and pageReqVO.sampleMineType != ''\">" +
|
||||
" AND t.sample_mine_type LIKE CONCAT('%',#{pageReqVO.sampleMineType},'%')" +
|
||||
" </if>" +
|
||||
"</where>" +
|
||||
"ORDER BY t.id DESC" +
|
||||
"GROUP BY t.id ORDER BY t.id DESC" +
|
||||
"</script>")
|
||||
IPage<AiSampleDO> getAiSamplePage(Page<AiSampleDO> objectPage, AiSamplePageReqVO pageReqVO);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.tashow.cloud.ai.dal.mysql.model;
|
||||
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelPageReqVO;
|
||||
import com.tashow.cloud.ai.dal.dataobject.model.AiModelDO;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* AI模型管理 Mapper
|
||||
*
|
||||
* @author tashow
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiModelMapper extends BaseMapperX<AiModelDO> {
|
||||
|
||||
default PageResult<AiModelDO> selectPage(AiModelPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AiModelDO>()
|
||||
.likeIfPresent(AiModelDO::getModelName, reqVO.getModelName())
|
||||
.eqIfPresent(AiModelDO::getVersion, reqVO.getVersion())
|
||||
.eqIfPresent(AiModelDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(AiModelDO::getCreateTime));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tashow.cloud.ai.framework.rpc.config;
|
||||
|
||||
import com.tashow.cloud.infraapi.api.file.FileApi;
|
||||
import com.tashow.cloud.fileapi.api.file.FileApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ public class SecurityConfiguration {
|
||||
.requestMatchers(adminSeverContextPath + "/**").permitAll();
|
||||
// 文件读取
|
||||
registry.requestMatchers(buildAdminApi("/infra/file/*/get/**")).permitAll();
|
||||
|
||||
// TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案
|
||||
// RPC 服务的安全配置
|
||||
registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.tashow.cloud.ai.dal.mysql.aisample.AiSampleTagMapper;
|
||||
import com.tashow.cloud.ai.dal.mysql.aisample.AiSampleTagRelateMapper;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infraapi.api.file.FileApi;
|
||||
import com.tashow.cloud.fileapi.api.file.FileApi;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.util.MyBatisUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.SneakyThrows;
|
||||
@@ -44,8 +44,7 @@ public class AiSampleServiceImpl implements AiSampleService {
|
||||
private AiSampleTagRelateMapper aiSampleTagRelateMapper;
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
@Value("file-server")
|
||||
private String fileServer;
|
||||
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@@ -55,15 +54,15 @@ public class AiSampleServiceImpl implements AiSampleService {
|
||||
/* 调用文件上传服务*/
|
||||
for (MultipartFile file : uploadReqVO.getFiles()) {
|
||||
//返回上传结果
|
||||
String file1 = fileServer + fileApi.createFile(file.getBytes());
|
||||
String filePath=fileApi.createFile(file.getOriginalFilename(), "", file.getBytes());
|
||||
//保存样本信息
|
||||
AiSampleDO aiSampleDO = new AiSampleDO();
|
||||
aiSampleDO.setSampleFilePath(file1);
|
||||
aiSampleDO.setSampleFilePath(filePath);
|
||||
aiSampleDO.setSampleName(file.getOriginalFilename());
|
||||
aiSampleDO.setSampleMineType(file.getContentType());
|
||||
aiSampleDO.setSampleSize(file.getSize());
|
||||
aiSampleMapper.insert(aiSampleDO);
|
||||
urls.add(new AiSampleFileRespVO().setFileUrl(file1).setFileName(file.getOriginalFilename()));
|
||||
urls.add(new AiSampleFileRespVO().setFileUrl(filePath).setFileName(file.getOriginalFilename()));
|
||||
}
|
||||
// 返回
|
||||
return urls;
|
||||
@@ -172,7 +171,6 @@ public class AiSampleServiceImpl implements AiSampleService {
|
||||
Object[] tagsId = list.stream().map(AiSampleTagRelateDO::getSampleTagId).toArray();
|
||||
List<AiSampleTagDO> list1 = aiSampleTagDOS.stream().filter(a -> ArrayUtil.containsAny(tagsId, a.getId())).toList();
|
||||
aiSampleDO.setTags(list1);
|
||||
aiSampleDO.setSampleFilePath(aiSampleDO.getSampleFilePath());
|
||||
}
|
||||
return new PageResult<>(aiSampleDOPageResult.getRecords(), aiSampleDOPageResult.getTotal());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.tashow.cloud.ai.dal.mysql.dialog.AiDialogMessageMapper;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infraapi.api.file.FileApi;
|
||||
import com.tashow.cloud.fileapi.api.file.FileApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.tashow.cloud.ai.service.model;
|
||||
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelPageReqVO;
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelSaveReqVO;
|
||||
import com.tashow.cloud.ai.dal.dataobject.model.AiModelDO;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI模型管理 Service 接口
|
||||
*
|
||||
* @author tashow
|
||||
*/
|
||||
public interface AiModelService {
|
||||
|
||||
/**
|
||||
* 创建模型
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createModel(@Valid AiModelSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新模型
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateModel(@Valid AiModelSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteModel(Long id);
|
||||
|
||||
/**
|
||||
* 获取所有已启用的模型
|
||||
*
|
||||
* @return 已启用的模型列表
|
||||
*/
|
||||
List<AiModelDO> getEnabledModels();
|
||||
|
||||
/**
|
||||
* 获得模型分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 模型分页
|
||||
*/
|
||||
PageResult<AiModelDO> getModelPage(AiModelPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.tashow.cloud.ai.service.model;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelPageReqVO;
|
||||
import com.tashow.cloud.ai.controller.admin.model.vo.AiModelSaveReqVO;
|
||||
import com.tashow.cloud.ai.dal.dataobject.model.AiModelDO;
|
||||
import com.tashow.cloud.ai.dal.mysql.model.AiModelMapper;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI模型管理 Service 实现类
|
||||
*
|
||||
* @author tashow
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AiModelServiceImpl implements AiModelService {
|
||||
|
||||
@Resource
|
||||
private AiModelMapper modelMapper;
|
||||
|
||||
@Override
|
||||
public Long createModel(AiModelSaveReqVO createReqVO) {
|
||||
AiModelDO model = BeanUtils.toBean(createReqVO, AiModelDO.class);
|
||||
modelMapper.insert(model);
|
||||
return model.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateModel(AiModelSaveReqVO updateReqVO) {
|
||||
AiModelDO updateObj = BeanUtils.toBean(updateReqVO, AiModelDO.class);
|
||||
modelMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteModel(Long id) {
|
||||
modelMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AiModelDO> getEnabledModels() {
|
||||
return modelMapper.selectList(
|
||||
new LambdaQueryWrapper<AiModelDO>()
|
||||
.eq(AiModelDO::getStatus, 1)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiModelDO> getModelPage(AiModelPageReqVO pageReqVO) {
|
||||
return modelMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,12 +7,15 @@ spring:
|
||||
username: nacos # Nacos 账号
|
||||
password: nacos # Nacos 密码
|
||||
discovery: # 【配置中心】配置项
|
||||
namespace: dev # 命名空间。这里使用 dev 开发环境
|
||||
namespace: 63caf548-313d-44bb-929c-531bf2f3b1a2 # 命名空间
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
metadata:
|
||||
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
|
||||
config: # 【注册中心】配置项
|
||||
namespace: dev # 命名空间。这里使用 dev 开发环境
|
||||
namespace: 63caf548-313d-44bb-929c-531bf2f3b1a2 # 命名空间
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
# 添加字符编码配置,解决YAML解析时的字符编码问题
|
||||
encode: UTF-8
|
||||
|
||||
--- #################### 外部服务配置 ####################
|
||||
|
||||
# AI翻译服务URL
|
||||
translate-server: http://43.139.42.137:8000/analyze/audio
|
||||
|
||||
19
tashow-module/tashow-module-file/Dockerfile
Normal file
19
tashow-module/tashow-module-file/Dockerfile
Normal 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
|
||||
102
tashow-module/tashow-module-file/pom.xml
Normal file
102
tashow-module/tashow-module-file/pom.xml
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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>
|
||||
文件 模块
|
||||
</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-security</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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -1,17 +1,17 @@
|
||||
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;
|
||||
|
||||
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class FileApiImpl implements FileApi {
|
||||
@@ -25,4 +25,11 @@ public class FileApiImpl implements FileApi {
|
||||
createReqDTO.getContent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> createFileMultipart(FileCreateReqDTO createReqDTO) {
|
||||
return success(fileService.createFileMultipart(createReqDTO.getName(), createReqDTO.getPath(),
|
||||
createReqDTO.getContent()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package com.tashow.cloud.user.api;
|
||||
@@ -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("/file/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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
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")
|
||||
@RequestMapping("/file/file-config")
|
||||
@Validated
|
||||
public class FileConfigController {
|
||||
|
||||
@@ -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);
|
||||
@@ -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,27 +6,25 @@ 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
|
||||
@RequestMapping("/infra/file")
|
||||
@RequestMapping("/file")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class FileController {
|
||||
@@ -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));
|
||||
@@ -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)
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
@@ -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;
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -0,0 +1 @@
|
||||
package com.tashow.cloud.user.controller.admin;
|
||||
@@ -1,24 +1,23 @@
|
||||
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")
|
||||
@RequestMapping("/file")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppFileController {
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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;
|
||||
@@ -0,0 +1 @@
|
||||
package com.tashow.cloud.file.controller.app;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 提供 POJO 类的实体转换
|
||||
*
|
||||
* 目前使用 MapStruct 框架
|
||||
*/
|
||||
package com.tashow.cloud.user.convert;
|
||||
@@ -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;
|
||||
@@ -1,20 +1,19 @@
|
||||
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.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;
|
||||
@@ -86,8 +85,6 @@ public class FileConfigDO extends BaseDO {
|
||||
String className = JsonUtils.parseObject(json, "@class", String.class);
|
||||
className = StrUtil.subAfter(className, ".", true);
|
||||
switch (className) {
|
||||
case "DBFileClientConfig":
|
||||
return JsonUtils.parseObject2(json, DBFileClientConfig.class);
|
||||
case "FtpFileClientConfig":
|
||||
return JsonUtils.parseObject2(json, FtpFileClientConfig.class);
|
||||
case "LocalFileClientConfig":
|
||||
@@ -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.*;
|
||||
|
||||
/**
|
||||
@@ -0,0 +1 @@
|
||||
package com.tashow.cloud.user.dal.dataobject;
|
||||
@@ -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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user