Browse Source

修改分页查询品牌,添加是否关注字段
品牌关注
品牌取消关注
网点关注
网点取消关注

云殇忆 1 year ago
parent
commit
ede70fcaac

+ 3 - 4
benyun-core/src/main/java/com/benyun/core/controller/BrandController.java

@@ -8,9 +8,7 @@ import com.ruoyi.common.core.domain.R;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -32,7 +30,8 @@ public class BrandController extends BaseController {
 //    获取品牌信息列表
     @GetMapping("/list")
     public R list(BrandListQueryBody body){
-        return R.ok(brandService.searchListByMulti(body));
+        String userId = "1";
+        return R.ok(brandService.searchListByMulti(body,userId));
     }
 
 //    获取品牌详细信息

+ 84 - 25
benyun-core/src/main/java/com/benyun/core/controller/WorkTableController.java

@@ -2,7 +2,6 @@ package com.benyun.core.controller;
 
 import com.benyun.core.entity.bo.AttentionPoolBo;
 import com.benyun.core.entity.bo.AttentionPoolStatisticsBo;
-import com.benyun.core.entity.bo.FollowUpRecordBo;
 import com.benyun.core.entity.vo.AddFollowRecordVo;
 import com.benyun.core.entity.vo.TurnBusinessOpportunitiesVo;
 import com.benyun.core.entity.vo.WorkTableSearchVo;
@@ -34,9 +33,9 @@ public class WorkTableController {
     @GetMapping("/databack/about")
     public R about(){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         AttentionPoolStatisticsBo bo = databackService.searchAbout(userId);
         return R.ok(bo);
     }
@@ -45,9 +44,9 @@ public class WorkTableController {
     @GetMapping("/databack/trend")
     public R trend(){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         List<AttentionPoolStatisticsBo> bos = databackService.searchTrand(userId);
         return R.ok(bos);
     }
@@ -56,9 +55,9 @@ public class WorkTableController {
     @GetMapping("/pool/list")
     public R poolList(WorkTableSearchVo workTableSearchVo){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         PageInfo<List<AttentionPoolBo>> listPageInfo = attentionPoolService.searchList(workTableSearchVo, userId);
         return R.ok(listPageInfo);
     }
@@ -67,9 +66,9 @@ public class WorkTableController {
     @DeleteMapping("/pool")
     public R cancel(String attentionId){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         if (attentionId == null || attentionId.equals(""))
             return R.fail("attentionId不能为空");
         int flag = attentionPoolService.cancelAttention(attentionId, userId);
@@ -82,9 +81,9 @@ public class WorkTableController {
     @PostMapping("/pool")
     public R turn(TurnBusinessOpportunitiesVo turnVo){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         int flag = attentionPoolService.turnBusinessOpportunities(turnVo, userId);
         if (flag == 1)
             return R.ok("转化成功!");
@@ -95,9 +94,9 @@ public class WorkTableController {
     @GetMapping("/clue/list")
     public R clueList(WorkTableSearchVo vo){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         return R.ok(businessOpportunitiesService.searchList(vo,userId));
     }
 
@@ -105,9 +104,9 @@ public class WorkTableController {
     @GetMapping("/follow/list")
     public R followList(WorkTableSearchVo vo){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         return R.ok(businessOpportunitiesService.searchFollowList(vo,userId));
     }
 
@@ -115,12 +114,72 @@ public class WorkTableController {
     @PostMapping("/follow")
     public R followAdd(AddFollowRecordVo addVo){
         // 获取用户id
-        String userId = null;
-//        if (userId == null || userId.equals(""))
-//            return R.fail("请登录");
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
         int flag = businessOpportunitiesService.addFollow(addVo, userId);
         if (flag == 1)
             return R.ok("添加成功!");
         return R.fail("添加失败");
     }
+
+    //    品牌关注
+    @PostMapping("/brand")
+    public R brandAttention(String brandId){
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
+        int flag = attentionPoolService.attentionBrand(brandId, userId);
+        if (flag == 1){
+            return R.ok("关注成功!");
+        }else if (flag == 2){
+            return R.fail("重复关注。");
+        }else if (flag == 3){
+            return R.fail("未知品牌");
+        }
+        return R.fail("关注失败。");
+    }
+
+    //    品牌取消关注
+    @DeleteMapping("/brand")
+    public R brandCancel(String brandId){
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
+        int flag = attentionPoolService.cancelBrand(brandId, userId);
+        if (flag == 1){
+            return R.ok("取消关注成功!");
+        }
+        return R.fail("取消关注失败。");
+    }
+
+//    网点关注
+    @PostMapping("/wdInfo")
+    public R wdInfoAttention(String wdId){
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
+        int flag = attentionPoolService.attentionWdInfo(wdId,userId);
+        if (flag == 1){
+            return R.ok("关注成功!");
+        }else if (flag == 2){
+            return R.fail("重复关注。");
+        }else if (flag == 3){
+            return R.fail("未知网点");
+        }
+        return R.fail("关注失败。");
+    }
+
+//    网点取消关注
+    @DeleteMapping("/wdInfo")
+    public R wdInfoCancel(String wdId){
+        String userId = "1";
+        if (userId == null || userId.equals(""))
+            return R.fail("请登录");
+        int flag = attentionPoolService.cancelWdInfo(wdId, userId);
+        if (flag == 1){
+            return R.ok("取消关注成功!");
+        }
+        return R.fail("取消关注失败。");
+    }
 }

+ 2 - 0
benyun-core/src/main/java/com/benyun/core/dao/AttentionPoolDao.java

@@ -12,4 +12,6 @@ public interface AttentionPoolDao extends BaseMapper<AttentionPool> {
     int searchCountByUserId(String userId);
     List<AttentionPool> searchByMulti(@Param("text") String text, @Param("userId") String userId);
     int deleteByAttentionIdAndUserId(@Param("attentionId") String attentionId, @Param("userId") String userId);
+    AttentionPool searchByBrandIdOrWdIdAndUserId(@Param("brandId") String brandId, @Param("wdId") String wdId, @Param("userId") String userId);
+    int deleteByBrandIdOrWdIdAndUserId(@Param("brandId") String brandId, @Param("wdId") String wdId, @Param("userId") String userId);
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/entity/AttentionPool.java

@@ -7,7 +7,7 @@ import lombok.Data;
 import java.util.Date;
 
 @Data
-@TableName("bl_attention_poll")
+@TableName("bl_attention_pool")
 public class AttentionPool {
     @TableField("attention_id")
     private String attentionId;

+ 4 - 1
benyun-core/src/main/java/com/benyun/core/entity/StoreWd.java

@@ -1,13 +1,14 @@
 package com.benyun.core.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 @Data
 @TableName("ddt_store_wd")
 public class StoreWd {
-    @TableField("wd_id")
+    @TableId("wd_id")
     private String wdId;
     @TableField("brand_id")
     private String brandId;
@@ -33,4 +34,6 @@ public class StoreWd {
     private String businessTime;
     @TableField("telephone")
     private String telephone;
+    @TableField("contact")
+    private String contact;
 }

+ 2 - 1
benyun-core/src/main/java/com/benyun/core/entity/WdInfo.java

@@ -1,6 +1,7 @@
 package com.benyun.core.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@@ -18,7 +19,7 @@ import java.time.LocalDateTime;
 @Data
 @TableName("ddt_wd_info")
 public class WdInfo {
-    @TableField("wd_id")
+    @TableId("wd_id")
     private String wdId;
     @TableField("wd_img")
     private String wdImg;

+ 1 - 0
benyun-core/src/main/java/com/benyun/core/entity/bo/BrandSearch.java

@@ -13,5 +13,6 @@ public class BrandSearch {
     private String enterpriseName;
     private Integer coverCityCount;
     private Integer total;
+    private String attention;
     private Date updateTime;
 }

+ 4 - 0
benyun-core/src/main/java/com/benyun/core/service/AttentionPoolService.java

@@ -11,4 +11,8 @@ public interface AttentionPoolService {
     PageInfo<List<AttentionPoolBo>> searchList(WorkTableSearchVo workVo, String userId);
     int cancelAttention(String attentionId, String userId);
     int turnBusinessOpportunities(TurnBusinessOpportunitiesVo turnVo, String userId);
+    int attentionBrand(String brandId, String userId);
+    int cancelBrand(String brnadId, String userId);
+    int attentionWdInfo(String wdId, String userId);
+    int cancelWdInfo(String wdId, String userId);
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/service/BrandService.java

@@ -15,7 +15,7 @@ public interface BrandService {
     BrandDistribution searchDistributionByBrandId(String brandId);
     List<BrandProvinceBo> searchProvinceByBrandId(String brandId);
     BrandDisCloud searchDisCloudByBrandId(String brandId);
-    PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body);
+    PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body,String userId);
     List<BrandTotal> searchTotal();
     BStoreData searchAvgScoreByBrandId(String brandId);
     List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes);

+ 86 - 6
benyun-core/src/main/java/com/benyun/core/service/impl/AttentionPoolServiceImpl.java

@@ -1,11 +1,7 @@
 package com.benyun.core.service.impl;
 
-import com.benyun.core.dao.AttentionPoolDao;
-import com.benyun.core.dao.BusinessOpportunitiesDao;
-import com.benyun.core.dao.FollowUpDao;
-import com.benyun.core.entity.AttentionPool;
-import com.benyun.core.entity.BusinessOpportunitiesClue;
-import com.benyun.core.entity.FollowUpRecord;
+import com.benyun.core.dao.*;
+import com.benyun.core.entity.*;
 import com.benyun.core.entity.bo.AttentionPoolBo;
 import com.benyun.core.entity.vo.TurnBusinessOpportunitiesVo;
 import com.benyun.core.entity.vo.WorkTableSearchVo;
@@ -28,6 +24,12 @@ public class AttentionPoolServiceImpl implements AttentionPoolService {
     BusinessOpportunitiesDao businessOpportunitiesDao;
     @Autowired
     FollowUpDao followUpDao;
+    @Autowired
+    BrandMapper brandMapper;
+    @Autowired
+    WdInfoDao wdInfoDao;
+    @Autowired
+    StoreWdDao storeWdDao;
 
     @Override
     public PageInfo<List<AttentionPoolBo>> searchList(WorkTableSearchVo workVo, String userId) {
@@ -76,4 +78,82 @@ public class AttentionPoolServiceImpl implements AttentionPoolService {
         clue.setCreateTime(new Date());
         return businessOpportunitiesDao.insert(clue);
     }
+
+    @Override
+    public int attentionBrand(String brandId, String userId) {
+        AttentionPool attentionPool = attentionPoolDao.searchByBrandIdOrWdIdAndUserId(brandId,null, userId);
+        if (attentionPool != null) // 判断是否已经关注
+            return 2;
+        Brand brand = brandMapper.searchById(brandId);
+        if (brand == null) // 判断是否有该品牌
+            return 3;
+        AttentionPool pool = new AttentionPool();
+        pool.setAttentionId(UUID.randomUUID().toString().replace("-",""));
+        pool.setContact(brand.getContact());
+        if (brand.getContact() == null)
+            pool.setContact("");
+        pool.setTelephone(brand.getTelephone());
+        if (brand.getTelephone() == null)
+            pool.setTelephone("");
+        pool.setBrandId(brand.getBrandId());
+        pool.setBrandName(brand.getBrandName());
+        pool.setWdId("");
+        pool.setWdName("");
+        pool.setWdAddrInfo("");
+        pool.setUserId(userId);
+        pool.setAttentionTime(new Date());
+        return attentionPoolDao.insert(pool);
+    }
+
+    @Override
+    public int cancelBrand(String brnadId, String userId) {
+        return attentionPoolDao.deleteByBrandIdOrWdIdAndUserId(brnadId,null,userId);
+    }
+
+    @Override
+    public int attentionWdInfo(String wdId, String userId) {
+        AttentionPool attentionPool = attentionPoolDao.searchByBrandIdOrWdIdAndUserId(null, wdId, userId);
+        if (attentionPool != null) // 判断是否已经关注
+            return 2;
+        WdInfo wdInfo = wdInfoDao.selectById(wdId);
+        if (wdInfo == null) // 判断是否有该网点
+            return 3;
+        AttentionPool pool = new AttentionPool();
+        pool.setAttentionId(UUID.randomUUID().toString().replace("-",""));
+        pool.setWdId(wdInfo.getWdId());
+        pool.setWdName(wdInfo.getWdName());
+        pool.setWdAddrInfo(wdInfo.getAddrInfo());
+        StoreWd storeWd = storeWdDao.selectById(wdId);
+        if (storeWd != null){
+            pool.setContact(storeWd.getContact());
+            if (storeWd.getContact() == null)
+                pool.setContact("");
+            pool.setTelephone(storeWd.getTelephone());
+            if (storeWd.getTelephone() == null)
+                pool.setTelephone("");
+            if (storeWd.getBrandId() != null || !storeWd.getBrandId().equals("")){
+                Brand brand = brandMapper.searchById(storeWd.getBrandId());
+                if (brand != null){
+                    pool.setBrandId(brand.getBrandId());
+                    pool.setBrandName(brand.getBrandName());
+                }else {
+                    pool.setBrandId("");
+                    pool.setBrandName("");
+                }
+            }
+        }else {
+            pool.setContact("");
+            pool.setTelephone("");
+            pool.setBrandId("");
+            pool.setBrandName("");
+        }
+        pool.setUserId(userId);
+        pool.setAttentionTime(new Date());
+        return attentionPoolDao.insert(pool);
+    }
+
+    @Override
+    public int cancelWdInfo(String wdId, String userId) {
+        return attentionPoolDao.deleteByBrandIdOrWdIdAndUserId(null,wdId,userId);
+    }
 }

+ 24 - 3
benyun-core/src/main/java/com/benyun/core/service/impl/BrandServiceImpl.java

@@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class BrandServiceImpl implements BrandService {
@@ -27,6 +29,8 @@ public class BrandServiceImpl implements BrandService {
     BrandZoneMapper brandZoneMapper;
     @Autowired
     EnterpriseMapper enterpriseMapper;
+    @Autowired
+    AttentionPoolDao attentionPoolDao;
 
     @Override
     public List<BrandSearch> searchByLikeName(String text) {
@@ -227,7 +231,7 @@ public class BrandServiceImpl implements BrandService {
     }
 
     @Override
-    public PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body) {
+    public PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body,String userId) {
         PageHelper.startPage(body.getPageNum(),body.getPageSize(),true);
         String text = body.getText();
         List<String> industryCode = body.getIndustryCode();
@@ -242,8 +246,25 @@ public class BrandServiceImpl implements BrandService {
             coverUp = Integer.parseInt(body.getCoverCityCount().get(1));
         }catch (Exception e){}
         List<BrandSearch> brandSearches = brandMapper.searchSearchByMulti(text, industryCode, countUp, countDown, coverUp, coverDown);
-        PageInfo info = new PageInfo(brandSearches);
-        return info;
+        if (userId == null || userId.equals("")){
+            for (BrandSearch search : brandSearches){
+                search.setAttention("0");
+            }
+        }else {
+            List<AttentionPool> pools = attentionPoolDao.searchByMulti(null, userId);
+            Map<String ,String> map = new HashMap<>();
+            for (AttentionPool pool : pools){
+                map.put(pool.getBrandId(),"1");
+            }
+            for (BrandSearch search : brandSearches){
+                if (map.get(search.getBrandId()) == null){
+                    search.setAttention("0");
+                }else {
+                    search.setAttention("1");
+                }
+            }
+        }
+        return new PageInfo(brandSearches);
     }
 
     @Override

+ 18 - 0
benyun-core/src/main/resources/mapper/AttentionPoolMapper.xml

@@ -24,6 +24,15 @@
             and attention_id = #{attentionId}
         </trim>
     </delete>
+    <delete id="deleteByBrandIdOrWdIdAndUserId">
+        delete from `bl_attention_pool` where user_id = #{userId}
+        <if test="brandId != null">
+            and brand_id = #{brandId} and wd_id = ''
+        </if>
+        <if test="wdId != null">
+            and wd_id = #{wdId}
+        </if>
+    </delete>
     <select id="searchByMulti" resultMap="AttentionPoolResult">
         select * from `bl_attention_pool`
         <trim prefix="where" prefixOverrides="and">
@@ -49,4 +58,13 @@
             </if>
         </where>
     </select>
+    <select id="searchByBrandIdOrWdIdAndUserId" resultMap="AttentionPoolResult">
+        select * from `bl_attention_pool` where user_id = #{userId}
+        <if test="brandId != null">
+            and brand_id = #{brandId} and wd_id = ''
+        </if>
+        <if test="wdId != null">
+            and wd_id = #{wdId}
+        </if>
+    </select>
 </mapper>

+ 30 - 0
benyun-core/src/test/java/com/benyun/core/service/AttentionPoolServiceImplTest.java

@@ -36,4 +36,34 @@ public class AttentionPoolServiceImplTest {
     public void cancelAttentionTest(){
         System.out.println(attentionPoolService.cancelAttention("3000","2"));
     }
+
+    @Test
+    public void attentionBrandTest(){
+        String userId = "1";
+//        String brandId = "5eb6d4ccee1d498997c26a140a4bef08";
+        String brandId = "fhlksjdflkjsldkjf";
+        System.out.println(attentionPoolService.attentionBrand(brandId, userId));
+    }
+
+    @Test
+    public void cancelBrandTest(){
+        String userId = "1";
+        String brandId = "5eb6d4ccee1d498997c26a140a4bef08";
+        System.out.println(attentionPoolService.cancelBrand(brandId,userId));
+    }
+
+    @Test
+    public void attentionWdInfoTest(){
+        String userId = "1";
+//        String wdId = "0001ec104d7049eab1f992732e089518";
+        String wdId = "fjklsdjflksjdfkljsdf";
+        System.out.println(attentionPoolService.attentionWdInfo(wdId,userId));
+    }
+
+    @Test
+    public void cancelWdInfo(){
+        String userId = "1";
+        String wdId = "0001ec104d7049eab1f992732e089518";
+        System.out.println(attentionPoolService.cancelWdInfo(wdId,userId));
+    }
 }

+ 2 - 1
benyun-core/src/test/java/com/benyun/core/service/BrandServiceImplTest.java

@@ -70,6 +70,7 @@ public class BrandServiceImplTest {
 
     @Test
     public void searchListByMultiTest(){
+        String userId = "1";
         BrandListQueryBody body = new BrandListQueryBody();
         body.setText("益禾堂");
         List<String> industryCode = new ArrayList<>();
@@ -90,7 +91,7 @@ public class BrandServiceImplTest {
         body.setOrderBy("check_first_time");
         body.setPageNum(1);
         body.setPageSize(10);
-        PageInfo<List<BrandSearch>> list = brandService.searchListByMulti(body);
+        PageInfo<List<BrandSearch>> list = brandService.searchListByMulti(body,userId);
         System.out.println(list);
     }