记得上下班打卡 | 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
050d89b6
Commit
050d89b6
authored
Mar 15, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现zxtnft购买功能
parent
1cecaaba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
18 deletions
+90
-18
GalaxyUserInfoBo.java
...com/liquidnet/service/galaxy/dto/bo/GalaxyUserInfoBo.java
+2
-0
MathUtil.java
.../java/com.liquidnet.common.cache/redis/util/MathUtil.java
+1
-1
liquidnet-service-galaxy.yml
...-bus-config/liquidnet-config/liquidnet-service-galaxy.yml
+5
-5
ZxinUserBiz.java
...liquidnet/service/galaxy/router/zxin/biz/ZxinUserBiz.java
+38
-10
DataUtils.java
...in/java/com/liquidnet/service/galaxy/utils/DataUtils.java
+3
-2
TestRedisUtil.java
...test/java/com/liquidnet/service/galaxy/TestRedisUtil.java
+41
-0
No files found.
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/bo/GalaxyUserInfoBo.java
View file @
050d89b6
...
@@ -26,6 +26,8 @@ public class GalaxyUserInfoBo implements Serializable,Cloneable{
...
@@ -26,6 +26,8 @@ public class GalaxyUserInfoBo implements Serializable,Cloneable{
private
String
userIdentification
;
private
String
userIdentification
;
private
String
userPubKey
;
private
String
userPubKey
;
private
String
userPriKey
;
private
String
userPriKey
;
private
String
routerType
;
private
String
blockChainAddress
;
@Override
@Override
public
String
toString
(){
public
String
toString
(){
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/MathUtil.java
View file @
050d89b6
...
@@ -42,6 +42,6 @@ public class MathUtil {
...
@@ -42,6 +42,6 @@ public class MathUtil {
log
.
info
(
"redisConfig.defaultDb==="
,
redisConfig
.
defaultDb
);
log
.
info
(
"redisConfig.defaultDb==="
,
redisConfig
.
defaultDb
);
log
.
info
(
"redisConfig.totalDbs==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisConfig.totalDbs==="
,
redisConfig
.
totalDbs
);
// redisConfig.getRedisTemplateByDb(MathUtil.getIndex("1",redisConfig.defaultDb,redisConfig.totalDbs));
// redisConfig.getRedisTemplateByDb(MathUtil.getIndex("1",redisConfig.defaultDb,redisConfig.totalDbs));
System
.
out
.
println
(
""
+
MathUtil
.
getIndex
(
"
redis-test
"
,
1
,
16
));
System
.
out
.
println
(
""
+
MathUtil
.
getIndex
(
"
galaxy:user:zxinchain:1222222
"
,
1
,
16
));
}
}
}
}
liquidnet-bus-config/liquidnet-config/liquidnet-service-galaxy.yml
View file @
050d89b6
...
@@ -70,11 +70,11 @@ spring:
...
@@ -70,11 +70,11 @@ spring:
profiles
:
profiles
:
include
:
common-service
#这里加载management相关公共配置
include
:
common-service
#这里加载management相关公共配置
redis
:
redis
:
database
:
${liquidnet.redis.
sweet
.database}
database
:
${liquidnet.redis.
galaxy
.database}
dbs
:
${liquidnet.redis.
sweet
.dbs}
dbs
:
${liquidnet.redis.
galaxy
.dbs}
port
:
${liquidnet.redis.
sweet
.port}
port
:
${liquidnet.redis.
galaxy
.port}
host
:
${liquidnet.redis.
sweet
.host}
host
:
${liquidnet.redis.
galaxy
.host}
password
:
${liquidnet.redis.
sweet
.password}
password
:
${liquidnet.redis.
galaxy
.password}
lettuce
:
lettuce
:
pool
:
pool
:
max-active
:
8
max-active
:
8
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/biz/ZxinUserBiz.java
View file @
050d89b6
...
@@ -16,8 +16,10 @@ import com.liquidnet.commons.lang.util.BASE64Util;
...
@@ -16,8 +16,10 @@ import com.liquidnet.commons.lang.util.BASE64Util;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
com.liquidnet.service.galaxy.utils.DataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -49,30 +51,37 @@ public class ZxinUserBiz {
...
@@ -49,30 +51,37 @@ public class ZxinUserBiz {
@Autowired
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
DataUtils
dataUtils
;
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
String
userId
=
reqDto
.
getUserId
();
String
userId
=
reqDto
.
getUserId
();
String
userName
=
reqDto
.
getUserName
();
String
userName
=
reqDto
.
getUserName
();
String
mobile
=
reqDto
.
getMobile
();
String
mobile
=
reqDto
.
getMobile
();
String
idCardType
=
reqDto
.
getIdCardType
();
String
idCardType
=
reqDto
.
getIdCardType
();
String
idCard
=
reqDto
.
getIdCard
();
String
idCard
=
reqDto
.
getIdCard
();
String
mnemonic
=
null
;
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
;
Long
index
=
0L
;
String
userIdentification
=
null
;
String
userIdentification
=
null
;
String
address
=
null
;
String
address
=
null
;
String
userPubKey
=
null
;
String
userPubKey
=
null
;
String
userPriKey
=
null
;
String
userPriKey
=
null
;
try
{
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouteType
(),
userId
);
//生成助记词
if
(
userInfoBo
!=
null
){
CreateMnemonicReq
req
=
CreateMnemonicReq
.
getNew
();
mnemonic
=
userInfoBo
.
getMnemonic
();
CreateMnemonicResp
createMnemonicResp
=
zxlWalletSdkUtil
.
createMnemonic
(
req
);
}
else
{
mnemonic
=
createMnemonicResp
.
getMnemonic
();
try
{
}
catch
(
Exception
e
){
//生成助记词
throw
new
ZxlNftException
(
ZxlErrorEnum
.
FAILURE
.
getCode
(),
"生成助记词失败!"
);
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
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
*/
...
@@ -150,6 +159,25 @@ public class ZxinUserBiz {
...
@@ -150,6 +159,25 @@ public class ZxinUserBiz {
}
else
{
}
else
{
return
ResponseDto
.
failure
(
nft016Resp
.
getMessage
());
return
ResponseDto
.
failure
(
nft016Resp
.
getMessage
());
}
}
//构造缓存数据
if
(
userInfoBo
==
null
){
userInfoBo
=
GalaxyUserInfoBo
.
getNew
();
userInfoBo
.
setUserId
(
userId
);
userInfoBo
.
setUserName
(
userName
);
userInfoBo
.
setMobile
(
mobile
);
userInfoBo
.
setIdCardType
(
idCardType
);
userInfoBo
.
setIdCard
(
idCard
);
userInfoBo
.
setMnemonic
(
mnemonic
);
userInfoBo
.
setIndex
(
index
.
toString
());
userInfoBo
.
setUserIdentification
(
userIdentification
);
userInfoBo
.
setUserPubKey
(
userPubKey
);
userInfoBo
.
setUserPriKey
(
userPriKey
);
userInfoBo
.
setRouterType
(
GalaxyConstant
.
RouterTypeEnum
.
ZXINCHAIN
.
getCode
());
userInfoBo
.
setBlockChainAddress
(
address
);
dataUtils
.
setGalaxyUserInfo
(
reqDto
.
getRouteType
(),
reqDto
.
getUserId
(),
userInfoBo
);
}
}
}
return
ResponseDto
.
success
(
respDto
);
return
ResponseDto
.
success
(
respDto
);
}
}
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/utils/DataUtils.java
View file @
050d89b6
package
com
.
liquidnet
.
service
.
galaxy
.
utils
;
package
com
.
liquidnet
.
service
.
galaxy
.
utils
;
import
com.liquidnet.common.cache.redis.util.Redis
Galaxy
Util
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
...
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
...
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
@Component
@Component
public
class
DataUtils
{
public
class
DataUtils
{
@Autowired
@Autowired
private
Redis
Galaxy
Util
redisUtil
;
private
RedisUtil
redisUtil
;
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
...
@@ -22,6 +22,7 @@ public class DataUtils {
...
@@ -22,6 +22,7 @@ public class DataUtils {
public
void
setGalaxyUserInfo
(
String
routeType
,
String
userId
,
GalaxyUserInfoBo
userInfoBo
)
{
public
void
setGalaxyUserInfo
(
String
routeType
,
String
userId
,
GalaxyUserInfoBo
userInfoBo
)
{
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KET_GALAXY_USER
.
concat
(
routeType
).
concat
(
":"
)
+
userId
,
userInfoBo
,
keyExpireTime
);
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KET_GALAXY_USER
.
concat
(
routeType
).
concat
(
":"
)
+
userId
,
userInfoBo
,
keyExpireTime
);
mongoTemplate
.
save
(
userInfoBo
,
GalaxyUserInfoBo
.
class
.
getSimpleName
());
}
}
public
GalaxyUserInfoBo
getGalaxyUserInfo
(
String
routeType
,
String
userId
)
{
public
GalaxyUserInfoBo
getGalaxyUserInfo
(
String
routeType
,
String
userId
)
{
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/test/java/com/liquidnet/service/galaxy/TestRedisUtil.java
0 → 100644
View file @
050d89b6
package
com
.
liquidnet
.
service
.
galaxy
;
import
com.liquidnet.common.cache.redis.util.RedisDataSourceUtil
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestRedisUtil
* @Package com.liquidnet.service.galaxy
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 16:26
*/
@Slf4j
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
TestRedisUtil
{
@Autowired
private
RedisDataSourceUtil
redisUtil
;
private
long
keyExpireTime
=
3600
*
24
*
30
;
@Test
public
void
testSet
(){
String
userId
=
"test123"
;
GalaxyUserInfoBo
userInfoBo
=
GalaxyUserInfoBo
.
getNew
();
userInfoBo
.
setUserId
(
userId
);
String
key
=
GalaxyConstant
.
REDIS_KET_GALAXY_USER
.
concat
(
GalaxyConstant
.
RouterTypeEnum
.
ZXINCHAIN
.
getCode
()).
concat
(
":"
)
+
userId
;
redisUtil
.
getRedisGalaxyUtil
().
set
(
key
,
userInfoBo
,
keyExpireTime
);
}
}
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