魏熙美 před 5 roky
rodič
revize
ee0704cd0d

+ 12
- 4
src/main/java/com/huiju/estateagents/common/CommConstant.java Zobrazit soubor

@@ -43,11 +43,21 @@ public class CommConstant {
43 43
      */
44 44
     public final static String FAVOR_CONSULTANT = "consultant";
45 45
 
46
+    /**
47
+     * 点赞资讯
48
+     */
49
+    public final static String FAVOR_NEWS = "news";
50
+
46 51
     /**
47 52
      * 点赞项目
48 53
      */
49 54
     public final static String FAVOR_PROJECT = "project";
50 55
 
56
+    /**
57
+     * 活动点赞
58
+     */
59
+    public final static String FAVOR_ACTIVITY = "activity";
60
+
51 61
 
52 62
     /**
53 63
      * 兑换商品
@@ -68,10 +78,8 @@ public class CommConstant {
68 78
      */
69 79
     public static final Integer STATUS_UNACCALIMED = 0;
70 80
 
71
-    /**
72
-     * 点赞资讯
73
-     */
74
-    public final static String FAVOR_NEWS = "news";
81
+
82
+
75 83
 
76 84
 
77 85
 }

+ 11
- 0
src/main/java/com/huiju/estateagents/controller/TaNewsController.java Zobrazit soubor

@@ -121,4 +121,15 @@ public class TaNewsController extends BaseController {
121 121
         ResponseBean responseBean = iTaNewsService.getWxTaNewsById(id);
122 122
         return responseBean;
123 123
     }
124
+
125
+    /**
126
+     * 微信 资讯阅读量+1
127
+     * @param id
128
+     * @return
129
+     */
130
+    @RequestMapping(value = "/wx/taNews/pvNum/{id}", method = RequestMethod.PUT)
131
+    public ResponseBean wxTaPvNum(@PathVariable Integer id) {
132
+        ResponseBean responseBean = iTaNewsService.wxTaPvNum(id);
133
+        return responseBean;
134
+    }
124 135
 }

+ 2
- 2
src/main/java/com/huiju/estateagents/controller/TaSaveController.java Zobrazit soubor

@@ -32,7 +32,7 @@ public class TaSaveController extends BaseController {
32 32
      * @param request
33 33
      * @return
34 34
      */
35
-    @PostMapping("/wx/{typeOf}/like/{id}")
35
+    @PostMapping("/wx/{typeOf}/save/{id}")
36 36
     public ResponseBean giveFavor(@PathVariable String typeOf, @PathVariable String id, HttpServletRequest request) {
37 37
         String openid = JWTUtils.getSubject(request);
38 38
 
@@ -46,7 +46,7 @@ public class TaSaveController extends BaseController {
46 46
      * @param request
47 47
      * @return
48 48
      */
49
-    @DeleteMapping("/wx/{typeOf}/like/{id}")
49
+    @DeleteMapping("/wx/{typeOf}/save/{id}")
50 50
     public ResponseBean cancelFavor(@PathVariable String typeOf, @PathVariable String id, HttpServletRequest request) {
51 51
         String openid = JWTUtils.getSubject(request);
52 52
         return iTaSaveService.cancelLike(openid, typeOf, id);

+ 11
- 0
src/main/java/com/huiju/estateagents/mapper/TaBuildingDynamicMapper.java Zobrazit soubor

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.entity.TaBuildingDynamic;
7 7
 import org.apache.ibatis.annotations.Mapper;
8 8
 import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Update;
9 10
 
10 11
 /**
11 12
  * <p>
@@ -43,4 +44,14 @@ public interface TaBuildingDynamicMapper extends BaseMapper<TaBuildingDynamic> {
43 44
      * @param buildingDynamic
44 45
      */
45 46
     void buildingDynamicUpdate(TaBuildingDynamic buildingDynamic);
47
+
48
+    /**
49
+     * 某个字段值 +1
50
+     * @param newsId
51
+     * @param field
52
+     * @param increment
53
+     */
54
+    @Update("UPDATE ta_building_dynamic  SET ${field} = IFNULL(${field}, 0) + #{increment}  WHERE dynamic_id = #{newsId}")
55
+    void setFieldNum(@Param("newsId") String newsId, @Param("field") String field, @Param("increment") int increment);
56
+
46 57
 }

+ 2
- 2
src/main/java/com/huiju/estateagents/mapper/TaNewsMapper.java Zobrazit soubor

@@ -19,11 +19,11 @@ public interface TaNewsMapper extends BaseMapper<TaNews> {
19 19
 
20 20
     /**
21 21
      * 某个字段值 +1
22
-     * @param personId
22
+     * @param newsId
23 23
      * @param field
24 24
      * @param increment
25 25
      */
26 26
     @Update("UPDATE ta_news  SET ${field} = IFNULL(${field}, 0) + #{increment}  WHERE news_id = #{newsId}")
27
-    void setFieldNum(@Param("newsId") String personId, @Param("field") String field, @Param("increment") int increment);
27
+    void setFieldNum(@Param("newsId") String newsId, @Param("field") String field, @Param("increment") int increment);
28 28
 
29 29
 }

+ 7
- 0
src/main/java/com/huiju/estateagents/service/ITaNewsService.java Zobrazit soubor

@@ -60,4 +60,11 @@ public interface ITaNewsService extends IService<TaNews> {
60 60
      * @return
61 61
      */
62 62
     ResponseBean getWxTaNewsById(Integer newsId);
63
+
64
+    /**
65
+     * 微信 阅读量 +1
66
+     * @param id
67
+     * @return
68
+     */
69
+    ResponseBean wxTaPvNum(Integer id);
63 70
 }

+ 16
- 0
src/main/java/com/huiju/estateagents/service/impl/TaFavorServiceImpl.java Zobrazit soubor

@@ -3,8 +3,10 @@ package com.huiju.estateagents.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.huiju.estateagents.base.ResponseBean;
5 5
 import com.huiju.estateagents.common.CommConstant;
6
+import com.huiju.estateagents.entity.TaBuildingDynamic;
6 7
 import com.huiju.estateagents.entity.TaFavor;
7 8
 import com.huiju.estateagents.entity.TaPerson;
9
+import com.huiju.estateagents.mapper.TaBuildingDynamicMapper;
8 10
 import com.huiju.estateagents.mapper.TaFavorMapper;
9 11
 import com.huiju.estateagents.mapper.TaNewsMapper;
10 12
 import com.huiju.estateagents.mapper.TaPersonMapper;
@@ -38,6 +40,9 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
38 40
     @Autowired
39 41
     private TaNewsMapper taNewsMapper;
40 42
 
43
+    @Autowired
44
+    private TaBuildingDynamicMapper taBuildingDynamicMapper;
45
+
41 46
     @Override
42 47
     public ResponseBean postLike(String openid, String typeOf, String like) {
43 48
         List<TaPerson> persons = getPersonsByOpenId(openid);
@@ -82,6 +87,11 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
82 87
             taNewsMapper.setFieldNum(like, "favor_num", 1);
83 88
         }
84 89
 
90
+        // 如果是活动点赞, 则 +1
91
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
92
+            taBuildingDynamicMapper.setFieldNum(like, "favor_num", 1);
93
+        }
94
+
85 95
         return ResponseBean.success("");
86 96
     }
87 97
 
@@ -120,6 +130,12 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
120 130
             taNewsMapper.setFieldNum(taPerson.getPersonId(),"favor_num", -1);
121 131
         }
122 132
 
133
+
134
+        // 如果是活动点赞, 则 -1
135
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
136
+            taBuildingDynamicMapper.setFieldNum(like, "favor_num", 1);
137
+        }
138
+
123 139
         return ResponseBean.success("");
124 140
     }
125 141
 

+ 19
- 0
src/main/java/com/huiju/estateagents/service/impl/TaNewsServiceImpl.java Zobrazit soubor

@@ -47,6 +47,8 @@ public class TaNewsServiceImpl extends ServiceImpl<TaNewsMapper, TaNews> impleme
47 47
     @Autowired
48 48
     private TaFavorMapper taFavorMapper;
49 49
 
50
+    @Autowired
51
+    private TaNewsMapper taNewsMapper;
50 52
 
51 53
 
52 54
     @Override
@@ -162,4 +164,21 @@ public class TaNewsServiceImpl extends ServiceImpl<TaNewsMapper, TaNews> impleme
162 164
         responseBean.addSuccess(taNews);
163 165
         return responseBean;
164 166
     }
167
+
168
+    @Override
169
+    public ResponseBean wxTaPvNum(Integer id) {
170
+        ResponseBean responseBean = getTaNewsById(id);
171
+        if (1 == responseBean.getCode()) {
172
+            return responseBean;
173
+        }
174
+        TaNews taNews = (TaNews) responseBean.getData();
175
+        if (null == taNews) {
176
+            responseBean.addError("数据不存!");
177
+        }
178
+
179
+        taNewsMapper.setFieldNum(id + "", "pv_num", 1);
180
+
181
+        responseBean.addSuccess((Object)"");
182
+        return responseBean;
183
+    }
165 184
 }