From 81714ac84eb9cf515c0dbf701b5b87d02bafb6bd Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期四, 06 六月 2024 14:41:05 +0800
Subject: [PATCH] feat: 修复前后端联调Bug

---
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java |   83 ++++++++++++++++++++++++++++++-----------
 1 files changed, 60 insertions(+), 23 deletions(-)

diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
index 60caadb..ba86ca7 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -2,7 +2,6 @@
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.page.PageInfo;
 import com.ruoyi.common.security.service.TokenService;
@@ -158,7 +157,6 @@
     @PostMapping("/addGoods")
     @ApiOperation(value = "添加", tags = {"后台-商品管理"})
     public R addGoods(@RequestBody TGoods dto) {
-        dto.setSurplus(dto.getTotal());
         goodsService.save(dto);
         return R.ok("添加成功");
     }
@@ -201,10 +199,23 @@
      * 兑换记录
      */
     @GetMapping("/exchangeRecord")
-    @ApiOperation(value = "学习端-兑换记录", tags = {"学习端-兑换记录"})
-    public R<List<TOrder>> exchangeRecord() {
-        return R.ok(orderService.lambdaQuery().eq(TOrder::getUserId, tokenService.getLoginUserStudy().getUserid())
-                .orderByDesc(TOrder::getCreateTime).list());
+    @ApiOperation(value = "学习端-兑换记录", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 28)
+    public R<List<ExchangeRecordVO>> exchangeRecord() {
+        List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(tokenService.getLoginUserStudy().getUserid());
+        for (ExchangeRecordVO record : exchangeRecord) {
+            TGoods goods = goodsService.getById(record.getGoodsId());
+            List<String> typeList;
+            if (null != goods) {
+                List<TGoodsType> goodsTypes = goodsTypeService.lambdaQuery().in(TGoodsType::getId, Arrays.stream(goods.getTypeIds().split(",")).collect(Collectors.toList()))
+                        .eq(TGoodsType::getIsDelete, 0).list();
+                typeList = goodsTypes.stream().map(TGoodsType::getName).collect(Collectors.toList());
+            } else {
+                typeList = new ArrayList<>();
+            }
+            record.setGoodsType(typeList);
+        }
+        return R.ok(exchangeRecord);
     }
 
     @GetMapping("/exchangeRecordParent")
@@ -241,6 +252,7 @@
      */
     @GetMapping("/confirm")
     @ApiOperation(value = "确认收货", tags = {"家长端-兑换记录"})
+    @ApiOperationSupport(order = 16)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true)
     })
@@ -257,7 +269,8 @@
      * 兑换记录
      */
     @GetMapping("/confirmStudy")
-    @ApiOperation(value = "确认收货", tags = {"学习端-兑换记录"})
+    @ApiOperation(value = "确认收货", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 29)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true)
     })
@@ -275,6 +288,7 @@
      */
     @GetMapping("/shopAddressParent")
     @ApiOperation(value = "获取用户收货地址", tags = {"家长端-获取用户收货地址"})
+    @ApiOperationSupport(order = 17)
     public R<List<Recipient>> shopAddressParent() {
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
@@ -288,6 +302,7 @@
      */
     @GetMapping("/setDefault")
     @ApiOperation(value = "设置默认地址", tags = {"家长端-设置默认地址"})
+    @ApiOperationSupport(order = 18)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true)
     })
@@ -313,7 +328,8 @@
      * 设置默认地址
      */
     @GetMapping("/setDefaultStudy")
-    @ApiOperation(value = "设置默认地址", tags = {"学习端-设置默认地址"})
+    @ApiOperation(value = "设置默认地址", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 30)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true)
     })
@@ -342,7 +358,8 @@
      * @return
      */
     @GetMapping("/getAddressById")
-    @ApiOperation(value = "获取地址详情", tags = {"家长端-获取地址详情"})
+    @ApiOperation(value = "获取地址详情", tags = {"家长端-收货地址"})
+    @ApiOperationSupport(order = 19)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true)
     })
@@ -361,7 +378,8 @@
      * @return
      */
     @GetMapping("/getAddressByIdStudy")
-    @ApiOperation(value = "获取地址详情", tags = {"学习端-获取地址详情"})
+    @ApiOperation(value = "获取地址详情", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 31)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true)
     })
@@ -377,7 +395,8 @@
      * 获取用户收货地址
      */
     @GetMapping("/shopAddress")
-    @ApiOperation(value = "获取用户收货地址", tags = {"学习端-获取用户收货地址"})
+    @ApiOperation(value = "获取用户收货地址列表", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 32)
     public R<List<Recipient>> shopAddress() {
         if (tokenService.getLoginUserStudy() == null) {
             return R.tokenError("登录失效");
@@ -390,7 +409,8 @@
      * 新增收货地址/修改收货地址
      */
     @PostMapping("/addressSaveOrUpdate")
-    @ApiOperation(value = "学习端-新增收货地址/修改收货地址", tags = {"学习端-新增收货地址/修改收货地址"})
+    @ApiOperation(value = "新增收货地址/修改收货地址", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 33)
     public R<String> addressSave(@RequestBody Recipient recipient) {
         recipient.setUserId(tokenService.getLoginUserStudy().getUserid());
         if (recipient.getIsDefault() == 1){
@@ -411,6 +431,7 @@
      */
     @PostMapping("/addressSaveOrUpdateParent")
     @ApiOperation(value = "家长端-新增收货地址/修改收货地址", tags = {"家长端-新增收货地址/修改收货地址"})
+    @ApiOperationSupport(order = 20)
     public R<String> addressSaveOrUpdateParent(@RequestBody Recipient recipient) {
         if (tokenService.getLoginUser1() == null){
             return R.tokenError("登录失效!");
@@ -447,11 +468,12 @@
      * 删除收货地址
      */
     @GetMapping("/addressDelete")
-    @ApiOperation(value = "学习端-删除收货地址", tags = {"学习端-删除收货地址"})
+    @ApiOperation(value = "删除收货地址", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 34)
     @ApiImplicitParams({
-            @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true)
+            @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "Integer", required = true)
     })
-    public R<String> addressDelete(@RequestParam String id) {
+    public R<String> addressDelete(@RequestParam Integer id) {
         return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!");
     }
 
@@ -460,8 +482,9 @@
      */
     @GetMapping("/addressDeleteParent")
     @ApiOperation(value = "家长端-删除收货地址", tags = {"家长端-删除收货地址"})
+    @ApiOperationSupport(order = 21)
     @ApiImplicitParams({
-            @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true)
+            @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "Integer", required = true)
     })
     public R<String> addressDeleteParent(@RequestParam Integer id) {
         return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!");
@@ -470,6 +493,7 @@
 
     @GetMapping("/getOrderAddressParent")
     @ApiOperation(value = "获取修改订单收货地址", tags = {"家长端-获取修改订单收货地址"})
+    @ApiOperationSupport(order = 22)
     public R<List<Recipient>> getOrderAddressParent() {
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
@@ -481,7 +505,8 @@
     }
 
     @GetMapping("/getOrderAddress")
-    @ApiOperation(value = "获取修改订单收货地址", tags = {"学习端-获取修改订单收货地址"})
+    @ApiOperation(value = "获取修改订单收货地址", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 35)
     public R<List<Recipient>> getOrderAddress() {
         if (tokenService.getLoginUserStudy() == null) {
             return R.tokenError("登录失效");
@@ -511,7 +536,8 @@
     }
 
     @GetMapping("/updateOrderAddress")
-    @ApiOperation(value = "修改订单收货地址", tags = {"学习端-修改订单收货地址"})
+    @ApiOperation(value = "修改订单收货地址", tags = {"学习端-收货地址"})
+    @ApiOperationSupport(order = 36)
     public R updateOrderAddress(@RequestParam Integer orderId, @RequestParam Integer recipientId) {
         if (tokenService.getLoginUserStudy() == null) {
             return R.tokenError("登录失效");
@@ -529,7 +555,8 @@
      * 收货地址省市区三级联动
      */
     @GetMapping("/addressTree")
-    @ApiOperation(value = "学习端-收货地址省市区三级联动", tags = {"学习端-收货地址省市区三级联动"})
+    @ApiOperation(value = "收货地址省市区三级联动", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 37)
     public R<List<Region>> addressTree() {
         return R.ok(regionService.addressTree());
     }
@@ -539,7 +566,8 @@
      * 远程调用
      */
     @GetMapping("/goodRecommend")
-    @ApiOperation(value = "学习端-可兑换商品推荐", tags = {"学习端-可兑换商品推荐"})
+    @ApiOperation(value = "可兑换商品推荐", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 38)
     public R<List<TGoodsVO>> goodRecommend() {
         return R.ok(goodsService.goodRecommend(tokenService.getLoginUserStudy().getUserid()));
     }
@@ -548,7 +576,8 @@
      * 获取所有商品分类
      */
     @GetMapping("/goodTypeStudy")
-    @ApiOperation(value = "学习端-商品分类列表", tags = {"学习端-商品分类列表"})
+    @ApiOperation(value = "商品分类列表", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 39)
     public R<List<TGoodsType>> goodTypeStudy() {
         return R.ok(goodsTypeService.lambdaQuery().eq(TGoodsType::getIsDelete, 0).eq(TGoodsType::getIsDelete, 0).list());
     }
@@ -559,7 +588,8 @@
      * @param goodId 商品id
      */
     @GetMapping("/goodDetail")
-    @ApiOperation(value = "学习端-商品详情", tags = {"学习端-商城"})
+    @ApiOperation(value = "商品详情", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 40)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true)
     })
@@ -580,6 +610,7 @@
      */
     @GetMapping("/goodDetailParent")
     @ApiOperation(value = "商品详情", tags = {"家长端-商城"})
+    @ApiOperationSupport(order = 24)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true)
     })
@@ -601,6 +632,7 @@
      */
     @GetMapping("/redeemNow")
     @ApiOperation(value = "商城立即兑换", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 41)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true)
     })
@@ -633,6 +665,7 @@
      */
     @GetMapping("/redeemNowParent")
     @ApiOperation(value = "商城立即兑换", tags = {"家长端-商城"})
+    @ApiOperationSupport(order = 25)
     @ApiImplicitParams({
             @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true)
     })
@@ -683,7 +716,8 @@
     }
 
     @PostMapping("/goodExchangeStudy")
-    @ApiOperation(value = "学习端-商品兑换确认", tags = {"学习端-商品兑换确认"})
+    @ApiOperation(value = "商品兑换确认", tags = {"学习端-商城"})
+    @ApiOperationSupport(order = 42)
     public R goodExchangeStudy(@RequestBody GoodExchangeDTO goodExchange) {
         Recipient recipient = recipientService.getById(goodExchange.getRecipientId());
         return goodsService.goodExchange(goodExchange, recipient);
@@ -695,6 +729,7 @@
 
     @PostMapping("/getOrderInfo/{id}")
     @ApiOperation(value = "查看详情", tags = {"后台-订单管理"})
+    @ApiOperationSupport(order = 11)
     public R<TOrderVO> getOrderInfo(@PathVariable("id") Integer id) {
         TOrder byId = orderService.getById(id);
         TGoods byId2 = goodsService.getById(byId.getGoodsId());
@@ -709,6 +744,7 @@
 
     @PostMapping("/confirm1")
     @ApiOperation(value = "确认发货", tags = {"后台-订单管理"})
+    @ApiOperationSupport(order = 12)
     public R getGoodsInfo1(@RequestBody OrderDTO dto) {
         TOrder byId = orderService.getById(dto.getId());
         byId.setState(2);
@@ -721,6 +757,7 @@
 
     @PostMapping("/listAll1")
     @ApiOperation(value = "列表查询", tags = {"后台-订单管理"})
+    @ApiOperationSupport(order = 13)
     public R<PageInfo<TOrderVO>> listAll1(@RequestBody OrderQuery query) throws ParseException {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 

--
Gitblit v1.7.1