From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001 From: lee <4766465@qq.com> Date: Wed, 18 Dec 2024 13:27:00 +0800 Subject: [PATCH] init --- yami-shop-api/src/main/java/com/yami/shop/api/controller/cdn/CdnIndexController.java | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 106 insertions(+), 0 deletions(-) diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/cdn/CdnIndexController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/cdn/CdnIndexController.java new file mode 100644 index 0000000..9572a0b --- /dev/null +++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/cdn/CdnIndexController.java @@ -0,0 +1,106 @@ +package com.yami.shop.api.controller.cdn; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.yami.shop.bean.model.CdnUserWallet; +import com.yami.shop.bean.param.CdnNodeInfoParam; +import com.yami.shop.bean.param.CdnWalletInfoParam; +import com.yami.shop.bean.param.MyCdnTeamParam; +import com.yami.shop.common.enums.WalletEnum; +import com.yami.shop.common.response.ServerResponseEntity; +import com.yami.shop.security.api.util.SecurityUtils; +import com.yami.shop.service.CdnBindService; +import com.yami.shop.service.CdnTeamRelationService; +import com.yami.shop.service.CdnUserWalletService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; + +@RestController +@RequestMapping("/p/cdn/index") +@Tag(name = "Cdn个人中心相关接口") +public class CdnIndexController { + @Autowired + private CdnTeamRelationService cdnTeamRelationService; + + @Autowired + private CdnUserWalletService cdnUserWalletService; + + @Autowired + private CdnBindService cdnBindService; + + @GetMapping("/myTeam") + @Operation(summary = "我的团队", description = "我的团队") + @Parameters({ + @Parameter(name = "userId",description = "用户id"), + @Parameter(name = "pattern", description = "模式 0托管 1自主") + }) + public ServerResponseEntity<MyCdnTeamParam> getMyTeam(@RequestParam(name = "userId") String userId){ + // 直推人数: 统计 pid = userId 的用户 + // 团队人数:统计 pids 包含 userId 的用户 + // 个人设备:统计个人设备数 + // 团队设备:统计团队设备数 + // 姓名,账号,等级,注册时间:在 user 表查询 + // 团队设备:pids 包含 userId 的用户设备 + MyCdnTeamParam myCdnTeamParam = cdnTeamRelationService.getMyCdnTeamInfo(userId); + return ServerResponseEntity.success(myCdnTeamParam); + } + + /** + * 团队列表展示接口 + */ + + + /** + * 个人中心展示数据 + */ + @GetMapping("/getWalletInfo") + @Operation(summary = "获取个人中心钱包展示数据", description = "获取个人中心钱包展示数据") + @Parameters({ + @Parameter(name = "userId",description = "用户id") + }) + public ServerResponseEntity<CdnWalletInfoParam> getWalletInfo(){ + String userId = SecurityUtils.getUser().getUserId(); + // 查询钱包币种数额 + CdnWalletInfoParam cdnWalletInfoParam = new CdnWalletInfoParam(); + // 根据币种查询钱包相关币种余额 + CdnUserWallet flow = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class) + .eq(CdnUserWallet::getUserId, userId) + .eq(CdnUserWallet::getWalletId, WalletEnum.FLOW.value())); + CdnUserWallet goldCowBean = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class) + .eq(CdnUserWallet::getUserId,userId) + .eq(CdnUserWallet::getWalletId, WalletEnum.GOLDCOWBEAN.value())); + CdnUserWallet luckPool = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class) + .eq(CdnUserWallet::getUserId,userId) + .eq(CdnUserWallet::getWalletId, WalletEnum.LUCKPOOL.value())); + CdnUserWallet integral = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class) + .eq(CdnUserWallet::getUserId,userId) + .eq(CdnUserWallet::getWalletId, WalletEnum.INTEGRAL.value())); + CdnUserWallet credit = cdnUserWalletService.getWalletByUserId(userId,WalletEnum.CREDIT.value()); + CdnUserWallet alloy = cdnUserWalletService.getWalletByUserId(userId,WalletEnum.ALLOY.value()); + BigDecimal b = new BigDecimal(0); + cdnWalletInfoParam.setFlow(flow != null ? flow.getMoney() : b); + cdnWalletInfoParam.setGoldCowBean(goldCowBean != null ? goldCowBean.getMoney() : b); + cdnWalletInfoParam.setLuckPool(luckPool != null ? luckPool.getMoney() : b); + cdnWalletInfoParam.setIntegral(integral != null ? integral.getMoney() : b); + cdnWalletInfoParam.setCredit(credit != null ? credit.getMoney() : b); + cdnWalletInfoParam.setAlloy(alloy != null ? alloy.getMoney() : b); + return ServerResponseEntity.success(cdnWalletInfoParam); + } + @GetMapping("/getNodeInfo") + @Operation(summary = "获取节点建设进度数据", description = "获取节点建设进度数据") + @Parameters({ + @Parameter(name = "userId",description = "用户id"), + }) + public ServerResponseEntity<CdnNodeInfoParam> getNodeInfo(@RequestParam(name = "userId") String userId){ + return ServerResponseEntity.success(cdnBindService.getNodeInfo(userId)); + } + +} -- Gitblit v1.9.3