Browse Source

公告轮播图

dingxin 6 years ago
parent
commit
95b7c0b986

+ 1
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpAnnouncementMapper.java View File

@@ -17,7 +17,7 @@ public interface TpAnnouncementMapper {
17 17
 
18 18
     TpAnnouncement selectByPrimaryKey(@Param("id") Integer id, @Param("communityId") Integer communityId);
19 19
 
20
-    int updateByPrimaryKeySelective(TpAnnouncement record);
20
+    int updateByPrimaryKeySelective(@Param("id")Integer id, @Param("viewCount")Integer viewCount);
21 21
 
22 22
     int updateByPrimaryKey(TpAnnouncement record);
23 23
 	

+ 2
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpSocialViewMapper.java View File

@@ -16,4 +16,6 @@ public interface TpSocialViewMapper {
16 16
     int updateByPrimaryKeySelective(TpSocialView record);
17 17
 
18 18
     int updateByPrimaryKey(TpSocialView record);
19
+
20
+    Integer selectViewNum(TpSocialView tpSocialView);
19 21
 }

+ 2
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/SocialServiceI.java View File

@@ -2,7 +2,7 @@ package com.community.huiju.service;
2 2
 
3 3
 import com.community.huiju.model.TpActivity;
4 4
 import com.community.huiju.model.TpAnnouncement;
5
-import com.community.huiju.model.TpMessage;
5
+import com.community.huiju.model.TpSocialView;
6 6
 
7 7
 import java.util.List;
8 8
 
@@ -13,7 +13,7 @@ import java.util.List;
13 13
  */
14 14
 public interface SocialServiceI {
15 15
     TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId);
16
-	
16
+
17 17
 	/**
18 18
 	 * 分页获取公告列表
19 19
 	 * @param communityId

+ 32
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/SocialServiceImpl.java View File

@@ -1,5 +1,11 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3
+import com.community.commom.constant.Constant;
4
+import com.community.huiju.dao.TpAnnouncementMapper;
5
+import com.community.huiju.dao.TpSocialViewMapper;
6
+import com.community.huiju.model.TpAnnouncement;
7
+import com.community.huiju.model.TpSocialView;
8
+import com.community.huiju.service.SocialServiceI;
3 9
 import com.community.huiju.dao.TpActivityMapper;
4 10
 import com.community.huiju.dao.TpAnnouncementMapper;
5 11
 import com.community.huiju.model.TpActivity;
@@ -9,28 +15,50 @@ import com.community.huiju.service.SocialServiceI;
9 15
 import com.github.pagehelper.PageHelper;
10 16
 import org.springframework.beans.factory.annotation.Autowired;
11 17
 import org.springframework.stereotype.Service;
18
+import org.springframework.transaction.annotation.Transactional;
19
+
20
+import java.util.Date;
12 21
 
13 22
 import java.util.List;
14 23
 
15 24
 /**
16
- * @author admin
25
+ * @author weichaochao
17 26
  * @Title: SocialServiceImpl
18
- * @Description: TODO
19 27
  * @date 2018/10/23
20 28
  */
21 29
 @Service("SocialService")
22 30
 public class SocialServiceImpl implements SocialServiceI {
31
+
23 32
     @Autowired
24 33
     private TpAnnouncementMapper tpAnnouncementMapper;
25
-    
34
+
35
+    @Autowired
36
+    private TpSocialViewMapper tpSocialViewMapper;
37
+
26 38
     @Autowired
27 39
     private TpActivityMapper tpActivityMapper;
28 40
     
29 41
     @Override
42
+    @Transactional
30 43
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId) {
44
+        TpSocialView tpSocialView = new TpSocialView();
45
+        //TODO
46
+        tpSocialView.setTaUserId(1);
47
+        tpSocialView.setSocialType(Constant.ANNOUNCEMENT);
48
+        tpSocialView.setCommunityId(communityId);
49
+        tpSocialView.setUuid(id);
50
+        Integer viewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
51
+
52
+        if (viewNum == 0){
53
+            tpSocialView.setCreateDate(new Date());
54
+            tpSocialViewMapper.insertSelective(tpSocialView);
55
+            tpSocialView.setTaUserId(null);
56
+            Integer allViewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
57
+            tpAnnouncementMapper.updateByPrimaryKeySelective(id, allViewNum);
58
+        }
31 59
         return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
32 60
     }
33
-    
61
+
34 62
     /**
35 63
      * 分页获取公告列表
36 64
      * @param communityId

+ 1
- 34
CODE/smart-community/app-api/src/main/resources/mapper/TpAnnouncementMapper.xml View File

@@ -129,45 +129,12 @@
129 129
       </if>
130 130
     </trim>
131 131
   </insert>
132
-  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpAnnouncement" >
132
+  <update id="updateByPrimaryKeySelective" >
133 133
     update tp_announcement
134 134
     <set >
135
-      <if test="communityId != null" >
136
-        community_id = #{communityId,jdbcType=INTEGER},
137
-      </if>
138
-      <if test="announcementTitle != null" >
139
-        announcement_title = #{announcementTitle,jdbcType=VARCHAR},
140
-      </if>
141
-      <if test="announcementCarouselImg != null" >
142
-        announcement_carousel_img = #{announcementCarouselImg,jdbcType=VARCHAR},
143
-      </if>
144
-      <if test="announcementContent != null" >
145
-        announcement_content = #{announcementContent,jdbcType=VARCHAR},
146
-      </if>
147
-      <if test="sort != null" >
148
-        sort = #{sort,jdbcType=INTEGER},
149
-      </if>
150 135
       <if test="viewCount != null" >
151 136
         view_count = #{viewCount,jdbcType=INTEGER},
152 137
       </if>
153
-      <if test="setUpCarousel != null" >
154
-        set_up_carousel = #{setUpCarousel,jdbcType=CHAR},
155
-      </if>
156
-      <if test="status != null" >
157
-        status = #{status,jdbcType=CHAR},
158
-      </if>
159
-      <if test="createUser != null" >
160
-        create_user = #{createUser,jdbcType=INTEGER},
161
-      </if>
162
-      <if test="createDate != null" >
163
-        create_date = #{createDate,jdbcType=TIMESTAMP},
164
-      </if>
165
-      <if test="updateUser != null" >
166
-        update_user = #{updateUser,jdbcType=INTEGER},
167
-      </if>
168
-      <if test="updateDate != null" >
169
-        update_date = #{updateDate,jdbcType=TIMESTAMP},
170
-      </if>
171 138
     </set>
172 139
     where id = #{id,jdbcType=INTEGER}
173 140
   </update>

+ 11
- 0
CODE/smart-community/app-api/src/main/resources/mapper/TpSocialViewMapper.xml View File

@@ -114,4 +114,15 @@
114 114
       create_date = #{createDate,jdbcType=TIMESTAMP}
115 115
     where id = #{id,jdbcType=INTEGER}
116 116
   </update>
117
+
118
+  <select id="selectViewNum" resultType="java.lang.Integer" parameterType="com.community.huiju.model.TpSocialView">
119
+    select count(*) from tp_social_view
120
+    where
121
+    <if test="taUserId != null" >
122
+      ta_user_id = #{taUserId} and
123
+    </if>
124
+    uuid = #{uuid}
125
+    and community_id = #{communityId}
126
+    and social_type = #{socialType}
127
+  </select>
117 128
 </mapper>

+ 9
- 0
CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java View File

@@ -29,4 +29,13 @@ public class Constant {
29 29
     
30 30
     /** 住户APP端待办 **/
31 31
     public static final Integer MODEL_TYPE_UPCOMING = 2;
32
+
33
+    /** 社交公告类型**/
34
+    public static final String ANNOUNCEMENT = "announcement";
35
+
36
+    /** 社交活动类型**/
37
+    public static final String ACTIVITY = "activity";
38
+
39
+    /** 社交二手租赁类型**/
40
+    public static final String LEASE = "lease";
32 41
 }

BIN
CODE/smart-community/community-common/target/classes/com/community/commom/constant/Constant.class View File