Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
xingyu 2023-01-05 09:41:54 +08:00
commit c5f29f18d3
9 changed files with 35 additions and 17 deletions

View File

@ -29,7 +29,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url> <url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties> <properties>
<revision>1.6.5-snapshot</revision> <revision>1.6.6-snapshot</revision>
<!-- Maven 相关 --> <!-- Maven 相关 -->
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>

View File

@ -14,7 +14,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url> <url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties> <properties>
<revision>1.6.5-snapshot</revision> <revision>1.6.6-snapshot</revision>
<!-- 统一依赖管理 --> <!-- 统一依赖管理 -->
<spring.boot.version>2.7.7</spring.boot.version> <spring.boot.version>2.7.7</spring.boot.version>
<!-- Web 相关 --> <!-- Web 相关 -->

View File

@ -9,10 +9,11 @@ import io.minio.*;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN; import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN;
import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_TENCENT;
/** /**
* 基于 S3 协议的文件客户端实现 MinIO阿里云腾讯云七牛云华为云等云服务 * 基于 S3 协议的文件客户端实现 MinIO阿里云腾讯云七牛云华为云等云服务
* * <p>
* S3 协议的客户端采用亚马逊提供的 software.amazon.awssdk.s3 * S3 协议的客户端采用亚马逊提供的 software.amazon.awssdk.s3
* *
* @author 芋道源码 * @author 芋道源码
@ -78,6 +79,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
.replaceAll("-internal", "")// 去除内网 Endpoint 的后缀 .replaceAll("-internal", "")// 去除内网 Endpoint 的后缀
.replaceAll("https://", ""); .replaceAll("https://", "");
} }
// 腾讯云必须有 region否则会报错
if (config.getEndpoint().contains(ENDPOINT_TENCENT)) {
return StrUtil.subAfter(config.getEndpoint(), ".cos.", false)
.replaceAll("." + ENDPOINT_TENCENT, ""); // 去除 Endpoint
}
return null; return null;
} }

View File

@ -19,6 +19,7 @@ public class S3FileClientConfig implements FileClientConfig {
public static final String ENDPOINT_QINIU = "qiniucs.com"; public static final String ENDPOINT_QINIU = "qiniucs.com";
public static final String ENDPOINT_ALIYUN = "aliyuncs.com"; public static final String ENDPOINT_ALIYUN = "aliyuncs.com";
public static final String ENDPOINT_TENCENT = "myqcloud.com";
/** /**
* 节点地址 * 节点地址

View File

@ -75,7 +75,7 @@ public class ConfigController {
if (config == null) { if (config == null) {
return null; return null;
} }
if (config.getVisible()) { if (!config.getVisible()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE); throw ServiceExceptionUtil.exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
} }
return success(config.getValue()); return success(config.getValue());

View File

@ -1,11 +1,14 @@
package cn.iocoder.yudao.module.infra.dal.mysql.file; package cn.iocoder.yudao.module.infra.dal.mysql.file;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.file.core.client.db.DBFileContentFrameworkDAO; import cn.iocoder.yudao.framework.file.core.client.db.DBFileContentFrameworkDAO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
@Repository @Repository
public class FileContentDAOImpl implements DBFileContentFrameworkDAO { public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
@ -27,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
@Override @Override
public byte[] selectContent(Long configId, String path) { public byte[] selectContent(Long configId, String path) {
FileContentDO fileContentDO = fileContentMapper.selectOne( List<FileContentDO> list = fileContentMapper.selectList(
buildQuery(configId, path).select(FileContentDO::getContent)); buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId));
return fileContentDO != null ? fileContentDO.getContent() : null; return Optional.ofNullable(CollUtil.getFirst(list))
.map(FileContentDO::getContent)
.orElse(null);
} }
private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) { private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) {

View File

@ -1,6 +1,6 @@
{ {
"name": "yudao-ui-admin-vue3", "name": "yudao-ui-admin-vue3",
"version": "1.6.5-snapshot.1901", "version": "1.6.6-snapshot.1901",
"description": "基于vue3、vite4、element-plus、typesScript", "description": "基于vue3、vite4、element-plus、typesScript",
"author": "xingyu", "author": "xingyu",
"private": false, "private": false,

View File

@ -1,6 +1,6 @@
{ {
"name": "yudao-ui-admin", "name": "yudao-ui-admin",
"version": "1.6.5-snapshot", "version": "1.6.6-snapshot",
"description": "芋道管理系统", "description": "芋道管理系统",
"author": "芋道", "author": "芋道",
"license": "MIT", "license": "MIT",

View File

@ -1,14 +1,16 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert title="上传下载" url="https://doc.iocoder.cn/file/" /> <doc-alert title="上传下载" url="https://doc.iocoder.cn/file/"/>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="文件路径" prop="path"> <el-form-item label="文件路径" prop="path">
<el-input v-model="queryParams.path" placeholder="请输入文件路径" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.path" placeholder="请输入文件路径" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="创建时间" prop="createTime"> <el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
@ -35,6 +37,9 @@
<template v-slot="scope"> <template v-slot="scope">
<image-preview v-if="scope.row.type&&scope.row.type.indexOf('image/') === 0" :src="scope.row.url" <image-preview v-if="scope.row.type&&scope.row.type.indexOf('image/') === 0" :src="scope.row.url"
:width="'100px'"></image-preview> :width="'100px'"></image-preview>
<video v-else-if="scope.row.type&&scope.row.type.indexOf('video/') === 0" :width="'100px'">
<source :src="scope.row.url"/>
</video>
<i v-else>无法预览点击 <i v-else>无法预览点击
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" target="_blank" <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" target="_blank"
:href="getFileUrl + scope.row.configId + '/get/' + scope.row.path">下载 :href="getFileUrl + scope.row.configId + '/get/' + scope.row.path">下载
@ -118,7 +123,7 @@ export default {
title: "", // title: "", //
isUploading: false, // isUploading: false, //
url: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // url: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", //
headers: { Authorization: "Bearer " + getAccessToken() }, // headers: {Authorization: "Bearer " + getAccessToken()}, //
data: {} // data: {} //
}, },
}; };
@ -189,19 +194,20 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal.confirm('是否确认删除文件编号为"' + id + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除文件编号为"' + id + '"的数据项?').then(function () {
return deleteFile(id); return deleteFile(id);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {
});
}, },
// //
sizeFormat(row, column) { sizeFormat(row, column) {
const unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"]; const unitArr = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const srcSize = parseFloat(row.size); const srcSize = parseFloat(row.size);
const index = Math.floor(Math.log(srcSize) / Math.log(1024)); const index = Math.floor(Math.log(srcSize) / Math.log(1024));
let size =srcSize/Math.pow(1024,index); let size = srcSize / Math.pow(1024, index);
size = size.toFixed(2);// size = size.toFixed(2);//
return size + ' ' + unitArr[index]; return size + ' ' + unitArr[index];
}, },