ソースを参照

商家列表增加是否收藏状态

wwl 4 年 前
コミット
e426823227

+ 8 - 2
zzjs-admin/src/main/java/com/miaxis/app/controller/customer/AppletCustomerInfoController.java

@@ -3,7 +3,9 @@ package com.miaxis.app.controller.customer;
 import com.miaxis.collection.service.ICollectionInfoService;
 import com.miaxis.common.constant.Constants;
 import com.miaxis.common.core.controller.BaseController;
+import com.miaxis.common.core.domain.entity.UserInfo;
 import com.miaxis.common.core.page.ResponsePageInfo;
+import com.miaxis.common.utils.SecurityUtils;
 import com.miaxis.customer.domain.CustomerInfo;
 import com.miaxis.customer.service.ICustomerInfoService;
 import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
@@ -58,7 +60,9 @@ public class AppletCustomerInfoController extends BaseController {
             @PathVariable("id") Long id
     ) {
         startPage();
-        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByProductId(id);
+        //获取当前用户
+        UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
+        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByProductId(id,userInfo.getId());
         return toResponsePageInfo(list);
     }
 
@@ -73,7 +77,9 @@ public class AppletCustomerInfoController extends BaseController {
     })
     public ResponsePageInfo<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount() {
         startPage();
-        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByCollectionCount();
+        //获取当前用户
+        UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
+        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByCollectionCount(userInfo.getId());
         return toResponsePageInfo(list);
     }
 

+ 4 - 2
zzjs-service/src/main/java/com/miaxis/customer/mapper/CustomerInfoMapper.java

@@ -35,15 +35,17 @@ public interface CustomerInfoMapper extends BaseMapper<CustomerInfo> {
     /**
      * 查询所属品类商家
      * @param productId
+     * @param userId
      * @return
      */
-    List<ExhibitionCustomerInfoVo> getCustomerListByProductId(@Param("productId") Long productId);
+    List<ExhibitionCustomerInfoVo> getCustomerListByProductId(@Param("productId") Long productId,@Param("userId")Long userId);
 
     /**
      * 查询精选商家列表 根据收藏数排行
+     * @param userId
      * @return
      */
-    List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount();
+    List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount(Long userId);
 
     /**
      * 查询用户收藏列表

+ 4 - 2
zzjs-service/src/main/java/com/miaxis/customer/service/ICustomerInfoService.java

@@ -50,15 +50,17 @@ public interface ICustomerInfoService extends IService<CustomerInfo>{
      * applet
      * 查询所属品类商家
      * @param productId
+     * @param userId
      * @return
      */
-    List<ExhibitionCustomerInfoVo> getCustomerListByProductId(Long productId);
+    List<ExhibitionCustomerInfoVo> getCustomerListByProductId(Long productId,Long userId);
 
 
     /**
      * 查询精选商家列表 根据收藏数排行
+     * @param userId
      * @return
      */
-    List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount();
+    List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount(Long userId);
 
 }

+ 6 - 4
zzjs-service/src/main/java/com/miaxis/customer/service/impl/CustomerInfoServiceImpl.java

@@ -85,11 +85,12 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
      * applet
      * 查询所属品类商家
      * @param productId
+     * @param userId
      * @return
      */
     @Override
-    public List<ExhibitionCustomerInfoVo> getCustomerListByProductId(Long productId) {
-        return customerInfoMapper.getCustomerListByProductId(productId);
+    public List<ExhibitionCustomerInfoVo> getCustomerListByProductId(Long productId,Long userId) {
+        return customerInfoMapper.getCustomerListByProductId(productId,userId);
     }
 
 
@@ -97,11 +98,12 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     /**
      * applet
      * 查询精选商家列表 根据收藏数排行
+     * @param userId
      * @return
      */
     @Override
-    public List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount() {
-        return customerInfoMapper.getCustomerListByCollectionCount();
+    public List<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount(Long userId) {
+        return customerInfoMapper.getCustomerListByCollectionCount(userId);
     }
 
 

+ 3 - 0
zzjs-service/src/main/java/com/miaxis/customer/vo/ExhibitionCustomerInfoVo.java

@@ -49,5 +49,8 @@ public class ExhibitionCustomerInfoVo extends BaseBusinessEntity{
     @ApiModelProperty(value = "收藏数量")
     private Integer collectionCount;
 
+    @ApiModelProperty(value = "是否收藏 0:未收藏 1:已收藏")
+    private String collectionStatus;
+
 
 }

+ 3 - 0
zzjs-service/src/main/resources/mapper/customer/CustomerInfoMapper.xml

@@ -115,6 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ci.applet_introduce,
         ci.create_time,
         ci.update_time,
+        (select COUNT(1) from collection_info coi where coi.customer_id = ci.id) as collectionCount,
+        (SELECT COUNT(1) from collection_info coi where coi.user_id = #{userId} and customer_id = ci.id) as collectionStatus,
         ci.status
         from customer_info ci
         LEFT JOIN file_info f1 on f1.file_id = ci.corporate_logo
@@ -137,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ci.applet_introduce,
         ci.create_time,
         ci.update_time,
+        (SELECT COUNT(1) from collection_info coi where coi.user_id = #{userId} and customer_id = ci.id) as collectionStatus,
         ci.status
         FROM `customer_info` ci
         LEFT JOIN file_info f1 on f1.file_id = ci.corporate_logo