Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liqin
chnmuseum-party
Commits
2def731a
Commit
2def731a
authored
Mar 30, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文件上传返回值
parent
739d901e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
FileUploadController.java
.../chnmuseum/party/web/controller/FileUploadController.java
+14
-14
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/FileUploadController.java
View file @
2def731a
...
...
@@ -105,7 +105,7 @@ public class FileUploadController {
@ApiOperation
(
value
=
"资料上传"
,
notes
=
"资料上传"
)
public
ResponseEntity
<
BatchUploadResVO
>
uploadFile
(
@RequestPart
(
value
=
"file"
,
required
=
false
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
}
int
successCount
=
0
;
int
failureCount
=
0
;
...
...
@@ -152,7 +152,7 @@ public class FileUploadController {
batchUploadResVO
.
setTotal
(
files
.
length
);
batchUploadResVO
.
setHandleList
(
handleList
);
batchUploadResVO
.
setUrlList
(
videoUrlList
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
batchUploadResVO
);
return
ResponseEntity
.
ok
(
batchUploadResVO
);
}
@PostMapping
(
value
=
"/image/upload"
,
headers
=
"content-type=multipart/form-data"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
...
...
@@ -160,16 +160,16 @@ public class FileUploadController {
@ApiOperation
(
value
=
"单图片上传"
,
notes
=
"单图片上传"
)
public
ResponseEntity
<
ImageUploadResult
>
uploadImage
(
@RequestParam
(
value
=
"file"
)
MultipartFile
uploadFile
)
throws
Exception
{
if
(
uploadFile
==
null
||
uploadFile
.
getSize
()
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
}
String
fileName
=
uploadFile
.
getOriginalFilename
();
String
extension
=
FilenameUtils
.
getExtension
(
fileName
);
if
(
StringUtils
.
isBlank
(
extension
))
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"文件格式不支持"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"文件格式不支持"
);
}
boolean
anyMatch
=
Arrays
.
stream
(
IMAGE_TYPE
).
anyMatch
(
s
->
Objects
.
equals
(
s
,
extension
.
toUpperCase
()));
if
(!
anyMatch
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"文件格式不支持"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"文件格式不支持"
);
}
String
url
=
FastDFSUtils
.
uploadFile
(
uploadFile
.
getInputStream
(),
uploadFile
.
getSize
(),
fileName
);
...
...
@@ -178,7 +178,7 @@ public class FileUploadController {
imageUploadResult
.
setFileExtName
(
extension
);
imageUploadResult
.
setFileSize
(
uploadFile
.
getSize
());
imageUploadResult
.
setUrl
(
url
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
imageUploadResult
);
return
ResponseEntity
.
ok
(
imageUploadResult
);
}
@ApiImplicitParams
({
...
...
@@ -188,12 +188,12 @@ public class FileUploadController {
@RequiresPermissions
(
"audio:upload"
)
@ApiOperation
(
value
=
"多音频上传"
,
notes
=
"多音频上传"
)
public
ResponseEntity
<
BatchUploadResVO
>
uploadAudio
(
@RequestPart
(
value
=
"file"
,
required
=
false
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
if
(
files
==
null
||
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
}
final
boolean
existChineseAudio
=
Arrays
.
stream
(
files
).
anyMatch
(
s
->
Objects
.
requireNonNull
(
s
.
getOriginalFilename
()).
contains
(
"汉语"
));
if
(!
existChineseAudio
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"必须包含汉语音频"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"必须包含汉语音频"
);
}
int
successCount
=
0
;
...
...
@@ -241,7 +241,7 @@ public class FileUploadController {
batchUploadResVO
.
setTotal
(
files
.
length
);
batchUploadResVO
.
setHandleList
(
handleList
);
batchUploadResVO
.
setUrlList
(
videoUrlList
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
batchUploadResVO
);
return
ResponseEntity
.
ok
(
batchUploadResVO
);
}
@ApiImplicitParams
({
...
...
@@ -250,13 +250,13 @@ public class FileUploadController {
@PostMapping
(
value
=
"/video/upload"
,
headers
=
"content-type=multipart/form-data"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
@RequiresPermissions
(
"video:upload"
)
@ApiOperation
(
value
=
"多视频上传"
,
notes
=
"多视频上传"
)
public
ResponseEntity
<
BatchUploadResVO
>
uploadVideo
(
@RequestPart
(
value
=
"file"
,
required
=
fals
e
)
MultipartFile
[]
files
)
throws
IOException
{
public
ResponseEntity
<
BatchUploadResVO
>
uploadVideo
(
@RequestPart
(
value
=
"file"
,
required
=
tru
e
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
==
null
||
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
}
final
boolean
matchChinese
=
Arrays
.
stream
(
files
).
anyMatch
(
s
->
Objects
.
requireNonNull
(
s
.
getOriginalFilename
()).
contains
(
"汉语"
));
if
(!
matchChinese
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS
_ERROR
.
getResultCode
(),
"必须包含汉语视频"
);
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER
_ERROR
.
getResultCode
(),
"必须包含汉语视频"
);
}
int
successCount
=
0
;
...
...
@@ -304,7 +304,7 @@ public class FileUploadController {
batchUploadResVO
.
setTotal
(
files
.
length
);
batchUploadResVO
.
setHandleList
(
handleList
);
batchUploadResVO
.
setUrlList
(
videoUrlList
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
batchUploadResVO
);
return
ResponseEntity
.
ok
(
batchUploadResVO
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment