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
 
17
 
18
     TpAnnouncement selectByPrimaryKey(@Param("id") Integer id, @Param("communityId") Integer communityId);
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
     int updateByPrimaryKey(TpAnnouncement record);
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
     int updateByPrimaryKeySelective(TpSocialView record);
16
     int updateByPrimaryKeySelective(TpSocialView record);
17
 
17
 
18
     int updateByPrimaryKey(TpSocialView record);
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
 
2
 
3
 import com.community.huiju.model.TpActivity;
3
 import com.community.huiju.model.TpActivity;
4
 import com.community.huiju.model.TpAnnouncement;
4
 import com.community.huiju.model.TpAnnouncement;
5
-import com.community.huiju.model.TpMessage;
5
+import com.community.huiju.model.TpSocialView;
6
 
6
 
7
 import java.util.List;
7
 import java.util.List;
8
 
8
 
13
  */
13
  */
14
 public interface SocialServiceI {
14
 public interface SocialServiceI {
15
     TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId);
15
     TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId);
16
-	
16
+
17
 	/**
17
 	/**
18
 	 * 分页获取公告列表
18
 	 * 分页获取公告列表
19
 	 * @param communityId
19
 	 * @param communityId

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

1
 package com.community.huiju.service.impl;
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
 import com.community.huiju.dao.TpActivityMapper;
9
 import com.community.huiju.dao.TpActivityMapper;
4
 import com.community.huiju.dao.TpAnnouncementMapper;
10
 import com.community.huiju.dao.TpAnnouncementMapper;
5
 import com.community.huiju.model.TpActivity;
11
 import com.community.huiju.model.TpActivity;
9
 import com.github.pagehelper.PageHelper;
15
 import com.github.pagehelper.PageHelper;
10
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
18
+import org.springframework.transaction.annotation.Transactional;
19
+
20
+import java.util.Date;
12
 
21
 
13
 import java.util.List;
22
 import java.util.List;
14
 
23
 
15
 /**
24
 /**
16
- * @author admin
25
+ * @author weichaochao
17
  * @Title: SocialServiceImpl
26
  * @Title: SocialServiceImpl
18
- * @Description: TODO
19
  * @date 2018/10/23
27
  * @date 2018/10/23
20
  */
28
  */
21
 @Service("SocialService")
29
 @Service("SocialService")
22
 public class SocialServiceImpl implements SocialServiceI {
30
 public class SocialServiceImpl implements SocialServiceI {
31
+
23
     @Autowired
32
     @Autowired
24
     private TpAnnouncementMapper tpAnnouncementMapper;
33
     private TpAnnouncementMapper tpAnnouncementMapper;
25
-    
34
+
35
+    @Autowired
36
+    private TpSocialViewMapper tpSocialViewMapper;
37
+
26
     @Autowired
38
     @Autowired
27
     private TpActivityMapper tpActivityMapper;
39
     private TpActivityMapper tpActivityMapper;
28
     
40
     
29
     @Override
41
     @Override
42
+    @Transactional
30
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId) {
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
         return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
59
         return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
32
     }
60
     }
33
-    
61
+
34
     /**
62
     /**
35
      * 分页获取公告列表
63
      * 分页获取公告列表
36
      * @param communityId
64
      * @param communityId

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

129
       </if>
129
       </if>
130
     </trim>
130
     </trim>
131
   </insert>
131
   </insert>
132
-  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpAnnouncement" >
132
+  <update id="updateByPrimaryKeySelective" >
133
     update tp_announcement
133
     update tp_announcement
134
     <set >
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
       <if test="viewCount != null" >
135
       <if test="viewCount != null" >
151
         view_count = #{viewCount,jdbcType=INTEGER},
136
         view_count = #{viewCount,jdbcType=INTEGER},
152
       </if>
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
     </set>
138
     </set>
172
     where id = #{id,jdbcType=INTEGER}
139
     where id = #{id,jdbcType=INTEGER}
173
   </update>
140
   </update>

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

114
       create_date = #{createDate,jdbcType=TIMESTAMP}
114
       create_date = #{createDate,jdbcType=TIMESTAMP}
115
     where id = #{id,jdbcType=INTEGER}
115
     where id = #{id,jdbcType=INTEGER}
116
   </update>
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
 </mapper>
128
 </mapper>

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

29
     
29
     
30
     /** 住户APP端待办 **/
30
     /** 住户APP端待办 **/
31
     public static final Integer MODEL_TYPE_UPCOMING = 2;
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