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

Commit da78000a authored by anjiabin's avatar anjiabin

实现百度链nft转让功能

parent 227dd64d
......@@ -57,7 +57,10 @@ public class DecryptAndVerifyAspect {
}
private String decryptAndVerify(EncryptedReq encryptedReq) {
String sign = CodecUtil.sha1Encrypt(encryptedReq.getEncryptedData() + encryptedReq.getTimestamp());
String encryptedData = CodecUtil.aesEncrypt(JsonUtils.toJson(encryptedReq.getData()));
log.info("验签 加密后的数据:" + encryptedData);
String sign = CodecUtil.sha1Encrypt(encryptedData + encryptedReq.getTimestamp());
if (sign.equals(encryptedReq.getSign())) {
return CodecUtil.aesDecrypt(encryptedReq.getEncryptedData());
} else {
......
package com.liquidnet.service.consumer.base.receiver;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.codec.util.CodecUtil;
import com.liquidnet.service.base.codec.vo.EncryptedReq;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftTransferReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftTransferRespDto;
......@@ -12,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.HashMap;
@Slf4j
......@@ -56,15 +60,49 @@ public class ConsumerGalaxyJsonNftTransferReceiver extends AbstractBizRedisRecei
return MQConst.GalaxyQueue.JSON_NFT_TRANSFER.getGroup();
}
// /**
// * 执行nft转让
// * @param reqDto
// * @return
// */
// private ResponseDto<GalaxyNftTransferRespDto> nftTransfer(GalaxyNftTransferReqDto reqDto) {
// String postUrl = serviceGoblinUrl + "/goblin/nftTrade/que/nftTransfer";
// try {
// String postRespStr = HttpUtil.postJson(postUrl, JsonUtils.toJson(reqDto));
// ResponseDto responseDto = JsonUtils.fromJson(postRespStr, ResponseDto.class);
// return responseDto;
// } catch (Exception e) {
// log.error("Ex.NFT转让:请求异常[url={},paramsStr={}],ex:{}", postUrl, JsonUtils.toJson(reqDto), e.getMessage());
// return ResponseDto.failure();
// }
// }
/**
* 执行nft转让
* @param reqDto
* @return
*/
private ResponseDto<GalaxyNftTransferRespDto> nftTransfer(GalaxyNftTransferReqDto reqDto) {
log.info("nftTransfer request queue message:{}", JsonUtils.toJson(reqDto));
String postUrl = serviceGoblinUrl + "/goblin/nftTrade/que/nftTransfer";
try {
String postRespStr = HttpUtil.postJson(postUrl, JsonUtils.toJson(reqDto));
//获取摘要
Long timeStamp = DateUtil.asDate(LocalDateTime.now()).getTime();
String encryptedData = CodecUtil.aesEncrypt(JsonUtils.toJson(reqDto));
log.info("加密后的数据:" + encryptedData);
String sign = CodecUtil.sha1Encrypt(encryptedData + timeStamp);
log.info("签名:" + sign);
// //设置header
// MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
// header.add("signData",sign);
EncryptedReq<GalaxyNftTransferReqDto> encryptedReq = new EncryptedReq<>();
encryptedReq.setEncryptedData(encryptedData);
encryptedReq.setTimestamp(timeStamp);
encryptedReq.setSign(sign);
encryptedReq.setData(reqDto);
String postRespStr = HttpUtil.postJson(postUrl, JsonUtils.toJson(encryptedReq));
ResponseDto responseDto = JsonUtils.fromJson(postRespStr, ResponseDto.class);
return responseDto;
} catch (Exception e) {
......
......@@ -3,6 +3,8 @@ package com.liquidnet.service.galaxy.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.codec.annotation.DecryptAndVerify;
import com.liquidnet.service.base.codec.vo.EncryptedReq;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.aop.annotation.ControllerLog;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
......@@ -75,11 +77,30 @@ public class GalaxyTradeController {
return galaxyTradeService.nftPublishAndBuyResultQuery(reqDto);
}
// @ControllerLog(description = "NFT转让")
// @ApiOperationSupport(order = 2)
// @ApiOperation(value = "NFT转让")
// @PostMapping(value = {"/que/nftTransfer"})
// public ResponseDto<GalaxyNftTransferRespDto> nftTransfer(@Valid @RequestBody GalaxyNftTransferReqDto reqDto, HttpServletRequest request){
//
//
// ResponseDto<GalaxyNftTransferRespDto> responseDto = galaxyTradeService.nftTransfer(reqDto);
// if(!responseDto.isSuccess()){
// //系统异常允许重试
// if(responseDto.getCode().equalsIgnoreCase(GalaxyErrorEnum.NFT_TRANSFER_ERROR.getCode())){
// queueUtil.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_TRANSFER.getKey(), JsonUtils.toJson(reqDto));
// }
// }
// return ResponseDto.success();
// }
@ControllerLog(description = "NFT转让")
@DecryptAndVerify(decryptedClass = GalaxyNftTransferReqDto.class)
@ApiOperationSupport(order = 2)
@ApiOperation(value = "NFT转让")
@PostMapping(value = {"/que/nftTransfer"})
public ResponseDto<GalaxyNftTransferRespDto> nftTransfer(@Valid @RequestBody GalaxyNftTransferReqDto reqDto){
public ResponseDto<GalaxyNftTransferRespDto> nftTransfer(@Valid @RequestBody EncryptedReq<GalaxyNftTransferReqDto> encryptedReq){
GalaxyNftTransferReqDto reqDto = encryptedReq.getData();
ResponseDto<GalaxyNftTransferRespDto> responseDto = galaxyTradeService.nftTransfer(reqDto);
if(!responseDto.isSuccess()){
//系统异常允许重试
......
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