Commit b100d41da16512e9328fffba330f4c953bf3cb8e

Authored by xingyu
2 parents 3cfa787e feb09900

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

Showing 16 changed files with 29 additions and 21 deletions
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/FileClient.java
... ... @@ -22,7 +22,7 @@ public interface FileClient {
22 22 * @return 完整路径,即 HTTP 访问地址
23 23 * @throws Exception 上传文件时,抛出 Exception 异常
24 24 */
25   - String upload(byte[] content, String path) throws Exception;
  25 + String upload(byte[] content, String path, String type) throws Exception;
26 26  
27 27 /**
28 28 * 删除文件
... ...
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/db/DBFileClient.java
... ... @@ -21,7 +21,7 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> {
21 21 }
22 22  
23 23 @Override
24   - public String upload(byte[] content, String path) {
  24 + public String upload(byte[] content, String path, String type) {
25 25 getDao().insert(getId(), path, content);
26 26 // 拼接返回路径
27 27 return super.formatFileUrl(config.getDomain(), path);
... ...
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClient.java
... ... @@ -38,7 +38,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
38 38 }
39 39  
40 40 @Override
41   - public String upload(byte[] content, String path) {
  41 + public String upload(byte[] content, String path, String type) {
42 42 // 执行写入
43 43 String filePath = getFilePath(path);
44 44 String fileName = FileUtil.getName(filePath);
... ...
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClient.java
... ... @@ -25,7 +25,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
25 25 }
26 26  
27 27 @Override
28   - public String upload(byte[] content, String path) {
  28 + public String upload(byte[] content, String path, String type) {
29 29 // 执行写入
30 30 String filePath = getFilePath(path);
31 31 FileUtil.writeBytes(content, filePath);
... ...
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClient.java
... ... @@ -82,10 +82,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
82 82 }
83 83  
84 84 @Override
85   - public String upload(byte[] content, String path) throws Exception {
  85 + public String upload(byte[] content, String path, String type) throws Exception {
86 86 // 执行上传
87 87 client.putObject(PutObjectArgs.builder()
88 88 .bucket(config.getBucket()) // bucket 必须传递
  89 + .contentType(type)
89 90 .object(path) // 相对路径作为 key
90 91 .stream(new ByteArrayInputStream(content), content.length, -1) // 文件内容
91 92 .build());
... ...
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClient.java
... ... @@ -31,7 +31,7 @@ public class SftpFileClient extends AbstractFileClient<SftpFileClientConfig> {
31 31 }
32 32  
33 33 @Override
34   - public String upload(byte[] content, String path) {
  34 + public String upload(byte[] content, String path, String type) {
35 35 // 执行写入
36 36 String filePath = getFilePath(path);
37 37 File file = FileUtils.createTempFile(content);
... ...
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientTest.java
... ... @@ -25,7 +25,7 @@ public class FtpFileClientTest {
25 25 // 上传文件
26 26 String path = IdUtil.fastSimpleUUID() + ".jpg";
27 27 byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
28   - String fullPath = client.upload(content, path);
  28 + String fullPath = client.upload(content, path, "image/jpeg");
29 29 System.out.println("访问地址:" + fullPath);
30 30 if (false) {
31 31 byte[] bytes = client.getContent(path);
... ...
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientTest.java
... ... @@ -19,7 +19,7 @@ public class LocalFileClientTest {
19 19 // 上传文件
20 20 String path = IdUtil.fastSimpleUUID() + ".jpg";
21 21 byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
22   - String fullPath = client.upload(content, path);
  22 + String fullPath = client.upload(content, path, "image/jpeg");
23 23 System.out.println("访问地址:" + fullPath);
24 24 client.delete(path);
25 25 }
... ...
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java
... ... @@ -101,7 +101,7 @@ public class S3FileClientTest {
101 101 // 上传文件
102 102 String path = IdUtil.fastSimpleUUID() + ".jpg";
103 103 byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
104   - String fullPath = client.upload(content, path);
  104 + String fullPath = client.upload(content, path, "image/jpeg");
105 105 System.out.println("访问地址:" + fullPath);
106 106 // 读取文件
107 107 if (true) {
... ...
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientTest.java
... ... @@ -23,7 +23,7 @@ public class SftpFileClientTest {
23 23 // 上传文件
24 24 String path = IdUtil.fastSimpleUUID() + ".jpg";
25 25 byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
26   - String fullPath = client.upload(content, path);
  26 + String fullPath = client.upload(content, path, "image/jpeg");
27 27 System.out.println("访问地址:" + fullPath);
28 28 if (false) {
29 29 byte[] bytes = client.getContent(path);
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
... ... @@ -77,6 +77,8 @@ public interface BpmTaskConvert {
77 77 }
78 78  
79 79 @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")
  80 + @Mapping(target = "claimTime", expression = "java(bean.getClaimTime()==null?null: LocalDateTime.ofInstant(bean.getClaimTime().toInstant(),ZoneId.systemDefault()))")
  81 + @Mapping(target = "createTime", expression = "java(bean.getCreateTime()==null?null:LocalDateTime.ofInstant(bean.getCreateTime().toInstant(),ZoneId.systemDefault()))")
80 82 BpmTaskTodoPageItemRespVO convert1(Task bean);
81 83  
82 84 @Named("convertSuspendedToSuspensionState")
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
... ... @@ -230,7 +230,7 @@ public class FileConfigServiceImpl implements FileConfigService {
230 230 this.validateFileConfigExists(id);
231 231 // 上传文件
232 232 byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
233   - return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg");
  233 + return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg", "image/jpeg");
234 234 }
235 235  
236 236 @Override
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
... ... @@ -52,7 +52,7 @@ public class FileServiceImpl implements FileService {
52 52 // 上传到文件存储器
53 53 FileClient client = fileConfigService.getMasterFileClient();
54 54 Assert.notNull(client, "客户端(master) 不能为空");
55   - String url = client.upload(content, path);
  55 + String url = client.upload(content, path, type);
56 56  
57 57 // 保存到数据库
58 58 FileDO file = new FileDO();
... ...
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
... ... @@ -240,7 +240,7 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
240 240 // mock 获得 Client
241 241 FileClient fileClient = mock(FileClient.class);
242 242 when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient);
243   - when(fileClient.upload(any(), any())).thenReturn("https://www.iocoder.cn");
  243 + when(fileClient.upload(any(), any(), any())).thenReturn("https://www.iocoder.cn");
244 244  
245 245 // 调用,并断言
246 246 assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id));
... ...
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java
... ... @@ -79,7 +79,7 @@ public class FileServiceTest extends BaseDbUnitTest {
79 79 FileClient client = mock(FileClient.class);
80 80 when(fileConfigService.getMasterFileClient()).thenReturn(client);
81 81 String url = randomString();
82   - when(client.upload(same(content), same(path))).thenReturn(url);
  82 + when(client.upload(same(content), same(path), same("image/jpeg"))).thenReturn(url);
83 83 when(client.getId()).thenReturn(10L);
84 84 String name = "单测文件名";
85 85 // 调用
... ...
yudao-ui-admin/src/store/modules/permission.js
1   -import { constantRoutes } from '@/router'
2   -import { getRouters } from '@/api/menu'
  1 +import {constantRoutes} from '@/router'
  2 +import {getRouters} from '@/api/menu'
3 3 import Layout from '@/layout/index'
4 4 import ParentView from '@/components/ParentView';
5   -import { toCamelCase } from "@/utils";
  5 +import {toCamelCase} from "@/utils";
6 6  
7 7 const permission = {
8 8 state: {
... ... @@ -28,7 +28,7 @@ const permission = {
28 28 },
29 29 actions: {
30 30 // 生成路由
31   - GenerateRoutes({ commit }) {
  31 + GenerateRoutes({commit}) {
32 32 return new Promise(resolve => {
33 33 // 向后端请求路由数据(菜单)
34 34 getRouters().then(res => {
... ... @@ -36,7 +36,7 @@ const permission = {
36 36 const rdata = JSON.parse(JSON.stringify(res.data)) // 用于最后添加到 Router 中的数据
37 37 const sidebarRoutes = filterAsyncRouter(sdata)
38 38 const rewriteRoutes = filterAsyncRouter(rdata, false, true)
39   - rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
  39 + rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
40 40 commit('SET_ROUTES', rewriteRoutes)
41 41 commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
42 42 commit('SET_DEFAULT_ROUTES', sidebarRoutes)
... ... @@ -60,6 +60,11 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
60 60 }
61 61 // 路由地址转首字母大写驼峰,作为路由名称,适配 keepAlive
62 62 route.name = toCamelCase(route.path, true)
  63 + // 处理三级及以上菜单路由缓存问题,将path名字赋值给name
  64 + if (route.path.indexOf("/") !== -1) {
  65 + var pathArr = route.path.split("/")
  66 + route.name = toCamelCase(pathArr[pathArr.length - 1], true)
  67 + }
63 68 route.hidden = !route.visible
64 69 // 处理 component 属性
65 70 if (route.children) { // 父节点
... ... @@ -86,10 +91,10 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
86 91 }
87 92  
88 93 function filterChildren(childrenMap, lastRouter = false) {
89   - let children = []
  94 + var children = []
90 95 childrenMap.forEach((el, index) => {
91 96 if (el.children && el.children.length) {
92   - if (el.component === 'ParentView' && !lastRouter) {
  97 + if (!el.component && !lastRouter) {
93 98 el.children.forEach(c => {
94 99 c.path = el.path + '/' + c.path
95 100 if (c.children && c.children.length) {
... ...