Commit 619205e0 authored by tangtuo's avatar tangtuo

新增nft nft列表 nft详情 类目列表等接口编写

parent c5825a20
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author tangtuo
* @date 2021/7/1 14:32
*/
@Data
@TableName("tb_category")
@Accessors(chain = true)
public class Category extends BaseEntity{
@ApiModelProperty("类目名称")
private String categoryName;
@ApiModelProperty("英文名")
private String englishName;
}
......@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/6/30 15:42
......@@ -55,4 +57,13 @@ public class Nft extends BaseEntity {
@ApiModelProperty("nft哈希")
private String nftHash;
@ApiModelProperty("nft发行时间")
private Date publishTime;
@ApiModelProperty("是否置顶 0-否 1-是")
private Integer isTop;
@ApiModelProperty("0-下架 1-上架")
private Integer status;
}
package com.fzm.common.entity.vo;
import cn.hutool.core.date.DateUtil;
import com.fzm.common.entity.Nft;
import com.fzm.common.entity.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import sun.management.counter.perf.PerfInstrumentation;
/**
* @author tangtuo
* @date 2021/7/1 10:35
*/
@Data
public class NftVo {
@ApiModelProperty("主键")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("类目")
private String category;
@ApiModelProperty("主题,多个用逗号,隔开")
private String theme;
@ApiModelProperty("发行人")
private String publisher;
@ApiModelProperty("头像")
private String avatar;
@ApiModelProperty("钱包地址")
private String wallet;
@ApiModelProperty("nft编号")
private String nftId;
@ApiModelProperty("剧本hash")
private String fileHash;
@ApiModelProperty("发行时间")
private String publishTime;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("简介")
private String synopsis;
@ApiModelProperty("关于nft")
private String aboutNft;
public NftVo(Nft nft, User user){
this.id = nft.getId();
this.author = nft.getAuthor();
this.name = nft.getName();
this.theme=nft.getTheme();
this.fileHash = nft.getFileHash();
this.nftId = nft.getNftId();
this.synopsis = nft.getSynopsis();
this.publisher = user.getNickname();
this.avatar = user.getAvatar();
this.wallet=user.getWallet();
this.publishTime = DateUtil.format(nft.getPublishTime(), "yyyy/MM/dd HH:mm:ss");
}
}
package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.Category;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tangtuo
* @date 2021/7/1 14:35
*/
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
}
......@@ -3,6 +3,9 @@ package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.Nft;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author tangtuo
......@@ -10,4 +13,13 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface NftMapper extends BaseMapper<Nft> {
/**
* 查询nft列表
* @param pageNum
* @param pageSize
* @param categoryId
* @return
*/
List<Nft> list(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize, @Param("categoryId") Integer categoryId);
}
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Category;
/**
* @author tangtuo
* @date 2021/7/1 14:35
*/
public interface CategoryService extends IService<Category> {
}
......@@ -3,10 +3,14 @@ package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Nft;
import java.util.List;
/**
* @author tangtuo
* @date 2021/6/30 15:55
*/
public interface NftService extends IService<Nft> {
String publish(Nft nft);
List<Nft> list(Integer pageNum, Integer pageSize, Integer categoryId);
}
package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Category;
import com.fzm.common.mapper.CategoryMapper;
import com.fzm.common.service.CategoryService;
import org.springframework.stereotype.Service;
/**
* @author tangtuo
* @date 2021/7/1 14:36
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
}
package com.fzm.common.service.impl;
import cn.fzm.chain.simplesdk.client.ParaChainClient;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Nft;
import com.fzm.common.mapper.NftMapper;
......@@ -8,6 +9,7 @@ import com.fzm.common.service.NftService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author tangtuo
......@@ -19,10 +21,18 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
@Resource
private ParaChainClient paraChainClient;
@Resource
private NftMapper nftMapper;
@Override
public String publish(Nft nft) {
save(nft);
//return paraChainClient.evmPublishNFT1155();
return null;
}
@Override
public List<Nft> list(Integer pageNum, Integer pageSize, Integer categoryId) {
return nftMapper.list(pageNum,pageSize,categoryId);
}
}
<?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.fzm.common.mapper.NftMapper">
<select id="list" resultType="com.fzm.common.entity.Nft">
select * from tb_nft
where status = 1
<if test="categoryId != null and categoryId > 0">
category_id=#{categoryId}
</if>
order by is_top , update_date desc
limit #{pageNum} #{pageSize}
</select>
</mapper>
\ No newline at end of file
artifactId=joying-common
groupId=com.fzm
version=1.0.0
com\fzm\common\utils\OssUtil.class
com\fzm\common\enums\AuthTypeEnum.class
com\fzm\common\service\UserService.class
com\fzm\common\constant\RedisConstant.class
com\fzm\common\entity\AuthPerson.class
com\fzm\common\entity\AbstractUser.class
com\fzm\common\params\LoginParam.class
com\fzm\common\properties\SmsProperties.class
com\fzm\common\config\SaTokenConfigure.class
com\fzm\common\enums\AuthStatusEnum.class
com\fzm\common\exception\handler\GlobalExceptionHandler.class
com\fzm\common\mapper\UserMapper.class
com\fzm\common\enums\IErrorCode.class
com\fzm\common\utils\SmsUtil.class
com\fzm\common\constant\TokenConstant.class
com\fzm\common\entity\User.class
com\fzm\common\service\impl\AuthPersonServiceImpl.class
com\fzm\common\entity\BaseEntity.class
com\fzm\common\utils\PasswordUtil.class
com\fzm\common\exception\GlobalException.class
com\fzm\common\service\impl\UserServiceImpl.class
com\fzm\common\service\AuthPersonService.class
com\fzm\common\model\ResponseModel.class
com\fzm\common\utils\JwtUtil.class
com\fzm\common\config\SecurityConfig.class
com\fzm\common\mapper\AuthPersonMapper.class
com\fzm\common\utils\RedisUtil.class
com\fzm\common\config\CorsConfig.class
com\fzm\common\properties\OssProperties.class
com\fzm\common\utils\JsonUtil.class
com\fzm\common\enums\ResultCode.class
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\User.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\properties\SmsProperties.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\constant\RedisConstant.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\IErrorCode.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\constant\TokenConstant.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\impl\UserServiceImpl.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\model\ResponseModel.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\mapper\AuthPersonMapper.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\SmsUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\SecurityConfig.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\AbstractUser.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\AuthPerson.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\JwtUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\SaTokenConfigure.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\AuthPersonService.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\impl\AuthPersonServiceImpl.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\AuthStatusEnum.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\RedisUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\mapper\UserMapper.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\CorsConfig.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\properties\OssProperties.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\OssUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\AuthTypeEnum.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\exception\handler\GlobalExceptionHandler.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\BaseEntity.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\JsonUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\exception\GlobalException.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\UserService.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\params\LoginParam.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\PasswordUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\ResultCode.java
package com.fzm.portal.controller;
import com.fzm.common.entity.Category;
import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author tangtuo
* @date 2021/7/1 14:37
*/
@RestController
@RequestMapping(value = "/category")
@Api(tags = "门户用户管理")
public class CategoryController {
@Resource
private CategoryService categoryService;
@GetMapping("/list")
@ApiOperation(value = "查询所有类目信息")
public ResponseModel<List<Category>> list() {
return ResponseModel.success(categoryService.list());
}
}
......@@ -4,21 +4,22 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.fzm.common.constant.SystemConstant;
import com.fzm.common.entity.Nft;
import com.fzm.common.entity.User;
import com.fzm.common.entity.vo.NftVo;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.NftService;
import com.fzm.common.service.UserService;
import com.fzm.common.utils.OssUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
/**
* @author tangtuo
......@@ -35,20 +36,23 @@ public class NftController {
@Resource
private NftService nftService;
@Resource
private UserService userService;
@SaCheckLogin
@PostMapping("/publish")
@ApiOperation(value = "/nft发行")
@ApiOperation(value = "nft发行")
public ResponseModel publish(@ApiParam(value = "类目id", required = true) Integer categoryId,
@ApiParam(value = "名称", required = true) String name,
@ApiParam(value = "作者", required = true) String author,
@ApiParam(value = "主题", required = true) String theme,
@ApiParam(value = "简介", required = true) String synopsis,
@ApiParam(value = "文件", required = false) MultipartFile file,
@ApiParam(value = "文件hash", required = true) String fileHash,
@ApiParam(value = "平台存档 0-不存档 1-加密存档", required = true) Integer isArchives,
@ApiParam(value = "授权阅读 0-不需要授权 1-需要授权", required = false) Integer isGrant,
@ApiParam(value = "nft编号", required = true) String nftId) {
@ApiParam(value = "名称", required = true) String name,
@ApiParam(value = "作者", required = true) String author,
@ApiParam(value = "主题", required = true) String theme,
@ApiParam(value = "简介", required = true) String synopsis,
@ApiParam(value = "文件", required = false) MultipartFile file,
@ApiParam(value = "文件hash", required = true) String fileHash,
@ApiParam(value = "平台存档 0-不存档 1-加密存档", required = true) Integer isArchives,
@ApiParam(value = "授权阅读 0-不需要授权 1-需要授权", required = false) Integer isGrant,
@ApiParam(value = "nft编号", required = true) String nftId) {
Nft nft = new Nft();
// 当平台存档选择加密存档时,文件必传
if (SystemConstant.BOOLEAN_DATA_TRUE.equals(isArchives)) {
......@@ -70,9 +74,29 @@ public class NftController {
return ResponseModel.success(nftHash);
}
/* @GetMapping("/list")
@GetMapping("/list")
@ApiOperation(value = "获取nft列表")
public ResponseModel list(){
public ResponseModel 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);
return ResponseModel.success(list);
}
@GetMapping("get/{id}")
@ApiOperation(value = "获取nft详情")
public ResponseModel<NftVo> getById(@PathVariable Integer id) {
Nft nft = nftService.getById(id);
if (nft == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的详情");
}
User user = userService.getById(nft.getUserId());
if (user == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的发布人的信息");
}
return ResponseModel.success(new NftVo(nft, user));
}
}*/
}
......@@ -29,7 +29,7 @@ spring:
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
useGlobalDataSourceStat: true
redis:
host: localhost
host: 172.16.101.135
port: 6379
password: 123456
lettuce:
......
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