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

Commit ff4314e4 authored by anjiabin's avatar anjiabin

实现nft中service接口

parent 64a5b495
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
*/ */
package com.liquidnet.commons.lang.util; package com.liquidnet.commons.lang.util;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.cglib.beans.BeanCopier; import org.springframework.cglib.beans.BeanCopier;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
...@@ -16,7 +18,9 @@ import java.lang.annotation.*; ...@@ -16,7 +18,9 @@ import java.lang.annotation.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier; import java.util.function.Supplier;
...@@ -312,4 +316,33 @@ public class BeanUtil { ...@@ -312,4 +316,33 @@ public class BeanUtil {
return JsonUtils.toJson(map); return JsonUtils.toJson(map);
} }
/**
* bean转换为NameValuePair 键值对 只能是String,String
* @param bean
* @return
* @throws IntrospectionException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
public static List<NameValuePair> convertBeanToNameValuePairList(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();
}
List<NameValuePair> params = new ArrayList<NameValuePair>();
// Map集合循环遍历方式三 推荐,尤其是容量大时
for (Map.Entry<String, Object> m : map.entrySet()) {
params.add(new BasicNameValuePair(m.getKey(),m.getValue().toString()));
}
return params;
}
} }
...@@ -5,13 +5,19 @@ import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig; ...@@ -5,13 +5,19 @@ import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.wallet.*; import com.liquidnet.common.third.zxlnft.dto.wallet.*;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException; import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
import com.liquidnet.common.third.zxlnft.service.WalletSdkService; import com.liquidnet.common.third.zxlnft.service.WalletSdkService;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIBuilder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
...@@ -69,7 +75,7 @@ public class ZxlnftBiz { ...@@ -69,7 +75,7 @@ public class ZxlnftBiz {
log.info("buildPlatFormHeader ---> {}",JsonUtils.toJson(commonHeader)); log.info("buildPlatFormHeader ---> {}",JsonUtils.toJson(commonHeader));
} }
public static <T> T buildNftRespObj(String response,Class<T> tClass){ public <T> T buildNftRespObj(String response,Class<T> tClass){
T resp = null; T resp = null;
try { try {
resp = tClass.newInstance(); resp = tClass.newInstance();
...@@ -105,10 +111,52 @@ public class ZxlnftBiz { ...@@ -105,10 +111,52 @@ public class ZxlnftBiz {
return resp.getSignedData(); return resp.getSignedData();
} }
/**
* 获取hash
* @param data
* @return
*/
public String getHashString(String data){ public String getHashString(String data){
SM3HashEncodeReq req = SM3HashEncodeReq.getNew(); SM3HashEncodeReq req = SM3HashEncodeReq.getNew();
req.setData(data.getBytes(StandardCharsets.UTF_8)); req.setData(data.getBytes(StandardCharsets.UTF_8));
SM3HashEncodeResp sm3HashEncodeResp = walletSdkService.sM3HashEncode(req); SM3HashEncodeResp sm3HashEncodeResp = walletSdkService.sM3HashEncode(req);
return sm3HashEncodeResp.getDigest(); return sm3HashEncodeResp.getDigest();
} }
/**
* 构造GET请求url
* @param requestUrl
* @param tClass
* @param <T>
* @return
*/
public <T> String buildGetRequestUrl(String requestUrl,Class<T> tClass,Object obj){
// List<NameValuePair> params = new ArrayList<NameValuePair>();
// if(StringUtil.isNotEmpty(req.getSeriesName())){
// params.add(new BasicNameValuePair("seriesName", req.getSeriesName()));
// }
// params.add(new BasicNameValuePair("platformIdentification", req.getPlatformIdentification()));
// if(StringUtil.isNotEmpty(req.getUserIdentification())){
// params.add(new BasicNameValuePair("userIdentification", req.getUserIdentification()));
// }
// T reqObj = null;
// try {
// reqObj = tClass.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
List<NameValuePair> params = BeanUtil.convertBeanToNameValuePairList(obj);
//拼接请求url
URI build = null;
try {
build = new URIBuilder(requestUrl).addParameters(params).build();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return build.toString();
}
} }
...@@ -240,4 +240,8 @@ public class ZxlnftConstant { ...@@ -240,4 +240,8 @@ public class ZxlnftConstant {
* NFT 售价变更状态查询(方案一) * NFT 售价变更状态查询(方案一)
*/ */
public static String ZXL_NFT_053_PRICE_UPDATE_RESULT_URL = "/api/v1/nft/price/update/result"; public static String ZXL_NFT_053_PRICE_UPDATE_RESULT_URL = "/api/v1/nft/price/update/result";
/**
* 检查地址是否属于同一个用户主体(方案一)
*/
public static String ZXL_NFT_054_PRICE_UPDATE_RESULT_URL = "/api/v1/nft/query/user/address/belong_to_user";
} }
package com.liquidnet.common.third.zxlnft.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 34.发行 NFT
* @class: PublishReq
* @Package com.liquidnet.common.third.zxlnft.dto.nft
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:45
*/
@Data
public class Nft034PublishReqDto implements Serializable {
/**
* 作者名,中文+英文(数字或符号为非法输入) 不超过30个字符
*/
private String author;
/**
* nft名字,中英文数字均可,不超过256个字符
*/
private String name;
/**
* 介质url,不超过1024个字符
*/
private String url;
/**
* 预览图url,不超过1024个字符。(至信链浏览器展示预览图尺寸为290*290,请上传比例为1:1的图片)
*/
private String displayUrl;
/**
* nft简介,500个字符以内
*/
// @Null(message = "nft简介,500个字符以内")
private String desc;
/**
* 标签,【文创】,游戏,动漫,30个字符以内
* 非必填
*/
private String flag;
/**
* 发行量,如果没有系列,就只能为1,如果有系列从1开始,比如如有100个,系列id范围则为[1-100],单次发行个数不超过1000,
* 同系列下同介质个数总共不能超过3000
*/
private Long publishCount;
/**
* 系列ID
*/
// @Null (message = "系列ID")
private String seriesId;
/**
* 系列子ID从多少开始,没有系列只能填1。有系列情况下,根据系列声明时指定
* seriesBeginFromZero决定是否可以从0开始。总体上不超过系列的最大值,
* (比如系列如果从1开始,最大值为100。系列ID只能从1-100)
*/
private Integer seriesBeginIndex;
/**
* 1:可售 2:不可售
*/
private Integer sellStatus;
/**
* 可售状态下有意义,表示售卖多少积分
*/
// @Null(message = "可售状态下有意义,表示售卖多少积分")
private Long sellCount;
/**
* 请求ID,每个请求需要填唯一的ID,重复请求用相同的ID,为了保证唯一性,必须使用uuid
*/
private String operateId;
/**
* 扩展字段,用户自定义,长度不超过1024个字符
*/
// @Null(message = "扩展字段")
private String metaData;
private static final Nft034PublishReqDto obj = new Nft034PublishReqDto();
private static final long serialVersionUID = -6804495011501136941L;
public static Nft034PublishReqDto getNew() {
try {
return (Nft034PublishReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Nft034PublishReqDto();
}
}
}
package com.liquidnet.common.third.zxlnft.dto;
import com.liquidnet.commons.lang.util.JsonUtils;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: PublishReq
* @Package com.liquidnet.common.third.zxlnft.dto.nft
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:45
*/
@Data
public class Nft034PublishRespDto implements Serializable {
/**
* 任务ID
*/
private String taskId;
private static final Nft034PublishRespDto obj = new Nft034PublishRespDto();
public static Nft034PublishRespDto getNew() {
try {
return (Nft034PublishRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Nft034PublishRespDto();
}
}
@Override
public String toString(){
return JsonUtils.toJson(this);
}
}
...@@ -7,7 +7,7 @@ import java.io.Serializable; ...@@ -7,7 +7,7 @@ import java.io.Serializable;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
* @Description: 检查地址是否属于同一个用户主体接口 * @Description: 检查地址是否属于同一个用户主体接口 GET请求方式
* GET请求方式 * GET请求方式
* @class: Nft054QueryUserAddressBelongToUser * @class: Nft054QueryUserAddressBelongToUser
* @Package com.liquidnet.common.third.zxlnft.dto.nft * @Package com.liquidnet.common.third.zxlnft.dto.nft
......
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