From f8cc44e926fd22f9d1d864dc684c827f6960270b Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期五, 26 七月 2024 11:51:30 +0800
Subject: [PATCH] feat: 最新代码及配置

---
 ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java
index 0204b90..cf5a89f 100644
--- a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java
+++ b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java
@@ -10,9 +10,12 @@
 import com.ruoyi.user.entity.RecoveryClassify;
 import com.ruoyi.user.entity.RecoveryServe;
 import com.ruoyi.user.entity.UserCollect;
+import com.ruoyi.user.entity.UserRecipient;
 import com.ruoyi.user.service.RecoveryClassifyService;
 import com.ruoyi.user.service.RecoveryServeService;
 import com.ruoyi.user.service.UserCollectService;
+import com.ruoyi.user.service.UserRecipientService;
+import com.ruoyi.user.vo.ServeDetailVO;
 import com.ruoyi.user.vo.ServeListVO;
 import com.ruoyi.user.vo.UserServeTypeVO;
 import io.swagger.annotations.Api;
@@ -49,6 +52,8 @@
     private UserCollectService collectService;
     @Resource
     private TokenService tokenService;
+    @Resource
+    private UserRecipientService userRecipientService;
 
     /**
      * 获取服务列表
@@ -68,7 +73,7 @@
         List<RecoveryClassify> serveList = recoveryClassifyService.lambdaQuery()
                 .eq(RecoveryClassify::getIsDelete, 0)
                 .eq(RecoveryClassify::getSupClassify, serveType)
-                .orderByAsc(RecoveryClassify::getSort)
+                .orderByDesc(RecoveryClassify::getSort)
                 .orderByDesc(RecoveryClassify::getCreateTime).list();
         List<UserServeTypeVO> list = new ArrayList<>();
         for (RecoveryClassify classify : serveList) {
@@ -89,7 +94,7 @@
         Page<RecoveryServe> page = recoveryServeService.lambdaQuery()
                 .eq(RecoveryServe::getClassifyId, id)
                 .eq(RecoveryServe::getIsDelete, 0)
-                .orderByAsc(RecoveryServe::getSort)
+                .orderByDesc(RecoveryServe::getSort)
                 .orderByDesc(RecoveryServe::getCreateTime).page(Page.of(pageNum, pageSize));
         return R.ok(page);
     }
@@ -111,12 +116,17 @@
     @ApiImplicitParams({
             @ApiImplicitParam(value = "服务id", name = "serveId", dataType = "String", required = true)
     })
-    public R<RecoveryServe> serveDetail(@RequestParam String serveId) {
+    public R<ServeDetailVO> serveDetail(@RequestParam String serveId) {
+        LoginUserInfo loginUser = tokenService.getLoginUserByUser();
+        if (null == loginUser) {
+            return R.loginExpire("登录失效!");
+        }
         RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId)
-                .eq(RecoveryServe::getIsDelete, 0).orderByAsc(RecoveryServe::getSort).one();
+                .eq(RecoveryServe::getIsDelete, 0).one();
         // 用户是否收藏
         UserCollect one = collectService.lambdaQuery()
                 .eq(UserCollect::getServeId, serveId)
+                .eq(UserCollect::getUserId, loginUser.getUserid())
                 .eq(UserCollect::getIsDelete, 0).one();
         if (null != one) {
             recoveryServe.setIsCollect(Boolean.TRUE);
@@ -126,14 +136,18 @@
         // 获取服务分类
         Integer classifyId = recoveryServe.getClassifyId();
         RecoveryClassify classify = recoveryClassifyService.lambdaQuery()
-                .eq(RecoveryClassify::getId, classifyId)
-                .eq(RecoveryClassify::getIsDelete, 0).one();
+                .eq(RecoveryClassify::getId, classifyId).one();
         if (classify.getSupClassify().equals(Constants.TRADE_IN)) {
             recoveryServe.setType(Constants.ZERO);
         } else {
             recoveryServe.setType(Constants.ONE);
         }
-        return R.ok(recoveryServe);
+        // 获取用户默认收货地址
+        UserRecipient userRecipient = userRecipientService.lambdaQuery()
+                .eq(UserRecipient::getIsDefault, Constants.ONE)
+                .eq(UserRecipient::getUserId, loginUser.getUserid())
+                .eq(UserRecipient::getIsDelete, Constants.ZERO).one();
+        return R.ok(new ServeDetailVO(recoveryServe, userRecipient));
     }
 
     /**

--
Gitblit v1.7.1