Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into develop

# Conflicts:
#	yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm
This commit is contained in:
YunaiV
2025-10-01 09:50:48 +08:00
599 changed files with 22350 additions and 13554 deletions

View File

@@ -26,6 +26,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -99,8 +100,10 @@ public class FileController {
if (StrUtil.isEmpty(path)) {
throw new IllegalArgumentException("结尾的 path 路径必须传递");
}
// 解码,解决中文路径的问题 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/807/
path = URLUtil.decode(path);
// 解码,解决中文路径的问题
// https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/807/
// https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1432/
path = URLUtil.decode(path, StandardCharsets.UTF_8, false);
// 读取内容
byte[] content = fileService.getFileContent(configId, path);

View File

@@ -9,8 +9,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.generator.config.po.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 代码生成 column 字段定义
@@ -20,8 +18,6 @@ import lombok.experimental.Accessors;
@TableName(value = "infra_codegen_column", autoResultMap = true)
@KeySequence("infra_codegen_column_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TenantIgnore
public class CodegenColumnDO extends BaseDO {

View File

@@ -11,8 +11,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 代码生成 table 表定义
@@ -22,8 +20,6 @@ import lombok.experimental.Accessors;
@TableName(value = "infra_codegen_table", autoResultMap = true)
@KeySequence("infra_codegen_table_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TenantIgnore
public class CodegenTableDO extends BaseDO {

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.ftp.Ftp;
import cn.hutool.extra.ftp.FtpConfig;
import cn.hutool.extra.ftp.FtpException;
import cn.hutool.extra.ftp.FtpMode;
import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient;
@@ -18,6 +19,15 @@ import java.io.ByteArrayOutputStream;
*/
public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
/**
* 连接超时时间,单位:毫秒
*/
private static final Long CONNECTION_TIMEOUT = 3000L;
/**
* 读写超时时间,单位:毫秒
*/
private static final Long SO_TIMEOUT = 10000L;
private Ftp ftp;
public FtpFileClient(Long id, FtpFileClientConfig config) {
@@ -26,9 +36,12 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
@Override
protected void doInit() {
// 初始化 Ftp 对象
this.ftp = new Ftp(config.getHost(), config.getPort(), config.getUsername(), config.getPassword(),
CharsetUtil.CHARSET_UTF_8, null, null, FtpMode.valueOf(config.getMode()));
// 初始化 Ftp 对象https://gitee.com/zhijiantianya/yudao-cloud/pulls/207/
FtpConfig ftpConfig = new FtpConfig(config.getHost(), config.getPort(), config.getUsername(), config.getPassword(),
CharsetUtil.CHARSET_UTF_8, null, null);
ftpConfig.setConnectionTimeout(CONNECTION_TIMEOUT);
ftpConfig.setSoTimeout(SO_TIMEOUT);
this.ftp = new Ftp(ftpConfig, FtpMode.valueOf(config.getMode()));
}
@Override
@@ -72,4 +85,4 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
ftp.reconnectIfTimeout();
}
}
}

View File

@@ -1,11 +1,10 @@
package cn.iocoder.yudao.module.infra.framework.file.core.client.ftp;
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
/**
* Ftp 文件客户端的配置类

View File

@@ -129,12 +129,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
.signatureDuration(expiration)
.getObjectRequest(b -> b.bucket(config.getBucket()).key(finalPath)).build())
.url();
// 特殊:适配未使用 domain 返回的情况!!!
String signedUrlStr = signedUrl.toString();
if (!signedUrlStr.startsWith(config.getDomain())) {
signedUrlStr = signedUrlStr.replaceFirst(signedUrl.getProtocol() + "://" + signedUrl.getHost(), config.getDomain());
}
return signedUrlStr;
return signedUrl.toString();
}
/**

View File

@@ -1,9 +1,14 @@
package cn.iocoder.yudao.module.infra.framework.file.core.client.sftp;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.ftp.FtpConfig;
import cn.hutool.extra.ssh.JschRuntimeException;
import cn.hutool.extra.ssh.Sftp;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient;
import com.jcraft.jsch.JSch;
import java.io.File;
@@ -14,6 +19,20 @@ import java.io.File;
*/
public class SftpFileClient extends AbstractFileClient<SftpFileClientConfig> {
/**
* 连接超时时间,单位:毫秒
*/
private static final Long CONNECTION_TIMEOUT = 3000L;
/**
* 读写超时时间,单位:毫秒
*/
private static final Long SO_TIMEOUT = 10000L;
static {
// 某些旧的 sftp 服务器仅支持 ssh-dss 协议,该协议并不安全,默认不支持该协议,按需添加
JSch.setConfig("server_host_key", JSch.getConfig("server_host_key") + ",ssh-dss");
}
private Sftp sftp;
public SftpFileClient(Long id, SftpFileClientConfig config) {
@@ -22,18 +41,27 @@ public class SftpFileClient extends AbstractFileClient<SftpFileClientConfig> {
@Override
protected void doInit() {
// 初始化 Ftp 对象
this.sftp = new Sftp(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
// 初始化 Sftp 对象
FtpConfig ftpConfig = new FtpConfig(config.getHost(), config.getPort(), config.getUsername(), config.getPassword(),
CharsetUtil.CHARSET_UTF_8, null, null);
ftpConfig.setConnectionTimeout(CONNECTION_TIMEOUT);
ftpConfig.setSoTimeout(SO_TIMEOUT);
this.sftp = new Sftp(ftpConfig);
}
@Override
public String upload(byte[] content, String path, String type) {
// 执行写入
String filePath = getFilePath(path);
String fileName = FileUtil.getName(filePath);
String dir = StrUtil.removeSuffix(filePath, fileName);
File file = FileUtils.createTempFile(content);
reconnectIfTimeout();
sftp.mkDirs(FileUtil.getParent(filePath, 1)); // 需要创建父目录,不然会报错
sftp.upload(filePath, file);
sftp.mkDirs(dir); // 需要创建父目录,不然会报错
boolean success = sftp.upload(filePath, file);
if (!success) {
throw new JschRuntimeException(StrUtil.format("上传文件到目标目录 ({}) 失败", filePath));
}
// 拼接返回路径
return super.formatFileUrl(config.getDomain(), path);
}

View File

@@ -1,11 +1,10 @@
package cn.iocoder.yudao.module.infra.framework.file.core.client.sftp;
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
/**
* Sftp 文件客户端的配置类

View File

@@ -80,17 +80,17 @@ public class FileTypeUtils {
*/
public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException {
// 设置 header 和 contentType
String contentType = getMineType(content, filename);
response.setContentType(contentType);
String mineType = getMineType(content, filename);
response.setContentType(mineType);
// 设置内容显示、下载文件名https://www.cnblogs.com/wq-9/articles/12165056.html
if (StrUtil.containsIgnoreCase(contentType, "image/")) {
if (isImage(mineType)) {
// 参见 https://github.com/YunaiV/ruoyi-vue-pro/issues/692 讨论
response.setHeader("Content-Disposition", "inline;filename=" + HttpUtils.encodeUtf8(filename));
} else {
response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename));
}
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
if (StrUtil.containsIgnoreCase(contentType, "video")) {
if (StrUtil.containsIgnoreCase(mineType, "video")) {
response.setHeader("Content-Length", String.valueOf(content.length));
response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length);
response.setHeader("Accept-Ranges", "bytes");
@@ -99,4 +99,14 @@ public class FileTypeUtils {
IoUtil.write(response.getOutputStream(), false, content);
}
/**
* 判断是否是图片
*
* @param mineType 类型
* @return 是否是图片
*/
public static boolean isImage(String mineType) {
return StrUtil.startWith(mineType, "image/");
}
}

View File

@@ -217,7 +217,7 @@ const handleDeleteBatch = async () => {
const checkedIds = ref<number[]>([])
const handleRowCheckboxChange = (records: ${subSimpleClassName}[]) => {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end
#end

View File

@@ -374,7 +374,7 @@ const handleDeleteBatch = async () => {
const checkedIds = ref<number[]>([])
const handleRowCheckboxChange = (records: ${simpleClassName}[]) => {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end

View File

@@ -176,7 +176,7 @@ function handleRowCheckboxChange({
}: {
records: ${simpleClassName}Api.${simpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end

View File

@@ -103,7 +103,7 @@ function handleRowCheckboxChange({
}: {
records: ${simpleClassName}Api.${subSimpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end
#end

View File

@@ -94,7 +94,7 @@ function handleRowCheckboxChange({
}: {
records: ${apiName}.${subSimpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end

View File

@@ -176,7 +176,7 @@ function handleRowCheckboxChange({
}: {
records: ${simpleClassName}Api.${simpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end

View File

@@ -103,7 +103,7 @@ function handleRowCheckboxChange({
}: {
records: ${simpleClassName}Api.${subSimpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end
#end

View File

@@ -105,7 +105,7 @@ function handleRowCheckboxChange({
}: {
records: ${apiName}.${subSimpleClassName}[];
}) {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id!);
}
#end