Merge remote-tracking branch 'origin/master' into feature/vue3

This commit is contained in:
xingyu 2022-11-29 23:25:39 +08:00
commit b100d41da1
16 changed files with 29 additions and 21 deletions

View File

@ -22,7 +22,7 @@ public interface FileClient {
* @return 完整路径 HTTP 访问地址 * @return 完整路径 HTTP 访问地址
* @throws Exception 上传文件时抛出 Exception 异常 * @throws Exception 上传文件时抛出 Exception 异常
*/ */
String upload(byte[] content, String path) throws Exception; String upload(byte[] content, String path, String type) throws Exception;
/** /**
* 删除文件 * 删除文件

View File

@ -21,7 +21,7 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> {
} }
@Override @Override
public String upload(byte[] content, String path) { public String upload(byte[] content, String path, String type) {
getDao().insert(getId(), path, content); getDao().insert(getId(), path, content);
// 拼接返回路径 // 拼接返回路径
return super.formatFileUrl(config.getDomain(), path); return super.formatFileUrl(config.getDomain(), path);

View File

@ -38,7 +38,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
} }
@Override @Override
public String upload(byte[] content, String path) { public String upload(byte[] content, String path, String type) {
// 执行写入 // 执行写入
String filePath = getFilePath(path); String filePath = getFilePath(path);
String fileName = FileUtil.getName(filePath); String fileName = FileUtil.getName(filePath);

View File

@ -25,7 +25,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
} }
@Override @Override
public String upload(byte[] content, String path) { public String upload(byte[] content, String path, String type) {
// 执行写入 // 执行写入
String filePath = getFilePath(path); String filePath = getFilePath(path);
FileUtil.writeBytes(content, filePath); FileUtil.writeBytes(content, filePath);

View File

@ -82,10 +82,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
} }
@Override @Override
public String upload(byte[] content, String path) throws Exception { public String upload(byte[] content, String path, String type) throws Exception {
// 执行上传 // 执行上传
client.putObject(PutObjectArgs.builder() client.putObject(PutObjectArgs.builder()
.bucket(config.getBucket()) // bucket 必须传递 .bucket(config.getBucket()) // bucket 必须传递
.contentType(type)
.object(path) // 相对路径作为 key .object(path) // 相对路径作为 key
.stream(new ByteArrayInputStream(content), content.length, -1) // 文件内容 .stream(new ByteArrayInputStream(content), content.length, -1) // 文件内容
.build()); .build());

View File

@ -31,7 +31,7 @@ public class SftpFileClient extends AbstractFileClient<SftpFileClientConfig> {
} }
@Override @Override
public String upload(byte[] content, String path) { public String upload(byte[] content, String path, String type) {
// 执行写入 // 执行写入
String filePath = getFilePath(path); String filePath = getFilePath(path);
File file = FileUtils.createTempFile(content); File file = FileUtils.createTempFile(content);

View File

@ -25,7 +25,7 @@ public class FtpFileClientTest {
// 上传文件 // 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg"; String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path); String fullPath = client.upload(content, path, "image/jpeg");
System.out.println("访问地址:" + fullPath); System.out.println("访问地址:" + fullPath);
if (false) { if (false) {
byte[] bytes = client.getContent(path); byte[] bytes = client.getContent(path);

View File

@ -19,7 +19,7 @@ public class LocalFileClientTest {
// 上传文件 // 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg"; String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path); String fullPath = client.upload(content, path, "image/jpeg");
System.out.println("访问地址:" + fullPath); System.out.println("访问地址:" + fullPath);
client.delete(path); client.delete(path);
} }

View File

@ -101,7 +101,7 @@ public class S3FileClientTest {
// 上传文件 // 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg"; String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path); String fullPath = client.upload(content, path, "image/jpeg");
System.out.println("访问地址:" + fullPath); System.out.println("访问地址:" + fullPath);
// 读取文件 // 读取文件
if (true) { if (true) {

View File

@ -23,7 +23,7 @@ public class SftpFileClientTest {
// 上传文件 // 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg"; String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path); String fullPath = client.upload(content, path, "image/jpeg");
System.out.println("访问地址:" + fullPath); System.out.println("访问地址:" + fullPath);
if (false) { if (false) {
byte[] bytes = client.getContent(path); byte[] bytes = client.getContent(path);

View File

@ -77,6 +77,8 @@ public interface BpmTaskConvert {
} }
@Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState") @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")
@Mapping(target = "claimTime", expression = "java(bean.getClaimTime()==null?null: LocalDateTime.ofInstant(bean.getClaimTime().toInstant(),ZoneId.systemDefault()))")
@Mapping(target = "createTime", expression = "java(bean.getCreateTime()==null?null:LocalDateTime.ofInstant(bean.getCreateTime().toInstant(),ZoneId.systemDefault()))")
BpmTaskTodoPageItemRespVO convert1(Task bean); BpmTaskTodoPageItemRespVO convert1(Task bean);
@Named("convertSuspendedToSuspensionState") @Named("convertSuspendedToSuspensionState")

View File

@ -230,7 +230,7 @@ public class FileConfigServiceImpl implements FileConfigService {
this.validateFileConfigExists(id); this.validateFileConfigExists(id);
// 上传文件 // 上传文件
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg"); return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg", "image/jpeg");
} }
@Override @Override

View File

@ -52,7 +52,7 @@ public class FileServiceImpl implements FileService {
// 上传到文件存储器 // 上传到文件存储器
FileClient client = fileConfigService.getMasterFileClient(); FileClient client = fileConfigService.getMasterFileClient();
Assert.notNull(client, "客户端(master) 不能为空"); Assert.notNull(client, "客户端(master) 不能为空");
String url = client.upload(content, path); String url = client.upload(content, path, type);
// 保存到数据库 // 保存到数据库
FileDO file = new FileDO(); FileDO file = new FileDO();

View File

@ -240,7 +240,7 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
// mock 获得 Client // mock 获得 Client
FileClient fileClient = mock(FileClient.class); FileClient fileClient = mock(FileClient.class);
when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient);
when(fileClient.upload(any(), any())).thenReturn("https://www.iocoder.cn"); when(fileClient.upload(any(), any(), any())).thenReturn("https://www.iocoder.cn");
// 调用并断言 // 调用并断言
assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id)); assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id));

View File

@ -79,7 +79,7 @@ public class FileServiceTest extends BaseDbUnitTest {
FileClient client = mock(FileClient.class); FileClient client = mock(FileClient.class);
when(fileConfigService.getMasterFileClient()).thenReturn(client); when(fileConfigService.getMasterFileClient()).thenReturn(client);
String url = randomString(); String url = randomString();
when(client.upload(same(content), same(path))).thenReturn(url); when(client.upload(same(content), same(path), same("image/jpeg"))).thenReturn(url);
when(client.getId()).thenReturn(10L); when(client.getId()).thenReturn(10L);
String name = "单测文件名"; String name = "单测文件名";
// 调用 // 调用

View File

@ -1,8 +1,8 @@
import { constantRoutes } from '@/router' import {constantRoutes} from '@/router'
import { getRouters } from '@/api/menu' import {getRouters} from '@/api/menu'
import Layout from '@/layout/index' import Layout from '@/layout/index'
import ParentView from '@/components/ParentView'; import ParentView from '@/components/ParentView';
import { toCamelCase } from "@/utils"; import {toCamelCase} from "@/utils";
const permission = { const permission = {
state: { state: {
@ -28,7 +28,7 @@ const permission = {
}, },
actions: { actions: {
// 生成路由 // 生成路由
GenerateRoutes({ commit }) { GenerateRoutes({commit}) {
return new Promise(resolve => { return new Promise(resolve => {
// 向后端请求路由数据(菜单) // 向后端请求路由数据(菜单)
getRouters().then(res => { getRouters().then(res => {
@ -36,7 +36,7 @@ const permission = {
const rdata = JSON.parse(JSON.stringify(res.data)) // 用于最后添加到 Router 中的数据 const rdata = JSON.parse(JSON.stringify(res.data)) // 用于最后添加到 Router 中的数据
const sidebarRoutes = filterAsyncRouter(sdata) const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true) const rewriteRoutes = filterAsyncRouter(rdata, false, true)
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
commit('SET_ROUTES', rewriteRoutes) commit('SET_ROUTES', rewriteRoutes)
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes)) commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
commit('SET_DEFAULT_ROUTES', sidebarRoutes) commit('SET_DEFAULT_ROUTES', sidebarRoutes)
@ -60,6 +60,11 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
} }
// 路由地址转首字母大写驼峰,作为路由名称,适配 keepAlive // 路由地址转首字母大写驼峰,作为路由名称,适配 keepAlive
route.name = toCamelCase(route.path, true) route.name = toCamelCase(route.path, true)
// 处理三级及以上菜单路由缓存问题将path名字赋值给name
if (route.path.indexOf("/") !== -1) {
var pathArr = route.path.split("/")
route.name = toCamelCase(pathArr[pathArr.length - 1], true)
}
route.hidden = !route.visible route.hidden = !route.visible
// 处理 component 属性 // 处理 component 属性
if (route.children) { // 父节点 if (route.children) { // 父节点
@ -86,10 +91,10 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
} }
function filterChildren(childrenMap, lastRouter = false) { function filterChildren(childrenMap, lastRouter = false) {
let children = [] var children = []
childrenMap.forEach((el, index) => { childrenMap.forEach((el, index) => {
if (el.children && el.children.length) { if (el.children && el.children.length) {
if (el.component === 'ParentView' && !lastRouter) { if (!el.component && !lastRouter) {
el.children.forEach(c => { el.children.forEach(c => {
c.path = el.path + '/' + c.path c.path = el.path + '/' + c.path
if (c.children && c.children.length) { if (c.children && c.children.length) {