Commit 99b46bc1 authored by tangtuo's avatar tangtuo

删除无效代码

修改部分接口的返回数据格式
parent bcc913ef
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/6/30 15:42
*/
@Data
@ApiModel("纪念版nft上链信息")
@Accessors(chain = true)
@TableName("tb_commemorate_nft_chain_info")
public class NftChainInfo {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("纪念版nft主键")
private Integer commemorateNftId;
@ApiModelProperty("nft编号")
private String nftNum;
@ApiModelProperty("nft哈希")
private String nftHash;
@ApiModelProperty("nft token")
private Long tokenId;
@ApiModelProperty("nft发行时间")
private Date publishTime;
@ApiModelProperty("是否已被领取 0-否 1-是")
private Integer isReceive;
}
package com.fzm.common.entity;
package com.fzm.common.entity.dto;
import com.fzm.common.entity.NftFile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
......
package com.fzm.common.entity.dto;
import com.fzm.common.entity.Nft;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author tangtuo
* @date 2021/7/22 16:28
* @date 2021/8/17 16:49
*/
@Data
public class ChainDto {
public class NftListDto extends Nft {
private String author;
private String name;
private String hash;
private String publishAddress;
@ApiModelProperty("nft持有人昵称")
private String owner;
}
......@@ -54,11 +54,16 @@ public class NftVo {
@ApiModelProperty("是否收藏")
private Boolean collection;
@ApiModelProperty("持有人")
private String owner;
@ApiModelProperty("持有人地址")
private String ownerAddress;
@ApiModelProperty("文件列表")
private List<NftFile> fileList;
public NftVo(Nft nft, User user) {
public NftVo(Nft nft, User user, User owner) {
this.id = nft.getId();
this.author = nft.getAuthor();
this.name = nft.getName();
......@@ -70,5 +75,7 @@ public class NftVo {
this.collection = false;
this.nftHash = nft.getNftHash();
this.nftNum = nft.getNftNum();
this.owner=owner.getNickname();
this.ownerAddress=owner.getWallet();
}
}
package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.NftChainInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tangtuo
* @date 2021/6/30 15:54
*/
@Mapper
public interface NftChainInfoMapper extends BaseMapper<NftChainInfo> {
}
......@@ -3,6 +3,7 @@ package com.fzm.common.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.Nft;
import com.fzm.common.entity.dto.NftListDto;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftListVo;
import org.apache.ibatis.annotations.Mapper;
......@@ -25,7 +26,7 @@ public interface NftMapper extends BaseMapper<Nft> {
* @param categoryId
* @return
*/
List<Nft> list(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize, @Param("categoryId") Integer categoryId);
List<NftListDto> list(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize, @Param("categoryId") Integer categoryId);
List<CollectionNftVo> getCollectionList(@Param("list") List<Integer> list);
......
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.NftChainInfo;
/**
* @author tangtuo
* @date 2021/7/5 15:08
*/
public interface NftChainInfoService extends IService<NftChainInfo> {
}
......@@ -2,9 +2,9 @@ package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Nft;
import com.fzm.common.entity.NftDto;
import com.fzm.common.entity.dto.NftDto;
import com.fzm.common.entity.dto.NftListDto;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftCertificateVo;
import com.fzm.common.entity.vo.NftListVo;
import com.fzm.common.params.NftTransferParam;
import com.github.pagehelper.PageInfo;
......@@ -25,7 +25,7 @@ public interface NftService extends IService<Nft> {
* @param categoryId
* @return
*/
List<Nft> list(Integer pageNum, Integer pageSize, Integer categoryId);
List<NftListDto> list(Integer pageNum, Integer pageSize, Integer categoryId);
/**
* 收藏nft
......
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.NftChainInfo;
import com.fzm.common.entity.NftTransferRecord;
/**
......
......@@ -43,9 +43,6 @@ import java.util.concurrent.TimeUnit;
public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper, CommemorateNft> implements CommemorateNftService {
@Resource
NftChainInfoService nftChainInfoService;
@Resource
private NftService nftService;
@Resource
......
package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.NftChainInfo;
import com.fzm.common.mapper.NftChainInfoMapper;
import com.fzm.common.service.NftChainInfoService;
import org.springframework.stereotype.Service;
/**
* @author tangtuo
* @date 2021/7/5 15:09
*/
@Service
public class NftChainInfoServiceImpl extends ServiceImpl<NftChainInfoMapper, NftChainInfo> implements NftChainInfoService {
}
......@@ -13,11 +13,12 @@ import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.constant.RedisConstant;
import com.fzm.common.constant.SystemConstant;
import com.fzm.common.entity.*;
import com.fzm.common.entity.dto.NftDto;
import com.fzm.common.entity.dto.NftListDto;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftListVo;
import com.fzm.common.enums.ResultCode;
......@@ -228,7 +229,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
}
@Override
public List<Nft> list(Integer pageNum, Integer pageSize, Integer categoryId) {
public List<NftListDto> list(Integer pageNum, Integer pageSize, Integer categoryId) {
return nftMapper.list(pageNum, pageSize, categoryId);
}
......
......@@ -2,8 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fzm.common.mapper.NftMapper">
<select id="list" resultType="com.fzm.common.entity.Nft">
select * from tb_nft
<select id="list" resultType="com.fzm.common.entity.dto.NftListDto">
select a.*,b.nickname as owner from tb_nft a
left join tb_user b on a.user_id=b.id
where status = 1
<if test="categoryId != null and categoryId > 0">
and category_id=#{categoryId}
......
......@@ -5,11 +5,11 @@ import cn.hutool.json.JSONUtil;
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.NftDto;
import com.fzm.common.entity.dto.NftDto;
import com.fzm.common.entity.NftFile;
import com.fzm.common.entity.User;
import com.fzm.common.entity.dto.NftListDto;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftCertificateVo;
import com.fzm.common.entity.vo.NftTransferVo;
......@@ -38,7 +38,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author tangtuo
......@@ -116,12 +115,12 @@ public class NftController {
@GetMapping("/list")
@ApiOperation(value = "获取nft列表")
public ResponseModel<List<Nft>> list(@ApiParam(value = "当前页码") @RequestParam Integer pageNum,
@ApiParam(value = "每页记录数") @RequestParam Integer pageSize,
@ApiParam(value = "类目id,查询所有的时候传null") @RequestParam(required = false) Integer categoryId) {
public ResponseModel<List<NftListDto>> list(@ApiParam(value = "当前页码") @RequestParam Integer pageNum,
@ApiParam(value = "每页记录数") @RequestParam Integer pageSize,
@ApiParam(value = "类目id,查询所有的时候传null") @RequestParam(required = false) Integer categoryId) {
pageNum = (pageNum - 1) * pageSize;
List<Nft> list = nftService.list(pageNum, pageSize, categoryId);
List<NftListDto> list = nftService.list(pageNum, pageSize, categoryId);
return ResponseModel.success(list);
}
......@@ -132,11 +131,15 @@ public class NftController {
if (nft == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的详情");
}
User user = userService.getUserByWallet(nft.getPublishAddress());
if (user == null) {
User publisher = userService.getUserByWallet(nft.getPublishAddress());
if (publisher == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的发布人的信息");
}
NftVo nftVo = new NftVo(nft, user);
User owner = userService.getById(nft.getUserId());
if (owner == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的拥有者的信息");
}
NftVo nftVo = new NftVo(nft, publisher, owner);
nftVo.setFileList(nftFileService.getByNftId(id));
nftVo.setCategory(categoryService.getById(nft.getSecondCategoryId()).getText());
if (StringUtils.isNotBlank(Authorization) && !Authorization.startsWith(SystemConstant.NULL_TOKEN)) {
......
......@@ -3,7 +3,7 @@ package com.fzm.portal.controller;
import cn.hutool.json.JSONUtil;
import com.fzm.common.annotation.Authentication;
import com.fzm.common.constant.RedisConstant;
import com.fzm.common.entity.NftDto;
import com.fzm.common.entity.dto.NftDto;
import com.fzm.common.entity.NftFile;
import com.fzm.common.model.ResponseModel;
import com.fzm.common.utils.JwtUtil;
......
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