记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
c63c5586
Commit
c63c5586
authored
Mar 04, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调试至信链NFt购买接口
parent
d3b56884
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
38 deletions
+92
-38
ZxlErrorEnum.java
.../liquidnet/common/third/zxlnft/constant/ZxlErrorEnum.java
+3
-3
TestZxlnftService.java
.../java/com/liquidnet/service/zxlnft/TestZxlnftService.java
+89
-35
No files found.
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/constant/ErrorEnum.java
→
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/constant/
Zxl
ErrorEnum.java
View file @
c63c5586
...
@@ -11,7 +11,7 @@ import java.util.Arrays;
...
@@ -11,7 +11,7 @@ import java.util.Arrays;
* @Copyright: LightNet @ Copyright (c) 2021
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 14:00
* @date 2022/2/21 14:00
*/
*/
public
enum
ErrorEnum
{
public
enum
Zxl
ErrorEnum
{
SECCESS
(
"0"
,
"成功"
),
SECCESS
(
"0"
,
"成功"
),
FAILURE
(
"1"
,
"失败"
),
FAILURE
(
"1"
,
"失败"
),
NO_INIT_ERROR
(
"000"
,
"没有初始化"
),
NO_INIT_ERROR
(
"000"
,
"没有初始化"
),
...
@@ -53,14 +53,14 @@ public enum ErrorEnum {
...
@@ -53,14 +53,14 @@ public enum ErrorEnum {
TORT_SOURCE_ERROR
(
"6026"
,
"侵权 Source 类型错误"
);
TORT_SOURCE_ERROR
(
"6026"
,
"侵权 Source 类型错误"
);
private
String
code
;
private
String
code
;
private
String
msg
;
private
String
msg
;
ErrorEnum
(
String
code
,
String
msg
)
{
Zxl
ErrorEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
public
String
getCode
()
{
return
this
.
code
;
}
public
String
getCode
()
{
return
this
.
code
;
}
public
String
getMsg
()
{
return
this
.
msg
;
}
public
String
getMsg
()
{
return
this
.
msg
;
}
public
static
String
errorMsg
(
String
content
)
{
public
static
String
errorMsg
(
String
content
)
{
ErrorEnum
err
=
Arrays
.<
ErrorEnum
>
asList
(
values
()).
stream
().
filter
(
errorEnum
->
errorEnum
.
getCode
().
equals
(
content
)).
findFirst
().
orElse
(
SERVER_INNER_ERROR
);
ZxlErrorEnum
err
=
Arrays
.<
Zxl
ErrorEnum
>
asList
(
values
()).
stream
().
filter
(
errorEnum
->
errorEnum
.
getCode
().
equals
(
content
)).
findFirst
().
orElse
(
SERVER_INNER_ERROR
);
return
err
.
getMsg
();
return
err
.
getMsg
();
}
}
}
}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-zxlnft/liquidnet-service-zxlnft-impl/src/test/java/com/liquidnet/service/zxlnft/TestZxlnftService.java
View file @
c63c5586
package
com
.
liquidnet
.
service
.
zxlnft
;
package
com
.
liquidnet
.
service
.
zxlnft
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicResp
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairResp
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairResp
;
import
com.liquidnet.common.third.zxlnft.exception.ZxlNftException
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.BASE64Util
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -16,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -16,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.io.UnsupportedEncodingException
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @version V1.0
...
@@ -56,47 +60,97 @@ public class TestZxlnftService {
...
@@ -56,47 +60,97 @@ public class TestZxlnftService {
*/
*/
@Test
@Test
public
void
personRegisterBind
(){
public
void
personRegisterBind
(){
//生成助记词
String
userId
=
"310508344264376327445470"
;
CreateMnemonicReq
req
=
CreateMnemonicReq
.
getNew
();
String
userName
=
"安家宾"
;
CreateMnemonicResp
createMnemonicResp
=
zxlWalletSdkUtil
.
createMnemonic
(
req
);
String
mobile
=
"13811314082"
;
//生成公私钥
String
idCardType
=
ZxlnftEnum
.
CardTypeEnum
.
ID_CARD
.
getCode
();
DeriveKeyPairReq
deriveKeyPairReq
=
DeriveKeyPairReq
.
getNew
();
String
idCard
=
"142323198302062216"
;
deriveKeyPairReq
.
setMnemonic
(
"economy cost balance weapon flight also nut biology very sun slight about"
);
// String userName = "周焕";
// String mobile = "18548596019";
// String idCardType = ZxlnftEnum.CardTypeEnum.ID_CARD.getCode();
// String idCard = "150422199805206019";
String
mnemonic
=
"stuff name goat health siren dumb gorilla antique board tenant buffalo present"
;
//安家宾
// String mnemonic = "economy cost balance weapon flight also nut biology very sun slight about"; //周焕
Long
index
=
0L
;
String
userIdentification
=
null
;
String
address
=
null
;
String
userPubKey
=
null
;
String
userPriKey
=
null
;
// try{
// //生成助记词
// CreateMnemonicReq req = CreateMnemonicReq.getNew();
// CreateMnemonicResp createMnemonicResp = zxlWalletSdkUtil.createMnemonic(req);
// mnemonic = createMnemonicResp.getMnemonic();
// }catch(Exception e){
// throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"生成助记词失败!");
// }
/**
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
if
(
StringUtil
.
isNotEmpty
(
mnemonic
)){
//生成公私钥
DeriveKeyPairReq
deriveKeyPairReq
=
DeriveKeyPairReq
.
getNew
();
deriveKeyPairReq
.
setMnemonic
(
mnemonic
);
// deriveKeyPairReq.setMnemonic(createMnemonicResp.getMnemonic());
// deriveKeyPairReq.setMnemonic(createMnemonicResp.getMnemonic());
deriveKeyPairReq
.
setIndex
(
0
l
);
deriveKeyPairReq
.
setIndex
(
index
);
DeriveKeyPairResp
deriveKeyPairResp
=
zxlWalletSdkUtil
.
deriveKeyPair
(
deriveKeyPairReq
);
try
{
DeriveKeyPairResp
deriveKeyPairResp
=
zxlWalletSdkUtil
.
deriveKeyPair
(
deriveKeyPairReq
);
if
(
deriveKeyPairResp
.
getErr
().
equals
(
""
))
throw
new
Exception
(
"生成公私钥失败!"
);
userPubKey
=
BASE64Util
.
encoded
(
deriveKeyPairResp
.
getPubKey
());
userPriKey
=
BASE64Util
.
encoded
(
deriveKeyPairResp
.
getPriKey
());
}
catch
(
Exception
e
){
throw
new
ZxlNftException
(
ZxlErrorEnum
.
FAILURE
.
getCode
(),
e
.
getMessage
());
}
}
//
1.2.1调用自然人注册实名(使用NFT平台签名)接口
//
1.2.1调用自然人注册实名(使用NFT平台签名)接口
Nft003RegisterPersonPlatformReqDto
nft003ReqDto
=
Nft003RegisterPersonPlatformReqDto
.
getNew
();
Nft003RegisterPersonPlatformReqDto
nft003ReqDto
=
Nft003RegisterPersonPlatformReqDto
.
getNew
();
nft003ReqDto
.
setPersonName
(
"周焕"
);
nft003ReqDto
.
setPersonName
(
userName
);
// reqDto.setEmail("");
// reqDto.setEmail("");
nft003ReqDto
.
setMobile
(
"18548596019"
);
nft003ReqDto
.
setMobile
(
mobile
);
nft003ReqDto
.
setIdCard
(
"150422199805206019"
);
nft003ReqDto
.
setIdCard
(
idCard
);
nft003ReqDto
.
setCardType
(
Integer
.
valueOf
(
ZxlnftEnum
.
CardTypeEnum
.
ID_CARD
.
getCode
()
));
nft003ReqDto
.
setCardType
(
Integer
.
valueOf
(
idCardType
));
ZxlnftResponseDto
<
Nft003RegisterPersonPlatformRespDto
>
nft003Resp
=
zxlnftSdkUtil
.
nft003RegisterPersonPlatform
(
nft003ReqDto
);
ZxlnftResponseDto
<
Nft003RegisterPersonPlatformRespDto
>
nft003Resp
=
zxlnftSdkUtil
.
nft003RegisterPersonPlatform
(
nft003ReqDto
);
// 1.2.2调用授信平台NFT地址绑定接口
if
(
nft003Resp
.
isSuccess
()){
Nft014IdentityBindSubmitByTrustedReqDto
nft004ReqDto
=
Nft014IdentityBindSubmitByTrustedReqDto
.
getNew
();
userIdentification
=
nft003Resp
.
getData
().
getUserIdentification
();
}
//周焕
nft004ReqDto
.
setUserPubKey
(
deriveKeyPairResp
.
getPubKey
());
nft004ReqDto
.
setUserIdentification
(
nft003Resp
.
getData
().
getUserIdentification
());
String
signature
=
zxlnftBiz
.
createSign
(
deriveKeyPairResp
.
getPriKey
(),
nft004ReqDto
.
getUserIdentification
());
nft004ReqDto
.
setUserSignData
(
signature
);
ZxlnftResponseDto
<
Nft014IdentityBindSubmitByTrustedRespDto
>
nft004Resp
=
zxlnftSdkUtil
.
nft014IdentityBindSubmitByTrusted
(
nft004ReqDto
);
if
(
nft004Resp
.
isSuccess
()){
//
// 1.2.3调用绑定状态批量查询
if
(
StringUtil
.
isNotEmpty
(
userPubKey
)&&
StringUtil
.
isNotEmpty
(
userPriKey
)&&
StringUtil
.
isNotEmpty
(
userIdentification
)){
Nft016IdentityBindQueryReqDto
nft016ReqDto
=
Nft016IdentityBindQueryReqDto
.
getNew
();
//1.2.2调用授信平台NFT地址绑定接口
nft016ReqDto
.
setAddressList
(
nft004Resp
.
getData
().
getAddress
());
Nft014IdentityBindSubmitByTrustedReqDto
nft004ReqDto
=
Nft014IdentityBindSubmitByTrustedReqDto
.
getNew
();
ZxlnftResponseDto
<
Nft016IdentityBindQueryRespDto
>
nft016Resp
=
zxlnftSdkUtil
.
nft016IdentityBindQuery
(
nft016ReqDto
);
}
else
{
try
{
log
.
info
(
"返回结果:{}"
,
nft004Resp
.
toJson
());
nft004ReqDto
.
setUserPubKey
(
BASE64Util
.
decode
(
userPubKey
));
nft004ReqDto
.
setUserIdentification
(
nft003Resp
.
getData
().
getUserIdentification
());
String
signature
=
zxlnftBiz
.
createSign
(
BASE64Util
.
decode
(
userPriKey
),
nft004ReqDto
.
getUserIdentification
());
nft004ReqDto
.
setUserSignData
(
signature
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"公私钥解密错误!"
);
}
ZxlnftResponseDto
<
Nft014IdentityBindSubmitByTrustedRespDto
>
nft004Resp
=
zxlnftSdkUtil
.
nft014IdentityBindSubmitByTrusted
(
nft004ReqDto
);
if
(
nft004Resp
.
isSuccess
()){
// 1.2.3调用绑定状态批量查询
Nft016IdentityBindQueryReqDto
nft016ReqDto
=
Nft016IdentityBindQueryReqDto
.
getNew
();
nft016ReqDto
.
setAddressList
(
nft004Resp
.
getData
().
getAddress
());
ZxlnftResponseDto
<
Nft016IdentityBindQueryRespDto
>
nft016Resp
=
zxlnftSdkUtil
.
nft016IdentityBindQuery
(
nft016ReqDto
);
if
(
nft016Resp
.
isSuccess
()){
log
.
info
(
"返回结果:{}"
,
nft016Resp
.
toJson
());
}
}
else
{
log
.
info
(
"返回结果:{}"
,
nft004Resp
.
toJson
());
}
}
}
}
}
...
...
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