Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
lei
fzm-joying
Commits
a9a3e640
Commit
a9a3e640
authored
Jul 15, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改oss签名的过期时间
优化部分代码
parent
a6c5c0d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
7 deletions
+28
-7
Nft.java
joying-common/src/main/java/com/fzm/common/entity/Nft.java
+3
-0
NftServiceImpl.java
...main/java/com/fzm/common/service/impl/NftServiceImpl.java
+9
-0
OssUtil.java
...ng-common/src/main/java/com/fzm/common/utils/OssUtil.java
+1
-1
NftController.java
...rc/main/java/com/fzm/portal/controller/NftController.java
+15
-6
No files found.
joying-common/src/main/java/com/fzm/common/entity/Nft.java
View file @
a9a3e640
...
@@ -27,6 +27,9 @@ public class Nft extends BaseEntity {
...
@@ -27,6 +27,9 @@ public class Nft extends BaseEntity {
@ApiModelProperty
(
"名称"
)
@ApiModelProperty
(
"名称"
)
private
String
name
;
private
String
name
;
@ApiModelProperty
(
"封面"
)
private
String
cover
;
@ApiModelProperty
(
"作者"
)
@ApiModelProperty
(
"作者"
)
private
String
author
;
private
String
author
;
...
...
joying-common/src/main/java/com/fzm/common/service/impl/NftServiceImpl.java
View file @
a9a3e640
...
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Array
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -184,6 +185,14 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
...
@@ -184,6 +185,14 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
if
(
CollectionUtil
.
isEmpty
(
set
))
{
if
(
CollectionUtil
.
isEmpty
(
set
))
{
// redis里为空,再从mysql里查一次
// redis里为空,再从mysql里查一次
list
=
collectionService
.
getNftIdListByUserId
(
userId
);
list
=
collectionService
.
getNftIdListByUserId
(
userId
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
// 往redis里保存一遍
String
[]
array
=
new
String
[
list
.
size
()];
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
array
[
i
]
=
list
.
get
(
i
).
toString
();
}
redisUtil
.
sAdd
(
RedisConstant
.
COLLECTION_USER_PREFIX
+
userId
,
array
);
}
}
else
{
}
else
{
list
=
set
.
stream
().
map
(
Integer:
:
valueOf
).
collect
(
Collectors
.
toList
());
list
=
set
.
stream
().
map
(
Integer:
:
valueOf
).
collect
(
Collectors
.
toList
());
}
}
...
...
joying-common/src/main/java/com/fzm/common/utils/OssUtil.java
View file @
a9a3e640
...
@@ -160,7 +160,7 @@ public class OssUtil {
...
@@ -160,7 +160,7 @@ public class OssUtil {
// 创建OSSClient实例。
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessId
,
accessKey
);
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessId
,
accessKey
);
try
{
try
{
long
expireTime
=
3
0
;
long
expireTime
=
12
0
;
long
expireEndTime
=
System
.
currentTimeMillis
()
+
expireTime
*
1000
;
long
expireEndTime
=
System
.
currentTimeMillis
()
+
expireTime
*
1000
;
Date
expiration
=
new
Date
(
expireEndTime
);
Date
expiration
=
new
Date
(
expireEndTime
);
// PostObject请求最大可支持的文件大小为5 GB,即CONTENT_LENGTH_RANGE为5*1024*1024*1024。
// PostObject请求最大可支持的文件大小为5 GB,即CONTENT_LENGTH_RANGE为5*1024*1024*1024。
...
...
joying-portal/src/main/java/com/fzm/portal/controller/NftController.java
View file @
a9a3e640
...
@@ -22,6 +22,7 @@ import io.swagger.annotations.Api;
...
@@ -22,6 +22,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -74,10 +75,22 @@ public class NftController {
...
@@ -74,10 +75,22 @@ public class NftController {
@ApiParam
(
value
=
"作者"
,
required
=
true
)
String
author
,
@ApiParam
(
value
=
"作者"
,
required
=
true
)
String
author
,
@ApiParam
(
value
=
"主题"
,
required
=
true
)
String
theme
,
@ApiParam
(
value
=
"主题"
,
required
=
true
)
String
theme
,
@ApiParam
(
value
=
"简介"
,
required
=
true
)
String
synopsis
,
@ApiParam
(
value
=
"简介"
,
required
=
true
)
String
synopsis
,
@ApiParam
(
value
=
"文件"
,
required
=
false
)
MultipartFile
file
,
@ApiParam
(
value
=
"文件"
)
MultipartFile
file
,
@ApiParam
(
value
=
"文件hash"
,
required
=
true
)
String
fileHash
,
@ApiParam
(
value
=
"文件hash"
,
required
=
true
)
String
fileHash
,
@ApiParam
(
value
=
"平台存档 0-不存档 1-加密存档"
,
required
=
true
)
Integer
isArchives
,
@ApiParam
(
value
=
"平台存档 0-不存档 1-加密存档"
,
required
=
true
)
Integer
isArchives
,
@ApiParam
(
value
=
"授权阅读 0-不需要授权 1-需要授权"
,
required
=
false
)
Integer
isGrant
)
throws
IOException
{
@ApiParam
(
value
=
"授权阅读 0-不需要授权 1-需要授权"
)
Integer
isGrant
)
throws
IOException
{
if
(
StringUtils
.
isAnyBlank
(
name
,
author
,
theme
,
synopsis
,
fileHash
)
||
categoryId
==
null
||
isArchives
==
null
)
{
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"缺失必填参数"
);
}
if
(
name
.
length
()
>
20
)
{
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"作品名称长度不能大于20"
);
}
if
(
author
.
length
()
>
20
)
{
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"作者长度不能大于20"
);
}
if
(
synopsis
.
length
()
>
500
)
{
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"简介长度不能大于500"
);
}
Nft
nft
=
new
Nft
();
Nft
nft
=
new
Nft
();
// 当平台存档选择加密存档时,文件必传
// 当平台存档选择加密存档时,文件必传
if
(
SystemConstant
.
BOOLEAN_DATA_TRUE
.
equals
(
isArchives
))
{
if
(
SystemConstant
.
BOOLEAN_DATA_TRUE
.
equals
(
isArchives
))
{
...
@@ -85,14 +98,10 @@ public class NftController {
...
@@ -85,14 +98,10 @@ public class NftController {
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"当选择加密存档的时候,文件和授权阅读不能为空"
);
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"当选择加密存档的时候,文件和授权阅读不能为空"
);
}
}
// 判断文件的hash是否被篡改过
// 判断文件的hash是否被篡改过
log
.
info
(
"verify fileHash start"
);
if
(!
SecureUtil
.
md5
(
file
.
getInputStream
()).
equals
(
fileHash
))
{
if
(!
SecureUtil
.
md5
(
file
.
getInputStream
()).
equals
(
fileHash
))
{
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"文件hash和文件内容不匹配"
);
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"文件hash和文件内容不匹配"
);
}
}
log
.
info
(
"verify fileHash end"
);
log
.
info
(
"upload file start"
);
String
fileUrl
=
ossUtil
.
putEncryptObject
(
file
);
String
fileUrl
=
ossUtil
.
putEncryptObject
(
file
);
log
.
info
(
"upload file end"
);
nft
.
setFileUrl
(
fileUrl
).
setIsGrant
(
isGrant
).
setFileName
(
file
.
getOriginalFilename
());
nft
.
setFileUrl
(
fileUrl
).
setIsGrant
(
isGrant
).
setFileName
(
file
.
getOriginalFilename
());
}
}
nft
.
setCategoryId
(
categoryId
)
nft
.
setCategoryId
(
categoryId
)
...
...
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