Commit d32e3b4d authored by tangtuo's avatar tangtuo

我的nft列表接口新增二维码展示

parent d65ecdb6
......@@ -17,10 +17,7 @@ import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.CategoryService;
import com.fzm.common.service.NftService;
import com.fzm.common.service.UserService;
import com.fzm.common.utils.JwtUtil;
import com.fzm.common.utils.OssUtil;
import com.fzm.common.utils.QRCodeUtil;
import com.fzm.common.utils.RedisUtil;
import com.fzm.common.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -112,7 +109,7 @@ public class NftController {
if (nft == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的详情");
}
User user = userService.getById(nft.getUserId());
User user = userService.getUserByWallet(nft.getPublishAddress());
if (user == null) {
throw GlobalException.newException(ResultCode.DATA_ERROR, "没找到此nft的发布人的信息");
}
......@@ -132,14 +129,23 @@ public class NftController {
@Authentication
@GetMapping("/list/current")
@ApiOperation(value = "获取我的nft列表")
public ResponseModel<Map<String, Object>> listCurrent(@ApiParam(value = "类目id,查询全部的时候传null") @RequestParam(required = false) Integer categoryId) {
List<Nft> list = nftService.listCurrent(categoryId, JwtUtil.getUserIdFromToken(request.getHeader("Authorization")));
public ResponseModel<Map<String, Object>> listCurrent(@ApiParam(value = "类目id,查询全部的时候传null") @RequestParam(required = false) Integer categoryId) throws Exception {
Integer userId = JwtUtil.getUserIdFromToken(request.getHeader("Authorization"));
List<Nft> list = nftService.listCurrent(categoryId, userId);
List<CollectionNftVo> nftVoList = list.stream()
.map(nft -> new CollectionNftVo(nft, categoryService.getCategoryById(nft.getCategoryId())))
.collect(Collectors.toList());
HashMap<String, Object> result = new HashMap<>(4);
User user = userService.getById(userId);
// 生成二维码
HashMap<String, Object> qrCodeMap = new HashMap<>();
qrCodeMap.put("nickname", user.getNickname());
qrCodeMap.put("avatar", user.getAvatar());
qrCodeMap.put("wallet", user.getWallet());
String qrCode = QRCodeUtil.encode(JsonUtil.toJson(qrCodeMap), null, false);
HashMap<String, Object> result = new HashMap<>(8);
result.put("list", nftVoList);
result.put("size", nftVoList.size());
result.put("qrCode", qrCode);
return ResponseModel.success(result);
}
......
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