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
2580bdfa
Commit
2580bdfa
authored
Apr 16, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
a7f88b77
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
30 deletions
+44
-30
AssetMapper.java
...java/cn/wisenergy/chnmuseum/party/mapper/AssetMapper.java
+10
-0
AssetService.java
...va/cn/wisenergy/chnmuseum/party/service/AssetService.java
+5
-0
AssetServiceImpl.java
...energy/chnmuseum/party/service/impl/AssetServiceImpl.java
+7
-0
AssetController.java
...nergy/chnmuseum/party/web/controller/AssetController.java
+22
-30
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/mapper/AssetMapper.java
View file @
2580bdfa
package
cn
.
wisenergy
.
chnmuseum
.
party
.
mapper
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.TBoxOperation
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* <p>
* 视频 Mapper 接口
...
...
@@ -31,4 +34,11 @@ public interface AssetMapper extends BaseMapper<Asset> {
"</script>"
)
Page
<
Asset
>
selectPageByConditions
(
Page
<
Object
>
page
,
String
videoContentCatId
,
String
videoContentCopyrightOwnerId
);
@Select
(
"<script>"
+
"SELECT b.*, o.code as organ_code, o.`name` as organ_name "
+
"FROM t_box_operation b, t_organ o "
+
"where b.organ_id = o.id and b.private_key <> NULL"
+
"</script>"
)
List
<
TBoxOperation
>
selectBoxListByOrgan
();
}
src/main/java/cn/wisenergy/chnmuseum/party/service/AssetService.java
View file @
2580bdfa
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.TBoxOperation
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* <p>
* 视频 服务类
...
...
@@ -16,4 +19,6 @@ public interface AssetService extends IService<Asset> {
Page
<
Asset
>
pageByConditions
(
Page
<
Object
>
page
,
String
videoContentCatId
,
String
videoContentCopyrightOwnerId
);
List
<
TBoxOperation
>
listBoxByOrgan
();
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/AssetServiceImpl.java
View file @
2580bdfa
...
...
@@ -2,12 +2,14 @@ package cn.wisenergy.chnmuseum.party.service.impl;
import
cn.wisenergy.chnmuseum.party.mapper.AssetMapper
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.TBoxOperation
;
import
cn.wisenergy.chnmuseum.party.service.AssetService
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* <p>
...
...
@@ -28,4 +30,9 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
return
assetMapper
.
selectPageByConditions
(
page
,
videoContentCatId
,
videoContentCopyrightOwnerId
);
}
@Override
public
List
<
TBoxOperation
>
listBoxByOrgan
()
{
return
assetMapper
.
selectBoxListByOrgan
();
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
2580bdfa
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.log.MethodLog
;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
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.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.extension.plugins.pagination.Page
;
import
com.github.tobato.fastdfs.domain.fdfs.MetaData
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -33,10 +35,10 @@ 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
;
import
java.util.Set
;
/**
* <pre>
...
...
@@ -110,18 +112,14 @@ public class AssetController extends BaseController {
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
());
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
for
(
final
Asset
asset
:
assetList
)
{
final
String
fileUrlCrypto
=
asset
.
getFileUrlCrypto
();
for
(
Asset
asset
:
assetList
)
{
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrlCrypto
,
byteOutputStream
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrlCrypto
);
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
()),
VideoEncryptUtil
.
cipher
));
FastDFSUtils
.
downloadFile
(
asset
.
getFileUrlCrypto
(),
byteOutputStream
);
map
.
put
(
asset
.
getMd5
()
+
".chnmuseum"
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
));
}
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
ZipUtil
.
zip
(
outputStream
,
paths
,
ins
);
ZipUtil
.
zip
(
response
.
getOutputStream
()
,
paths
,
ins
);
}
@ApiOperation
(
value
=
"视频文件汇出GET"
,
notes
=
"视频文件汇出GET"
)
...
...
@@ -133,39 +131,33 @@ public class AssetController extends BaseController {
@MethodLog
(
operModule
=
OperModule
.
VIDEOREMIT
,
operType
=
OperType
.
VIDEO_EXPORT
)
public
void
downloadByGet
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"
file
.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
());
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
for
(
final
Asset
asset
:
assetList
)
{
final
String
fileUrlCrypto
=
asset
.
getFileUrlCrypto
();
for
(
Asset
asset
:
assetList
)
{
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrlCrypto
,
byteOutputStream
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrlCrypto
);
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
()),
VideoEncryptUtil
.
cipher
));
FastDFSUtils
.
downloadFile
(
asset
.
getFileUrlCrypto
(),
byteOutputStream
);
map
.
put
(
asset
.
getMd5
()
+
".chnmuseum"
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
));
}
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
ZipUtil
.
zip
(
outputStream
,
paths
,
ins
);
ZipUtil
.
zip
(
response
.
getOutputStream
()
,
paths
,
ins
);
}
@ApiOperation
(
value
=
"视频文件汇出GET"
,
notes
=
"视频文件汇出GET"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"idList"
,
value
=
"视频文件标识ID集合"
,
dataType
=
"String"
,
paramType
=
"query"
)
})
@GetMapping
(
"/downloadCipher"
)
@ApiOperation
(
value
=
"导出所有机顶盒的文件加密密钥"
,
notes
=
"导出所有机顶盒的文件加密密钥"
)
@PostMapping
(
"/downloadCipher"
)
@RequiresAuthentication
@MethodLog
(
operModule
=
OperModule
.
VIDEOREMIT
,
operType
=
OperType
.
VIDEO_EXPORT
)
public
void
downloadCipher
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
public
void
downloadCipher
(
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"file.zip"
,
"UTF-8"
));
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
// final TBoxOperation tBoxOperation = this.tBoxOperationService.getOne(Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getOrganId, user.getOrgId()));
// map.put("cipher.txt", IoUtil.toStream(RSAUtils.encrypt(VideoEncryptUtil.cipher, tBoxOperation.getPublicKey()), StandardCharsets.UTF_8));
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"cipher.zip"
,
"UTF-8"
));
final
List
<
TBoxOperation
>
tBoxOperationList
=
assetService
.
listBoxByOrgan
();
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
tBoxOperationList
.
size
());
for
(
TBoxOperation
tBoxOperation
:
tBoxOperationList
)
{
map
.
put
(
tBoxOperation
.
getOrganName
()
+
".cipher"
,
IoUtil
.
toStream
(
RSAUtils
.
encrypt
(
VideoEncryptUtil
.
cipher
,
tBoxOperation
.
getPublicKey
()),
StandardCharsets
.
UTF_8
));
}
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
...
...
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