Commit 47e43ee4 authored by tangtuo's avatar tangtuo

修改类目管理 nft发行等接口

parent a30a59b0
...@@ -26,9 +26,9 @@ public class CategoryController { ...@@ -26,9 +26,9 @@ public class CategoryController {
@Resource @Resource
private CategoryService categoryService; private CategoryService categoryService;
@GetMapping("/list") /*@GetMapping("/list")
@ApiOperation(value = "查询所有类目信息") @ApiOperation(value = "查询所有类目信息")
public ResponseModel<List<Category>> list() { public ResponseModel<List<Category>> list() {
return ResponseModel.success(categoryService.listAll()); return ResponseModel.success(categoryService.getByPid());
} }*/
} }
...@@ -28,13 +28,4 @@ public abstract class BaseEntity { ...@@ -28,13 +28,4 @@ public abstract class BaseEntity {
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private Date updateDate; private Date updateDate;
@ApiModelProperty("记录创建的时间戳")
@TableField(fill = FieldFill.INSERT)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createTime;
@ApiModelProperty("记录更新的时间戳")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateTime;
} }
package com.fzm.common.entity; package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date;
/** /**
* @author tangtuo * @author tangtuo
* @date 2021/7/1 14:32 * @date 2021/7/1 14:32
...@@ -12,11 +15,23 @@ import lombok.experimental.Accessors; ...@@ -12,11 +15,23 @@ import lombok.experimental.Accessors;
@Data @Data
@TableName("tb_category") @TableName("tb_category")
@Accessors(chain = true) @Accessors(chain = true)
public class Category extends BaseEntity{ public class Category {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("父id,一级目录的父id为0")
private Integer pid;
@ApiModelProperty("类目名称") @ApiModelProperty("类目名称")
private String categoryName; private String text;
@ApiModelProperty("创建时间")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date createDate;
@ApiModelProperty("修改时间")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date updateDate;
@ApiModelProperty("英文名")
private String englishName;
} }
...@@ -21,57 +21,29 @@ import java.util.Date; ...@@ -21,57 +21,29 @@ import java.util.Date;
@TableName("tb_nft") @TableName("tb_nft")
public class Nft extends BaseEntity { public class Nft extends BaseEntity {
@NotNull(message = "类目id不能为空") @ApiModelProperty("一级类目id")
@ApiModelProperty("类目id")
private Integer categoryId; private Integer categoryId;
@ApiModelProperty("二级类目id")
private Integer secondCategoryId;
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
private Integer userId; private Integer userId;
@ApiModelProperty("发行人地址") @ApiModelProperty("发行人地址")
private String publishAddress; private String publishAddress;
@NotBlank(message = "名称不能为空")
@Length(max = 20, message = "名称最大长度为20")
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String name;
@ApiModelProperty("封面")
private String cover;
@NotBlank(message = "作者不能为空")
@Length(max = 20, message = "作者最大长度为20")
@ApiModelProperty("作者") @ApiModelProperty("作者")
private String author; private String author;
@NotBlank(message = "主题不能为空")
@ApiModelProperty("主题,多个用逗号,隔开")
private String theme;
@NotBlank(message = "简介不能为空")
@Length(max = 500, message = "简介最大长度为500")
@ApiModelProperty("简介") @ApiModelProperty("简介")
private String synopsis; private String synopsis;
@ApiModelProperty("文件名")
private String fileName;
@ApiModelProperty("文件地址--用户选择不存档的情况下为空")
private String fileUrl;
@NotBlank(message = "作品哈希不能为空")
@ApiModelProperty("文件hash")
private String fileHash;
@NotNull(message = "平台存档不能为空")
@ApiModelProperty("平台存档 0-不存档 1-加密存档")
private Integer isArchives;
@ApiModelProperty("授权阅读 0-不需要授权 1-需要授权")
private Integer isGrant;
@ApiModelProperty("nft编号") @ApiModelProperty("nft编号")
private String nftId; private String nftNum;
@ApiModelProperty("nft哈希") @ApiModelProperty("nft哈希")
private String nftHash; private String nftHash;
...@@ -85,16 +57,10 @@ public class Nft extends BaseEntity { ...@@ -85,16 +57,10 @@ public class Nft extends BaseEntity {
@ApiModelProperty("交易转让hash") @ApiModelProperty("交易转让hash")
private String transferHash; private String transferHash;
@ApiModelProperty("纪念版nft主键")
private Integer commemorateId;
@ApiModelProperty("是否置顶 0-否 1-是") @ApiModelProperty("是否置顶 0-否 1-是")
private Integer isTop; private Integer isTop;
@ApiModelProperty("0-下架 1-上架") @ApiModelProperty("0-下架 1-上架")
private Integer status; private Integer status;
@ApiModelProperty("是否是纪念版nft 0-否 1-是")
private Integer isCommemorate;
} }
...@@ -2,9 +2,12 @@ package com.fzm.common.entity; ...@@ -2,9 +2,12 @@ package com.fzm.common.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
/** /**
* @author tangtuo * @author tangtuo
...@@ -13,19 +16,38 @@ import javax.validation.constraints.NotNull; ...@@ -13,19 +16,38 @@ import javax.validation.constraints.NotNull;
@Data @Data
public class NftDto { public class NftDto {
@NotNull(message = "nft主键不能为空") @NotNull(message = "一级类目id不能为空")
@ApiModelProperty("nft主键") @ApiModelProperty("一级类目id")
private Integer id; private Integer categoryId;
@NotBlank(message = "nft哈希不能为空") @NotNull(message = "二级类目id不能为空")
@ApiModelProperty("nft哈希") @ApiModelProperty("二级类目id")
private String fileHash; private Integer secondCategoryId;
@NotBlank(message = "名称不能为空")
@Length(max = 20, message = "名称最大长度为20")
@ApiModelProperty("名称")
private String name;
@NotBlank(message = "作者不能为空")
@Length(max = 20, message = "作者最大长度为20")
@ApiModelProperty("作者")
private String author;
@NotBlank(message = "简介不能为空")
@Length(max = 500, message = "简介最大长度为500")
@ApiModelProperty("简介")
private String synopsis;
@NotBlank(message = "nft编号不能为空") @NotBlank(message = "nft编号不能为空")
@ApiModelProperty("nft编号") @ApiModelProperty("nft编号")
private String nftId; private String nftNum;
@NotNull(message = "发行数量不能为空")
@ApiModelProperty("发行数量")
private Integer publishCount;
@NotBlank(message = "发行人地址不能为空") @Size(max = 9, min = 1, message = "文件数量必须介于1-9之间")
@ApiModelProperty("发行人地址") @ApiModelProperty("文件列表")
private String wallet; private List<NftFile> fileList;
} }
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/8/10 17:22
*/
@Data
@TableName("tb_nft_file")
@Accessors(chain = true)
public class NftFile {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("nft的主键")
private Integer nftId;
@ApiModelProperty("文件路径")
private String fileUrl;
@ApiModelProperty("文件名")
private String fileName;
@ApiModelProperty("文件哈希")
private String fileHash;
@ApiModelProperty("创建时间")
private Date createDate;
@ApiModelProperty("修改时间")
private Date updateDate;
}
...@@ -37,11 +37,7 @@ public class CollectionNftVo { ...@@ -37,11 +37,7 @@ public class CollectionNftVo {
public CollectionNftVo(Nft nft, Category category) { public CollectionNftVo(Nft nft, Category category) {
this.id = nft.getId(); this.id = nft.getId();
this.theme = nft.getTheme(); this.category = category.getText();
this.nftId = nft.getNftId();
this.category = category.getCategoryName();
this.name = nft.getName(); this.name = nft.getName();
this.cover = nft.getCover();
this.isCommemorate = nft.getIsCommemorate();
} }
} }
...@@ -47,7 +47,6 @@ public class NftCertificateVo { ...@@ -47,7 +47,6 @@ public class NftCertificateVo {
public NftCertificateVo(Nft nft, User user, String qrCode) { public NftCertificateVo(Nft nft, User user, String qrCode) {
this.name = nft.getName(); this.name = nft.getName();
this.fileHash = nft.getFileHash();
this.nftHash = nft.getNftHash(); this.nftHash = nft.getNftHash();
this.id = nft.getId(); this.id = nft.getId();
this.publisher = user.getNickname(); this.publisher = user.getNickname();
......
...@@ -41,6 +41,5 @@ public class NftTransferVo { ...@@ -41,6 +41,5 @@ public class NftTransferVo {
this.avatar = user.getAvatar(); this.avatar = user.getAvatar();
this.wallet = user.getWallet(); this.wallet = user.getWallet();
this.nickname = user.getNickname(); this.nickname = user.getNickname();
this.nftId=nft.getNftId();
} }
} }
...@@ -84,22 +84,13 @@ public class NftVo { ...@@ -84,22 +84,13 @@ public class NftVo {
this.id = nft.getId(); this.id = nft.getId();
this.author = nft.getAuthor(); this.author = nft.getAuthor();
this.name = nft.getName(); this.name = nft.getName();
this.theme = nft.getTheme();
this.fileHash = nft.getFileHash();
this.nftId = nft.getNftId();
this.synopsis = nft.getSynopsis(); this.synopsis = nft.getSynopsis();
this.publisher = user.getNickname(); this.publisher = user.getNickname();
this.avatar = user.getAvatar(); this.avatar = user.getAvatar();
this.wallet = nft.getPublishAddress(); this.wallet = nft.getPublishAddress();
this.publishTime = DateUtil.format(nft.getPublishTime(), "yyyy/MM/dd HH:mm:ss"); this.publishTime = DateUtil.format(nft.getPublishTime(), "yyyy/MM/dd HH:mm:ss");
this.isArchives = nft.getIsArchives();
this.isGrant = nft.getIsGrant();
this.userId = nft.getUserId(); this.userId = nft.getUserId();
this.cover = nft.getCover();
this.collection = false; this.collection = false;
this.fileName = nft.getFileName();
this.fileUrl = nft.getFileUrl();
this.isCommemorate = nft.getIsCommemorate();
this.nftHash = nft.getNftHash(); this.nftHash = nft.getNftHash();
} }
} }
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.NftFile;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author tangtuo
* @date 2021/6/30 15:54
*/
@Mapper
public interface NftFileMapper extends BaseMapper<NftFile> {
}
...@@ -14,5 +14,11 @@ public interface CategoryService extends IService<Category> { ...@@ -14,5 +14,11 @@ public interface CategoryService extends IService<Category> {
Category getCategoryById(Integer categoryId); Category getCategoryById(Integer categoryId);
List<Category> listAll(); /**
* 根据pid查新类目列表
*
* @param pid
* @return
*/
List<Category> getByPid(Integer pid);
} }
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.AuthPerson;
import com.fzm.common.entity.NftFile;
/**
* @author tangtuo
* @date 2021/6/28 11:28
*/
public interface NftFileService extends IService<NftFile> {
}
...@@ -16,13 +16,6 @@ import java.util.List; ...@@ -16,13 +16,6 @@ import java.util.List;
* @date 2021/6/30 15:55 * @date 2021/6/30 15:55
*/ */
public interface NftService extends IService<Nft> { public interface NftService extends IService<Nft> {
/**
* 保存nft基本信息
*
* @param nft
* @return
*/
NftDto saveNft(Nft nft);
/** /**
* 查看nft列表 * 查看nft列表
......
package com.fzm.common.service.impl; package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Category; import com.fzm.common.entity.Category;
import com.fzm.common.mapper.CategoryMapper; import com.fzm.common.mapper.CategoryMapper;
import com.fzm.common.service.CategoryService; import com.fzm.common.service.CategoryService;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
...@@ -16,6 +19,9 @@ import java.util.List; ...@@ -16,6 +19,9 @@ import java.util.List;
@Service @Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService { public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
@Resource
private CategoryMapper categoryMapper;
@Override @Override
public Category getCategoryById(Integer categoryId) { public Category getCategoryById(Integer categoryId) {
List<Category> list = list(); List<Category> list = list();
...@@ -28,8 +34,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i ...@@ -28,8 +34,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
} }
@Override @Override
@Cacheable(value = "category", key = "'list'") @Cacheable(value = "category:list", key = "#pid")
public List<Category> listAll() { public List<Category> getByPid(Integer pid) {
return list(); QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pid", pid);
return categoryMapper.selectList(queryWrapper);
} }
} }
...@@ -151,15 +151,10 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper, ...@@ -151,15 +151,10 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper,
int availablePermits = commemorateNft.getCount() - semaphore.availablePermits(); int availablePermits = commemorateNft.getCount() - semaphore.availablePermits();
// nft编号为BJIFF11+5为顺序编号 : BJIFF1100123 // nft编号为BJIFF11+5为顺序编号 : BJIFF1100123
String code = "00000" + availablePermits; String code = "00000" + availablePermits;
nft.setNftId("BJIFF11" + code.substring(code.length() - 5));
nft.setTransferHash(realHash); nft.setTransferHash(realHash);
nft.setCommemorateId(id);
nft.setUserId(user.getId()); nft.setUserId(user.getId());
nft.setCreateDate(new Date()); nft.setCreateDate(new Date());
nft.setUpdateDate(new Date()); nft.setUpdateDate(new Date());
nft.setIsArchives(SystemConstant.BOOLEAN_DATA_TRUE);
nft.setIsGrant(SystemConstant.BOOLEAN_DATA_FALSE);
nft.setIsCommemorate(SystemConstant.BOOLEAN_DATA_TRUE);
nftService.save(nft); nftService.save(nft);
// 领取完毕,把当前用户id加入到纪念版nft的领取记录中 // 领取完毕,把当前用户id加入到纪念版nft的领取记录中
redisUtil.sAdd(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString()); redisUtil.sAdd(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString());
......
package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.AuthPerson;
import com.fzm.common.entity.NftFile;
import com.fzm.common.mapper.AuthPersonMapper;
import com.fzm.common.mapper.NftFileMapper;
import com.fzm.common.service.AuthPersonService;
import com.fzm.common.service.NftFileService;
import org.springframework.stereotype.Service;
/**
* @author tangtuo
* @date 2021/6/28 11:29
*/
@Service
public class NftFileServiceImpl extends ServiceImpl<NftFileMapper, NftFile> implements NftFileService {
}
...@@ -13,9 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -13,9 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.constant.RedisConstant; import com.fzm.common.constant.RedisConstant;
import com.fzm.common.constant.SystemConstant; import com.fzm.common.constant.SystemConstant;
import com.fzm.common.entity.*; import com.fzm.common.entity.*;
import com.fzm.common.entity.dto.ChainDto;
import com.fzm.common.entity.vo.CollectionNftVo; 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.entity.vo.NftListVo;
import com.fzm.common.enums.ResultCode; import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException; import com.fzm.common.exception.GlobalException;
...@@ -69,7 +67,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -69,7 +67,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
private NftTransferRecordService nftTransferRecordService; private NftTransferRecordService nftTransferRecordService;
@Resource @Resource
private OssUtil ossUtil; private NftFileService nftFileService;
@Resource @Resource
private SmsUtil smsUtil; private SmsUtil smsUtil;
...@@ -83,21 +81,6 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -83,21 +81,6 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
@Value("${chain.para.contract-name}") @Value("${chain.para.contract-name}")
private String contractName; private String contractName;
@Override
public NftDto saveNft(Nft nft) {
Integer userId = JwtUtil.getUserIdFromToken(request.getHeader("Authorization"));
nft.setUserId(userId);
save(nft);
User user = userService.getById(userId);
NftDto nftDto = new NftDto();
// 获取用户的钱包地址
String wallet = user.getWallet();
nftDto.setNftId(generateNftId(nft.getCategoryId()));
nftDto.setWallet(wallet);
nftDto.setId(nft.getId());
nftDto.setFileHash(nft.getFileHash());
return nftDto;
}
@Override @Override
public Integer publish(NftDto nftDto) { public Integer publish(NftDto nftDto) {
...@@ -106,23 +89,14 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -106,23 +89,14 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
// 获取用户的私钥 // 获取用户的私钥
String privkey = paraChainClient.walletDumpPrivkey(wallet); String privkey = paraChainClient.walletDumpPrivkey(wallet);
// 发行nft // 发行nft
String txHash = paraChainClient.evmPublishNFT1155(contractName, wallet, privkey, 1, true); String txHash = paraChainClient.evmPublishNFT1155(contractName, wallet, privkey, nftDto.getPublishCount(), true);
if (StringUtils.isBlank(txHash) || !txHash.contains("-")) { if (StringUtils.isBlank(txHash) || !txHash.contains("-")) {
throw GlobalException.newException(ResultCode.FAILED, "nft发行失败"); throw GlobalException.newException(ResultCode.FAILED, "nft发行失败");
} }
String[] split = txHash.split("-"); String[] split = txHash.split("-");
String hash = split[0]; String hash = split[0];
long tokenId = Long.parseLong(split[1]); long tokenId = Long.parseLong(split[1]);
Nft nft = getById(nftDto.getId()); HashMap<String, Object> map = new HashMap<>();
// 构建上链信息
ChainDto chainDto = new ChainDto();
chainDto.setName(nft.getName());
chainDto.setAuthor(nft.getAuthor());
chainDto.setHash(nft.getFileHash());
chainDto.setPublishAddress(wallet);
Map<String, String> map = new HashMap<>();
map.put("hash", nft.getFileHash());
log.info("加密上链数据: {}", chainDto);
String tradeHash = paraChainClient.evmSetTokenInfo(contractName, tokenId, JSONUtil.toJsonStr(map), wallet, privkey, true); String tradeHash = paraChainClient.evmSetTokenInfo(contractName, tokenId, JSONUtil.toJsonStr(map), wallet, privkey, true);
if (StringUtils.isBlank(tradeHash)) { if (StringUtils.isBlank(tradeHash)) {
throw GlobalException.newException(ResultCode.PUBLISH_ERROR, "nft发行失败"); throw GlobalException.newException(ResultCode.PUBLISH_ERROR, "nft发行失败");
...@@ -134,12 +108,25 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -134,12 +108,25 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
throw GlobalException.newException(ResultCode.PUBLISH_ERROR, txResult.getErrMsg().getValue()); throw GlobalException.newException(ResultCode.PUBLISH_ERROR, txResult.getErrMsg().getValue());
} }
String realHash = paraChainClient.getRealTxHashFromGrp(hash); String realHash = paraChainClient.getRealTxHashFromGrp(hash);
Nft nft = new Nft();
nft.setCategoryId(nftDto.getCategoryId());
nft.setSecondCategoryId(nftDto.getSecondCategoryId());
nft.setPublishAddress(wallet);
nft.setPublishTime(new Date());
nft.setUserId(user.getId());
nft.setSynopsis(nftDto.getSynopsis());
nft.setName(nftDto.getName());
nft.setAuthor(nftDto.getAuthor());
nft.setNftNum(nftDto.getNftNum());
nft.setNftHash(realHash); nft.setNftHash(realHash);
nft.setTokenId(tokenId); nft.setTokenId(tokenId);
nft.setPublishTime(new Date()); nft.setPublishTime(new Date());
nft.setNftId(nftDto.getNftId());
nft.setPublishAddress(wallet); nft.setPublishAddress(wallet);
updateById(nft); save(nft);
List<NftFile> fileList = nftDto.getFileList();
fileList.forEach(file -> file.setNftId(nft.getId()));
// 保存文件信息
nftFileService.saveBatch(fileList);
// 如果用户是第一次发行作品,把用户的isPublish修改成1,并清空用户统计的缓存信息 // 如果用户是第一次发行作品,把用户的isPublish修改成1,并清空用户统计的缓存信息
if (SystemConstant.BOOLEAN_DATA_FALSE.equals(user.getIsPublish())) { if (SystemConstant.BOOLEAN_DATA_FALSE.equals(user.getIsPublish())) {
User u = new User().setId(user.getId()).setIsPublish(SystemConstant.BOOLEAN_DATA_TRUE); User u = new User().setId(user.getId()).setIsPublish(SystemConstant.BOOLEAN_DATA_TRUE);
...@@ -288,7 +275,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -288,7 +275,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此类目"); throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此类目");
} }
int code = RandomUtil.randomInt(1000, 10000); int code = RandomUtil.randomInt(1000, 10000);
return String.format("INMVO-%s-%s%s", category.getEnglishName(), System.currentTimeMillis(), code); return String.format("INMVO-%s-%s%s", category.getText(), System.currentTimeMillis(), code);
} }
@Override @Override
...@@ -348,10 +335,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe ...@@ -348,10 +335,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
if (nft == null) { if (nft == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft详情"); throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft详情");
} }
if (SystemConstant.BOOLEAN_DATA_FALSE.equals(nft.getIsArchives()) || SystemConstant.BOOLEAN_DATA_TRUE.equals(nft.getIsGrant())) {
throw GlobalException.newException(ResultCode.FILE_DOWNLOAD_ERROR, "当前文件不支持下载");
}
ossUtil.downloadFile(nft.getFileUrl(), nft.getFileName());
} }
} }
...@@ -11,9 +11,9 @@ import org.springframework.cache.annotation.EnableCaching; ...@@ -11,9 +11,9 @@ import org.springframework.cache.annotation.EnableCaching;
@EnableCaching @EnableCaching
@SpringBootApplication(scanBasePackages = {"com.fzm.portal", "com.fzm.common"}) @SpringBootApplication(scanBasePackages = {"com.fzm.portal", "com.fzm.common"})
@MapperScan(value = "com.fzm.common.mapper") @MapperScan(value = "com.fzm.common.mapper")
public class JoyingPortalApplication { public class ArtPortalApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(JoyingPortalApplication.class, args); SpringApplication.run(ArtPortalApplication.class, args);
} }
} }
...@@ -5,8 +5,10 @@ import com.fzm.common.model.ResponseModel; ...@@ -5,8 +5,10 @@ import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.CategoryService; import com.fzm.common.service.CategoryService;
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 org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -25,8 +27,8 @@ public class CategoryController { ...@@ -25,8 +27,8 @@ public class CategoryController {
private CategoryService categoryService; private CategoryService categoryService;
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "查询所有类目信息") @ApiOperation(value = "查询所有类目信息", notes = "如果查所有一级目录的话,pid传0或者空值")
public ResponseModel<List<Category>> list() { public ResponseModel<List<Category>> list(@ApiParam(value = "父id,对应的是一级目录的id") @RequestParam(required = false, defaultValue = "0") Integer pid) {
return ResponseModel.success(categoryService.listAll()); return ResponseModel.success(categoryService.getByPid(pid));
} }
} }
...@@ -4,7 +4,6 @@ import cn.hutool.crypto.SecureUtil; ...@@ -4,7 +4,6 @@ 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.RedisConstant;
import com.fzm.common.entity.CommemorateNft; import com.fzm.common.entity.CommemorateNft;
import com.fzm.common.entity.Label;
import com.fzm.common.entity.User; import com.fzm.common.entity.User;
import com.fzm.common.entity.vo.CommemorateNftVo; import com.fzm.common.entity.vo.CommemorateNftVo;
import com.fzm.common.enums.ResultCode; import com.fzm.common.enums.ResultCode;
...@@ -12,7 +11,6 @@ import com.fzm.common.exception.GlobalException; ...@@ -12,7 +11,6 @@ import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel; import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.CategoryService; import com.fzm.common.service.CategoryService;
import com.fzm.common.service.CommemorateNftService; import com.fzm.common.service.CommemorateNftService;
import com.fzm.common.service.LabelService;
import com.fzm.common.service.UserService; import com.fzm.common.service.UserService;
import com.fzm.common.utils.JwtUtil; import com.fzm.common.utils.JwtUtil;
import com.fzm.common.utils.OssUtil; import com.fzm.common.utils.OssUtil;
...@@ -29,7 +27,6 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -29,7 +27,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* @author tangtuo * @author tangtuo
...@@ -107,7 +104,7 @@ public class CommemorateNftController { ...@@ -107,7 +104,7 @@ public class CommemorateNftController {
} }
User user = userService.getById(nft.getUserId()); User user = userService.getById(nft.getUserId());
CommemorateNftVo commemorateNftVo = new CommemorateNftVo(nft, user); CommemorateNftVo commemorateNftVo = new CommemorateNftVo(nft, user);
commemorateNftVo.setCategory(categoryService.getById(nft.getCategoryId()).getCategoryName()); commemorateNftVo.setCategory(categoryService.getById(nft.getCategoryId()).getText());
RSemaphore semaphore = redisson.getSemaphore(RedisConstant.COMMEMORATE_NFT_PREFIX + id); RSemaphore semaphore = redisson.getSemaphore(RedisConstant.COMMEMORATE_NFT_PREFIX + id);
int permits = semaphore.availablePermits(); int permits = semaphore.availablePermits();
commemorateNftVo.setReceiveCount(nft.getCount() - permits); commemorateNftVo.setReceiveCount(nft.getCount() - permits);
......
...@@ -3,7 +3,6 @@ package com.fzm.portal.controller; ...@@ -3,7 +3,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.RedisConstant;
import com.fzm.common.constant.SystemConstant;
import com.fzm.common.constant.TokenConstant; 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;
...@@ -70,19 +69,6 @@ public class NftController { ...@@ -70,19 +69,6 @@ public class NftController {
@Authentication @Authentication
@PostMapping("/save")
@ApiOperation(value = "nft基本信息保存(基本信息和加密上链两个步骤)")
public ResponseModel<NftDto> save(@Validated @ModelAttribute Nft nft) {
if (SystemConstant.BOOLEAN_DATA_TRUE.equals(nft.getIsArchives())) {
if (StringUtils.isAnyBlank(nft.getFileUrl(), nft.getName()) || nft.getIsGrant() == null) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "当选择平台存档时,文件名和文件路径必传");
}
}
return ResponseModel.success(nftService.saveNft(nft));
}
@Authentication
@PostMapping("/publish") @PostMapping("/publish")
@ApiOperation("发行nft") @ApiOperation("发行nft")
public ResponseModel<Integer> publish(@Validated @RequestBody NftDto nftDto) { public ResponseModel<Integer> publish(@Validated @RequestBody NftDto nftDto) {
...@@ -113,7 +99,7 @@ public class NftController { ...@@ -113,7 +99,7 @@ public class NftController {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的发布人的信息"); throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的发布人的信息");
} }
NftVo nftVo = new NftVo(nft, user); NftVo nftVo = new NftVo(nft, user);
nftVo.setCategory(categoryService.getById(nft.getCategoryId()).getCategoryName()); nftVo.setCategory(categoryService.getById(nft.getCategoryId()).getText());
if (StringUtils.isNotBlank(Authorization)) { if (StringUtils.isNotBlank(Authorization)) {
String realToken = Authorization.substring(TokenConstant.TOKEN_PREFIX.length()); String realToken = Authorization.substring(TokenConstant.TOKEN_PREFIX.length());
if (StringUtils.isNotBlank(realToken) && !"null".equals(realToken)) { if (StringUtils.isNotBlank(realToken) && !"null".equals(realToken)) {
...@@ -132,7 +118,7 @@ public class NftController { ...@@ -132,7 +118,7 @@ public class NftController {
Integer userId = JwtUtil.getUserIdFromToken(request.getHeader("Authorization")); Integer userId = JwtUtil.getUserIdFromToken(request.getHeader("Authorization"));
List<Nft> list = nftService.listCurrent(categoryId, userId); List<Nft> list = nftService.listCurrent(categoryId, userId);
List<CollectionNftVo> nftVoList = list.stream() List<CollectionNftVo> nftVoList = list.stream()
.map(nft -> new CollectionNftVo(nft, categoryService.getCategoryById(nft.getCategoryId()))) .map(nft -> new CollectionNftVo(nft, categoryService.getCategoryById(nft.getId())))
.collect(Collectors.toList()); .collect(Collectors.toList());
User user = userService.getById(userId); User user = userService.getById(userId);
// 生成二维码 // 生成二维码
......
server: server:
port: 8001 port: 9001
spring: spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_dev?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: 172.16.101.135 host: 172.16.101.135
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
server: server:
port: 8001 port: 9001
spring: spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_dev?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: localhost host: localhost
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
server: server:
port: 8001 port: 9001
spring: spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: 172.16.101.136 host: 172.16.101.136
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_dev?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: 172.16.101.135 host: 172.16.101.135
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_dev?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: localhost host: localhost
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
datasource: datasource:
url: jdbc:mysql://172.16.101.135:3306/joying_test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://172.16.101.135:3306/zhuixin-art?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root username: root
password: Joying@123456 password: Joying@123456
platform: mysql platform: mysql
...@@ -30,6 +30,7 @@ spring: ...@@ -30,6 +30,7 @@ spring:
host: 172.16.101.136 host: 172.16.101.136
port: 6379 port: 6379
password: 123456 password: 123456
database: 2
lettuce: lettuce:
pool: pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8 # 连接池最大连接数(使用负值表示没有限制) 默认 8
......
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