记得上下班打卡 | git大法好,push需谨慎

Commit 28111e2f authored by anjiabin's avatar anjiabin

nft增加用户数字账户开通

parent 88827d1f
package com.liquidnet.service.consumer.nft.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.nft.receiver.ConsumerGalaxyJsonNftUserRegisterReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.util.ArrayList;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 区块链nft订单相关
* @class: ConsumerSqlNftOrderInfoConfig
* @Package com.liquidnet.service.consumer.galaxy.config
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/25 14:45
*/
@Configuration
public class ConsumerGalaxyJsonNftUserRegisterConfig extends RedisStreamConfig {
@Autowired
private ConsumerGalaxyJsonNftUserRegisterReceiver jsonNftUserRegisterReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
@Bean
public List<Subscription> subscriptionJsonNftUserRegister(RedisConnectionFactory factory) {
List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GalaxyQueue stream = MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 10; i++) {
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory);
subscriptionList.add(listenerContainer.receiveAutoAck(
Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)),
StreamOffset.create(stream.getKey(), ReadOffset.lastConsumed()), jsonNftUserRegisterReceiver
));
listenerContainer.start();
}
return subscriptionList;
}
}
package com.liquidnet.service.consumer.nft.receiver;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftUserRegisterProcessor;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterReceiver extends AbstractBizRedisReceiver {
@Autowired
private ConsumerGalaxyJsonNftUserRegisterProcessor jsonNftUserRegisterProcessor;
@Override
protected boolean consumerMessageHandler(String msg) {
boolean aBoolean = false;
try {
GalaxyUserRegisterReqDto textMessage = JsonUtils.fromJson(msg, GalaxyUserRegisterReqDto.class);
if (textMessage == null) {
aBoolean = true;
} else {
//执行计数
ResponseDto<GalaxyUserRegisterRespDto> responseDto = jsonNftUserRegisterProcessor.userRegister(textMessage);
// if(responseDto.isSuccess()){
aBoolean = true;
// }
}
} catch (Exception e) {
log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
} finally {
if (!aBoolean) {
HashMap<String, String> map = CollectionUtil.mapStringString();
map.put("message", msg);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
}
}
return aBoolean;
}
@Override
protected String getRedisStreamKey() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getGroup();
}
}
package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerJsonNftPublishAndBuyProcessor
* @Package com.liquidnet.service.consumer.kylin.service.processor
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/29 17:04
*/
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterProcessor {
@Autowired
private ZxinUserCommonBiz zxinUserCommonBiz;
/**
* 执行用户注册
* @param reqDto
* @return
*/
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserCommonBiz.userRegister(reqDto);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment