Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
51b6ea28
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 3 年多
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51b6ea28
编写于
4月 01, 2021
作者:
C
Captain.B
提交者:
BugKing
4月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(项目文件更新): 修复项目文件更新时不能上传同名文件
上级
f7e0c650
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
24 addition
and
11 deletion
+24
-11
backend/src/main/java/io/metersphere/controller/ProjectController.java
...ain/java/io/metersphere/controller/ProjectController.java
+3
-3
backend/src/main/java/io/metersphere/service/FileService.java
...end/src/main/java/io/metersphere/service/FileService.java
+7
-0
backend/src/main/java/io/metersphere/service/ProjectService.java
.../src/main/java/io/metersphere/service/ProjectService.java
+13
-7
frontend/src/business/components/performance/test/components/ResourceFiles.vue
.../components/performance/test/components/ResourceFiles.vue
+1
-1
未找到文件。
backend/src/main/java/io/metersphere/controller/ProjectController.java
浏览文件 @
51b6ea28
...
...
@@ -91,9 +91,9 @@ public class ProjectController {
return
projectService
.
uploadFiles
(
projectId
,
files
);
}
@PostMapping
(
value
=
"/update/file/{
projectId}/{
fileId}"
,
consumes
=
{
"multipart/form-data"
})
public
FileMetadata
updateFile
(
@PathVariable
String
projectId
,
@PathVariable
String
fileId
,
@RequestPart
(
value
=
"file"
)
MultipartFile
file
)
{
return
projectService
.
updateFile
(
projectId
,
fileId
,
file
);
@PostMapping
(
value
=
"/update/file/{fileId}"
,
consumes
=
{
"multipart/form-data"
})
public
FileMetadata
updateFile
(
@PathVariable
String
fileId
,
@RequestPart
(
value
=
"file"
)
MultipartFile
file
)
{
return
projectService
.
updateFile
(
fileId
,
file
);
}
@GetMapping
(
value
=
"delete/file/{fileId}"
)
...
...
backend/src/main/java/io/metersphere/service/FileService.java
浏览文件 @
51b6ea28
...
...
@@ -43,6 +43,13 @@ public class FileService {
return
fileContentMapper
.
selectByPrimaryKey
(
fileId
);
}
public
void
setFileContent
(
String
fileId
,
byte
[]
content
)
{
FileContent
record
=
new
FileContent
();
record
.
setFile
(
content
);
record
.
setFileId
(
fileId
);
fileContentMapper
.
updateByPrimaryKeySelective
(
record
);
}
public
void
deleteFileByIds
(
List
<
String
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
;
...
...
backend/src/main/java/io/metersphere/service/ProjectService.java
浏览文件 @
51b6ea28
...
...
@@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -186,16 +187,21 @@ public class ProjectService {
return
result
;
}
public
FileMetadata
updateFile
(
String
projectId
,
String
fileId
,
MultipartFile
file
)
{
public
FileMetadata
updateFile
(
String
fileId
,
MultipartFile
file
)
{
QueryProjectFileRequest
request
=
new
QueryProjectFileRequest
();
request
.
setName
(
file
.
getOriginalFilename
());
if
(
CollectionUtils
.
isEmpty
(
fileService
.
getProjectFiles
(
projectId
,
request
)))
{
fileService
.
deleteFileById
(
fileId
);
return
fileService
.
saveFile
(
file
,
projectId
);
}
else
{
MSException
.
throwException
(
Translator
.
get
(
"project_file_already_exists"
));
}
return
null
;
FileMetadata
fileMetadata
=
fileService
.
getFileMetadataById
(
fileId
);
if
(
fileMetadata
!=
null
)
{
fileMetadata
.
setSize
(
file
.
getSize
());
fileMetadata
.
setUpdateTime
(
System
.
currentTimeMillis
());
fileService
.
updateFileMetadata
(
fileMetadata
);
try
{
fileService
.
setFileContent
(
fileId
,
file
.
getBytes
());
}
catch
(
IOException
e
)
{
MSException
.
throwException
(
e
);
}
}
return
fileMetadata
;
}
public
void
deleteFile
(
String
fileId
)
{
...
...
frontend/src/business/components/performance/test/components/ResourceFiles.vue
浏览文件 @
51b6ea28
...
...
@@ -167,7 +167,7 @@ export default {
}
let
formData
=
new
FormData
();
let
url
=
'
/project/update/file/
'
+
this
.
projectId
+
'
/
'
+
this
.
currentRow
.
id
let
url
=
'
/project/update/file/
'
+
'
/
'
+
this
.
currentRow
.
id
formData
.
append
(
"
file
"
,
file
);
let
options
=
{
method
:
'
POST
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录