Authored by mlge

鉴定结果查询接口--返回字段 增加区块链Id

package com.yohoufo.dal.product;
import com.yohoufo.dal.product.model.ProductChain;
import org.apache.ibatis.annotations.Param;
public interface ProductChainMapper {
ProductChain selectByTagId(@Param("tagId") String tagId);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product.model;
import lombok.Data;
@Data
public class ProductChain {
private String tagId;
private Long chainId;
private String transactionId;
private Integer transactionTime;
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yohoufo.dal.product.ProductChainMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.ProductChain">
<result column="tag_id" jdbcType="VARCHAR" property="tagId" />
<result column="chain_id" jdbcType="BIGINT" property="chainId" />
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="transaction_time" jdbcType="INTEGER" property="transactionTime" />
</resultMap>
<sql id="Base_Column_List">
tag_id, chain_id, transaction_id,transaction_time
</sql>
<select id="selectByTagId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from product_chain
where tag_id = #{tagId,jdbcType=VARCHAR}
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -15,5 +15,6 @@ public class ProductIdentifyResp {
private String identifyTime;
private String identifyPlat;
private List<IdentifyTrackResp> trackList;
private String transactionId;//区块链Id
}
... ...
... ... @@ -26,8 +26,10 @@ import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.product.IdentifyRecordsMapper;
import com.yohoufo.dal.product.IdentifyRelationMapper;
import com.yohoufo.dal.product.ProductChainMapper;
import com.yohoufo.dal.product.model.IdentifyRecord;
import com.yohoufo.dal.product.model.IdentifyRelation;
import com.yohoufo.dal.product.model.ProductChain;
import com.yohoufo.product.response.IdentifyShareInfoResp;
import com.yohoufo.product.response.IdentifyTrackResp;
import com.yohoufo.product.response.ProductIdentifyResp;
... ... @@ -66,6 +68,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
private IdentifyRelationMapper identifyRelationMapper;
@Autowired
private ProductChainMapper productChainMapper;
@Autowired
private ServiceCaller serviceCaller;
@Autowired
... ... @@ -127,6 +132,10 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
String vedioFileUrl = getLiveVideoUrlByOrderCode(orderCode);
result.setVedioFileUrl(vedioFileUrl);
//查询区块链id
ProductChain productChain = queryTransactionIdByTagId(tagId);
result.setTransactionId(productChain == null ? null : productChain.getTransactionId());
//组装查询结果
//鉴定者的信息、鉴定时间、鉴定中心等
int authTime = identifyRecord.getAuthTime();
... ... @@ -145,8 +154,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
identifyTrack.setTime(authTime);
identifyTrack.setTimeStr(timeStr);
identifyTrack.setContent( authGroup + "鉴定结果为\"真\"");
//测试数据还得再改
String auth_inco = configReader.getString("ufo.product.authIcon", "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png");
//鉴定中心,默认的展示头像
String auth_inco = configReader.getString("ufo.product.defaultAuthHeadIcon", "http://head.static.yhbimg.com/yhb-head/2018/12/24/10/01187dd372e153ea9c062cd0604cd169b2.jpg?imageView2/{mode}/w/{width}/h/{height}");
identifyTrack.setHeadIcon(auth_inco);
trackRespList.add(identifyTrack);
... ... @@ -198,7 +207,25 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return result;
}
/**
* 查询区块链Id
* @param tagId
* @return
*/
private ProductChain queryTransactionIdByTagId(String tagId) {
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:relateTransactionId:").appendVar(tagId);
ProductChain result = clientCache.get(kb, ProductChain.class);
if(result != null ){
logger.info("queryTransactionIdByTagId from cache success! tagId={},result={}", tagId,result);
return result;
}
result = productChainMapper.selectByTagId(tagId);
if(result != null){
clientCache.set(kb.getKey(), 10 * 60 , result );//10分钟
}
logger.info("queryTransactionIdByTagId from db success! tagId={},result={}", tagId,result);
return result;
}
/**
... ...
... ... @@ -30,6 +30,7 @@ datasources:
- com.yohoufo.dal.product.SaleCategoryMapper
- com.yohoufo.dal.product.IdentifyRecordsMapper
- com.yohoufo.dal.product.IdentifyRelationMapper
- com.yohoufo.dal.product.ProductChainMapper
ufo_order:
servers:
... ...
#UFOĬͷ
ufo.product.defaultAuthHeadIcon=http://head.static.yhbimg.com/yhb-head/2018/12/24/10/01187dd372e153ea9c062cd0604cd169b2.jpg?imageView2/{mode}/w/{width}/h/{height}
\ No newline at end of file
... ...
... ... @@ -30,6 +30,7 @@ datasources:
- com.yohoufo.dal.product.SaleCategoryMapper
- com.yohoufo.dal.product.IdentifyRecordsMapper
- com.yohoufo.dal.product.IdentifyRelationMapper
- com.yohoufo.dal.product.ProductChainMapper
ufo_order:
servers:
... ...