Authored by mlge

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

  1 +package com.yohoufo.dal.product;
  2 +
  3 +import com.yohoufo.dal.product.model.ProductChain;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
  6 +public interface ProductChainMapper {
  7 + ProductChain selectByTagId(@Param("tagId") String tagId);
  8 +
  9 +}
  1 +package com.yohoufo.dal.product.model;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class ProductChain {
  7 + private String tagId;
  8 + private Long chainId;
  9 + private String transactionId;
  10 + private Integer transactionTime;
  11 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.yohoufo.dal.product.ProductChainMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.ProductChain">
  5 + <result column="tag_id" jdbcType="VARCHAR" property="tagId" />
  6 + <result column="chain_id" jdbcType="BIGINT" property="chainId" />
  7 + <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  8 + <result column="transaction_time" jdbcType="INTEGER" property="transactionTime" />
  9 + </resultMap>
  10 + <sql id="Base_Column_List">
  11 + tag_id, chain_id, transaction_id,transaction_time
  12 + </sql>
  13 + <select id="selectByTagId" resultMap="BaseResultMap">
  14 + select <include refid="Base_Column_List"/>
  15 + from product_chain
  16 + where tag_id = #{tagId,jdbcType=VARCHAR}
  17 + limit 1
  18 + </select>
  19 +</mapper>
@@ -15,5 +15,6 @@ public class ProductIdentifyResp { @@ -15,5 +15,6 @@ public class ProductIdentifyResp {
15 private String identifyTime; 15 private String identifyTime;
16 private String identifyPlat; 16 private String identifyPlat;
17 private List<IdentifyTrackResp> trackList; 17 private List<IdentifyTrackResp> trackList;
  18 + private String transactionId;//区块链Id
18 19
19 } 20 }
@@ -26,8 +26,10 @@ import com.yohoufo.dal.order.model.QiniuLiveRecord; @@ -26,8 +26,10 @@ import com.yohoufo.dal.order.model.QiniuLiveRecord;
26 import com.yohoufo.dal.order.model.SellerOrderGoods; 26 import com.yohoufo.dal.order.model.SellerOrderGoods;
27 import com.yohoufo.dal.product.IdentifyRecordsMapper; 27 import com.yohoufo.dal.product.IdentifyRecordsMapper;
28 import com.yohoufo.dal.product.IdentifyRelationMapper; 28 import com.yohoufo.dal.product.IdentifyRelationMapper;
  29 +import com.yohoufo.dal.product.ProductChainMapper;
29 import com.yohoufo.dal.product.model.IdentifyRecord; 30 import com.yohoufo.dal.product.model.IdentifyRecord;
30 import com.yohoufo.dal.product.model.IdentifyRelation; 31 import com.yohoufo.dal.product.model.IdentifyRelation;
  32 +import com.yohoufo.dal.product.model.ProductChain;
31 import com.yohoufo.product.response.IdentifyShareInfoResp; 33 import com.yohoufo.product.response.IdentifyShareInfoResp;
32 import com.yohoufo.product.response.IdentifyTrackResp; 34 import com.yohoufo.product.response.IdentifyTrackResp;
33 import com.yohoufo.product.response.ProductIdentifyResp; 35 import com.yohoufo.product.response.ProductIdentifyResp;
@@ -66,6 +68,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -66,6 +68,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
66 private IdentifyRelationMapper identifyRelationMapper; 68 private IdentifyRelationMapper identifyRelationMapper;
67 69
68 @Autowired 70 @Autowired
  71 + private ProductChainMapper productChainMapper;
  72 +
  73 + @Autowired
69 private ServiceCaller serviceCaller; 74 private ServiceCaller serviceCaller;
70 75
71 @Autowired 76 @Autowired
@@ -127,6 +132,10 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -127,6 +132,10 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
127 String vedioFileUrl = getLiveVideoUrlByOrderCode(orderCode); 132 String vedioFileUrl = getLiveVideoUrlByOrderCode(orderCode);
128 result.setVedioFileUrl(vedioFileUrl); 133 result.setVedioFileUrl(vedioFileUrl);
129 134
  135 + //查询区块链id
  136 + ProductChain productChain = queryTransactionIdByTagId(tagId);
  137 + result.setTransactionId(productChain == null ? null : productChain.getTransactionId());
  138 +
130 //组装查询结果 139 //组装查询结果
131 //鉴定者的信息、鉴定时间、鉴定中心等 140 //鉴定者的信息、鉴定时间、鉴定中心等
132 int authTime = identifyRecord.getAuthTime(); 141 int authTime = identifyRecord.getAuthTime();
@@ -145,8 +154,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -145,8 +154,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
145 identifyTrack.setTime(authTime); 154 identifyTrack.setTime(authTime);
146 identifyTrack.setTimeStr(timeStr); 155 identifyTrack.setTimeStr(timeStr);
147 identifyTrack.setContent( authGroup + "鉴定结果为\"真\""); 156 identifyTrack.setContent( authGroup + "鉴定结果为\"真\"");
148 - //测试数据还得再改  
149 - String auth_inco = configReader.getString("ufo.product.authIcon", "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png"); 157 + //鉴定中心,默认的展示头像
  158 + 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}");
150 identifyTrack.setHeadIcon(auth_inco); 159 identifyTrack.setHeadIcon(auth_inco);
151 trackRespList.add(identifyTrack); 160 trackRespList.add(identifyTrack);
152 161
@@ -198,7 +207,25 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -198,7 +207,25 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
198 return result; 207 return result;
199 } 208 }
200 209
201 - 210 + /**
  211 + * 查询区块链Id
  212 + * @param tagId
  213 + * @return
  214 + */
  215 + private ProductChain queryTransactionIdByTagId(String tagId) {
  216 + RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:relateTransactionId:").appendVar(tagId);
  217 + ProductChain result = clientCache.get(kb, ProductChain.class);
  218 + if(result != null ){
  219 + logger.info("queryTransactionIdByTagId from cache success! tagId={},result={}", tagId,result);
  220 + return result;
  221 + }
  222 + result = productChainMapper.selectByTagId(tagId);
  223 + if(result != null){
  224 + clientCache.set(kb.getKey(), 10 * 60 , result );//10分钟
  225 + }
  226 + logger.info("queryTransactionIdByTagId from db success! tagId={},result={}", tagId,result);
  227 + return result;
  228 + }
202 229
203 230
204 /** 231 /**
@@ -30,6 +30,7 @@ datasources: @@ -30,6 +30,7 @@ datasources:
30 - com.yohoufo.dal.product.SaleCategoryMapper 30 - com.yohoufo.dal.product.SaleCategoryMapper
31 - com.yohoufo.dal.product.IdentifyRecordsMapper 31 - com.yohoufo.dal.product.IdentifyRecordsMapper
32 - com.yohoufo.dal.product.IdentifyRelationMapper 32 - com.yohoufo.dal.product.IdentifyRelationMapper
  33 + - com.yohoufo.dal.product.ProductChainMapper
33 34
34 ufo_order: 35 ufo_order:
35 servers: 36 servers:
  1 +#UFOĬͷ
  2 +ufo.product.defaultAuthHeadIcon=http://head.static.yhbimg.com/yhb-head/2018/12/24/10/01187dd372e153ea9c062cd0604cd169b2.jpg?imageView2/{mode}/w/{width}/h/{height}
@@ -30,6 +30,7 @@ datasources: @@ -30,6 +30,7 @@ datasources:
30 - com.yohoufo.dal.product.SaleCategoryMapper 30 - com.yohoufo.dal.product.SaleCategoryMapper
31 - com.yohoufo.dal.product.IdentifyRecordsMapper 31 - com.yohoufo.dal.product.IdentifyRecordsMapper
32 - com.yohoufo.dal.product.IdentifyRelationMapper 32 - com.yohoufo.dal.product.IdentifyRelationMapper
  33 + - com.yohoufo.dal.product.ProductChainMapper
33 34
34 ufo_order: 35 ufo_order:
35 servers: 36 servers: