Commit 837b634e authored by tangtuo's avatar tangtuo

分布式锁加上过期时间

nft详情页面加上文件名 文件地址字段
parent ef434138
...@@ -32,6 +32,9 @@ public class CollectionNftVo { ...@@ -32,6 +32,9 @@ public class CollectionNftVo {
@ApiModelProperty("nft编号") @ApiModelProperty("nft编号")
private String nftId; private String nftId;
@ApiModelProperty("是否是纪念版nft 0-否 1-是")
private Integer isCommemorate;
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.theme = nft.getTheme();
...@@ -39,5 +42,6 @@ public class CollectionNftVo { ...@@ -39,5 +42,6 @@ public class CollectionNftVo {
this.category = category.getCategoryName(); this.category = category.getCategoryName();
this.name = nft.getName(); this.name = nft.getName();
this.cover = nft.getCover(); this.cover = nft.getCover();
this.isCommemorate = nft.getIsCommemorate();
} }
} }
...@@ -47,6 +47,12 @@ public class NftVo { ...@@ -47,6 +47,12 @@ public class NftVo {
@ApiModelProperty("剧本hash") @ApiModelProperty("剧本hash")
private String fileHash; private String fileHash;
@ApiModelProperty("文件名")
private String fileName;
@ApiModelProperty("文件地址")
private String fileUrl;
@ApiModelProperty("发行时间") @ApiModelProperty("发行时间")
private String publishTime; private String publishTime;
...@@ -85,5 +91,7 @@ public class NftVo { ...@@ -85,5 +91,7 @@ public class NftVo {
this.userId = nft.getUserId(); this.userId = nft.getUserId();
this.cover = nft.getCover(); this.cover = nft.getCover();
this.collection = false; this.collection = false;
this.fileName = nft.getFileName();
this.fileUrl = nft.getFileUrl();
} }
} }
...@@ -24,5 +24,5 @@ public interface CommemorateNftService extends IService<CommemorateNft> { ...@@ -24,5 +24,5 @@ public interface CommemorateNftService extends IService<CommemorateNft> {
* @param id * @param id
* @return * @return
*/ */
Boolean receive(Integer id); Boolean receive(Integer id) throws InterruptedException;
} }
...@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service; ...@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.TimeUnit;
/** /**
* @author tangtuo * @author tangtuo
...@@ -103,11 +104,11 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper, ...@@ -103,11 +104,11 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper,
} }
@Override @Override
public Boolean receive(Integer id) { public Boolean receive(Integer id) throws InterruptedException {
User user = userService.getUserByToken(); User user = userService.getUserByToken();
// 加锁,避免一个用户可以并发领取 // 加锁,避免一个用户可以并发领取
RLock lock = redisson.getLock("receive:nft:" + user.getId()); RLock lock = redisson.getLock("receive:nft:" + user.getId());
boolean tryLock = lock.tryLock(); boolean tryLock = lock.tryLock(30, TimeUnit.SECONDS);
if (!tryLock){ if (!tryLock){
throw GlobalException.newException(ResultCode.RECEIVE_ERROR, "操作频繁"); throw GlobalException.newException(ResultCode.RECEIVE_ERROR, "操作频繁");
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
a.name, a.name,
a.theme, a.theme,
a.nft_id, a.nft_id,
a.is_commemorate,
b.category_name as category b.category_name as category
from tb_nft a left join tb_category b on a.category_id = b.id from tb_nft a left join tb_category b on a.category_id = b.id
where a.id in ( where a.id in (
......
...@@ -91,7 +91,7 @@ public class CommemorateNftController { ...@@ -91,7 +91,7 @@ public class CommemorateNftController {
@Authentication @Authentication
@PostMapping("/receive") @PostMapping("/receive")
@ApiOperation(value = "领取纪念版nft") @ApiOperation(value = "领取纪念版nft")
public ResponseModel<Boolean> receive(@RequestParam Integer id) { public ResponseModel<Boolean> receive(@RequestParam Integer id) throws InterruptedException {
Boolean result = commemorateNftService.receive(id); Boolean result = commemorateNftService.receive(id);
return ResponseModel.success(result); return ResponseModel.success(result);
} }
......
...@@ -92,7 +92,7 @@ public class NftController { ...@@ -92,7 +92,7 @@ public class NftController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "获取nft列表") @ApiOperation(value = "获取nft列表")
public ResponseModel list(@ApiParam(value = "当前页码") @RequestParam Integer pageNum, public ResponseModel<List<Nft>> list(@ApiParam(value = "当前页码") @RequestParam Integer pageNum,
@ApiParam(value = "每页记录数") @RequestParam Integer pageSize, @ApiParam(value = "每页记录数") @RequestParam Integer pageSize,
@ApiParam(value = "类目id,查询所有的时候传null") @RequestParam(required = false) Integer categoryId) { @ApiParam(value = "类目id,查询所有的时候传null") @RequestParam(required = false) Integer categoryId) {
......
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