Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
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
085f1561
Commit
085f1561
authored
Apr 08, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
0a0c76f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
65 deletions
+18
-65
AssetController.java
...nergy/chnmuseum/party/web/controller/AssetController.java
+15
-62
FileUploadController.java
.../chnmuseum/party/web/controller/FileUploadController.java
+2
-2
BaseController.java
...y/chnmuseum/party/web/controller/base/BaseController.java
+1
-1
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
085f1561
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.util.RSAUtils
;
import
cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.TBoxOperation
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.service.AssetService
;
import
cn.wisenergy.chnmuseum.party.service.TBoxOperationService
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.github.tobato.fastdfs.domain.fdfs.MetaData
;
import
io.swagger.annotations.Api
;
...
...
@@ -29,6 +35,7 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -53,6 +60,9 @@ public class AssetController extends BaseController {
@Resource
private
AssetService
assetService
;
@Resource
private
TBoxOperationService
tBoxOperationService
;
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
...
...
@@ -93,67 +103,10 @@ public class AssetController extends BaseController {
@ApiImplicitParam
(
name
=
"idList"
,
value
=
"视频文件标识ID集合"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
@PostMapping
(
"/download"
)
//
@RequiresAuthentication
@RequiresAuthentication
public
void
download
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/octet-stream"
);
//保证下载时文件名为指定文件名,避免中文文件名乱码
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\""
+
URLEncoder
.
encode
(
"1.zip"
,
"UTF-8"
)
+
"\""
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
InputStream
[]
inputStreams
=
new
InputStream
[
idList
.
size
()];
final
String
[]
paths
=
new
String
[
idList
.
size
()];
for
(
int
i
=
0
;
i
<
assetList
.
size
();
i
++)
{
final
Asset
asset
=
assetList
.
get
(
i
);
final
String
fileUrl
=
asset
.
getFileUrl
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
inputStreams
[
i
]
=
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
String
md5
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
();
paths
[
i
]
=
md5
+
".chnmuseum"
;
}
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ZipUtil
.
zip
(
outputStream
,
paths
,
inputStreams
);
}
@ApiOperation
(
value
=
"视频文件汇出"
,
notes
=
"视频文件汇出"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"idList"
,
value
=
"视频文件标识ID集合"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
@GetMapping
(
"/download1"
)
//@RequiresAuthentication
public
void
download1
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/octet-stream"
);
//保证下载时文件名为指定文件名,避免中文文件名乱码
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\""
+
URLEncoder
.
encode
(
"1.zip"
,
"UTF-8"
)
+
"\""
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
InputStream
[]
inputStreams
=
new
InputStream
[
idList
.
size
()];
final
String
[]
paths
=
new
String
[
idList
.
size
()];
for
(
int
i
=
0
;
i
<
assetList
.
size
();
i
++)
{
final
Asset
asset
=
assetList
.
get
(
i
);
final
String
fileUrl
=
asset
.
getFileUrl
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
inputStreams
[
i
]
=
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
String
md5
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
();
paths
[
i
]
=
md5
+
".chnmuseum"
;
}
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ZipUtil
.
zip
(
outputStream
,
paths
,
inputStreams
);
}
@ApiOperation
(
value
=
"视频文件汇出"
,
notes
=
"视频文件汇出"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"idList"
,
value
=
"视频文件标识ID集合"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
@GetMapping
(
"/download2"
)
//@RequiresAuthentication
public
void
download2
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/octet-stream"
);
//保证下载时文件名为指定文件名,避免中文文件名乱码
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\""
+
URLEncoder
.
encode
(
"1.zip"
,
"UTF-8"
)
+
"\""
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\""
+
URLEncoder
.
encode
(
"video.zip"
,
"UTF-8"
)
+
"\""
);
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
...
...
@@ -166,9 +119,9 @@ public class AssetController extends BaseController {
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
map
.
put
(
fileName
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
cipher
));
}
map
.
put
(
"23432423432.key"
,
null
);
final
TUser
user
=
getcurUser
(
);
final
TBoxOperation
tBoxOperation
=
this
.
tBoxOperationService
.
getOne
(
Wrappers
.<
TBoxOperation
>
lambdaQuery
().
eq
(
TBoxOperation:
:
getOrganId
,
user
.
getOrgId
()));
map
.
put
(
"cipher.txt"
,
IoUtil
.
toStream
(
RSAUtils
.
encrypt
(
cipher
,
tBoxOperation
.
getPublicKey
()),
StandardCharsets
.
UTF_8
));
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/FileUploadController.java
View file @
085f1561
...
...
@@ -74,8 +74,8 @@ public class FileUploadController extends BaseController {
@PostMapping
(
value
=
"/datum/upload"
,
headers
=
"content-type=multipart/form-data"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
@ApiOperation
(
value
=
"展板资料上传"
,
notes
=
"展板资料上传"
)
public
Map
<
String
,
Object
>
uploadFile
(
@RequestPart
(
value
=
"file"
,
required
=
false
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
if
(
files
==
null
||
files
.
length
==
0
)
{
return
getFailResult
(
"没有文件可供上传"
);
}
int
successCount
=
0
;
int
failureCount
=
0
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/base/BaseController.java
View file @
085f1561
...
...
@@ -143,7 +143,7 @@ public class BaseController implements Serializable {
*/
protected
Map
<
String
,
Object
>
getFailResult
(
String
msg
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
RESULT_INFO_ENUM
.
RESULT_CODE
.
getKey
(),
RESPONSE_CODE_ENUM
.
SERVER_ERROR
.
getResultCode
());
map
.
put
(
RESULT_INFO_ENUM
.
RESULT_CODE
.
getKey
(),
RESPONSE_CODE_ENUM
.
PARAM_NOT_VALID
.
getResultCode
());
map
.
put
(
RESULT_INFO_ENUM
.
RESULT_MSG
.
getKey
(),
msg
);
return
map
;
}
...
...
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