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
675d9604
Commit
675d9604
authored
Jul 08, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改nft上链逻辑
新增查询所有主题接口
parent
f5a76b3d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
187 additions
and
22 deletions
+187
-22
Label.java
joying-common/src/main/java/com/fzm/common/entity/Label.java
+19
-0
NftDto.java
...ng-common/src/main/java/com/fzm/common/entity/NftDto.java
+31
-0
LabelMapper.java
...mmon/src/main/java/com/fzm/common/mapper/LabelMapper.java
+14
-0
LabelService.java
...on/src/main/java/com/fzm/common/service/LabelService.java
+13
-0
NftService.java
...mmon/src/main/java/com/fzm/common/service/NftService.java
+11
-2
LabelServiceImpl.java
...in/java/com/fzm/common/service/impl/LabelServiceImpl.java
+21
-0
NftServiceImpl.java
...main/java/com/fzm/common/service/impl/NftServiceImpl.java
+26
-11
LabelController.java
.../main/java/com/fzm/portal/controller/LabelController.java
+34
-0
NftController.java
...rc/main/java/com/fzm/portal/controller/NftController.java
+18
-9
No files found.
joying-common/src/main/java/com/fzm/common/entity/Label.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
common
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
/**
* @author tangtuo
* @date 2021/7/8 16:26
*/
@Data
@TableName
(
"tb_label"
)
public
class
Label
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
name
;
}
joying-common/src/main/java/com/fzm/common/entity/NftDto.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
common
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
/**
* @author tangtuo
* @date 2021/7/8 16:04
*/
@Data
public
class
NftDto
{
@NotNull
(
message
=
"nft主键不能为空"
)
@ApiModelProperty
(
"nft主键"
)
private
Integer
id
;
@NotBlank
(
message
=
"nft哈希不能为空"
)
@ApiModelProperty
(
"nft哈希"
)
private
String
fileHash
;
@NotBlank
(
message
=
"nft编号不能为空"
)
@ApiModelProperty
(
"nft编号"
)
private
String
nftId
;
@NotBlank
(
message
=
"发行人地址不能为空"
)
@ApiModelProperty
(
"发行人地址"
)
private
String
wallet
;
}
joying-common/src/main/java/com/fzm/common/mapper/LabelMapper.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
common
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.fzm.common.entity.Category
;
import
com.fzm.common.entity.Label
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* @author tangtuo
* @date 2021/7/1 14:35
*/
@Mapper
public
interface
LabelMapper
extends
BaseMapper
<
Label
>
{
}
joying-common/src/main/java/com/fzm/common/service/LabelService.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
common
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.fzm.common.entity.Category
;
import
com.fzm.common.entity.Label
;
/**
* @author tangtuo
* @date 2021/7/1 14:35
*/
public
interface
LabelService
extends
IService
<
Label
>
{
}
joying-common/src/main/java/com/fzm/common/service/NftService.java
View file @
675d9604
...
...
@@ -2,6 +2,7 @@ package com.fzm.common.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.NftDto
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.NftListVo
;
import
com.github.pagehelper.PageInfo
;
...
...
@@ -14,12 +15,12 @@ import java.util.List;
*/
public
interface
NftService
extends
IService
<
Nft
>
{
/**
*
发行nft
*
保存nft基本信息
*
* @param nft
* @return
*/
Nft
publish
(
Nft
nft
);
Nft
Dto
saveNft
(
Nft
nft
);
/**
* 查看nft列表
...
...
@@ -117,4 +118,12 @@ public interface NftService extends IService<Nft> {
* @param id
*/
void
download
(
Integer
id
);
/**
* 发行nft
*
* @param nftDto
* @return
*/
Boolean
publish
(
NftDto
nftDto
);
}
joying-common/src/main/java/com/fzm/common/service/impl/LabelServiceImpl.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
common
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fzm.common.entity.Category
;
import
com.fzm.common.entity.Label
;
import
com.fzm.common.mapper.CategoryMapper
;
import
com.fzm.common.mapper.LabelMapper
;
import
com.fzm.common.service.CategoryService
;
import
com.fzm.common.service.LabelService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author tangtuo
* @date 2021/7/1 14:36
*/
@Service
public
class
LabelServiceImpl
extends
ServiceImpl
<
LabelMapper
,
Label
>
implements
LabelService
{
}
joying-common/src/main/java/com/fzm/common/service/impl/NftServiceImpl.java
View file @
675d9604
...
...
@@ -10,10 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.entity.BaseEntity
;
import
com.fzm.common.entity.Category
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.*
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.NftListVo
;
import
com.fzm.common.enums.ResultCode
;
...
...
@@ -68,26 +65,41 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
private
String
contractName
;
@Override
public
Nft
publish
(
Nft
nft
)
{
public
Nft
Dto
saveNft
(
Nft
nft
)
{
User
user
=
userService
.
getById
(
StpUtil
.
getLoginIdAsInt
());
// 如果用户是第一次发行作品,把用户的isPublish修改成1
if
(
SystemConstant
.
BOOLEAN_DATA_FALSE
.
equals
(
user
.
getIsPublish
()))
{
User
u
=
new
User
().
setId
(
user
.
getId
()).
setIsPublish
(
SystemConstant
.
BOOLEAN_DATA_TRUE
);
userService
.
updateById
(
u
);
}
save
(
nft
);
NftDto
nftDto
=
new
NftDto
();
// 获取用户的钱包地址
String
wallet
=
user
.
getWallet
();
nftDto
.
setNftId
(
generateNftId
(
nft
.
getCategoryId
()));
nftDto
.
setWallet
(
wallet
);
nftDto
.
setId
(
nft
.
getId
());
nftDto
.
setFileHash
(
nft
.
getFileHash
());
return
nftDto
;
/*
*/
}
@Override
public
Boolean
publish
(
NftDto
nftDto
)
{
// 获取用户的私钥
String
privkey
=
paraChainClient
.
walletDumpPrivkey
(
wallet
);
User
user
=
userService
.
getById
(
StpUtil
.
getLoginIdAsInt
());
String
wallet
=
user
.
getWallet
();
String
privkey
=
paraChainClient
.
walletDumpPrivkey
(
user
.
getWallet
());
String
txHash
=
paraChainClient
.
evmPublishNFT1155
(
contractName
,
wallet
,
privkey
,
1
,
true
);
if
(
StringUtils
.
isBlank
(
txHash
)
||
!
txHash
.
contains
(
"-"
))
{
throw
GlobalException
.
newException
(
ResultCode
.
FAILED
,
"nft发行失败"
);
}
String
[]
split
=
txHash
.
split
(
"-"
);
long
tokenId
=
Long
.
parseLong
(
split
[
1
]);
nft
.
setNftHash
(
split
[
0
]);
nft
.
setTokenId
(
tokenId
);
nft
.
setPublishTime
(
new
Date
());
Nft
nft
=
getById
(
nftDto
.
getId
());
// 构建上链信息
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"author"
,
nft
.
getAuthor
());
...
...
@@ -99,8 +111,11 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
if
(
StringUtils
.
isBlank
(
tradeHash
))
{
throw
GlobalException
.
newException
(
ResultCode
.
FAILED
,
"nft发行失败"
);
}
save
(
nft
);
return
getById
(
nft
.
getId
());
nft
.
setNftHash
(
split
[
0
]);
nft
.
setTokenId
(
tokenId
);
nft
.
setPublishTime
(
new
Date
());
nft
.
setNftId
(
nftDto
.
getNftId
());
return
updateById
(
nft
);
}
@Override
...
...
joying-portal/src/main/java/com/fzm/portal/controller/LabelController.java
0 → 100644
View file @
675d9604
package
com
.
fzm
.
portal
.
controller
;
import
com.fzm.common.entity.Category
;
import
com.fzm.common.entity.Label
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.service.CategoryService
;
import
com.fzm.common.service.LabelService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author tangtuo
* @date 2021/7/1 14:37
*/
@RestController
@RequestMapping
(
value
=
"/label"
)
@Api
(
tags
=
"主题管理"
)
public
class
LabelController
{
@Resource
private
LabelService
labelService
;
@GetMapping
(
"/list"
)
@ApiOperation
(
value
=
"查询所有主题信息"
)
public
ResponseModel
<
List
<
Label
>>
list
()
{
return
ResponseModel
.
success
(
labelService
.
list
());
}
}
joying-portal/src/main/java/com/fzm/portal/controller/NftController.java
View file @
675d9604
...
...
@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import
cn.hutool.crypto.SecureUtil
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.NftDto
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.NftCertificateVo
;
...
...
@@ -20,6 +21,7 @@ import com.fzm.common.utils.QRCodeUtil;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -55,13 +57,13 @@ public class NftController {
* 存证二维码跳转地址
* todo 修改成动态前端路由
*/
private
static
final
String
path
=
"https://chain.33.cn/document/60"
;
private
static
final
String
PATH
=
"https://chain.33.cn/document/60"
;
@SaCheckLogin
@PostMapping
(
"/
publish
"
)
@ApiOperation
(
value
=
"nft
发行
"
)
public
ResponseModel
<
Nft
>
publish
(
@ApiParam
(
value
=
"类目id"
,
required
=
true
)
Integer
categoryId
,
@PostMapping
(
"/
save
"
)
@ApiOperation
(
value
=
"nft
基本信息保存(基本信息和加密上链两个步骤)
"
)
public
ResponseModel
<
Nft
Dto
>
save
(
@ApiParam
(
value
=
"类目id"
,
required
=
true
)
Integer
categoryId
,
@ApiParam
(
value
=
"名称"
,
required
=
true
)
String
name
,
@ApiParam
(
value
=
"作者"
,
required
=
true
)
String
author
,
@ApiParam
(
value
=
"主题"
,
required
=
true
)
String
theme
,
...
...
@@ -69,8 +71,7 @@ public class NftController {
@ApiParam
(
value
=
"文件"
,
required
=
false
)
MultipartFile
file
,
@ApiParam
(
value
=
"文件hash"
,
required
=
true
)
String
fileHash
,
@ApiParam
(
value
=
"平台存档 0-不存档 1-加密存档"
,
required
=
true
)
Integer
isArchives
,
@ApiParam
(
value
=
"授权阅读 0-不需要授权 1-需要授权"
,
required
=
false
)
Integer
isGrant
,
@ApiParam
(
value
=
"nft编号"
,
required
=
true
)
String
nftId
)
throws
IOException
{
@ApiParam
(
value
=
"授权阅读 0-不需要授权 1-需要授权"
,
required
=
false
)
Integer
isGrant
)
throws
IOException
{
Nft
nft
=
new
Nft
();
// 当平台存档选择加密存档时,文件必传
if
(
SystemConstant
.
BOOLEAN_DATA_TRUE
.
equals
(
isArchives
))
{
...
...
@@ -91,9 +92,17 @@ public class NftController {
.
setTheme
(
theme
)
.
setSynopsis
(
synopsis
)
.
setFileHash
(
fileHash
)
.
setNftId
(
nftId
)
.
setIsArchives
(
isArchives
);
return
ResponseModel
.
success
(
nftService
.
publish
(
nft
));
return
ResponseModel
.
success
(
nftService
.
saveNft
(
nft
));
}
@SaCheckLogin
@PostMapping
(
"/publish"
)
@ApiOperation
(
"发行nft"
)
public
ResponseModel
<
Boolean
>
publish
(
@Validated
@RequestBody
NftDto
nftDto
)
{
Boolean
result
=
nftService
.
publish
(
nftDto
);
return
ResponseModel
.
success
(
result
);
}
@GetMapping
(
"/list"
)
...
...
@@ -165,7 +174,7 @@ public class NftController {
throw
GlobalException
.
newException
(
ResultCode
.
FORBIDDEN
,
"您无权查看别人的nft证书"
);
}
User
user
=
userService
.
getById
(
userId
);
String
qrCode
=
QRCodeUtil
.
encode
(
path
,
null
,
false
);
String
qrCode
=
QRCodeUtil
.
encode
(
PATH
,
null
,
false
);
NftCertificateVo
vo
=
new
NftCertificateVo
(
nft
,
user
,
qrCode
);
return
ResponseModel
.
success
(
vo
);
}
...
...
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