Commit 1250e1d1 authored by tangtuo's avatar tangtuo

debug

parent 1744e9c6
...@@ -23,7 +23,7 @@ import java.util.List; ...@@ -23,7 +23,7 @@ import java.util.List;
* @author tangtuo * @author tangtuo
* @date 2021/7/5 15:34 * @date 2021/7/5 15:34
*/ */
//@Authentication @Authentication
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/nft") @RequestMapping("/nft")
......
...@@ -101,6 +101,10 @@ public class CopyrightLister { ...@@ -101,6 +101,10 @@ public class CopyrightLister {
} }
try { try {
CopyrightApply copyrightApply = copyrightApplyService.getBySerialNum(serial_code); CopyrightApply copyrightApply = copyrightApplyService.getBySerialNum(serial_code);
// if (copyrightApply == null) {
// log.error("unknown serial_code: {}", serial_code);
// return;
// }
//审核状态(0:未提交,1:待审核,2:同意,3:驳回,4:已提交,5:待终审,6:审核通过) //审核状态(0:未提交,1:待审核,2:同意,3:驳回,4:已提交,5:待终审,6:审核通过)
if (!copyrightResponse.getAudit_status().equals(3) && !copyrightResponse.getAudit_status().equals(6)) { if (!copyrightResponse.getAudit_status().equals(3) && !copyrightResponse.getAudit_status().equals(6)) {
if (copyrightResponse.getAudit_status().equals(1)) { if (copyrightResponse.getAudit_status().equals(1)) {
...@@ -113,7 +117,6 @@ public class CopyrightLister { ...@@ -113,7 +117,6 @@ public class CopyrightLister {
// 审核还未完成, 需要把当前流水号丢进死信队列, 6小时后再去查询 // 审核还未完成, 需要把当前流水号丢进死信队列, 6小时后再去查询
rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "copyright.apply", serial_code); rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "copyright.apply", serial_code);
} else { } else {
if (copyrightResponse.getAudit_status().equals(6)) { if (copyrightResponse.getAudit_status().equals(6)) {
// 审核成功 // 审核成功
String nftHash = copyrightApply.getNftHash(); String nftHash = copyrightApply.getNftHash();
...@@ -142,10 +145,11 @@ public class CopyrightLister { ...@@ -142,10 +145,11 @@ public class CopyrightLister {
copyrightApply.setRejectReason(copyrightResponse.getRemark()); copyrightApply.setRejectReason(copyrightResponse.getRemark());
copyrightApply.setRegisterState(CopyrightApplyState.FAILED.getCode()); copyrightApply.setRegisterState(CopyrightApplyState.FAILED.getCode());
} }
copyrightApplyService.updateById(copyrightApply);
} }
copyrightApplyService.updateById(copyrightApply);
} catch (Exception e) { } catch (Exception e) {
// 如果上链失败或者更新状态失败, 那么就把消息重新丢入延时队列,稍后重试 // 如果上链失败或者更新状态失败, 那么就把消息重新丢入延时队列,稍后重试
rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "copyright.apply", serial_code); rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "copyright.apply", serial_code);
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
...@@ -155,35 +159,6 @@ public class CopyrightLister { ...@@ -155,35 +159,6 @@ public class CopyrightLister {
} }
/**
* 更新存证hash
*/
@RabbitListener(queues = RabbitMQConfig.EVIDENCE_HASH_QUEUE)
public void listenEvidenceHash(EvidenceHashMessage evidenceHashMessage, Message message, Channel channel) throws IOException {
long deliveryTag = message.getMessageProperties().getDeliveryTag();
try {
String hash = evidenceHashMessage.getHash();
String serial_code = evidenceHashMessage.getSerial_code();
String realTxHash = paraChainClient.getRealTxHashFromGrp(hash);
if (StringUtils.isBlank(realTxHash)) {
log.error("存证hash查询为空, 交易hash为: {}, 流水号为: {}", hash, serial_code);
// 查询失败,拒绝签收
channel.basicReject(deliveryTag, true);
return;
}
CopyrightApply apply = copyrightApplyService.getBySerialNum(serial_code);
apply.setEvidenceHash(realTxHash);
copyrightApplyService.updateById(apply);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.error(e.getMessage(), e);
// 发生异常, 拒收消息
channel.basicReject(deliveryTag, true);
}
}
private TreeMap<String, String> beanToMap(CopyrightQueryRequest request, String app_secret) { private TreeMap<String, String> beanToMap(CopyrightQueryRequest request, String app_secret) {
TreeMap<String, String> map = JSONUtil.toBean(JSONUtil.toJsonStr(request), new TypeReference<TreeMap<String, String>>() { TreeMap<String, String> map = JSONUtil.toBean(JSONUtil.toJsonStr(request), new TypeReference<TreeMap<String, String>>() {
......
package com.fzm.admin.listener;
import cn.fzm.chain.simplesdk.client.ParaChainClient;
import com.fzm.common.config.RabbitMQConfig;
import com.fzm.common.entity.CopyrightApply;
import com.fzm.common.entity.dto.EvidenceHashMessage;
import com.fzm.common.service.CopyrightApplyService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
/**
* @author tangtuo
* @date 2022/1/7 16:13
*/
@Slf4j
@Component
public class EvidenceHashLister {
@Resource
private CopyrightApplyService copyrightApplyService;
@Resource
private ParaChainClient paraChainClient;
/**
* 更新存证hash
*/
@RabbitListener(queues = RabbitMQConfig.EVIDENCE_HASH_QUEUE)
public void listenEvidenceHash(EvidenceHashMessage evidenceHashMessage, Message message, Channel channel) throws IOException {
long deliveryTag = message.getMessageProperties().getDeliveryTag();
try {
String hash = evidenceHashMessage.getHash();
String serial_code = evidenceHashMessage.getSerial_code();
String realTxHash = paraChainClient.getRealTxHashFromGrp(hash);
if (StringUtils.isBlank(realTxHash)) {
log.error("存证hash查询为空, 交易hash为: {}, 流水号为: {}", hash, serial_code);
// 查询失败,拒绝签收
channel.basicReject(deliveryTag, true);
return;
}
CopyrightApply apply = copyrightApplyService.getBySerialNum(serial_code);
apply.setEvidenceHash(realTxHash);
copyrightApplyService.updateById(apply);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.error(e.getMessage(), e);
// 发生异常, 拒收消息
channel.basicReject(deliveryTag, true);
}
}
}
...@@ -48,7 +48,7 @@ spring: ...@@ -48,7 +48,7 @@ spring:
# 缓存失效时间 # 缓存失效时间
time-to-live: 86400000 time-to-live: 86400000
rabbitmq: rabbitmq:
host: 172.16.101.135 host: 10.0.0.81
port: 5672 port: 5672
username: admin username: admin
password: admin password: admin
......
...@@ -67,7 +67,7 @@ public class RabbitMQConfig { ...@@ -67,7 +67,7 @@ public class RabbitMQConfig {
public Queue dlQueue() { public Queue dlQueue() {
return QueueBuilder.durable(DEAD_LETTER_QUEUE) return QueueBuilder.durable(DEAD_LETTER_QUEUE)
.ttl(1000 * 60 * 60 * 6) .ttl(1000 * 60 * 60 * 6)
//.ttl(1000 * 60 * 2) // 测试环境 .ttl(1000 * 10) // 测试环境
.deadLetterExchange(DEAD_LETTER_DIRECT) .deadLetterExchange(DEAD_LETTER_DIRECT)
.deadLetterRoutingKey("copyright.notify") .deadLetterRoutingKey("copyright.notify")
.build(); .build();
......
...@@ -3,6 +3,7 @@ package com.fzm.common.entity; ...@@ -3,6 +3,7 @@ package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
...@@ -44,6 +45,11 @@ public class Nft extends BaseEntity { ...@@ -44,6 +45,11 @@ public class Nft extends BaseEntity {
@ApiModelProperty("作者") @ApiModelProperty("作者")
private String author; private String author;
@ApiModelProperty("存证人")
@NotBlank(message = "存证人不能为空")
@Length(max = 20, message = "存证人最大长度为20")
private String evidencer;
@NotBlank(message = "简介不能为空") @NotBlank(message = "简介不能为空")
@Length(max = 500, message = "简介最大长度为500") @Length(max = 500, message = "简介最大长度为500")
......
...@@ -5,6 +5,7 @@ import com.fzm.common.entity.CopyrightApplyOwnerRelation; ...@@ -5,6 +5,7 @@ import com.fzm.common.entity.CopyrightApplyOwnerRelation;
import com.fzm.common.entity.CopyrightAuthor; import com.fzm.common.entity.CopyrightAuthor;
import com.fzm.common.entity.Nft; import com.fzm.common.entity.Nft;
import com.fzm.common.entity.User; import com.fzm.common.entity.User;
import com.fzm.common.enums.CopyrightApplyState;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -41,6 +42,9 @@ public class NftVo { ...@@ -41,6 +42,9 @@ public class NftVo {
@ApiModelProperty("存证人") @ApiModelProperty("存证人")
private String evidencer; private String evidencer;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("文件哈希") @ApiModelProperty("文件哈希")
private String fileHash; private String fileHash;
...@@ -91,8 +95,10 @@ public class NftVo { ...@@ -91,8 +95,10 @@ public class NftVo {
@ApiModelProperty("存证时间") @ApiModelProperty("存证时间")
private Date evidenceTime; private Date evidenceTime;
private Integer registerState;
public Copyright(CopyrightVo copyrightVo, Date evidenceTime) { public Copyright(CopyrightVo copyrightVo) {
this.registerCode = copyrightVo.getRegisterCode(); this.registerCode = copyrightVo.getRegisterCode();
this.opusName = copyrightVo.getOpusName(); this.opusName = copyrightVo.getOpusName();
this.opusType = copyrightVo.getOpusCategory().getValue(); this.opusType = copyrightVo.getOpusCategory().getValue();
...@@ -100,22 +106,24 @@ public class NftVo { ...@@ -100,22 +106,24 @@ public class NftVo {
this.copyrightOwner = copyrightVo.getOwners().stream().map(CopyrightApplyOwnerRelation::getOwner).collect(Collectors.joining()); this.copyrightOwner = copyrightVo.getOwners().stream().map(CopyrightApplyOwnerRelation::getOwner).collect(Collectors.joining());
this.opusCompleteDate = copyrightVo.getOpusCompleteDate(); this.opusCompleteDate = copyrightVo.getOpusCompleteDate();
this.firstPublishDate = copyrightVo.getFirstPublishDate(); this.firstPublishDate = copyrightVo.getFirstPublishDate();
this.evidenceTime = evidenceTime; this.evidenceTime = copyrightVo.getEvidenceDate();
this.evidenceHash = copyrightVo.getEvidenceHash(); this.evidenceHash = copyrightVo.getEvidenceHash();
this.registerState = copyrightVo.getRegisterState();
} }
} }
public NftVo(Nft nft, CopyrightVo copyrightVo) { public NftVo(Nft nft, CopyrightVo copyrightVo) {
this.id = nft.getId(); this.id = nft.getId();
this.evidencer = nft.getAuthor(); this.evidencer = nft.getEvidencer();
this.author = nft.getAuthor();
this.userId = nft.getUserId(); this.userId = nft.getUserId();
this.name = nft.getName(); this.name = nft.getName();
this.nftId = nft.getNftId(); this.nftId = nft.getNftId();
this.nftHash = nft.getNftHash(); this.nftHash = nft.getNftHash();
this.fileHash = nft.getFileHash(); this.fileHash = nft.getFileHash();
this.evidenceTime = nft.getPublishTime(); this.evidenceTime = nft.getPublishTime();
this.copyright = copyrightVo == null ? null : new Copyright(copyrightVo, nft.getPublishTime()); this.copyright = (copyrightVo == null) ? null : new Copyright(copyrightVo);
} }
} }
...@@ -29,6 +29,8 @@ import com.github.pagehelper.PageHelper; ...@@ -29,6 +29,8 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
...@@ -39,6 +41,7 @@ import javax.annotation.Resource; ...@@ -39,6 +41,7 @@ import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/** /**
* @author tangtuo * @author tangtuo
...@@ -91,6 +94,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper, ...@@ -91,6 +94,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
@Resource @Resource
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;
@Resource
private Redisson redisson;
@Override @Override
public Integer submit(CopyrightDTO copyrightDTO) { public Integer submit(CopyrightDTO copyrightDTO) {
...@@ -327,6 +333,11 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper, ...@@ -327,6 +333,11 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
@Override @Override
public boolean pass(Integer id) throws ExecutionException, InterruptedException { public boolean pass(Integer id) throws ExecutionException, InterruptedException {
RLock lock = redisson.getLock("copyright:apply:" + id);
boolean tryLock = lock.tryLock(10, TimeUnit.SECONDS);
if (!tryLock) {
throw GlobalException.newException(ResultCode.FAILED, "操作频繁");
}
CopyrightApply copyright = getById(id); CopyrightApply copyright = getById(id);
if (copyright == null) { if (copyright == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "此版权登记记录不存在,请核对后重试"); throw GlobalException.newException(ResultCode.DATA_ERROR, "此版权登记记录不存在,请核对后重试");
...@@ -390,7 +401,6 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper, ...@@ -390,7 +401,6 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
public CopyrightVo getByNftHash(String nftHash) throws ExecutionException, InterruptedException { public CopyrightVo getByNftHash(String nftHash) throws ExecutionException, InterruptedException {
QueryWrapper<CopyrightApply> wrapper = new QueryWrapper<>(); QueryWrapper<CopyrightApply> wrapper = new QueryWrapper<>();
wrapper.eq("nft_hash", nftHash); wrapper.eq("nft_hash", nftHash);
wrapper.eq("register_state", CopyrightApplyState.SUCCEEDED.getCode());
CopyrightApply copyrightApply = this.getOne(wrapper); CopyrightApply copyrightApply = this.getOne(wrapper);
if (copyrightApply == null) { if (copyrightApply == null) {
return null; return null;
......
...@@ -133,6 +133,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -133,6 +133,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
map.put("publishAddress", wallet); map.put("publishAddress", wallet);
map.put("author", nft.getAuthor()); map.put("author", nft.getAuthor());
map.put("synopsis", nft.getSynopsis()); map.put("synopsis", nft.getSynopsis());
map.put("evidencer", nft.getEvidencer());
String str = JSONUtil.toJsonStr(map); String str = JSONUtil.toJsonStr(map);
String tokenInfo = this.formatTokenInfo(map); String tokenInfo = this.formatTokenInfo(map);
log.info("tokenInfo:{}", tokenInfo); log.info("tokenInfo:{}", tokenInfo);
......
...@@ -2,9 +2,6 @@ package com.fzm.portal.controller; ...@@ -2,9 +2,6 @@ package com.fzm.portal.controller;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.fzm.common.annotation.Authentication; import com.fzm.common.annotation.Authentication;
import com.fzm.common.constant.RedisConstant;
import com.fzm.common.constant.SystemConstant;
import com.fzm.common.constant.TokenConstant;
import com.fzm.common.entity.Nft; import com.fzm.common.entity.Nft;
import com.fzm.common.entity.NftDto; import com.fzm.common.entity.NftDto;
import com.fzm.common.entity.User; import com.fzm.common.entity.User;
...@@ -12,19 +9,20 @@ import com.fzm.common.entity.vo.CollectionNftVo; ...@@ -12,19 +9,20 @@ import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftCertificateVo; import com.fzm.common.entity.vo.NftCertificateVo;
import com.fzm.common.entity.vo.NftTransferVo; import com.fzm.common.entity.vo.NftTransferVo;
import com.fzm.common.entity.vo.NftVo; import com.fzm.common.entity.vo.NftVo;
import com.fzm.common.enums.CopyrightApplyState;
import com.fzm.common.enums.ResultCode; import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException; import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel; import com.fzm.common.model.ResponseModel;
import com.fzm.common.params.NftTransferParam; import com.fzm.common.params.NftTransferParam;
import com.fzm.common.service.CategoryService;
import com.fzm.common.service.NftService; import com.fzm.common.service.NftService;
import com.fzm.common.service.UserService; import com.fzm.common.service.UserService;
import com.fzm.common.utils.*; import com.fzm.common.utils.JsonUtil;
import com.fzm.common.utils.JwtUtil;
import com.fzm.common.utils.QRCodeUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -36,7 +34,6 @@ import java.util.HashMap; ...@@ -36,7 +34,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
/** /**
* @author tangtuo * @author tangtuo
...@@ -55,20 +52,8 @@ public class NftController { ...@@ -55,20 +52,8 @@ public class NftController {
private UserService userService; private UserService userService;
@Resource @Resource
private CategoryService categoryService;
@Resource
private RedisUtil redisUtil;
@Resource
private HttpServletRequest request; private HttpServletRequest request;
/**
* 存证二维码跳转地址
* todo 修改成动态前端路由
*/
private static final String PATH = "https://chain.33.cn/document/60";
@Authentication @Authentication
@PostMapping("/save") @PostMapping("/save")
...@@ -102,6 +87,9 @@ public class NftController { ...@@ -102,6 +87,9 @@ public class NftController {
@ApiOperation(value = "获取nft详情") @ApiOperation(value = "获取nft详情")
public ResponseModel<NftVo> get(@PathVariable String nftHash) throws ExecutionException, InterruptedException { public ResponseModel<NftVo> get(@PathVariable String nftHash) throws ExecutionException, InterruptedException {
NftVo nftVo = nftService.getDetail(nftHash); NftVo nftVo = nftService.getDetail(nftHash);
if (!nftVo.getCopyright().getRegisterState().equals(CopyrightApplyState.SUCCEEDED.getCode())) {
nftVo.setCopyright(null);
}
return ResponseModel.success(nftVo); return ResponseModel.success(nftVo);
} }
......
This diff is collapsed.
...@@ -546,4 +546,4 @@ SET FOREIGN_KEY_CHECKS = 1; ...@@ -546,4 +546,4 @@ SET FOREIGN_KEY_CHECKS = 1;
alter table tb_copyright_apply modify column create_process varchar(1000) NOT NULL DEFAULT '' COMMENT '创作过程'; alter table tb_copyright_apply modify column create_process varchar(1000) NOT NULL DEFAULT '' COMMENT '创作过程';
UPDATE `tb_file_template` SET `file_name` = '业务代理委托书.docx', `file_url` = 'https://filmchain-file.obs.cn-east-3.myhuaweicloud.com/5444e0358d6b4038806b5a63d60284e5/业务代理委托书.docx', `type` = 1 WHERE `id` = 2; UPDATE `tb_file_template` SET `file_name` = '业务代理委托书.docx', `file_url` = 'https://filmchain-file.obs.cn-east-3.myhuaweicloud.com/5444e0358d6b4038806b5a63d60284e5/业务代理委托书.docx', `type` = 1 WHERE `id` = 2;
UPDATE `tb_file_template` SET `file_name` = '作品登记委托书.docx', `file_url` = 'https://filmchain-file.obs.cn-east-3.myhuaweicloud.com/88c2f750cabd44e4b75f3cb054b3326a/作品登记委托书.docx', `type` = 6 WHERE `id` = 8; UPDATE `tb_file_template` SET `file_name` = '作品登记委托书.docx', `file_url` = 'https://filmchain-file.obs.cn-east-3.myhuaweicloud.com/88c2f750cabd44e4b75f3cb054b3326a/作品登记委托书.docx', `type` = 6 WHERE `id` = 8;
alter table tb_nft add column evidencer varchar(20) not null default '' comment '存证人' after author;
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