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

Commit 03d2edd2 authored by anjiabin's avatar anjiabin

调试至信链NFt购买接口

parent c63c5586
...@@ -528,6 +528,7 @@ public abstract class DateUtil { ...@@ -528,6 +528,7 @@ public abstract class DateUtil {
return second; return second;
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(DateUtil.getNowTime());
//获取秒数 //获取秒数
Long second = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")); Long second = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
//获取毫秒数 //获取毫秒数
......
...@@ -41,6 +41,9 @@ public enum ErrorCode implements ServiceErrorCode { ...@@ -41,6 +41,9 @@ public enum ErrorCode implements ServiceErrorCode {
ERROR("1",""), ERROR("1",""),
HTTP_PARAM_ERROR("2", "Param error"), HTTP_PARAM_ERROR("2", "Param error"),
HTTP_SYSTEM_ERROR("50000", "System busy, please try again later"), HTTP_SYSTEM_ERROR("50000", "System busy, please try again later"),
SYSTEM_ERROR("SYS0010001", "系统异常,请联系管理员"),
SERVER_INNER_ERROR("SYS0010002", "系统内部错误"),
SERVER_ERROR("SYS0010003", "服务不可用,调用后端服务失败")
; ;
......
...@@ -56,7 +56,7 @@ public class ZxlnftBiz { ...@@ -56,7 +56,7 @@ public class ZxlnftBiz {
commonHeader.add("Nonce", resp.getSignData().getNonce()); commonHeader.add("Nonce", resp.getSignData().getNonce());
commonHeader.add("Content-Type", "application/json;charset=utf-8"); commonHeader.add("Content-Type", "application/json;charset=utf-8");
log.info("buildHeader ---> {}",JsonUtils.toJson(commonHeader)); log.debug("buildHeader ---> {}",JsonUtils.toJson(commonHeader));
} }
/** /**
...@@ -76,7 +76,7 @@ public class ZxlnftBiz { ...@@ -76,7 +76,7 @@ public class ZxlnftBiz {
commonHeader.add("Nonce", resp.getSignData().getNonce()); commonHeader.add("Nonce", resp.getSignData().getNonce());
commonHeader.add("Content-Type", "application/json;charset=utf-8"); commonHeader.add("Content-Type", "application/json;charset=utf-8");
log.info("buildPlatFormHeader ---> {}",JsonUtils.toJson(commonHeader)); log.debug("buildPlatFormHeader ---> {}",JsonUtils.toJson(commonHeader));
} }
public <T> T buildNftRespObj(String response,Class<T> tClass){ public <T> T buildNftRespObj(String response,Class<T> tClass){
......
...@@ -10,47 +10,27 @@ import java.util.Arrays; ...@@ -10,47 +10,27 @@ import java.util.Arrays;
* @Package com.liquidnet.common.third.zxlnft.constant * @Package com.liquidnet.common.third.zxlnft.constant
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 14:00 * @date 2022/2/21 14:00
*
* * SYS001[0001~9999] : 系统占用 SYS0010001
* * ZXL001[0001~9999] : 至信链NFT业务
* 说明 ZXL001为NFT业务 ZXL002为存证业务
*/ */
public enum ZxlErrorEnum { public enum ZxlErrorEnum {
SECCESS("0","成功"), SECCESS("0","成功"),
FAILURE("1","失败"), FAILURE("1","失败"),
NO_INIT_ERROR("000", "没有初始化"), SYSTEM_ERROR("SYS0010001", "系统异常,请联系管理员"),
APP_TYPE_ERROR("001", "应用类型错误"), SERVER_INNER_ERROR("SYS0010002", "系统内部错误"),
INVALID_PARAM_ERROR("002", "参数错误"), SERVER_ERROR("SYS0010003", "服务不可用,调用后端服务失败"),
GENERATE_KEYPAIR_ERROR("003", "生成公私钥错误"), INVALID_PARAM_ERROR("ZXL0010001", "参数错误"),
SIGN_ERROR("004", "签名错误"), GENERATE_KEYPAIR_ERROR("ZXL0010002", "生成公私钥错误"),
VERIFY_ERROR("005", "验签错误"), SIGN_ERROR("ZXL0010003", "签名错误"),
ENCRYPT_ERROR("006", "加密数据错误"), VERIFY_ERROR("ZXL0010004", "验签错误"),
DECODE_ERROR("007", "解密数据错误"), ENCRYPT_ERROR("ZXL0010005", "加密数据错误"),
CALCULATE_FILE_HASH_ERROR("008", "计算文件hash错误"), DECODE_ERROR("ZXL0010006", "解密数据错误"),
BIND_USER_CERT_ERROR("009", "绑定用户证书错误"), IMAGE_CHECK_ERROR("ZXL0010007", "图片内容检测未通过"),
UPDATE_USER_CERT_ERROR("010", "更新用户证书错误"), PARAM_FORMAT_ERROR("ZXL0010008", "参数格式错误"),
APPLY_EVIDENCE_ERROR("011", "申请存证错误"), ORDER_NOT_FOUND_ERROR("ZXL0010009", "此编号未查到对应信息"),
SAVE_EVIDENCE_ERROR("012", "存证错误"), UPLOAD_TEMP_SECRET("ZXL0010010", "生成素材上传临时密钥失败");
QUERY_EVIDENCE_ERROR("013", "查询存证错误"),
AUTHOR_LIMIT_ERROR("027", "作者数量超限错误"),
CALCULATE_HASH_ERROR("014", "计算字符串hash错误"),
EVIDENCE_HASH_IS_NULL("016", "存证hash为空"),
ISSUE_TASK_ERROR("017", "下发任务失败"),
EVIDENCE_HASH_CAL_SM3("018", "存证hash摘要算法不通过,仅支持SM3"),
QUERY_OBTAIN_TASK_ERROR("019", "获取取证任务结果失败"),
OBTAIN_TASK_FAIL("020", "取证失败"),
QUERY_CERT_FAIL("021", "获取取证证书信息失败"),
URL_INVALID("022", "url不合规,请检查"),
DATE_INVALID("023", "时间不合规,请检查"),
CREATE_TORT_TASK_ERR("024", "创建侵权监控任务失败"),
FILE_AND_URL_NOT_MATCH("025", "evHash与url文件的hash不匹配"),
URL_OR_NETWORK_ERR("026", "url地址不正确或者网络不佳,文件下载失败"),
PARAM_FORMAT_ERROR("461000", "参数格式错误"),
INVALID_APP_ERROR("461010", "无效的用户appid"),
PACKAGE_CLOSE_ERROR("562012", "用户消费套餐已被关闭"),
NO_PACKAGE_ERROR("562013", "没有可用的消费套餐"),
SERVER_INNER_ERROR("562014", "内部错误"),
ORDER_NOT_FOUND_ERROR("-101", "此编号未查到对应信息"),
SERVER_ERROR("3108", "服务不可用,调用后端服务失败"),
UPDATE_CONSUME_ERROR("563006", "更新消费流水状态失败"),
MID_SERVER_ERROR("022", "中间件服务异常"),
TORT_SOURCE_ERROR("6026", "侵权 Source 类型错误");
private String code; private String code;
private String msg; private String msg;
ZxlErrorEnum(String code, String msg) { ZxlErrorEnum(String code, String msg) {
......
...@@ -14,6 +14,36 @@ public class ZxlnftEnum { ...@@ -14,6 +14,36 @@ public class ZxlnftEnum {
* txType 交易类别, 1:发行 2:购买 3:转移 4:设置价格 5:设置状态 * txType 交易类别, 1:发行 2:购买 3:转移 4:设置价格 5:设置状态
*/ */
/**
* 图片检测结果建议
*/
public enum SuggestionEnum{
BLOCK("Block","建议屏蔽"),
REVIEW("Review","建议复审"),
PASS("Pass","建议通过");
private String code;
private String message;
SuggestionEnum(String code, String message) {
this.code = code;
this.message = message;
}
public SuggestionEnum getEnumByCode(String code){
SuggestionEnum[] arry = SuggestionEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
}
/** /**
* 下发用户信息查询验证码(使用场景) * 下发用户信息查询验证码(使用场景)
*/ */
......
package com.liquidnet.common.third.zxlnft.dto.wallet; package com.liquidnet.common.third.zxlnft.dto.wallet;
import com.liquidnet.commons.lang.util.JsonUtils;
import lombok.Data; import lombok.Data;
/** /**
...@@ -14,4 +15,9 @@ import lombok.Data; ...@@ -14,4 +15,9 @@ import lombok.Data;
@Data @Data
public class UploadToCosResp { public class UploadToCosResp {
private String err; private String err;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
} }
...@@ -31,7 +31,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -31,7 +31,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_01_CREATE_MNEMONIC; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_01_CREATE_MNEMONIC;
log.info("createMnemonic--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("createMnemonic--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -45,7 +45,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -45,7 +45,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("createUser error",e); log.error("createUser error",e);
} }
log.info("createMnemonic--->>> response : {} ",response); log.debug("createMnemonic--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -61,7 +61,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -61,7 +61,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("appKey", req.getAppKey()); json.put("appKey", req.getAppKey());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_02_GENERATE_API_SIGN; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_02_GENERATE_API_SIGN;
log.info("generateApiSign--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("generateApiSign--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode(); // ObjectNode objectNode = JsonUtils.OM().createObjectNode();
...@@ -72,7 +72,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -72,7 +72,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("generateApiSign error",e); log.error("generateApiSign error",e);
} }
log.info("generateApiSign--->>> response : {} ",response); log.debug("generateApiSign--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -123,7 +123,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -123,7 +123,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("index", req.getIndex()); json.put("index", req.getIndex());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_05_DERIVE_KEY_PAIR; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_05_DERIVE_KEY_PAIR;
log.info("deriveKeyPair--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("deriveKeyPair--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode(); // ObjectNode objectNode = JsonUtils.OM().createObjectNode();
...@@ -134,7 +134,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -134,7 +134,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("deriveKeyPair error",e); log.error("deriveKeyPair error",e);
} }
log.info("deriveKeyPair--->>> response : {} ",response); log.debug("deriveKeyPair--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -150,7 +150,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -150,7 +150,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("data", req.getData()); json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_06_SIGN_BY_PRI_KEY; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_06_SIGN_BY_PRI_KEY;
log.info("signByPriKey--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("signByPriKey--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode(); // ObjectNode objectNode = JsonUtils.OM().createObjectNode();
...@@ -161,7 +161,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -161,7 +161,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("signByPriKey error",e); log.error("signByPriKey error",e);
} }
log.info("signByPriKey--->>> response : {} ",response); log.debug("signByPriKey--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -175,7 +175,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -175,7 +175,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("pri", req.getPri()); json.put("pri", req.getPri());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_07_PRI_KEY_2_PUB_KEY; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_07_PRI_KEY_2_PUB_KEY;
log.info("priKey2PubKey--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("priKey2PubKey--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -185,7 +185,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -185,7 +185,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("priKey2PubKey error",e); log.error("priKey2PubKey error",e);
} }
log.info("priKey2PubKey--->>> response : {} ",response); log.debug("priKey2PubKey--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -200,7 +200,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -200,7 +200,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("pubKey", req.getPubKey()); json.put("pubKey", req.getPubKey());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_08_PUB_KEY_2_ADDRESS; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_08_PUB_KEY_2_ADDRESS;
log.info("pubKey2Address--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("pubKey2Address--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -210,7 +210,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -210,7 +210,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("pubKey2Address error",e); log.error("pubKey2Address error",e);
} }
log.info("pubKey2Address--->>> response : {} ",response); log.debug("pubKey2Address--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -225,7 +225,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -225,7 +225,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("priKey", req.getPriKey()); json.put("priKey", req.getPriKey());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_09_PRI_KEY_2_ADDRESS; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_09_PRI_KEY_2_ADDRESS;
log.info("priKey2Address--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("priKey2Address--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -235,7 +235,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -235,7 +235,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("priKey2Address error",e); log.error("priKey2Address error",e);
} }
log.info("priKey2Address--->>> response : {} ",response); log.debug("priKey2Address--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -252,7 +252,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -252,7 +252,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("data", req.getData()); json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_10_VERIFY_BY_PUB_KEY; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_10_VERIFY_BY_PUB_KEY;
log.info("verifyByPubKey--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("verifyByPubKey--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -262,7 +262,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -262,7 +262,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("verifyByPubKey error",e); log.error("verifyByPubKey error",e);
} }
log.info("verifyByPubKey--->>> response : {} ",response); log.debug("verifyByPubKey--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -277,7 +277,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -277,7 +277,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("data", req.getData()); json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_11_SM3_HASH; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_11_SM3_HASH;
log.info("sM3Hash--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("sM3Hash--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -287,7 +287,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -287,7 +287,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("sM3Hash error",e); log.error("sM3Hash error",e);
} }
log.info("sM3Hash--->>> response : {} ",response); log.debug("sM3Hash--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
...@@ -302,7 +302,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -302,7 +302,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
json.put("data", req.getData()); json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_12_SM3_HASH_ENCODE; String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_12_SM3_HASH_ENCODE;
log.info("sM3HashEncode--->>> request url : {} body : {} ",requestUrl, json.toString()); log.debug("sM3HashEncode--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null; String response = null;
try { try {
...@@ -312,7 +312,7 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -312,7 +312,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
}catch (Exception e) { }catch (Exception e) {
log.error("sM3HashEncode error",e); log.error("sM3HashEncode error",e);
} }
log.info("sM3HashEncode--->>> response : {} ",response); log.debug("sM3HashEncode--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
return null; return null;
......
...@@ -7,9 +7,6 @@ import com.liquidnet.common.third.zxlnft.dto.nft.Nft022UploadSecretResp; ...@@ -7,9 +7,6 @@ import com.liquidnet.common.third.zxlnft.dto.nft.Nft022UploadSecretResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.*; import com.liquidnet.common.third.zxlnft.dto.wallet.*;
import com.liquidnet.common.third.zxlnft.service.WalletSdkService; import com.liquidnet.common.third.zxlnft.service.WalletSdkService;
import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService; import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil;
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;
...@@ -61,33 +58,7 @@ public class ZxlWalletSdkUtil { ...@@ -61,33 +58,7 @@ public class ZxlWalletSdkUtil {
* @param req * @param req
* @return * @return
*/ */
public UploadToCosResp uploadToCos(UploadToCosReq req,String seriesName){ public UploadToCosResp uploadToCos(UploadToCosReq req){
//获取临时密钥
Nft022UploadSecretReq nft022Req = Nft022UploadSecretReq.getNew();
nft022Req.setTimestamp(DateUtil.getNowSeconds().toString());
nft022Req.setPubKey(zxlnftConfig.getNftPlatformPubKey());
nft022Req.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
//系列为空
String pubData = nft022Req.getTimestamp() + "_" + nft022Req.getUserPubKey();
String userData = nft022Req.getTimestamp();
//系列不为空
if(StringUtil.isNotEmpty(seriesName)){
nft022Req.setSeriesName(seriesName);
pubData = nft022Req.getTimestamp() + "_" + nft022Req.getSeriesName() + "_" + nft022Req.getUserPubKey();
userData = nft022Req.getTimestamp() + "_" + nft022Req.getSeriesName();
}
nft022Req.setPubSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),pubData));
nft022Req.setUserSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),userData));
Nft022UploadSecretResp nft022Resp = zxlnftSdkService.nft022UploadSecret(nft022Req);
//执行上传
req.setCosPath(nft022Resp.getUploadAddress() + "2022-02-24/" + IDGenerator.getZxlNftImageCosCode()+".jpg");
req.setTempSecretId(nft022Resp.getTempSecretId());
req.setTempSecretKey(nft022Resp.getTempSecretKey());
req.setSessionToken(nft022Resp.getSessionToken());
req.setFilePath(req.getFilePath());
UploadToCosResp resp = walletSdkService.uploadToCos(req); UploadToCosResp resp = walletSdkService.uploadToCos(req);
return resp; return resp;
} }
......
...@@ -7,6 +7,7 @@ import com.liquidnet.common.third.zxlnft.dto.nft.*; ...@@ -7,6 +7,7 @@ import com.liquidnet.common.third.zxlnft.dto.nft.*;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException; import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService; import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService;
import com.liquidnet.commons.lang.util.BeanUtil; import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.StringUtil;
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;
...@@ -444,6 +445,15 @@ public class ZxlnftSdkUtil { ...@@ -444,6 +445,15 @@ public class ZxlnftSdkUtil {
Nft022UploadSecretReq req = Nft022UploadSecretReq.getNew(); Nft022UploadSecretReq req = Nft022UploadSecretReq.getNew();
BeanUtil.copy(reqDto,req); BeanUtil.copy(reqDto,req);
req.setPubKey(zxlnftConfig.getNftPlatformPubKey());
//系列为空
String pubData = req.getTimestamp() + "_" + req.getUserPubKey();
//系列不为空
if(StringUtil.isNotEmpty(req.getSeriesName())){
pubData = req.getTimestamp() + "_" + req.getSeriesName() + "_" + req.getUserPubKey();
}
req.setPubSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),pubData));
Nft022UploadSecretRespDto respDto = Nft022UploadSecretRespDto.getNew(); Nft022UploadSecretRespDto respDto = Nft022UploadSecretRespDto.getNew();
try{ try{
Nft022UploadSecretResp resp = zxlnftSdkService.nft022UploadSecret(req); Nft022UploadSecretResp resp = zxlnftSdkService.nft022UploadSecret(req);
......
package com.liquidnet.service.zxlnft; package com.liquidnet.service.zxlnft;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig; import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.Nft022UploadSecretReqDto;
import com.liquidnet.common.third.zxlnft.dto.Nft022UploadSecretRespDto;
import com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto;
import com.liquidnet.common.third.zxlnft.dto.wallet.*; import com.liquidnet.common.third.zxlnft.dto.wallet.*;
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.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
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;
...@@ -40,6 +48,12 @@ public class TestZxlWalletSdkUtil { ...@@ -40,6 +48,12 @@ public class TestZxlWalletSdkUtil {
@Autowired @Autowired
private ZxlnftConfig zxlnftConfig; private ZxlnftConfig zxlnftConfig;
@Autowired
private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
/** /**
* 1、生成助记词 * 1、生成助记词
*/ */
...@@ -65,16 +79,40 @@ public class TestZxlWalletSdkUtil { ...@@ -65,16 +79,40 @@ public class TestZxlWalletSdkUtil {
*/ */
@Test @Test
public void uploadToCos(){ public void uploadToCos(){
UploadToCosReq req = UploadToCosReq.getNew(); // String filePath = "/Users/anjiabin/Downloads/zxl_image_test_002.jpeg";
// req.setCosPath("https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/"+"zxl_image_test_001"); // String filePath = "/Users/anjiabin/Downloads/zxl_image_series_test_001.jpeg";
// req.setTempSecretId("AKIDhVGgR7gKaVE5qUIpSPD9k6pcmUj7fobmEspHDlCjC27Te6Dmputh-fI87qvL2EDT"); String filePath = "/Users/anjiabin/Downloads/zxl_image_test_001.jpg";
// req.setTempSecretKey("xuNqn+FfVjm0Ug0je9k1Mn5MQHKlWKs18uU03KIMAH0="); String seriesName = "NOW_ZXL_NFT_PIC001_skuId001_test";
// req.setSessionToken("fwJfhxx5ILXFYNItgiQid1bBiTrofX5af128eb2fa96eef4d9841c98756853142d0X-nPNtZgA0AEIwJ-MAJigzB3IZOgDjLorykjfoxAHusyQ_HeAhvHSlORtPol_iqqJVolGP78H5byiZKhKxATIZiJzrTCQysR02tR1vJPkJp03VH70sSzTJ3WcyTPpBs_NCuXkYvLZaDbRKmE8Xln4uqDJDSthNNaQKBJBYJNnxmVpCRCIeIyqOvQrSKXRGkvkjQ79Enlq7iUeKSqXrpKEBliAq9hgMrXPRHapqihseRl-WerjB4BgQ261mmOuZD6oHg37EPy_JrHAJxHh9dJlFlqz3CxUL-We36RcQeDpLvL1KuzZUBBmjSb0SYMvnun7SOEDdDMF0-1ApATsyQ-bTgDiCHAoo5Xqf9CcFKop-rUeQEDKSV17raeRRcN6ZcBQ-BJ5s4R4bqRm3y1nUwePNKD1Hi2__-nPUKuI5o535wkQcqMeDhQ40Fg3jCcPPRJ-9_Egp3yTEraTkfihKDAXTZnhiQdxaDInlP1JFJKZwY5b0hinlW6yaxnaUzYyXqTVY2tEufNOu5Sn4fGOTZmyqJJ0oDsCJiby-92vKqIS9fHIzemEXfuCULNdonmEThspBA7tUAUr-fY1KCjTMolhG0XvsJ-hNVzwNbpLMLd87TwajlyqJisnn5-sR-wuj9Hx9Inoe5kTRX-0F0NeP9vcfpYZns5No5jrBM74HMgOOSplXZ3yuML42LxTtw9SWcsxqFQJpohTyijpbrwdkKlwc0qGyUIPy7WQ7Jltb7iE"); // String fileName = "/"+ seriesName + "/" + DateUtil.getNowTime()+"/"+ IDGenerator.getZxlNftImageCosCode() +".jpg";
// req.setFilePath("/Users/anjiabin/Downloads/zxl_image_test_001.jpg"); String fileName = "/" + DateUtil.getNowTime()+"/"+ IDGenerator.getZxlNftImageCosCode() +".jpg";
// req.setFilePath("/Users/anjiabin/Downloads/zxl_image_test_002.jpeg");
req.setFilePath("/Users/anjiabin/Downloads/zxl_image_series_test_001.jpeg"); //调用生成素材上传临时密钥接口
// zxlWalletSdkUtil.uploadToCos(req,null); Nft022UploadSecretReqDto nft022ReqDto = Nft022UploadSecretReqDto.getNew();
zxlWalletSdkUtil.uploadToCos(req,"NOW_ZXL_NFT_PIC001"); nft022ReqDto.setSeriesName(seriesName);
nft022ReqDto.setTimestamp(DateUtil.getNowSeconds().toString());
nft022ReqDto.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
//系列为空
String userData = nft022ReqDto.getTimestamp();
//系列不为空
if(StringUtil.isNotEmpty(nft022ReqDto.getSeriesName())){
userData = nft022ReqDto.getTimestamp() + "_" + nft022ReqDto.getSeriesName();
}
nft022ReqDto.setUserSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),userData));
ZxlnftResponseDto<Nft022UploadSecretRespDto> nft022RespDto = zxlnftSdkUtil.nft022UploadSecret(nft022ReqDto);
if(nft022RespDto.isSuccess()){
UploadToCosReq req = UploadToCosReq.getNew();
req.setCosPath(nft022RespDto.getData().getUploadAddress().concat(fileName));
req.setTempSecretId(nft022RespDto.getData().getTempSecretId());
req.setTempSecretKey(nft022RespDto.getData().getTempSecretKey());
req.setSessionToken(nft022RespDto.getData().getSessionToken());
req.setFilePath(filePath);
UploadToCosResp resp = zxlWalletSdkUtil.uploadToCos(req);
System.out.println("返回结果:"+resp.toString());
}
} }
/** /**
......
...@@ -8,6 +8,7 @@ import com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil; ...@@ -8,6 +8,7 @@ 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.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
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;
...@@ -256,7 +257,8 @@ public class TestZxlnftSdkUtil { ...@@ -256,7 +257,8 @@ public class TestZxlnftSdkUtil {
@Test @Test
public void nft016IdentityBindQuery(){ public void nft016IdentityBindQuery(){
Nft016IdentityBindQueryReqDto reqDto = Nft016IdentityBindQueryReqDto.getNew(); Nft016IdentityBindQueryReqDto reqDto = Nft016IdentityBindQueryReqDto.getNew();
reqDto.setAddressList("ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4"); // reqDto.setAddressList("ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4");
reqDto.setAddressList("ZXfa63b4ff148dbebb6ed9c185a5f7f8b8fdcf90ad");
ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> resp = zxlnftSdkUtil.nft016IdentityBindQuery(reqDto); ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> resp = zxlnftSdkUtil.nft016IdentityBindQuery(reqDto);
System.out.println(resp.toJson()); System.out.println(resp.toJson());
} }
...@@ -280,33 +282,51 @@ public class TestZxlnftSdkUtil { ...@@ -280,33 +282,51 @@ public class TestZxlnftSdkUtil {
@Test @Test
public void nft021UploadUrl(){ public void nft021UploadUrl(){
Nft021UploadUrlReqDto reqDto = Nft021UploadUrlReqDto.getNew(); Nft021UploadUrlReqDto reqDto = Nft021UploadUrlReqDto.getNew();
// reqDto.setSeriesName(""); reqDto.setSeriesName("NOW_ZXL_NFT_PIC001_test_skuId001");
reqDto.setPlatformIdentification(zxlnftConfig.getPlatformIdentification()); reqDto.setPlatformIdentification(zxlnftConfig.getPlatformIdentification());
// reqDto.setUserIdentification(zxlnftConfig.getPlatformIdentification()); reqDto.setUserIdentification(zxlnftConfig.getPlatformIdentification()); //暂时素材上传人和平台管理员是同一个人
ZxlnftResponseDto<Nft021UploadUrlRespDto> resp = zxlnftSdkUtil.nft021UploadUrl(reqDto); ZxlnftResponseDto<Nft021UploadUrlRespDto> resp = zxlnftSdkUtil.nft021UploadUrl(reqDto);
System.out.println(resp.toJson()); System.out.println(resp.toJson());
// {
// "code": "0",
// "data": {
// "materialAddress": "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/NOW_ZXL_NFT_PIC001_test_skuId001/"
// },
// "success": true
// }
} }
@Test @Test
public void nft022UploadSecret(){ public void nft022UploadSecret(){
Nft022UploadSecretReqDto req = Nft022UploadSecretReqDto.getNew(); Nft022UploadSecretReqDto reqDto = Nft022UploadSecretReqDto.getNew();
// req.setSeriesName(""); reqDto.setSeriesName("NOW_ZXL_NFT_PIC001_test_skuId001");
req.setTimestamp(DateUtil.getNowSeconds().toString()); reqDto.setTimestamp(DateUtil.getNowSeconds().toString());
req.setPubKey(zxlnftConfig.getNftPlatformPubKey()); reqDto.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
req.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
//系列为空 //系列为空
String pubData = req.getTimestamp() + "_" + req.getUserPubKey(); String userData = reqDto.getTimestamp();
String userData = req.getTimestamp();
//系列不为空 //系列不为空
// String pubData = req.getTimestamp() + "_" + req.getSeriesName() + "_" + req.getUserPubKey(); if(StringUtil.isNotEmpty(reqDto.getSeriesName())){
// String userData = req.getTimestamp() + "_" + req.getSeriesName(); userData = reqDto.getTimestamp() + "_" + reqDto.getSeriesName();
}
req.setPubSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),pubData));
req.setUserSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),userData)); reqDto.setUserSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),userData));
ZxlnftResponseDto<Nft022UploadSecretRespDto> resp = zxlnftSdkUtil.nft022UploadSecret(req); ZxlnftResponseDto<Nft022UploadSecretRespDto> resp = zxlnftSdkUtil.nft022UploadSecret(reqDto);
System.out.println(resp.toJson()); System.out.println(resp.toJson());
//为什了发行人和平台是同一个人时,uploadAddres会少一级目录 少了个人目录,是自动省略了吗?
// {
// "code": "0",
// "data": {
// "tempSecretId": "AKIDhhEkTGgB37L_rc-Wy6sfqvz70a1AspdRh11oawassCa6Rg2SZ-V7Z-x66cGtRpOO",
// "tempSecretKey": "2KZKWE/BfzgbHoCYTTihLJW2QyVm4Bz48gsD1uPLvJg=",
// "sessionToken": "kgtsbjIKkVgYlIEGTZRJ1NJ3UhadM7Ea1eff3b33758e079d44b6fe4fd1f60e47ug5Dj85tZJxxa9efvA0xBWj6fZWagnsEzf25ZSGsEJrjjEY8ydKuIQrUuIjW9ifGHC1BYQ9kChXrSyXxHKO9O2RD4qDa-g3ljhBAbChtFyMCLxZKCG9OKpmB3yyRnF9mb-D5CHTDhO7ubUap_tIldEyqkWxmvfrvHgF0ndnhRt_I444-YQxnroHEnEk4gcBkRdDTeI_9JhVhQy3LZoBflfW1h0ZOHk2O1U7JrnsS7t5hOdjfXIul142mimp2YsDifJc8j2U5uAlml37iNqZ1OFsvxVcbPSI8dWCOiZvRk3ndN9EDEXDZjgrr-1nC3j1ZdXXE5ii1DCWbfmvhWFBbJit6PGqO7M-95Zuw-6VkzX5vwNaYMqtcU_a7u3brFu1DihZHxcjt3O6avzjaU_su6t_98G0DzL_CjvR_fLFKCpI3f3OhGC8jFm6D10cGYadwW7uQ10waXgMs11xjsgiC-By2K4G5xNa36t11wuXxISzJg5-v_eLCXQue8YXwZJNN2e49CdK2trGEwtB8z0Ok6HnlXK68fSCk0PDcmo1MhP18kCDC3Cm_LgbOQGExpuTDPc_HKlUZn9xBVJWqqiySE05aFSs8nr6WLlce5lzFbhIY_yJLMprZNNg8azBK_bgiyEJWavf3Kt8KRAo0YEMs8R0Cuma5YLsCzzCN6vBkW_hWfqZceT_BAcrP3p_-4IPtj7LtbfbhrhnfcUtfC2BoJiBIQXFPita4QrKwpkKVW5SyDw6O2zh0Iam7DjdXlKFrdH8nJef3oRYEqLsS_MOMU29kNRIxLfcrsXw_jTQ1Bjs",
// "uploadAddress": "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/NOW_ZXL_NFT_PIC001_test_skuId001/"
// },
// "success": true
// }
} }
@Test @Test
......
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.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum; 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.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.dto.wallet.UploadToCosReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.UploadToCosResp;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException; 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.BASE64Util;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil; 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;
...@@ -41,6 +46,9 @@ public class TestZxlnftService { ...@@ -41,6 +46,9 @@ public class TestZxlnftService {
@Autowired @Autowired
private ZxlnftBiz zxlnftBiz; private ZxlnftBiz zxlnftBiz;
@Autowired
private ZxlnftConfig zxlnftConfig;
/** /**
* 1、NFT平台在至信链的注册、审核 * 1、NFT平台在至信链的注册、审核
*/ */
...@@ -73,7 +81,7 @@ public class TestZxlnftService { ...@@ -73,7 +81,7 @@ public class TestZxlnftService {
String mnemonic = "stuff name goat health siren dumb gorilla antique board tenant buffalo present"; //安家宾 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"; //周焕 // String mnemonic = "economy cost balance weapon flight also nut biology very sun slight about"; //周焕
Long index = 0L; Long index = 1L;
String userIdentification = null; String userIdentification = null;
String address = null; String address = null;
String userPubKey = null; String userPubKey = null;
...@@ -100,7 +108,7 @@ public class TestZxlnftService { ...@@ -100,7 +108,7 @@ public class TestZxlnftService {
deriveKeyPairReq.setIndex(index); deriveKeyPairReq.setIndex(index);
try{ try{
DeriveKeyPairResp deriveKeyPairResp = zxlWalletSdkUtil.deriveKeyPair(deriveKeyPairReq); DeriveKeyPairResp deriveKeyPairResp = zxlWalletSdkUtil.deriveKeyPair(deriveKeyPairReq);
if(deriveKeyPairResp.getErr().equals("")) throw new Exception("生成公私钥失败!"); if(!deriveKeyPairResp.getErr().equals("")) throw new Exception("生成公私钥失败!");
userPubKey = BASE64Util.encoded(deriveKeyPairResp.getPubKey()); userPubKey = BASE64Util.encoded(deriveKeyPairResp.getPubKey());
userPriKey = BASE64Util.encoded(deriveKeyPairResp.getPriKey()); userPriKey = BASE64Util.encoded(deriveKeyPairResp.getPriKey());
}catch(Exception e){ }catch(Exception e){
...@@ -140,7 +148,7 @@ public class TestZxlnftService { ...@@ -140,7 +148,7 @@ public class TestZxlnftService {
ZxlnftResponseDto<Nft014IdentityBindSubmitByTrustedRespDto> nft004Resp = zxlnftSdkUtil.nft014IdentityBindSubmitByTrusted(nft004ReqDto); ZxlnftResponseDto<Nft014IdentityBindSubmitByTrustedRespDto> nft004Resp = zxlnftSdkUtil.nft014IdentityBindSubmitByTrusted(nft004ReqDto);
if(nft004Resp.isSuccess()){ if(nft004Resp.isSuccess()){
// 1.2.3调用绑定状态批量查询 //1.2.3调用绑定状态批量查询
Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew(); Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew();
nft016ReqDto.setAddressList(nft004Resp.getData().getAddress()); nft016ReqDto.setAddressList(nft004Resp.getData().getAddress());
ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> nft016Resp = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto); ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> nft016Resp = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
...@@ -159,10 +167,61 @@ public class TestZxlnftService { ...@@ -159,10 +167,61 @@ public class TestZxlnftService {
*/ */
@Test @Test
public void nftUpload(){ public void nftUpload(){
String imageUrl = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg";
String seriesName = "NOW_ZXL_NFT_PIC001_test_skuId001"; //系列名字 skuId
// String filePath = "/Users/anjiabin/Downloads/zxl_image_test_002.jpeg";
// String filePath = "/Users/anjiabin/Downloads/zxl_image_series_test_001.jpeg";
String filePath = "/Users/anjiabin/Downloads/zxl_image_test_001.jpg";
String fileName = DateUtil.getNowTime(DateUtil.DATE_SMALL_STR)+"/"+ IDGenerator.getZxlNftImageCosCode() +".jpg";
String fullFilePath = null;
// 1.4.1调用图片内容检测接口 // 1.4.1调用图片内容检测接口
Nft008QueryImageModerationReqDto nft008ReqDto = Nft008QueryImageModerationReqDto.getNew();
nft008ReqDto.setImageUrl(imageUrl);
ZxlnftResponseDto<Nft008QueryImageModerationRespDto> nft008RespDto = zxlnftSdkUtil.nft008QueryImageModeration(nft008ReqDto);
if(!nft008RespDto.getData().getSuggestion().equals(ZxlnftEnum.SuggestionEnum.PASS.getCode())){
throw new ZxlNftException(ZxlErrorEnum.IMAGE_CHECK_ERROR.getCode(),ZxlErrorEnum.IMAGE_CHECK_ERROR.getMsg());
}
// 1.4.2调用生成素材上传临时密钥接口 // 1.4.2调用生成素材上传临时密钥接口
Nft022UploadSecretReqDto nft022ReqDto = Nft022UploadSecretReqDto.getNew();
nft022ReqDto.setSeriesName(seriesName);
nft022ReqDto.setTimestamp(DateUtil.getNowSeconds().toString());
nft022ReqDto.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
//系列为空
String userData = nft022ReqDto.getTimestamp();
//系列不为空
if(StringUtil.isNotEmpty(nft022ReqDto.getSeriesName())){
userData = nft022ReqDto.getTimestamp() + "_" + nft022ReqDto.getSeriesName();
}
nft022ReqDto.setUserSignedData(zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),userData));
ZxlnftResponseDto<Nft022UploadSecretRespDto> nft022RespDto = zxlnftSdkUtil.nft022UploadSecret(nft022ReqDto);
if(!nft022RespDto.isSuccess()){
throw new ZxlNftException(ZxlErrorEnum.UPLOAD_TEMP_SECRET.getCode(),ZxlErrorEnum.UPLOAD_TEMP_SECRET.getMsg());
}
// 1.4.3调用sdk接口-上传cos接口 // 1.4.3调用sdk接口-上传cos接口
if(nft022RespDto.isSuccess()){
fullFilePath = nft022RespDto.getData().getUploadAddress().concat(fileName);
UploadToCosReq req = UploadToCosReq.getNew();
req.setCosPath(fullFilePath);
req.setTempSecretId(nft022RespDto.getData().getTempSecretId());
req.setTempSecretKey(nft022RespDto.getData().getTempSecretKey());
req.setSessionToken(nft022RespDto.getData().getSessionToken());
req.setFilePath(filePath);
UploadToCosResp uploadToCosResp = zxlWalletSdkUtil.uploadToCos(req);
}
log.info("完整的素材访问fullFilePath url:{}",fullFilePath);
// 1.4.4调用查询素材地址接口 -- 非必需 // 1.4.4调用查询素材地址接口 -- 非必需
Nft021UploadUrlReqDto nft021ReqDto = Nft021UploadUrlReqDto.getNew();
nft021ReqDto.setSeriesName(seriesName);
nft021ReqDto.setPlatformIdentification(zxlnftConfig.getPlatformIdentification());
// reqDto.setUserIdentification(zxlnftConfig.getPlatformIdentification());
ZxlnftResponseDto<Nft021UploadUrlRespDto> resp = zxlnftSdkUtil.nft021UploadUrl(nft021ReqDto);
} }
/** /**
......
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