From 1a912819dfedad2ca9f2f31522db9b3f58a30716 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期四, 02 九月 2021 10:18:54 +0800
Subject: [PATCH] 邻里圈改版接口

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java |   82 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
index c055873..28dd6aa 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
@@ -8,6 +8,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.constants.NeighborCircleConstants;
 import com.panzhihua.common.model.dtos.neighbor.*;
 import com.panzhihua.common.model.vos.R;
 import com.panzhihua.common.model.vos.neighbor.*;
@@ -130,6 +131,22 @@
         if(StringUtils.isNotEmpty(addNeighborCircleAppDTO.getPhone())){
             neighborCircleDO.setReleasePhone(addNeighborCircleAppDTO.getPhone());
         }
+        //判断当前邻里圈是否需要审核
+        if(addNeighborCircleAppDTO.getIsExamine().equals(AddComActNeighborCircleAppDTO.isExamine.no)){
+            //当邻里圈不需要审核才进入自动审核
+            //判断邻里圈自动审核结果
+            if(addNeighborCircleAppDTO.getWxExamineResult().equals(AddComActNeighborCircleAppDTO.isExamine.yes)){
+                neighborCircleDO.setStatus(ComActNeighborCircleDO.status.xs);
+                if(neighborCircleDO.getTopicId() != null){
+                    //给邻里圈话题添加邻里圈数量
+                    comActNeighborCircleTopicMapper.addCount(neighborCircleDO.getTopicId());
+                }
+            }else{
+                neighborCircleDO.setStatus(ComActNeighborCircleDO.status.bh);
+                neighborCircleDO.setRefuseReason("内容违规");
+            }
+        }
+
         if(this.baseMapper.insert(neighborCircleDO) > 0){
             return R.ok();
         }else{
@@ -277,6 +294,11 @@
             neighborCircleDO.setRefuseReason(editVO.getRefuseReason());
         }
         this.baseMapper.updateById(neighborCircleDO);
+
+        if(editVO.getStatus().equals(EditNeighborCircleAdminVO.status.xs) && neighborCircleDO.getTopicId() != null){
+            //给邻里圈话题添加邻里圈数量
+            comActNeighborCircleTopicMapper.addCount(neighborCircleDO.getTopicId());
+        }
         return R.ok(neighborCircleDO.getReleaseId());
     }
 
@@ -337,7 +359,11 @@
             if(neighborCircleDO != null){
                 neighborCircleDO.setFabulousNum(neighborCircleDO.getFabulousNum() + 1);
                 neighborCircleDO.setViewsNum(neighborCircleDO.getViewsNum() + 1);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM + NeighborCircleConstants.VIEW_HOT_NUM;
+                neighborCircleDO.setHotNum(neighborCircleDO.getHotNum() + hotNum);
                 this.baseMapper.updateById(neighborCircleDO);
+                comActNeighborCircleTopicMapper.addHotNum(neighborCircleDO.getTopicId(),hotNum);
                 circleFabulousDO.setCircleId(neighborCircleDO.getId());
             }
             //添加邻里圈浏览记录
@@ -355,6 +381,10 @@
             if(circleCommentDO != null){
                 circleCommentDO.setFabulousNum(circleCommentDO.getFabulousNum() + 1);
                 comActNeighborCircleCommentDAO.updateById(circleCommentDO);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM + NeighborCircleConstants.VIEW_HOT_NUM;
+                this.baseMapper.addTopicHotNum(circleCommentDO.getCircleId(),hotNum);
+                this.baseMapper.addHotNum(circleCommentDO.getCircleId(),hotNum);
                 circleFabulousDO.setCircleId(circleCommentDO.getCircleId());
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.hf)){
@@ -370,6 +400,10 @@
             if(circleCommentReplyDO != null){
                 circleCommentReplyDO.setFabulousNum(circleCommentReplyDO.getFabulousNum() + 1);
                 comActNeighborCircleCommentReplyDAO.updateById(circleCommentReplyDO);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM + NeighborCircleConstants.VIEW_HOT_NUM;
+                this.baseMapper.addTopicHotNum(circleCommentReplyDO.getCircleId(),hotNum);
+                this.baseMapper.addHotNum(circleCommentReplyDO.getCircleId(),hotNum);
                 circleFabulousDO.setCircleId(circleCommentReplyDO.getCircleId());
             }
         }
@@ -399,6 +433,10 @@
         }
         circleDO.setForwardNum(circleDO.getForwardNum() + 1);
         if(this.baseMapper.updateById(circleDO) > 0){
+            //计算需要增加的热度值
+            Long hotNum = NeighborCircleConstants.VIEW_HOT_NUM;
+            this.baseMapper.addHotNum(forwardAppDTO.getCircleId(),hotNum);
+            this.baseMapper.addTopicHotNum(forwardAppDTO.getCircleId(),hotNum);
             return R.ok();
         }else{
             return R.fail("转发失败");
@@ -423,6 +461,11 @@
         neighborCircleDO.setCommentNum(neighborCircleDO.getCommentNum() + 1);
         neighborCircleDO.setReplyAt(new Date());
         this.baseMapper.updateById(neighborCircleDO);
+
+        //计算需要增加的热度值
+        Long hotNum = NeighborCircleConstants.COMMENT_HOT_NUM;
+        this.baseMapper.addHotNum(commentAppDTO.getCircleId(),hotNum);
+        this.baseMapper.addTopicHotNum(commentAppDTO.getCircleId(),hotNum);
 
         circleCommentDO.setCircleId(commentAppDTO.getCircleId());
         circleCommentDO.setUserId(commentAppDTO.getUserId());
@@ -456,6 +499,11 @@
         neighborCircleDO.setCommentNum(neighborCircleDO.getCommentNum() + 1);
         neighborCircleDO.setReplyAt(new Date());
         this.baseMapper.updateById(neighborCircleDO);
+
+        //计算需要增加的热度值
+        Long hotNum = NeighborCircleConstants.COMMENT_HOT_NUM;
+        this.baseMapper.addHotNum(replyAppDTO.getCircleId(),hotNum);
+        this.baseMapper.addTopicHotNum(replyAppDTO.getCircleId(),hotNum);
 
         circleCommentReplyDO.setCircleId(replyAppDTO.getCircleId());
         circleCommentReplyDO.setUserId(replyAppDTO.getUserId());
@@ -659,6 +707,7 @@
      * @return  取消点赞结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public R neighborFabulousCancelByApp(ComActNeighborFabulousAppDTO fabulousAppDTO){
         ComActNeighborCircleFabulousDO circleFabulousDO = null;
         //查询邻里圈点赞信息
@@ -678,6 +727,10 @@
             if(neighborCircleDO != null){
                 neighborCircleDO.setFabulousNum(neighborCircleDO.getFabulousNum() - 1);
                 this.baseMapper.updateById(neighborCircleDO);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM;
+                this.baseMapper.addHotNum(neighborCircleDO.getId(),-hotNum);
+                this.baseMapper.addTopicHotNum(neighborCircleDO.getId(),-hotNum);
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.pl)){
             circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
@@ -694,6 +747,10 @@
             if(circleCommentDO != null){
                 circleCommentDO.setFabulousNum(circleCommentDO.getFabulousNum() - 1);
                 comActNeighborCircleCommentDAO.updateById(circleCommentDO);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM;
+                this.baseMapper.addHotNum(circleCommentDO.getCircleId(),-hotNum);
+                this.baseMapper.addTopicHotNum(circleCommentDO.getCircleId(),-hotNum);
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.hf)){
             circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
@@ -709,6 +766,10 @@
             if(circleCommentReplyDO != null){
                 circleCommentReplyDO.setFabulousNum(circleCommentReplyDO.getFabulousNum() - 1);
                 comActNeighborCircleCommentReplyDAO.updateById(circleCommentReplyDO);
+                //计算需要增加的热度值
+                Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM;
+                this.baseMapper.addHotNum(circleCommentReplyDO.getCircleId(),-hotNum);
+                this.baseMapper.addTopicHotNum(circleCommentReplyDO.getCircleId(),-hotNum);
             }
         }
         if(circleFabulousDO != null){
@@ -733,6 +794,11 @@
         if(neighborCircleDO != null){
             neighborCircleDO.setViewsNum(neighborCircleDO.getViewsNum() + 1);
             this.baseMapper.updateById(neighborCircleDO);
+
+            //计算需要增加的热度值
+            Long hotNum = NeighborCircleConstants.FABULOUS_HOT_NUM;
+            this.baseMapper.addHotNum(neighborCircleDO.getId(),hotNum);
+            this.baseMapper.addTopicHotNum(neighborCircleDO.getId(),hotNum);
         }
         return R.ok();
     }
@@ -765,4 +831,20 @@
         }
         return R.ok(neighborCircleIPage);
     }
+
+    /**
+     * 小程序-删除邻里圈
+     * @param circleTopicAppDTO 请求参数
+     * @return  删除结果
+     */
+    @Override
+    public R deleteNeighborByApp(DeleteNeighborCircleAppDTO circleTopicAppDTO){
+        ComActNeighborCircleDO neighborCircleDO = new ComActNeighborCircleDO();
+        neighborCircleDO.setId(circleTopicAppDTO.getId());
+        neighborCircleDO.setIsDel(ComActNeighborCircleDO.isDel.yes);
+        if(this.baseMapper.updateById(neighborCircleDO) > 0){
+            return R.ok();
+        }
+        return R.fail();
+    }
 }

--
Gitblit v1.7.1