Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhuixin-art
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NFT
zhuixin-art
Commits
bcc913ef
Commit
bcc913ef
authored
Aug 17, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
9f100031
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
223 additions
and
149 deletions
+223
-149
pom.xml
art-common/pom.xml
+1
-1
RedisConstant.java
.../src/main/java/com/fzm/common/constant/RedisConstant.java
+3
-0
SystemConstant.java
...src/main/java/com/fzm/common/constant/SystemConstant.java
+2
-0
Nft.java
art-common/src/main/java/com/fzm/common/entity/Nft.java
+3
-0
CollectionNftVo.java
...c/main/java/com/fzm/common/entity/vo/CollectionNftVo.java
+5
-13
NftVo.java
art-common/src/main/java/com/fzm/common/entity/vo/NftVo.java
+13
-35
NftMapper.java
...common/src/main/java/com/fzm/common/mapper/NftMapper.java
+3
-0
CategoryService.java
...src/main/java/com/fzm/common/service/CategoryService.java
+0
-3
NftFileService.java
.../src/main/java/com/fzm/common/service/NftFileService.java
+10
-0
NftService.java
...mmon/src/main/java/com/fzm/common/service/NftService.java
+1
-1
CategoryServiceImpl.java
...java/com/fzm/common/service/impl/CategoryServiceImpl.java
+0
-11
NftFileServiceImpl.java
.../java/com/fzm/common/service/impl/NftFileServiceImpl.java
+15
-0
NftServiceImpl.java
...main/java/com/fzm/common/service/impl/NftServiceImpl.java
+0
-0
UserServiceImpl.java
...ain/java/com/fzm/common/service/impl/UserServiceImpl.java
+1
-1
OssUtil.java
art-common/src/main/java/com/fzm/common/utils/OssUtil.java
+4
-3
NftMapper.xml
art-common/src/main/resources/mapper/NftMapper.xml
+45
-31
NftController.java
...rc/main/java/com/fzm/portal/controller/NftController.java
+49
-24
OssController.java
...rc/main/java/com/fzm/portal/controller/OssController.java
+35
-4
application-dev.yml
art-portal/src/main/resources/application-dev.yml
+3
-3
application-local.yml
art-portal/src/main/resources/application-local.yml
+4
-5
application-prod.yml
art-portal/src/main/resources/application-prod.yml
+4
-5
application-test.yml
art-portal/src/main/resources/application-test.yml
+4
-5
ArtPortalApplicationTests.java
...c/test/java/com/fzm/portal/ArtPortalApplicationTests.java
+18
-4
No files found.
art-common/pom.xml
View file @
bcc913ef
...
...
@@ -61,7 +61,7 @@
<dependency>
<groupId>
cn.fzm.chain
</groupId>
<artifactId>
simple-sdk
</artifactId>
<version>
2.
2
.1
</version>
<version>
2.
6
.1
</version>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
...
...
art-common/src/main/java/com/fzm/common/constant/RedisConstant.java
View file @
bcc913ef
...
...
@@ -32,6 +32,9 @@ public class RedisConstant {
public
static
final
String
COMMEMORATE_NFT_MEMBERS_PREFIX
=
"commemorateNft:members:"
;
public
static
final
String
PUBLISH_NFT_PREFIX
=
"NFT:"
;
}
art-common/src/main/java/com/fzm/common/constant/SystemConstant.java
View file @
bcc913ef
...
...
@@ -15,4 +15,6 @@ public class SystemConstant {
*/
public
static
final
Integer
BOOLEAN_DATA_TRUE
=
1
;
public
static
final
Integer
BOOLEAN_DATA_FALSE
=
0
;
public
static
final
String
NULL_TOKEN
=
"Bearer null"
;
}
art-common/src/main/java/com/fzm/common/entity/Nft.java
View file @
bcc913ef
...
...
@@ -42,6 +42,9 @@ public class Nft extends BaseEntity {
@ApiModelProperty
(
"简介"
)
private
String
synopsis
;
@ApiModelProperty
(
"封面"
)
private
String
cover
;
@ApiModelProperty
(
"nft编号"
)
private
String
nftNum
;
...
...
art-common/src/main/java/com/fzm/common/entity/vo/CollectionNftVo.java
View file @
bcc913ef
...
...
@@ -17,27 +17,19 @@ public class CollectionNftVo {
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"类目"
)
@ApiModelProperty
(
"
一级
类目"
)
private
String
category
;
@ApiModelProperty
(
"二级类目"
)
private
String
secondCategory
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"封面"
)
private
String
cover
;
@ApiModelProperty
(
"主题,多个用逗号,隔开"
)
private
String
theme
;
@ApiModelProperty
(
"nft编号"
)
private
String
nftId
;
@ApiModelProperty
(
"是否是纪念版nft 0-否 1-是"
)
private
Integer
isCommemorate
;
private
String
nftNum
;
public
CollectionNftVo
(
Nft
nft
,
Category
category
)
{
this
.
id
=
nft
.
getId
();
this
.
category
=
category
.
getText
();
this
.
name
=
nft
.
getName
();
}
}
art-common/src/main/java/com/fzm/common/entity/vo/NftVo.java
View file @
bcc913ef
...
...
@@ -2,11 +2,15 @@ package com.fzm.common.entity.vo;
import
cn.hutool.core.date.DateUtil
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.NftFile
;
import
com.fzm.common.entity.User
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
sun.management.counter.perf.PerfInstrumentation
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author tangtuo
* @date 2021/7/1 10:35
...
...
@@ -23,62 +27,36 @@ public class NftVo {
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"
封面
"
)
private
String
cove
r
;
@ApiModelProperty
(
"
作者
"
)
private
String
autho
r
;
@ApiModelProperty
(
"类目"
)
private
String
category
;
@ApiModelProperty
(
"主题,多个用逗号,隔开"
)
private
String
theme
;
@ApiModelProperty
(
"发行人"
)
private
String
publisher
;
@ApiModelProperty
(
"头像"
)
private
String
avatar
;
@ApiModelProperty
(
"钱包地址"
)
private
String
wallet
;
@ApiModelProperty
(
"nft编号"
)
private
String
nftId
;
@ApiModelProperty
(
"剧本hash"
)
private
String
fileHash
;
@ApiModelProperty
(
"文件名"
)
private
String
fileName
;
@ApiModelProperty
(
"文件地址"
)
private
String
fileUrl
;
@ApiModelProperty
(
"nft哈希"
)
private
String
nftHash
;
@ApiModelProperty
(
"发行时间"
)
private
String
publishTime
;
@ApiModelProperty
(
"作者"
)
private
String
author
;
private
Date
publishTime
;
@ApiModelProperty
(
"简介"
)
private
String
synopsis
;
@ApiModelProperty
(
"平台存档 0-不存档 1-加密存档"
)
private
Integer
isArchives
;
@ApiModelProperty
(
"授权阅读 0-不需要授权 1-需要授权"
)
private
Integer
isGrant
;
@ApiModelProperty
(
"nft编号"
)
private
String
nftNum
;
@ApiModelProperty
(
"是否收藏"
)
private
Boolean
collection
;
@ApiModelProperty
(
"
关于nft
"
)
private
String
aboutNf
t
;
@ApiModelProperty
(
"
文件列表
"
)
private
List
<
NftFile
>
fileLis
t
;
@ApiModelProperty
(
"是否是纪念版nft 0-否 1-是"
)
private
Integer
isCommemorate
;
public
NftVo
(
Nft
nft
,
User
user
)
{
this
.
id
=
nft
.
getId
();
...
...
@@ -86,11 +64,11 @@ public class NftVo {
this
.
name
=
nft
.
getName
();
this
.
synopsis
=
nft
.
getSynopsis
();
this
.
publisher
=
user
.
getNickname
();
this
.
avatar
=
user
.
getAvatar
();
this
.
wallet
=
nft
.
getPublishAddress
();
this
.
publishTime
=
DateUtil
.
format
(
nft
.
getPublishTime
(),
"yyyy/MM/dd HH:mm:ss"
);
this
.
publishTime
=
nft
.
getPublishTime
(
);
this
.
userId
=
nft
.
getUserId
();
this
.
collection
=
false
;
this
.
nftHash
=
nft
.
getNftHash
();
this
.
nftNum
=
nft
.
getNftNum
();
}
}
art-common/src/main/java/com/fzm/common/mapper/NftMapper.java
View file @
bcc913ef
...
...
@@ -42,4 +42,7 @@ public interface NftMapper extends BaseMapper<Nft> {
* @return
*/
List
<
NftListVo
>
page
(
@Param
(
"categoryId"
)
Integer
categoryId
,
@Param
(
"name"
)
String
name
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"theme"
)
String
theme
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"startDate"
)
DateTime
startDate
,
@Param
(
"endDate"
)
DateTime
endDate
);
List
<
CollectionNftVo
>
listCurrent
(
@Param
(
"categoryId"
)
Integer
categoryId
,
@Param
(
"userId"
)
Integer
userId
);
}
art-common/src/main/java/com/fzm/common/service/CategoryService.java
View file @
bcc913ef
...
...
@@ -11,9 +11,6 @@ import java.util.List;
*/
public
interface
CategoryService
extends
IService
<
Category
>
{
Category
getCategoryById
(
Integer
categoryId
);
/**
* 根据pid查新类目列表
*
...
...
art-common/src/main/java/com/fzm/common/service/NftFileService.java
View file @
bcc913ef
...
...
@@ -4,9 +4,19 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.fzm.common.entity.AuthPerson
;
import
com.fzm.common.entity.NftFile
;
import
java.util.List
;
/**
* @author tangtuo
* @date 2021/6/28 11:28
*/
public
interface
NftFileService
extends
IService
<
NftFile
>
{
/**
* 查询nft的文件列表
*
* @param nftId
* @return
*/
List
<
NftFile
>
getByNftId
(
Integer
nftId
);
}
art-common/src/main/java/com/fzm/common/service/NftService.java
View file @
bcc913ef
...
...
@@ -49,7 +49,7 @@ public interface NftService extends IService<Nft> {
* @param userId
* @return
*/
List
<
Nft
>
listCurrent
(
Integer
categoryId
,
Integer
userId
);
List
<
CollectionNftVo
>
listCurrent
(
Integer
categoryId
,
Integer
userId
);
/**
* 生成nft编号
...
...
art-common/src/main/java/com/fzm/common/service/impl/CategoryServiceImpl.java
View file @
bcc913ef
...
...
@@ -23,17 +23,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
private
CategoryMapper
categoryMapper
;
@Override
public
Category
getCategoryById
(
Integer
categoryId
)
{
List
<
Category
>
list
=
list
();
for
(
Category
category
:
list
)
{
if
(
categoryId
.
equals
(
category
.
getId
()))
{
return
category
;
}
}
return
null
;
}
@Override
@Cacheable
(
value
=
"category:list"
,
key
=
"#pid"
)
public
List
<
Category
>
getByPid
(
Integer
pid
)
{
QueryWrapper
<
Category
>
queryWrapper
=
new
QueryWrapper
<>();
...
...
art-common/src/main/java/com/fzm/common/service/impl/NftFileServiceImpl.java
View file @
bcc913ef
package
com
.
fzm
.
common
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fzm.common.entity.AuthPerson
;
import
com.fzm.common.entity.NftFile
;
import
com.fzm.common.mapper.AuthPersonMapper
;
import
com.fzm.common.mapper.NftFileMapper
;
import
com.fzm.common.mapper.NftMapper
;
import
com.fzm.common.service.AuthPersonService
;
import
com.fzm.common.service.NftFileService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author tangtuo
* @date 2021/6/28 11:29
*/
@Service
public
class
NftFileServiceImpl
extends
ServiceImpl
<
NftFileMapper
,
NftFile
>
implements
NftFileService
{
@Resource
private
NftFileMapper
nftFileMapper
;
@Override
public
List
<
NftFile
>
getByNftId
(
Integer
nftId
)
{
QueryWrapper
<
NftFile
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"nft_id"
,
nftId
);
return
nftFileMapper
.
selectList
(
queryWrapper
);
}
}
art-common/src/main/java/com/fzm/common/service/impl/NftServiceImpl.java
View file @
bcc913ef
This diff is collapsed.
Click to expand it.
art-common/src/main/java/com/fzm/common/service/impl/UserServiceImpl.java
View file @
bcc913ef
...
...
@@ -173,7 +173,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
User
loginUser
=
getUserByToken
();
// 如果不是第一次上传头像,需要删除旧头像
if
(
StringUtils
.
isNotBlank
(
loginUser
.
getAvatar
()))
{
ossUtil
.
delete
(
loginUser
.
getAvatar
()
,
ossProperties
.
getBucket
()
);
ossUtil
.
delete
(
loginUser
.
getAvatar
());
}
User
user
=
new
User
().
setAvatar
(
avatar
).
...
...
art-common/src/main/java/com/fzm/common/utils/OssUtil.java
View file @
bcc913ef
...
...
@@ -142,16 +142,17 @@ public class OssUtil {
}
}
public
void
delete
(
String
fileUrl
,
String
bucketName
)
{
public
void
delete
(
String
fileUrl
)
{
String
endpoint
=
ossProperties
.
getEndPoint
();
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String
accessKeyId
=
ossProperties
.
getAppKey
();
String
accessKeySecret
=
ossProperties
.
getAppSecret
();
String
bucket
=
ossProperties
.
getBucket
();
// <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如20210629/a8703bcf7d354ea2bbb5ccdf76b7405f/123.jpg。
String
objectName
=
fileUrl
.
replace
(
String
.
format
(
"https://%s.%s/"
,
bucket
Name
,
endpoint
),
""
);
String
objectName
=
fileUrl
.
replace
(
String
.
format
(
"https://%s.%s/"
,
bucket
,
endpoint
),
""
);
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
ossClient
.
deleteObject
(
bucket
Name
,
objectName
);
ossClient
.
deleteObject
(
bucket
,
objectName
);
}
...
...
art-common/src/main/resources/mapper/NftMapper.xml
View file @
bcc913ef
...
...
@@ -4,7 +4,7 @@
<select
id=
"list"
resultType=
"com.fzm.common.entity.Nft"
>
select * from tb_nft
where status = 1
and is_commemorate=0 and nft_hash != ''
where status = 1
<if
test=
"categoryId != null and categoryId > 0"
>
and category_id=#{categoryId}
</if>
...
...
@@ -16,10 +16,8 @@
select a.id,
a.name,
a.cover,
a.theme,
a.nft_id,
a.is_commemorate,
b.category_name as category
a.nft_num,
b.text as category
from tb_nft a left join tb_category b on a.category_id = b.id
where a.id in (
<foreach
collection=
"list"
item=
"id"
separator=
","
>
...
...
@@ -44,36 +42,51 @@
tb_nft n
LEFT JOIN tb_user u ON n.publish_address = u.wallet
LEFT JOIN tb_category c ON n.category_id = c.id
WHERE
is_commemorate=0 and nft_hash != ''
<if
test=
"name != null and name != ''"
>
and n.name like concat ('%',#{name},'%')
</if>
<if
test=
"categoryId != null"
>
and n.category_id = #{categoryId}
</if>
<if
test=
"theme != null and theme != ''"
>
and FIND_IN_SET(#{theme},n.theme)
</if>
<if
test=
"categoryId != null"
>
and n.category_id = #{categoryId}
</if>
<if
test=
"status != null"
>
and n.status = #{status}
</if>
<if
test=
"telephone != null and telephone != ''"
>
and u.telephone = #{telephone}
</if>
<if
test=
"startDate != null"
>
and n.create_date >= #{startDate}
</if>
<if
test=
"endDate != null"
>
and n.create_date
<
= #{endDate}
</if>
<where>
<if
test=
"name != null and name != ''"
>
and n.name like concat ('%',#{name},'%')
</if>
<if
test=
"categoryId != null"
>
and n.category_id = #{categoryId}
</if>
<if
test=
"categoryId != null"
>
and n.category_id = #{categoryId}
</if>
<if
test=
"status != null"
>
and n.status = #{status}
</if>
<if
test=
"telephone != null and telephone != ''"
>
and u.telephone = #{telephone}
</if>
<if
test=
"startDate != null"
>
and n.create_date >= #{startDate}
</if>
<if
test=
"endDate != null"
>
and n.create_date
<
= #{endDate}
</if>
</where>
ORDER BY
is_top DESC,
`status` DESC,
publish_time DESC
</select>
<select
id=
"listCurrent"
resultType=
"com.fzm.common.entity.vo.CollectionNftVo"
>
select a.id,
a.name,
a.cover,
a.nft_num,
b.text as category,
c.text as second_category
from tb_nft a
left join tb_category b on a.category_id = b.id
left join tb_category c on a.second_category_id = c.id
where a.user_id = #{userId}
<if
test=
"categoryId != null"
>
and a.category_id = #{categoryId}
</if>
order by a.publish_time desc
</select>
</mapper>
\ No newline at end of file
art-portal/src/main/java/com/fzm/portal/controller/NftController.java
View file @
bcc913ef
package
com
.
fzm
.
portal
.
controller
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.constant.TokenConstant
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.NftDto
;
import
com.fzm.common.entity.NftFile
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.NftCertificateVo
;
...
...
@@ -16,6 +19,7 @@ import com.fzm.common.exception.GlobalException;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.params.NftTransferParam
;
import
com.fzm.common.service.CategoryService
;
import
com.fzm.common.service.NftFileService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.UserService
;
import
com.fzm.common.utils.*
;
...
...
@@ -61,6 +65,12 @@ public class NftController {
@Resource
private
HttpServletRequest
request
;
@Resource
private
OssUtil
ossUtil
;
@Resource
private
NftFileService
nftFileService
;
/**
* 存证二维码跳转地址
* todo 修改成动态前端路由
...
...
@@ -76,11 +86,39 @@ public class NftController {
return
ResponseModel
.
success
(
id
);
}
@Authentication
@GetMapping
(
"/get/temp"
)
@ApiOperation
(
"查询用户缓存的nft信息"
)
public
ResponseModel
<
NftDto
>
getTemp
(
@RequestHeader
(
name
=
"Authorization"
)
String
token
)
{
NftDto
nftDto
=
null
;
String
str
=
redisUtil
.
get
(
RedisConstant
.
PUBLISH_NFT_PREFIX
+
JwtUtil
.
getUserIdFromToken
(
token
));
if
(
StringUtils
.
isNotBlank
(
str
))
{
nftDto
=
JSONUtil
.
toBean
(
str
,
NftDto
.
class
);
}
return
ResponseModel
.
success
(
nftDto
);
}
@Authentication
@PostMapping
(
"/delete/temp"
)
@ApiOperation
(
"删除用户缓存的nft信息"
)
public
ResponseModel
<
Boolean
>
deleteTemp
(
@RequestHeader
(
name
=
"Authorization"
)
String
token
)
{
String
key
=
RedisConstant
.
PUBLISH_NFT_PREFIX
+
JwtUtil
.
getUserIdFromToken
(
token
);
String
str
=
redisUtil
.
get
(
key
);
if
(
StringUtils
.
isNotBlank
(
str
))
{
NftDto
nftDto
=
JSONUtil
.
toBean
(
str
,
NftDto
.
class
);
List
<
NftFile
>
fileList
=
nftDto
.
getFileList
();
// 删除oss缓存的文件
fileList
.
forEach
(
file
->
ossUtil
.
delete
(
file
.
getFileUrl
()));
}
redisUtil
.
delete
(
key
);
return
ResponseModel
.
success
(
true
);
}
@GetMapping
(
"/list"
)
@ApiOperation
(
value
=
"获取nft列表"
)
public
ResponseModel
<
List
<
Nft
>>
list
(
@ApiParam
(
value
=
"当前页码"
)
@RequestParam
Integer
pageNum
,
@ApiParam
(
value
=
"每页记录数"
)
@RequestParam
Integer
pageSize
,
@ApiParam
(
value
=
"类目id,查询所有的时候传null"
)
@RequestParam
(
required
=
false
)
Integer
categoryId
)
{
@ApiParam
(
value
=
"每页记录数"
)
@RequestParam
Integer
pageSize
,
@ApiParam
(
value
=
"类目id,查询所有的时候传null"
)
@RequestParam
(
required
=
false
)
Integer
categoryId
)
{
pageNum
=
(
pageNum
-
1
)
*
pageSize
;
List
<
Nft
>
list
=
nftService
.
list
(
pageNum
,
pageSize
,
categoryId
);
...
...
@@ -99,14 +137,12 @@ public class NftController {
throw
GlobalException
.
newException
(
ResultCode
.
DATA_ERROR
,
"没找到此nft的发布人的信息"
);
}
NftVo
nftVo
=
new
NftVo
(
nft
,
user
);
nftVo
.
setCategory
(
categoryService
.
getById
(
nft
.
getCategoryId
()).
getText
());
if
(
StringUtils
.
isNotBlank
(
Authorization
))
{
String
realToken
=
Authorization
.
substring
(
TokenConstant
.
TOKEN_PREFIX
.
length
());
if
(
StringUtils
.
isNotBlank
(
realToken
)
&&
!
"null"
.
equals
(
realToken
))
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
Authorization
);
Boolean
collection
=
redisUtil
.
sIsMember
(
RedisConstant
.
COLLECTION_USER_PREFIX
+
userId
,
id
.
toString
());
nftVo
.
setCollection
(
collection
);
}
nftVo
.
setFileList
(
nftFileService
.
getByNftId
(
id
));
nftVo
.
setCategory
(
categoryService
.
getById
(
nft
.
getSecondCategoryId
()).
getText
());
if
(
StringUtils
.
isNotBlank
(
Authorization
)
&&
!
Authorization
.
startsWith
(
SystemConstant
.
NULL_TOKEN
))
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
Authorization
);
Boolean
collection
=
redisUtil
.
sIsMember
(
RedisConstant
.
COLLECTION_USER_PREFIX
+
userId
,
id
.
toString
());
nftVo
.
setCollection
(
collection
);
}
return
ResponseModel
.
success
(
nftVo
);
}
...
...
@@ -116,10 +152,7 @@ public class NftController {
@ApiOperation
(
value
=
"获取我的nft列表"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
listCurrent
(
@ApiParam
(
value
=
"类目id,查询全部的时候传null"
)
@RequestParam
(
required
=
false
)
Integer
categoryId
)
throws
Exception
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
request
.
getHeader
(
"Authorization"
));
List
<
Nft
>
list
=
nftService
.
listCurrent
(
categoryId
,
userId
);
List
<
CollectionNftVo
>
nftVoList
=
list
.
stream
()
.
map
(
nft
->
new
CollectionNftVo
(
nft
,
categoryService
.
getCategoryById
(
nft
.
getId
())))
.
collect
(
Collectors
.
toList
());
List
<
CollectionNftVo
>
list
=
nftService
.
listCurrent
(
categoryId
,
userId
);
User
user
=
userService
.
getById
(
userId
);
// 生成二维码
HashMap
<
String
,
Object
>
qrCodeMap
=
new
HashMap
<>();
...
...
@@ -128,21 +161,13 @@ public class NftController {
qrCodeMap
.
put
(
"wallet"
,
user
.
getWallet
());
String
qrCode
=
QRCodeUtil
.
encode
(
JsonUtil
.
toJson
(
qrCodeMap
),
null
,
false
);
HashMap
<
String
,
Object
>
result
=
new
HashMap
<>(
8
);
result
.
put
(
"list"
,
nftVoL
ist
);
result
.
put
(
"size"
,
nftVoL
ist
.
size
());
result
.
put
(
"list"
,
l
ist
);
result
.
put
(
"size"
,
l
ist
.
size
());
result
.
put
(
"qrCode"
,
qrCode
);
return
ResponseModel
.
success
(
result
);
}
@Authentication
@GetMapping
(
"/generateNftId"
)
@ApiOperation
(
value
=
"生成nft编号"
)
public
ResponseModel
<
String
>
generateNftId
(
@ApiParam
(
value
=
"类目id"
,
required
=
true
)
@RequestParam
Integer
categoryId
)
{
String
nftId
=
nftService
.
generateNftId
(
categoryId
);
return
ResponseModel
.
success
(
nftId
);
}
@Authentication
@PostMapping
(
"/file/md5"
)
@ApiOperation
(
value
=
"获取文件的md5值"
)
public
ResponseModel
<
String
>
getFileMd5Value
(
MultipartFile
file
)
throws
IOException
{
...
...
art-portal/src/main/java/com/fzm/portal/controller/OssController.java
View file @
bcc913ef
package
com
.
fzm
.
portal
.
controller
;
import
cn.hutool.json.JSONUtil
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.entity.NftDto
;
import
com.fzm.common.entity.NftFile
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.utils.JwtUtil
;
import
com.fzm.common.utils.OssUtil
;
import
com.fzm.common.utils.RedisUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -27,6 +32,9 @@ public class OssController {
@Resource
private
OssUtil
ossUtil
;
@Resource
private
RedisUtil
redisUtil
;
@Authentication
@GetMapping
(
"/policy"
)
@ApiOperation
(
"完成oss签名"
)
...
...
@@ -41,4 +49,27 @@ public class OssController {
public
ResponseModel
<
String
>
upload
(
MultipartFile
file
)
throws
IOException
{
return
ResponseModel
.
success
(
ossUtil
.
putObject
(
file
));
}
@Authentication
@PostMapping
(
"/delete"
)
@ApiOperation
(
"删除文件"
)
public
ResponseModel
<
Boolean
>
delete
(
@RequestParam
String
url
,
@RequestHeader
(
name
=
"Authorization"
)
String
token
)
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
token
);
String
key
=
RedisConstant
.
PUBLISH_NFT_PREFIX
+
userId
;
String
str
=
redisUtil
.
get
(
key
);
if
(
StringUtils
.
isNotBlank
(
str
))
{
NftDto
nftDto
=
JSONUtil
.
toBean
(
str
,
NftDto
.
class
);
List
<
NftFile
>
list
=
nftDto
.
getFileList
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
url
.
equals
(
list
.
get
(
i
).
getFileUrl
()))
{
list
.
remove
(
i
);
break
;
}
}
nftDto
.
setFileList
(
list
);
redisUtil
.
set
(
key
,
JSONUtil
.
toJsonStr
(
nftDto
));
}
ossUtil
.
delete
(
url
);
return
ResponseModel
.
success
(
true
);
}
}
art-portal/src/main/resources/application-dev.yml
View file @
bcc913ef
...
...
@@ -84,12 +84,12 @@ chain:
title
:
user.p.joying.
admin
:
16naUoLwjNUgMhGVRmL3xTVpCso2DJp8JZ
admin-key
:
8cd19e9bf39055f95e3e33cc1e08b9f9fc2e9be48a5b3a4d401e64041c97aec7
contract-name
:
user.evm.0x
d996a3a866c577596df260844a045a068ec5accd8d71ccaa3d578c9617ec5490
contract-address
:
1
iDWTHZQxPES4hLveZRcwJH6AMaMfZfZZ
contract-name
:
user.evm.0x
72ab91df57d70ddca74c219fee29a4e08632bb7b1109c1627fc11173961b180c
contract-address
:
1
ErrPnk5mocNL5k87Yx66ihqmprc8avjPJ
aliyun
:
oss
:
app-key
:
LTAI5tHGn7cVJdEtihTFLSeB
app-secret
:
XYmfBSbLaZoblGXZwIXkbhfBD7a1eg
end-point
:
oss-cn-
hangzhou
.aliyuncs.com
end-point
:
oss-cn-
beijing
.aliyuncs.com
bucket
:
test-zhuixin
art-portal/src/main/resources/application-local.yml
View file @
bcc913ef
...
...
@@ -77,9 +77,8 @@ aliyun:
oss
:
app-key
:
LTAI5tHGn7cVJdEtihTFLSeB
app-secret
:
XYmfBSbLaZoblGXZwIXkbhfBD7a1eg
end-point
:
oss-cn-hangzhou.aliyuncs.com
simple-bucket
:
test-nft
encrypt-bucket
:
test-nft-2
end-point
:
oss-cn-beijing.aliyuncs.com
bucket
:
test-zhuixin
sms
:
app-key
:
Yiru
...
...
@@ -101,7 +100,7 @@ chain:
title
:
user.p.joying.
admin
:
16naUoLwjNUgMhGVRmL3xTVpCso2DJp8JZ
admin-key
:
8cd19e9bf39055f95e3e33cc1e08b9f9fc2e9be48a5b3a4d401e64041c97aec7
contract-name
:
user.evm.0x
d996a3a866c577596df260844a045a068ec5accd8d71ccaa3d578c9617ec5490
contract-address
:
1
iDWTHZQxPES4hLveZRcwJH6AMaMfZfZZ
contract-name
:
user.evm.0x
72ab91df57d70ddca74c219fee29a4e08632bb7b1109c1627fc11173961b180c
contract-address
:
1
ErrPnk5mocNL5k87Yx66ihqmprc8avjPJ
art-portal/src/main/resources/application-prod.yml
View file @
bcc913ef
...
...
@@ -88,8 +88,7 @@ chain:
aliyun
:
oss
:
app-key
:
LTAI5tAAXBCtnQ2ytwagazjt
app-secret
:
x0T6hyJvRFLtPjZYrNo5egEc4kShlU
end-point
:
oss-cn-shanghai.aliyuncs.com
simple-bucket
:
joying-file
encrypt-bucket
:
joying-nft
app-key
:
LTAI5tHGn7cVJdEtihTFLSeB
app-secret
:
XYmfBSbLaZoblGXZwIXkbhfBD7a1eg
end-point
:
oss-cn-beijing.aliyuncs.com
bucket
:
test-zhuixin
art-portal/src/main/resources/application-test.yml
View file @
bcc913ef
...
...
@@ -93,13 +93,12 @@ chain:
title
:
user.p.joying.
admin
:
16naUoLwjNUgMhGVRmL3xTVpCso2DJp8JZ
admin-key
:
8cd19e9bf39055f95e3e33cc1e08b9f9fc2e9be48a5b3a4d401e64041c97aec7
contract-name
:
user.evm.0x
d996a3a866c577596df260844a045a068ec5accd8d71ccaa3d578c9617ec5490
contract-address
:
1
iDWTHZQxPES4hLveZRcwJH6AMaMfZfZZ
contract-name
:
user.evm.0x
72ab91df57d70ddca74c219fee29a4e08632bb7b1109c1627fc11173961b180c
contract-address
:
1
ErrPnk5mocNL5k87Yx66ihqmprc8avjPJ
aliyun
:
oss
:
app-key
:
LTAI5tHGn7cVJdEtihTFLSeB
app-secret
:
XYmfBSbLaZoblGXZwIXkbhfBD7a1eg
end-point
:
oss-cn-hangzhou.aliyuncs.com
simple-bucket
:
test-nft
encrypt-bucket
:
test-nft-2
end-point
:
oss-cn-beijing.aliyuncs.com
bucket
:
test-zhuixin
art-portal/src/test/java/com/fzm/portal/ArtPortalApplicationTests.java
View file @
bcc913ef
package
com
.
fzm
.
portal
;
import
org.junit.jupiter.api.Test
;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
cn.hutool.core.collection.CollectionUtil
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
//@SpringBootTest
class
ArtPortalApplicationTests
{
@Test
void
contextLoads
()
{
public
static
void
main
(
String
[]
args
)
{
List
<
Integer
>
list
=
new
ArrayList
<>(
Arrays
.
asList
(
2
,
1
,
3
,
4
,
5
,
1
));
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
list
.
get
(
i
)==
1
){
list
.
remove
(
i
);
//i--;
}
}
list
.
forEach
(
System
.
out
::
println
);
}
}
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