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
fd0c287a
Commit
fd0c287a
authored
Jul 06, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改nft上链逻辑
parent
dc6d9e09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
Nft.java
joying-common/src/main/java/com/fzm/common/entity/Nft.java
+1
-1
NftServiceImpl.java
...main/java/com/fzm/common/service/impl/NftServiceImpl.java
+17
-2
No files found.
joying-common/src/main/java/com/fzm/common/entity/Nft.java
View file @
fd0c287a
...
...
@@ -58,7 +58,7 @@ public class Nft extends BaseEntity {
private
String
nftHash
;
@ApiModelProperty
(
"nft token"
)
private
Stri
ng
tokenId
;
private
Lo
ng
tokenId
;
@ApiModelProperty
(
"nft发行时间"
)
private
Date
publishTime
;
...
...
joying-common/src/main/java/com/fzm/common/service/impl/NftServiceImpl.java
View file @
fd0c287a
...
...
@@ -27,6 +27,7 @@ import com.fzm.common.utils.OssUtil;
import
com.fzm.common.utils.RedisUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
* @author tangtuo
* @date 2021/6/30 15:55
*/
@Slf4j
@Service
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
class
NftServiceImpl
extends
ServiceImpl
<
NftMapper
,
Nft
>
implements
NftService
{
...
...
@@ -73,17 +75,30 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
User
u
=
new
User
().
setId
(
user
.
getId
()).
setIsPublish
(
SystemConstant
.
BOOLEAN_DATA_TRUE
);
userService
.
updateById
(
u
);
}
// 获取用户的
私钥
// 获取用户的
钱包地址
String
wallet
=
user
.
getWallet
();
// 获取用户的私钥
String
privkey
=
paraChainClient
.
walletDumpPrivkey
(
wallet
);
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
(
split
[
1
]
);
nft
.
setTokenId
(
tokenId
);
nft
.
setPublishTime
(
new
Date
());
// 构建上链信息
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"author"
,
nft
.
getAuthor
());
map
.
put
(
"name"
,
nft
.
getName
());
map
.
put
(
"hash"
,
nft
.
getNftHash
());
String
tokenInfo
=
JsonUtil
.
toJson
(
map
);
log
.
info
(
"加密上链数据: {}"
,
tokenInfo
);
String
tradeHash
=
paraChainClient
.
evmSetTokenInfo
(
contractName
,
tokenId
,
tokenInfo
,
wallet
,
privkey
,
true
);
if
(
StringUtils
.
isBlank
(
tradeHash
))
{
throw
GlobalException
.
newException
(
ResultCode
.
FAILED
,
"nft发行失败"
);
}
save
(
nft
);
return
getById
(
nft
.
getId
());
}
...
...
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