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

Commit 64a5b495 authored by anjiabin's avatar anjiabin

调试素材上传接口

parent 8079b502
......@@ -289,4 +289,27 @@ public class BeanUtil {
return convertBeanToMultiValueMap(bean,true);
}
/**
* bean转换为jsonString
* @param bean
* @return
* @throws IntrospectionException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
public static String convertBeanToJsonString(Object bean)
{
Map<String,Object> map = null;
try {
map = BeanUtil.convertBeanToMap(bean,false);
} catch (IntrospectionException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return JsonUtils.toJson(map);
}
}
......@@ -27,11 +27,10 @@
<artifactId>liquidnet-common-cache-redis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.easemob.im</groupId>
<artifactId>im-sdk-core</artifactId>
<version>0.3.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>jakarta.validation</groupId>-->
<!-- <artifactId>jakarta.validation-api</artifactId>-->
<!-- </dependency>-->
</dependencies>
<dependencyManagement>
<dependencies>
......
......@@ -2,10 +2,7 @@ package com.liquidnet.common.third.zxlnft.biz;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.SignByPriKeyReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.SignByPriKeyResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.*;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
import com.liquidnet.common.third.zxlnft.service.WalletSdkService;
import com.liquidnet.commons.lang.util.JsonUtils;
......@@ -14,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import java.nio.charset.StandardCharsets;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
......@@ -105,4 +104,11 @@ public class ZxlnftBiz {
SignByPriKeyResp resp = walletSdkService.signByPriKey(req);
return resp.getSignedData();
}
public String getHashString(String data){
SM3HashEncodeReq req = SM3HashEncodeReq.getNew();
req.setData(data.getBytes(StandardCharsets.UTF_8));
SM3HashEncodeResp sm3HashEncodeResp = walletSdkService.sM3HashEncode(req);
return sm3HashEncodeResp.getDigest();
}
}
package com.liquidnet.common.third.zxlnft.constant;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxlnftEnum
* @Package com.liquidnet.common.third.zxlnft.constant
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/25 11:16
*/
public class ZxlnftEnum {
/**
* 支付状态
*/
public enum SellStatusEnum{
CAN_SELL("1","可售"),
CAN_NOT_SELL("2","不可售");
private String code;
private String message;
SellStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public SellStatusEnum getEnumByCode(String code){
SellStatusEnum[] arry = SellStatusEnum.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;
}
}
}
......@@ -5,44 +5,53 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import java.io.Serializable;
/**
*
* @param <T>
* REDIRECT(-1),
* SUCCESS(0),
* FAIL(1),
* UNAUTH(2),
*/
public class ZxlNftResponseDto<T> implements Serializable, Cloneable {
public class ZxlnftResponseDto<T> implements Serializable, Cloneable {
private static final long serialVersionUID = 8377276776600901982L;
private String retCode;
private String retMsg;
private String code;
private String message;
private T data;
public boolean isSuccess() {
return this.retCode.equals("0");
return this.code.equals("0");
}
private ZxlNftResponseDto() {
private ZxlnftResponseDto() {
}
private ZxlNftResponseDto(String retCode) {
this.retCode = retCode;
private ZxlnftResponseDto(String code) {
this.code = code;
}
private ZxlNftResponseDto(String retCode, T data) {
this.retCode = retCode;
private ZxlnftResponseDto(String code, T data) {
this.code = code;
this.data = data;
}
private ZxlNftResponseDto(String retCode, String retMsg) {
this.retCode = retCode;
this.retMsg = retMsg;
private ZxlnftResponseDto(String code, String message) {
this.code = code;
this.message = message;
}
private ZxlNftResponseDto(String retCode, String retMsg, T data) {
this.retCode = retCode;
this.retMsg = retMsg;
private ZxlnftResponseDto(String code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public String getCode() {
return code;
}
public String getMessage() {
return message;
}
/**
* <p>Getter for the field <retCode>data</retCode>.</p>
* <p>Getter for the field <code>data</code>.</p>
*
* @return a T object.
*/
......@@ -50,28 +59,28 @@ public class ZxlNftResponseDto<T> implements Serializable, Cloneable {
return data;
}
public static <Object> ZxlNftResponseDto<Object> success() {
return new ZxlNftResponseDto<>("0");
public static <Object> ZxlnftResponseDto<Object> success() {
return new ZxlnftResponseDto<>("0");
}
public static <Object> ZxlNftResponseDto<Object> success(Object data) {
return new ZxlNftResponseDto<>("0", data);
public static <Object> ZxlnftResponseDto<Object> success(Object data) {
return new ZxlnftResponseDto<>("0", data);
}
public static <Object> ZxlNftResponseDto<Object> failure() {
return new ZxlNftResponseDto<>("1", "系统繁忙,请稍后再试");
public static <Object> ZxlnftResponseDto<Object> failure() {
return new ZxlnftResponseDto<>("1", "系统繁忙,请稍后再试");
}
public static <Object> ZxlNftResponseDto<Object> failure(String retMsg) {
return new ZxlNftResponseDto<>("1", retMsg);
public static <Object> ZxlnftResponseDto<Object> failure(String message) {
return new ZxlnftResponseDto<>("1", message);
}
public static <Object> ZxlNftResponseDto<Object> failure(String retCode, String retMsg) {
return new ZxlNftResponseDto<>(retCode, retMsg);
public static <Object> ZxlnftResponseDto<Object> failure(String code, String message) {
return new ZxlnftResponseDto<>(code, message);
}
public static <Object> ZxlNftResponseDto<Object> failure(String retCode, String retMsg, Object data) {
return new ZxlNftResponseDto<>(retCode, retMsg, data);
public static <Object> ZxlnftResponseDto<Object> failure(String code, String message, Object data) {
return new ZxlnftResponseDto<>(code, message, data);
}
public <T> T getParseData(Class<T> clazz) {
......
......@@ -17,6 +17,7 @@ import java.io.Serializable;
public class Nft002RegisterPersonReq implements Serializable {
private static final long serialVersionUID = 3035063716845958619L;
private String personName;
//@Null
private String email;
private String mobile;
private String verifyCode;
......
......@@ -20,6 +20,7 @@ public class Nft003RegisterPersonPlatformReq implements Serializable {
/**
* 用户邮箱(非必填)
*/
//@Null
private String email;
private String mobile;
private String idCard;
......
......@@ -22,10 +22,12 @@ public class Nft008QueryImageModerationReq implements Serializable {
/**
* 截帧频率,GIF图/长图检测专用,默认值为0,表示只会检测GIF图/长图的第一帧
*/
//@Null
private int intrval;
/**
* GIF图/长图检测专用,代表均匀最大截帧数量,默认值为1(即只取GIF第一张,或长图不做切分处理(可能会造成处理超时))
*/
//@Null
private int maxFrames;
private static final Nft008QueryImageModerationReq obj = new Nft008QueryImageModerationReq();
private static final long serialVersionUID = 6578525145142483650L;
......
......@@ -22,6 +22,7 @@ public class Nft009RegisterCompanyReq implements Serializable {
/**
* 企业邮箱
*/
//@Null
private String email;
/**
* 手机验证码
......@@ -38,6 +39,7 @@ public class Nft009RegisterCompanyReq implements Serializable {
/**
* 电子公函盖章扫描件标识,通过调用上传接口后获得
*/
//@Null
private int officialLetterId;
/**
* 法人代表姓名
......@@ -62,14 +64,17 @@ public class Nft009RegisterCompanyReq implements Serializable {
/**
* 接入平台名称
*/
//@Null
private String platformName;
/**
* 接入平台地址
*/
//@Null
private String platformUrl;
/**
* 平台业务类型(1:金融类 2:版权类 3:其他类 4:未填写)默认是未填写
*/
//@Null
private int businessType;
private static final Nft009RegisterCompanyReq obj = new Nft009RegisterCompanyReq();
......
......@@ -22,6 +22,7 @@ public class Nft010RegisterCompanyPlatformReq implements Serializable {
/**
* 企业邮箱
*/
//@Null
private String email;
/**
* 企业信用代码
......@@ -34,6 +35,7 @@ public class Nft010RegisterCompanyPlatformReq implements Serializable {
/**
* 电子公函盖章扫描件标识,通过调用上传接口后获得
*/
//@Null
private int officialLetterId;
/**
* 法人代表姓名
......@@ -58,14 +60,17 @@ public class Nft010RegisterCompanyPlatformReq implements Serializable {
/**
* 接入平台名称
*/
//@Null
private String platformName;
/**
* 接入平台地址
*/
//@Null
private String platformUrl;
/**
* 平台业务类型(1:金融类 2:版权类 3:其他类 4:未填写)默认是未填写
*/
//@Null
private int businessType;
/**
* 平台公钥
......
......@@ -22,6 +22,7 @@ public class Nft018FaceUrlReq implements Serializable {
/**
* browser:标识在浏览器启动刷脸 App:标识在App里启动刷脸,默认值为App
*/
//@Null
private String from;
private static final Nft018FaceUrlReq obj = new Nft018FaceUrlReq();
......
......@@ -22,6 +22,7 @@ public class Nft019FaceUrlByAddressReq implements Serializable {
/**
* browser:标识在浏览器启动刷脸 App:标识在App里启动刷脸,默认值为App
*/
//@Null
private String from;
private static final Nft019FaceUrlByAddressReq obj = new Nft019FaceUrlByAddressReq();
private static final long serialVersionUID = -2844476559915417939L;
......
......@@ -18,6 +18,7 @@ public class Nft021UploadUrlReq implements Serializable {
/**
* 系列名
*/
//@Null
private String seriesName;
/**
* 平台唯一标识
......@@ -26,6 +27,7 @@ public class Nft021UploadUrlReq implements Serializable {
/**
* 发行唯一标识
*/
//@Null
private String userIdentification;
private static final Nft021UploadUrlReq obj = new Nft021UploadUrlReq();
......
......@@ -18,6 +18,7 @@ public class Nft022UploadSecretReq implements Serializable {
/**
* 系列名
*/
//@Null
private String seriesName;
/**
* 10位时间戳,秒为单位,5分钟内有效
......
......@@ -50,6 +50,7 @@ public class Nft030SeriesClaimReq implements Serializable {
/**
* 系列下的nftId后缀,是否从0开始,true就是从0开始,默认为false,从1开始
*/
//@Null
private String seriesBeginFromZero;
/**
* 系列声明人的私钥签名,签名对象是(platformPubKey_pubKey_接口名_seriesName_totalCount_coverUrl_desc_maxPublishCount
......
......@@ -50,6 +50,7 @@ public class Nft034PublishReq implements Serializable {
/**
* 标签,【文创】,游戏,动漫,30个字符以内
*/
//@Null
private String flag;
/**
* 发行量,如果没有系列,就只能为1,如果有系列从1开始,比如如有100个,系列id范围则为[1-100],单次发行个数不超过1000,
......@@ -59,6 +60,7 @@ public class Nft034PublishReq implements Serializable {
/**
* 系列ID
*/
//@Null
private String seriesId;
/**
* 系列子ID从多少开始,没有系列只能填1。有系列情况下,根据系列声明时指定
......@@ -69,11 +71,12 @@ public class Nft034PublishReq implements Serializable {
/**
* 1:可售 2:不可售
*/
private String sellStatus;
private Integer sellStatus;
/**
* 可售状态下有意义,表示售卖多少积分
*/
private String sellCount;
//@Null
private Long sellCount;
/**
* 请求ID,每个请求需要填唯一的ID,重复请求用相同的ID,为了保证唯一性,必须使用uuid
*/
......@@ -81,6 +84,7 @@ public class Nft034PublishReq implements Serializable {
/**
* 扩展字段,用户自定义,长度不超过1024个字符
*/
//@Null
private String metaData;
/**
* 发行人的私钥签名,签名对象是(platformPubKey_pubKey_接口名_author_name_url_displayUrl_hash_desc_flag_publishCount_seriesId_seriesBeginIndex
......
......@@ -22,10 +22,12 @@ public class Nft037AddressListReq implements Serializable {
/**
* 通过系列id过滤
*/
//@Null
private String seriesId;
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -22,6 +22,7 @@ public class Nft038AddressWithoutSeriesListReq implements Serializable {
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -22,6 +22,7 @@ public class Nft039TradeListReq implements Serializable {
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -23,6 +23,7 @@ public class Nft040TradeInListReq implements Serializable
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -22,6 +22,7 @@ public class Nft041TradeOutListReq implements Serializable {
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -22,6 +22,7 @@ public class Nft042TradeAllListReq implements Serializable {
/**
* 查询偏移量,从0开始,和mysql一个语义
*/
//@Null
private Long offset;
/**
* 最大1000
......
......@@ -214,11 +214,51 @@ public class WalletSdkServiceImpl implements WalletSdkService {
@Override
public SM3HashResp sM3Hash(SM3HashReq req) {
return null;
JSONObject json = new JSONObject();
json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_11_SM3_HASH;
log.info("sM3Hash--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null;
try {
response = HttpUtil.postJson(requestUrl,json.toString(),commonHeader);
} catch(HttpClientErrorException e) {
log.error("sM3Hash error", e);
}catch (Exception e) {
log.error("sM3Hash error",e);
}
log.info("sM3Hash--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
SM3HashResp resp = JsonUtils.fromJson(response,SM3HashResp.class);
return resp;
}
@Override
public SM3HashEncodeResp sM3HashEncode(SM3HashEncodeReq req) {
return null;
JSONObject json = new JSONObject();
json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_12_SM3_HASH_ENCODE;
log.info("sM3HashEncode--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null;
try {
response = HttpUtil.postJson(requestUrl,json.toString(),commonHeader);
} catch(HttpClientErrorException e) {
log.error("sM3HashEncode error", e);
}catch (Exception e) {
log.error("sM3HashEncode error",e);
}
log.info("sM3HashEncode--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
SM3HashEncodeResp resp = JsonUtils.fromJson(response,SM3HashEncodeResp.class);
return resp;
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlnftConstant;
import com.liquidnet.common.third.zxlnft.dto.nft.*;
import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -387,7 +388,54 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
@Override
public Nft034PublishResp nft034Publish(Nft034PublishReq req) {
return null;
zxlnftBiz.buildPlatFormHeader(commonHeader);
//构造请求参数
String reqJsonStr = BeanUtil.convertBeanToJsonString(req);
String requestUrl = zxlnftConfig.getNftApiUrl() + ZxlnftConstant.ZXL_NFT_034_PUBLISH_URL;
log.info("nft034Publish--->>> request url : {} body : {} ",requestUrl,reqJsonStr);
String response = null;
try {
response = HttpUtil.postJson(requestUrl,reqJsonStr,commonHeader);
} catch(HttpClientErrorException e) {
log.error("nft034Publish error", e);
}catch (Exception e) {
log.error("nft034Publish error",e);
}
log.info("nft034Publish--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
/**
* 构造返回结果
*/
Nft034PublishResp resp = zxlnftBiz.buildNftRespObj(response,Nft034PublishResp.class);
log.info("nft034Publish--->>> return result : {} ",resp.toString());
return resp;
// JSONObject json = new JSONObject();
// json.put("pubKey", req.getPubKey());
// json.put("platformPubKey", req.getPlatformPubKey());
// json.put("author", req.getAuthor());
// json.put("name", req.getName());
// json.put("url", req.getUrl());
// json.put("displayUrl", req.getDisplayUrl());
// json.put("hash", req.getHash());
// json.put("desc", req.getDesc());
// json.put("flag", req.getFlag());
// json.put("publishCount", req.getPublishCount());
// json.put("seriesId", req.getSeriesId());
// json.put("seriesBeginIndex", req.getSeriesBeginIndex());
// json.put("sellStatus", req.getSellStatus());
// json.put("sellCount", req.getSellCount());
// json.put("operateId", req.getOperateId());
// json.put("metaData", req.getMetaData());
// json.put("signature", req.getSignature());
// json.put("platformSignature", req.getPlatformSignature());
}
@Override
......
......@@ -9,6 +9,7 @@ import com.liquidnet.common.third.zxlnft.service.WalletSdkService;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -60,10 +61,9 @@ public class ZxlWalletSdkUtil {
* @param req
* @return
*/
public UploadToCosResp uploadToCos(UploadToCosReq req){
public UploadToCosResp uploadToCos(UploadToCosReq req,String seriesName){
//获取临时密钥
Nft022UploadSecretReq nft022Req = Nft022UploadSecretReq.getNew();
// req.setSeriesName("");
nft022Req.setTimestamp(DateUtil.getNowSeconds().toString());
nft022Req.setPubKey(zxlnftConfig.getNftPlatformPubKey());
nft022Req.setUserPubKey(zxlnftConfig.getNftPlatformPubKey());
......@@ -72,15 +72,18 @@ public class ZxlWalletSdkUtil {
String pubData = nft022Req.getTimestamp() + "_" + nft022Req.getUserPubKey();
String userData = nft022Req.getTimestamp();
//系列不为空
// String pubData = req.getTimestamp() + "_" + req.getSeriesName() + "_" + req.getUserPubKey();
// String userData = req.getTimestamp() + "_" + req.getSeriesName();
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() + IDGenerator.getZxlNftImageCosCode()+".jpg");
req.setCosPath(nft022Resp.getUploadAddress() + "2022-02-24/" + IDGenerator.getZxlNftImageCosCode()+".jpg");
req.setTempSecretId(nft022Resp.getTempSecretId());
req.setTempSecretKey(nft022Resp.getTempSecretKey());
req.setSessionToken(nft022Resp.getSessionToken());
......@@ -133,4 +136,24 @@ public class ZxlWalletSdkUtil {
VerifyByPubKeyResp resp = walletSdkService.verifyByPubKey(req);
return resp;
}
/**
* 11、SDK-SM3哈希
* @param req
* @return
*/
public SM3HashResp sM3Hash(SM3HashReq req){
SM3HashResp resp = walletSdkService.sM3Hash(req);
return resp;
}
/**
* 12、SDK-SM3哈希EnCode
* @param req
* @return
*/
public SM3HashEncodeResp sM3HashEncode(SM3HashEncodeReq req){
SM3HashEncodeResp resp = walletSdkService.sM3HashEncode(req);
return resp;
}
}
package com.liquidnet.common.third.zxlnft.util;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.Nft034PublishReqDto;
import com.liquidnet.common.third.zxlnft.dto.Nft034PublishRespDto;
import com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto;
import com.liquidnet.common.third.zxlnft.dto.nft.*;
import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService;
import com.liquidnet.commons.lang.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -25,17 +30,61 @@ public class ZxlnftSdkUtil {
@Autowired
private ZxlnftSdkService zxlnftSdkService;
@Autowired
private ZxlnftBiz zxlnftBiz;
public Nft016IdentityBindQueryResp nft016IdentityBindQuery(Nft016IdentityBindQueryReq req){
req.setAddressList(zxlnftConfig.getNftPlatformAddress());
Nft016IdentityBindQueryResp resp = zxlnftSdkService.nft016IdentityBindQuery(req);
return resp;
}
public Nft021UploadUrlResp nft021UploadUrl(Nft021UploadUrlReq req){
Nft021UploadUrlResp resp = zxlnftSdkService.nft021UploadUrl(req);
return resp;
}
public Nft022UploadSecretResp nft022UploadSecret(Nft022UploadSecretReq req){
Nft022UploadSecretResp resp = zxlnftSdkService.nft022UploadSecret(req);
return resp;
}
public ZxlnftResponseDto<Nft034PublishRespDto> nft034Publish(Nft034PublishReqDto reqDto){
Nft034PublishReq req = Nft034PublishReq.getNew();
BeanUtil.copy(reqDto,req);
req.setPubKey(zxlnftConfig.getNftPlatformPubKey());
req.setPlatformPubKey(zxlnftConfig.getNftPlatformPubKey());
req.setHash(zxlnftBiz.getHashString(req.getUrl()));
/**
* 发行人的私钥签名,签名对象是(platformPubKey_pubKey_接口名_author_name_url_displayUrl_hash_desc_flag_publishCount_seriesId_seriesBeginIndex
* _sellStatus_sellCount_metaData_operateId)
* 接口名:publish_nft
*/
String signMetaData = req.getPlatformPubKey().concat("_").concat("publish_nft")
.concat("_").concat(req.getAuthor())
.concat("_").concat(req.getName())
.concat("_").concat(req.getUrl())
.concat("_").concat(req.getDisplayUrl())
.concat("_").concat(req.getHash())
.concat("_").concat(req.getDesc())
.concat("_").concat(req.getFlag()==null?"":req.getFlag())
.concat("_").concat(req.getPublishCount().toString())
.concat("_").concat(req.getSeriesId()==null?"":req.getSeriesId())
.concat("_").concat(req.getSeriesBeginIndex().toString())
.concat("_").concat(req.getSellStatus().toString())
.concat("_").concat(req.getSellCount()==null?Long.toString(0): req.getSellCount().toString())
.concat("_").concat(req.getMetaData()==null?"":req.getMetaData())
.concat("_").concat(req.getOperateId());
String signature = zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),signMetaData);
req.setSignature(signature);
String platformSignature = zxlnftBiz.createSign(zxlnftConfig.getNftPlatformPriKey(),signMetaData);
req.setPlatformSignature(platformSignature);
Nft034PublishResp resp = zxlnftSdkService.nft034Publish(req);
Nft034PublishRespDto respDto = Nft034PublishRespDto.getNew();
BeanUtil.copy(resp,respDto);
return ZxlnftResponseDto.success(respDto);
}
}
package com.liquidnet.common.third.zxlnft.test;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestJavaBeanToMap
* @Package com.liquidnet.common.third.zxlnft.test
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/24 18:40
*/
import com.liquidnet.common.third.zxlnft.dto.nft.Nft034PublishReq;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
/**
*
*/
public class TestJavaBeanToMap {
public static void main(String[] args) {
Nft034PublishReq req = Nft034PublishReq.getNew();
req.setPubKey("11222");
req.setPlatformPubKey("2222222");
try {
Map<String,Object> map = BeanUtil.convertBeanToMap(req,false);
System.out.println(JsonUtils.toJson(map));
} catch (IntrospectionException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.liquidnet.service.zxlnft.test;
package com.liquidnet.service.zxlnft;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.wallet.*;
......@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.nio.charset.StandardCharsets;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
......@@ -59,8 +61,11 @@ public class TestZxlWalletSdkUtil {
// req.setTempSecretId("AKIDhVGgR7gKaVE5qUIpSPD9k6pcmUj7fobmEspHDlCjC27Te6Dmputh-fI87qvL2EDT");
// req.setTempSecretKey("xuNqn+FfVjm0Ug0je9k1Mn5MQHKlWKs18uU03KIMAH0=");
// req.setSessionToken("fwJfhxx5ILXFYNItgiQid1bBiTrofX5af128eb2fa96eef4d9841c98756853142d0X-nPNtZgA0AEIwJ-MAJigzB3IZOgDjLorykjfoxAHusyQ_HeAhvHSlORtPol_iqqJVolGP78H5byiZKhKxATIZiJzrTCQysR02tR1vJPkJp03VH70sSzTJ3WcyTPpBs_NCuXkYvLZaDbRKmE8Xln4uqDJDSthNNaQKBJBYJNnxmVpCRCIeIyqOvQrSKXRGkvkjQ79Enlq7iUeKSqXrpKEBliAq9hgMrXPRHapqihseRl-WerjB4BgQ261mmOuZD6oHg37EPy_JrHAJxHh9dJlFlqz3CxUL-We36RcQeDpLvL1KuzZUBBmjSb0SYMvnun7SOEDdDMF0-1ApATsyQ-bTgDiCHAoo5Xqf9CcFKop-rUeQEDKSV17raeRRcN6ZcBQ-BJ5s4R4bqRm3y1nUwePNKD1Hi2__-nPUKuI5o535wkQcqMeDhQ40Fg3jCcPPRJ-9_Egp3yTEraTkfihKDAXTZnhiQdxaDInlP1JFJKZwY5b0hinlW6yaxnaUzYyXqTVY2tEufNOu5Sn4fGOTZmyqJJ0oDsCJiby-92vKqIS9fHIzemEXfuCULNdonmEThspBA7tUAUr-fY1KCjTMolhG0XvsJ-hNVzwNbpLMLd87TwajlyqJisnn5-sR-wuj9Hx9Inoe5kTRX-0F0NeP9vcfpYZns5No5jrBM74HMgOOSplXZ3yuML42LxTtw9SWcsxqFQJpohTyijpbrwdkKlwc0qGyUIPy7WQ7Jltb7iE");
req.setFilePath("/Users/anjiabin/Downloads/zxl_image_test_001.jpg");
zxlWalletSdkUtil.uploadToCos(req);
// req.setFilePath("/Users/anjiabin/Downloads/zxl_image_test_001.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);
zxlWalletSdkUtil.uploadToCos(req,"NOW_ZXL_NFT_PIC001");
}
/**
......@@ -116,4 +121,28 @@ public class TestZxlWalletSdkUtil {
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxlWalletSdkUtil.verifyByPubKey(req);
}
/**
* 11、SDK-SM3哈希 这个是44位,暂时不用
*/
@Test
public void sM3Hash(){
// String cosUrl = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg";
// SM3HashReq req = SM3HashReq.getNew();
// req.setData(cosUrl.getBytes(StandardCharsets.UTF_8));
// zxlWalletSdkUtil.sM3Hash(req);
}
/**
* 12、SDK-SM3哈希EnCode 这个是64位
*/
@Test
public void sM3HashEncode(){
String cosUrl = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg";
// String cosUrl = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241628485194860245.jpg";
// String cosUrl = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef//2022-02-24/ZXLNFTIMAGE202202241704292368452405.jpg";
SM3HashEncodeReq req = SM3HashEncodeReq.getNew();
req.setData(cosUrl.getBytes(StandardCharsets.UTF_8));
zxlWalletSdkUtil.sM3HashEncode(req);
}
}
package com.liquidnet.service.zxlnft.test;
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.constant.ZxlnftEnum;
import com.liquidnet.common.third.zxlnft.dto.Nft034PublishReqDto;
import com.liquidnet.common.third.zxlnft.dto.Nft034PublishRespDto;
import com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto;
import com.liquidnet.common.third.zxlnft.dto.nft.*;
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 lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -50,7 +55,7 @@ public class TestZxlnftSdkUtil {
Nft021UploadUrlReq req = Nft021UploadUrlReq.getNew();
// req.setSeriesName("");
req.setPlatformIdentification(zxlnftConfig.getPlatformIdentification());
req.setUserIdentification(zxlnftConfig.getPlatformIdentification());
// req.setUserIdentification(zxlnftConfig.getPlatformIdentification());
Nft021UploadUrlResp resp = zxlnftSdkUtil.nft021UploadUrl(req);
}
......@@ -74,4 +79,25 @@ public class TestZxlnftSdkUtil {
Nft022UploadSecretResp resp = zxlnftSdkUtil.nft022UploadSecret(req);
}
@Test
public void nft034Publish(){
Nft034PublishReqDto reqDto = Nft034PublishReqDto.getNew();
reqDto.setAuthor("正在现场作者");
reqDto.setName("正在现场NFT001");
reqDto.setUrl("https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg");
reqDto.setDisplayUrl("https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg");
reqDto.setDesc("NFT描述信息");
reqDto.setFlag("文创");
reqDto.setPublishCount(10l);
// reqDto.setSeriesId("");
reqDto.setSeriesBeginIndex(1);
reqDto.setSellStatus(Integer.parseInt(ZxlnftEnum.SellStatusEnum.CAN_SELL.getCode()));
reqDto.setSellCount(1000l);
reqDto.setOperateId(IDGenerator.get32UUID());
reqDto.setMetaData("");
ZxlnftResponseDto<Nft034PublishRespDto> resp = zxlnftSdkUtil.nft034Publish(reqDto);
System.out.println(resp.toJson());
}
}
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