init: 导入团队知识库内容

This commit is contained in:
yueqian-ai
2026-05-14 16:56:48 +08:00
commit acca2041f0
1681 changed files with 285734 additions and 0 deletions
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2026 Qiantong Technology Co., Ltd.
qModel Model Platform(Open Source Edition)
*
License:
Released under the Apache License, Version 2.0.
You may use, modify, and distribute this software for commercial purposes
under the terms of the License.
*
Special Notice:
All derivative versions are strictly prohibited from modifying or removing
the default system logo and copyright information.
For brand customization, please apply for brand customization authorization via official channels.
*
More information: https://qmodel.qiantong.tech/business.html
*
============================================================================
*
版权所有 © 2026 江苏千桐科技有限公司
qModel 模型平台(开源版)
*
许可协议:
本项目基于 Apache License 2.0 开源协议发布,
允许在遵守协议的前提下进行商用、修改和分发。
*
特别说明:
所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
如需定制品牌,请通过官方渠道申请品牌定制授权。
*
更多信息请访问:https://qmodel.qiantong.tech/business.html
-->
<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>
<artifactId>qmodel-framework</artifactId>
<groupId>tech.qiantong</groupId>
<version>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>qmodel-file</artifactId>
<description>
file模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>tech.qiantong</groupId>
<artifactId>qmodel-common</artifactId>
</dependency>
<!-- 文件存储 https://gitee.com/dromara/x-file-storage-->
<dependency>
<groupId>org.dromara.x-file-storage</groupId>
<artifactId>x-file-storage-spring</artifactId>
<version>2.2.1</version>
</dependency>
<!-- 框架配置模块 -->
<dependency>
<groupId>tech.qiantong</groupId>
<artifactId>qmodel-config</artifactId>
</dependency>
<dependency>
<groupId>tech.qiantong</groupId>
<artifactId>qmodel-config</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
<!-- 阿里云OSS -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.16.1</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,127 @@
/*
* Copyright © 2026 Qiantong Technology Co., Ltd.
* qModel Model Platform(Open Source Edition)
* *
* License:
* Released under the Apache License, Version 2.0.
* You may use, modify, and distribute this software for commercial purposes
* under the terms of the License.
* *
* Special Notice:
* All derivative versions are strictly prohibited from modifying or removing
* the default system logo and copyright information.
* For brand customization, please apply for brand customization authorization via official channels.
* *
* More information: https://qmodel.qiantong.tech/business.html
* *
* ============================================================================
* *
* 版权所有 © 2026 江苏千桐科技有限公司
* qModel 模型平台(开源版)
* *
* 许可协议:
* 本项目基于 Apache License 2.0 开源协议发布,
* 允许在遵守协议的前提下进行商用、修改和分发。
* *
* 特别说明:
* 所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
* 如需定制品牌,请通过官方渠道申请品牌定制授权。
* *
* 更多信息请访问:https://qmodel.qiantong.tech/business.html
*/
package tech.qiantong.qmodel.file.controller;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import tech.qiantong.qmodel.config.ServerConfig;
import tech.qiantong.qmodel.file.util.FileUploadUtil;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 文件上传控制器
* 提供一系列文件上传的 API 接口
* 该控制器将调用静态工具类 FileUploadUtil 来实现文件上传功能
* 使用 @RestController 注解以支持 RESTful API 形式
*
* @author qModel
*/
@RestController
public class FileUploadController {
/**
* 文件存储服务
* 使用 Spring 的 @Resource 注解自动注入 FileStorageService 实例
*/
@Resource
private FileStorageService fileStorageService;
@Resource
private ServerConfig serverConfig;
@Value("${dromara.x-file-storage.local-plus[0].storage-path}")
private String storagePath;
/**
* 初始化方法
* 使用 @PostConstruct 注解表示在依赖注入完成后会自动调用该方法
* 将注入的 FileStorageService 实例传递给静态工具类 FileUploadUtil
*/
@PostConstruct
public void init() {
FileUploadUtil.init(fileStorageService, serverConfig, storagePath);
}
/**
* 上传文件接口 -可用
* 处理文件上传请求,将文件上传到默认存储平台
*
* @param file 要上传的文件,使用 MultipartFile 接收上传的文件
* @return 上传成功后返回文件信息(FileInfo 对象)
*/
@PostMapping("/upload")
public FileInfo upload(MultipartFile file, String platForm) {
return FileUploadUtil.uploadByParam(file, null,platForm);
}
/**
* 上传图片接口 -暂不可用
* 处理图片文件上传请求,同时生成缩略图
*
* @param file 要上传的图片文件,使用 MultipartFile 接收上传的图片文件
* @return 上传成功后返回图片文件的信息(FileInfo 对象)
*/
@PostMapping("/upload-image")
public FileInfo uploadImage(MultipartFile file) {
return FileUploadUtil.uploadImage(file);
}
/**
* 上传文件到指定存储平台的接口 -暂不可用
* 处理文件上传请求,将文件上传到指定的存储平台
*
* @param file 要上传的文件,使用 MultipartFile 接收上传的文件
* @return 上传成功后返回文件信息(FileInfo 对象)
*/
@PostMapping("/upload-platform")
public FileInfo uploadPlatform(MultipartFile file) {
return FileUploadUtil.uploadPlatform(file);
}
/**
* 通过 HttpServletRequest 直接上传文件的接口 -暂不可用
* 处理文件上传请求,直接从 HttpServletRequest 中读取文件进行上传
*
* @param request HttpServletRequest 对象,包含上传的文件数据
* @return 上传成功后返回文件信息(FileInfo 对象)
*/
@PostMapping("/upload-request")
public FileInfo uploadPlatform(HttpServletRequest request) {
return FileUploadUtil.uploadRequest(request);
}
}
@@ -0,0 +1,203 @@
/*
* Copyright © 2026 Qiantong Technology Co., Ltd.
* qModel Model Platform(Open Source Edition)
* *
* License:
* Released under the Apache License, Version 2.0.
* You may use, modify, and distribute this software for commercial purposes
* under the terms of the License.
* *
* Special Notice:
* All derivative versions are strictly prohibited from modifying or removing
* the default system logo and copyright information.
* For brand customization, please apply for brand customization authorization via official channels.
* *
* More information: https://qmodel.qiantong.tech/business.html
* *
* ============================================================================
* *
* 版权所有 © 2026 江苏千桐科技有限公司
* qModel 模型平台(开源版)
* *
* 许可协议:
* 本项目基于 Apache License 2.0 开源协议发布,
* 允许在遵守协议的前提下进行商用、修改和分发。
* *
* 特别说明:
* 所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
* 如需定制品牌,请通过官方渠道申请品牌定制授权。
* *
* 更多信息请访问:https://qmodel.qiantong.tech/business.html
*/
package tech.qiantong.qmodel.file.util;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.web.multipart.MultipartFile;
import tech.qiantong.qmodel.common.constant.Constants;
import tech.qiantong.qmodel.common.utils.StringUtils;
import tech.qiantong.qmodel.config.ServerConfig;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 文件上传工具类
* 提供文件上传的静态方法,便于在项目的其他部分调用。
* 该类使用静态方法操作 FileStorageService 实例,支持多种上传方式。
*
* @author qModel
*/
public class FileUploadUtil {
/**
* 文件存储服务
*/
private static FileStorageService fileStorageService;
/**
* 文件配置
*/
private static ServerConfig serverConfig;
/**
* 文件存储地址
*/
private static String storagePath;
/**
* 初始化工具类
* 该方法用于初始化 FileStorageService 实例。必须在使用其他方法之前调用该方法。
*
* @param service FileStorageService 实例,用于文件的上传和存储操作
*/
public static void init(FileStorageService service, ServerConfig config, String path) {
fileStorageService = service;
serverConfig = config;
storagePath = path;
}
/**
* 上传文件
* 将 MultipartFile 文件上传到默认的存储平台。
*
* @param file 要上传的文件
* @param basePath 最前面没有 / 结尾带有 /
* @return 返回上传后的文件信息(FileInfo 对象)
*/
public static FileInfo upload(MultipartFile file, String basePath) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd/");
String path;
if (StringUtils.isNotEmpty(basePath)) {
path = basePath + formatter.format( new Date());
} else {
path = formatter.format( new Date());
}
FileInfo fileInfo = fileStorageService.of(file)
.setPath(path)
.upload();
String url = serverConfig.getUrl() + Constants.RESOURCE_PREFIX + fileInfo.getUrl();
fileInfo.setUrl(url);
return fileInfo;
}
/**
* 上传文件
* 将 MultipartFile 根据请求参数上传到入参指定的存储平台。
*
* @param file 要上传的文件
* @param basePath 最前面没有 / 结尾带有 /
* @param platform 存储平台名称
* @return 返回上传后的文件信息(FileInfo 对象)
*/
public static FileInfo uploadByParam(MultipartFile file, String basePath, String platform) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd/");
// 构造路径
String path;
if (StringUtils.isNotEmpty(basePath)) {
path = basePath + formatter.format(new Date());
} else {
path = formatter.format(new Date());
}
FileInfo fileInfo;
// 如果指定了存储平台,上传到对应平台
if (StringUtils.isNotEmpty(platform)) {
fileInfo = fileStorageService.of(file)
.setPlatform(platform)
.setPath(path)
.upload();
} else {
fileInfo = fileStorageService.of(file)
.setPath(path)
.upload();
String url = serverConfig.getUrl() + Constants.RESOURCE_PREFIX + fileInfo.getUrl();
fileInfo.setUrl(url);
}
return fileInfo;
}
/**
* 上传文件并返回文件 URL
* 该方法将文件上传到指定路径,并返回上传后的文件 URL。
*
* @param file 要上传的文件
* @return 上传成功后返回文件的 URL,失败则返回 "上传失败!"
*/
/* public static String upload2(MultipartFile file) {
FileInfo fileInfo = fileStorageService.of(file)
.setPath("upload/") // 设置文件保存的相对路径
.setSaveFilename("image.jpg") // 设置保存的文件名,如果不设置将随机生成
.setObjectId("0") // 关联对象 ID,用于管理,不需要可以不写
.setObjectType("0") // 关联对象类型,用于管理,不需要可以不写
.putAttr("role", "admin") // 设置自定义属性,用于在其他地方获取使用
.upload();
return fileInfo == null ? "上传失败!" : fileInfo.getUrl();
}*/
/**
* 上传图片并生成缩略图
* 该方法将图片文件上传并自动生成缩略图。
*
* @param file 要上传的图片文件
* @return 返回上传后的文件信息(FileInfo 对象)
*/
public static FileInfo uploadImage(MultipartFile file) {
return fileStorageService.of(file)
.image(img -> img.size(1000, 1000)) // 调整图片大小到 1000*1000
.thumbnail(th -> th.size(200, 200)) // 生成 200*200 的缩略图
.upload();
}
/**
* 上传文件到指定存储平台
* 该方法将文件上传到指定的平台,如阿里云 OSS。
*
* @param file 要上传的文件
* @return 返回上传后的文件信息(FileInfo 对象)
*/
public static FileInfo uploadPlatform(MultipartFile file) {
return fileStorageService.of(file)
.setPlatform("aliyun-oss-1") // 使用指定的存储平台
.upload();
}
/**
* 通过 HttpServletRequest 上传文件
* 直接从 HttpServletRequest 对象中读取文件并上传。
*
* @param request HttpServletRequest 对象,包含上传的文件数据
* @return 返回上传后的文件信息(FileInfo 对象)
*/
public static FileInfo uploadRequest(HttpServletRequest request) {
return fileStorageService.of(request).upload();
}
}
@@ -0,0 +1,53 @@
# Copyright © 2026 Qiantong Technology Co., Ltd.
# qModel Model Platform(Open Source Edition)
# *
# License:
# Released under the Apache License, Version 2.0.
# You may use, modify, and distribute this software for commercial purposes
# under the terms of the License.
# *
# Special Notice:
# All derivative versions are strictly prohibited from modifying or removing
# the default system logo and copyright information.
# For brand customization, please apply for brand customization authorization via official channels.
# *
# More information: https://qmodel.qiantong.tech/business.html
# *
# ============================================================================
# *
# 版权所有 © 2026 江苏千桐科技有限公司
# qModel 模型平台(开源版)
# *
# 许可协议:
# 本项目基于 Apache License 2.0 开源协议发布,
# 允许在遵守协议的前提下进行商用、修改和分发。
# *
# 特别说明:
# 所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
# 如需定制品牌,请通过官方渠道申请品牌定制授权。
# *
# 更多信息请访问:https://qmodel.qiantong.tech/business.html
# 文件上传配置
dromara:
x-file-storage: #文件存储配置
default-platform: local #默认使用的存储平台
thumbnail-suffix: ".min.jpg" #缩略图后缀,例如【.min.jpg】【.png】
#对应平台的配置写在这里,注意缩进要对齐
local-plus:
- platform: local # 存储平台标识
enable-storage: true #启用存储
enable-access: false #启用访问(线上请使用 Nginx 配置,效率更高)
domain: "" # 访问域名,例如:“http://127.0.0.1:8081/file/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
path-patterns: /** # 访问路径
base-path: / # 基础路径
storage-path: ${user.dir}/upload/ # 存储路径
aliyun-oss:
- platform: xxxx-oss-xx # 存储平台标识
enable-storage: true # 启用存储
access-key: xxxxxxxxxxx # 阿里云访问秘钥
secret-key: xxxxxxxxxxx # 阿里云秘钥
end-point: https://abc.oss-cn-shanghai.aliyuncs.com # OSS服务节点
bucket-name: xxxxx # 存储桶名
domain: https://abc.oss-cn-shanghai.aliyuncs.com/ # 访问域名,注意“/”结尾,例如:https://abc.oss-cn-shanghai.aliyuncs.com/
# base-path: /document # 基础路径
@@ -0,0 +1,53 @@
# Copyright © 2026 Qiantong Technology Co., Ltd.
# qModel Model Platform(Open Source Edition)
# *
# License:
# Released under the Apache License, Version 2.0.
# You may use, modify, and distribute this software for commercial purposes
# under the terms of the License.
# *
# Special Notice:
# All derivative versions are strictly prohibited from modifying or removing
# the default system logo and copyright information.
# For brand customization, please apply for brand customization authorization via official channels.
# *
# More information: https://qmodel.qiantong.tech/business.html
# *
# ============================================================================
# *
# 版权所有 © 2026 江苏千桐科技有限公司
# qModel 模型平台(开源版)
# *
# 许可协议:
# 本项目基于 Apache License 2.0 开源协议发布,
# 允许在遵守协议的前提下进行商用、修改和分发。
# *
# 特别说明:
# 所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
# 如需定制品牌,请通过官方渠道申请品牌定制授权。
# *
# 更多信息请访问:https://qmodel.qiantong.tech/business.html
# 文件上传配置
dromara:
x-file-storage: #文件存储配置
default-platform: local #默认使用的存储平台
thumbnail-suffix: ".min.jpg" #缩略图后缀,例如【.min.jpg】【.png】
#对应平台的配置写在这里,注意缩进要对齐
local-plus:
- platform: local # 存储平台标识
enable-storage: true #启用存储
enable-access: false #启用访问(线上请使用 Nginx 配置,效率更高)
domain: "" # 访问域名,例如:“http://127.0.0.1:8081/file/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
path-patterns: /** # 访问路径
base-path: / # 基础路径
storage-path: ${user.dir}/upload/ # 存储路径
aliyun-oss:
- platform: xxxx-oss-xx # 存储平台标识
enable-storage: true # 启用存储
access-key: xxxxxxxxxxx # 阿里云访问秘钥
secret-key: xxxxxxxxxxx # 阿里云秘钥
end-point: https://abc.oss-cn-shanghai.aliyuncs.com # OSS服务节点
bucket-name: xxxxx # 存储桶名
domain: https://abc.oss-cn-shanghai.aliyuncs.com/ # 访问域名,注意“/”结尾,例如:https://abc.oss-cn-shanghai.aliyuncs.com/
# base-path: /document # 基础路径
@@ -0,0 +1,53 @@
# Copyright © 2026 Qiantong Technology Co., Ltd.
# qModel Model Platform(Open Source Edition)
# *
# License:
# Released under the Apache License, Version 2.0.
# You may use, modify, and distribute this software for commercial purposes
# under the terms of the License.
# *
# Special Notice:
# All derivative versions are strictly prohibited from modifying or removing
# the default system logo and copyright information.
# For brand customization, please apply for brand customization authorization via official channels.
# *
# More information: https://qmodel.qiantong.tech/business.html
# *
# ============================================================================
# *
# 版权所有 © 2026 江苏千桐科技有限公司
# qModel 模型平台(开源版)
# *
# 许可协议:
# 本项目基于 Apache License 2.0 开源协议发布,
# 允许在遵守协议的前提下进行商用、修改和分发。
# *
# 特别说明:
# 所有衍生版本不得修改或移除系统默认的 LOGO 和版权信息;
# 如需定制品牌,请通过官方渠道申请品牌定制授权。
# *
# 更多信息请访问:https://qmodel.qiantong.tech/business.html
# 文件上传配置
dromara:
x-file-storage: #文件存储配置
default-platform: local #默认使用的存储平台
thumbnail-suffix: ".min.jpg" #缩略图后缀,例如【.min.jpg】【.png】
#对应平台的配置写在这里,注意缩进要对齐
local-plus:
- platform: local # 存储平台标识
enable-storage: true #启用存储
enable-access: false #启用访问(线上请使用 Nginx 配置,效率更高)
domain: "" # 访问域名,例如:“http://127.0.0.1:8081/file/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
path-patterns: /** # 访问路径
base-path: / # 基础路径
storage-path: ${user.dir}/upload/ # 存储路径
aliyun-oss:
- platform: xxxx-oss-xx # 存储平台标识
enable-storage: true # 启用存储
access-key: xxxxxxxxxxx # 阿里云访问秘钥
secret-key: xxxxxxxxxxx # 阿里云秘钥
end-point: https://abc.oss-cn-shanghai.aliyuncs.com # OSS服务节点
bucket-name: xxxxx # 存储桶名
domain: https://abc.oss-cn-shanghai.aliyuncs.com/ # 访问域名,注意“/”结尾,例如:https://abc.oss-cn-shanghai.aliyuncs.com/
# base-path: /document # 基础路径