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
6d2bc8ad
Commit
6d2bc8ad
authored
Apr 08, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
e812104a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
59 deletions
+110
-59
RandomUtil.java
.../cn/wisenergy/chnmuseum/party/common/util/RandomUtil.java
+96
-53
Asset.java
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
+2
-2
AssetController.java
...nergy/chnmuseum/party/web/controller/AssetController.java
+9
-1
FileUploadController.java
.../chnmuseum/party/web/controller/FileUploadController.java
+3
-3
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/common/util/RandomUtil.java
View file @
6d2bc8ad
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
util
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
util
;
import
java.util.Random
;
public
class
RandomUtil
{
public
class
RandomUtil
{
public
static
String
[]
arr
=
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"o"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"u"
,
"v"
,
"w"
,
"x"
,
"y"
,
"z"
,
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
/**
/**
* 创建指定数量的随机字符串
* 创建指定数量的随机字符串
*
*
...
@@ -33,12 +41,12 @@ public class RandomUtil {
...
@@ -33,12 +41,12 @@ public class RandomUtil {
}
}
public
static
String
createLetterRandom
(
int
length
)
{
public
static
String
createLetterRandom
(
int
length
)
{
String
retStr
=
null
;
StringBuilder
retStr
;
String
strTable
=
"1234567890abcdefghijklmnopqrstuvwxyz
"
;
String
strTable
=
"1234567890abcdef
"
;
int
len
=
strTable
.
length
();
int
len
=
strTable
.
length
();
boolean
bDone
=
true
;
boolean
bDone
=
true
;
do
{
do
{
retStr
=
""
;
retStr
=
new
StringBuilder
()
;
int
count
=
0
;
int
count
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
double
dblR
=
Math
.
random
()
*
len
;
double
dblR
=
Math
.
random
()
*
len
;
...
@@ -47,13 +55,48 @@ public class RandomUtil {
...
@@ -47,13 +55,48 @@ public class RandomUtil {
if
((
'0'
<=
c
)
&&
(
c
<=
'9'
))
{
if
((
'0'
<=
c
)
&&
(
c
<=
'9'
))
{
count
++;
count
++;
}
}
retStr
+=
strTable
.
charAt
(
intR
);
retStr
.
append
(
strTable
.
charAt
(
intR
)
);
}
}
if
(
count
>=
2
)
{
if
(
count
>=
2
)
{
bDone
=
false
;
bDone
=
false
;
}
}
}
while
(
bDone
);
}
while
(
bDone
);
return
retStr
;
return
retStr
.
toString
();
}
public
static
String
createCipher
(
int
length
)
{
StringBuilder
retStr
;
String
strTable
=
"1234567890abcdef"
;
int
len
=
strTable
.
length
();
boolean
bDone
=
true
;
do
{
retStr
=
new
StringBuilder
();
int
count
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
double
dblR
=
Math
.
random
()
*
len
;
int
intR
=
(
int
)
Math
.
floor
(
dblR
);
char
c
=
strTable
.
charAt
(
intR
);
if
((
'0'
<=
c
)
&&
(
c
<=
'9'
))
{
count
++;
}
retStr
.
append
(
strTable
.
charAt
(
intR
));
}
if
(
count
>=
2
)
{
bDone
=
false
;
}
}
while
(
bDone
);
return
retStr
.
toString
();
}
public
static
String
getRandom
(
Integer
len
)
{
String
nums
=
""
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Random
r
=
new
Random
();
int
index
=
r
.
nextInt
(
arr
.
length
-
1
);
String
str
=
arr
[
index
];
nums
=
nums
+
str
;
}
return
nums
;
}
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
View file @
6d2bc8ad
...
@@ -115,12 +115,12 @@ public class Asset implements Serializable {
...
@@ -115,12 +115,12 @@ public class Asset implements Serializable {
return
false
;
return
false
;
}
}
Asset
asset
=
(
Asset
)
o
;
Asset
asset
=
(
Asset
)
o
;
return
md5
.
equals
(
asset
.
md5
);
return
Objects
.
equals
(
getMd5
(),
asset
.
getMd5
()
);
}
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
Objects
.
hash
(
md5
);
return
Objects
.
hash
(
getMd5
()
);
}
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
6d2bc8ad
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil
;
import
cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil
;
...
@@ -46,6 +47,8 @@ import java.util.Set;
...
@@ -46,6 +47,8 @@ import java.util.Set;
@Api
(
tags
=
{
"文件资产操作接口"
})
@Api
(
tags
=
{
"文件资产操作接口"
})
public
class
AssetController
extends
BaseController
{
public
class
AssetController
extends
BaseController
{
private
static
final
String
BASE_STRING
=
"1234567890abcdef"
;
@Resource
@Resource
private
AssetService
assetService
;
private
AssetService
assetService
;
...
@@ -153,14 +156,19 @@ public class AssetController extends BaseController {
...
@@ -153,14 +156,19 @@ public class AssetController extends BaseController {
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
String
cipher
=
RandomUtil
.
randomString
(
BASE_STRING
,
16
);
for
(
final
Asset
asset
:
assetList
)
{
for
(
final
Asset
asset
:
assetList
)
{
final
String
fileUrl
=
asset
.
getFileUrl
();
final
String
fileUrl
=
asset
.
getFileUrl
();
ByteOutputStream
byteOutputStream
=
new
ByteOutputStream
();
ByteOutputStream
byteOutputStream
=
new
ByteOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
map
.
put
(
fileName
,
byteOutputStream
.
newInputStream
(
));
map
.
put
(
fileName
,
VideoEncryptUtil
.
encrypt
(
byteOutputStream
.
newInputStream
(),
cipher
));
}
}
map
.
put
(
"23432423432.key"
,
null
);
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/FileUploadController.java
View file @
6d2bc8ad
...
@@ -434,10 +434,10 @@ public class FileUploadController extends BaseController {
...
@@ -434,10 +434,10 @@ public class FileUploadController extends BaseController {
final
FileInfo
fileInfo
=
FastDFSUtils
.
getFileInfo
(
fileUrl
);
final
FileInfo
fileInfo
=
FastDFSUtils
.
getFileInfo
(
fileUrl
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
String
md5
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
();
String
md5
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
();
final
Asset
one
=
this
.
assetService
.
getOne
(
Wrappers
.<
Asset
>
lambdaQuery
().
eq
(
Asset:
:
getMd5
,
md5
));
final
List
<
Asset
>
list
=
this
.
assetService
.
list
(
Wrappers
.<
Asset
>
lambdaQuery
().
eq
(
Asset:
:
getMd5
,
md5
));
if
(
one
!=
null
)
{
if
(
!
list
.
isEmpty
()
)
{
FastDFSUtils
.
deleteFile
(
fileUrl
);
FastDFSUtils
.
deleteFile
(
fileUrl
);
fileList
.
add
(
one
);
fileList
.
add
(
list
.
get
(
0
)
);
handleResult
.
setFileUrl
(
fileUrl
);
handleResult
.
setFileUrl
(
fileUrl
);
handleResult
.
setFileName
(
originalFilename
);
handleResult
.
setFileName
(
originalFilename
);
...
...
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