魏超 6 years ago
parent
commit
ae7cb7b482

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

5
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
7
 
7
 
8
+import java.util.List;
9
+
8
 @Mapper
10
 @Mapper
9
 public interface TpAnnouncementMapper {
11
 public interface TpAnnouncementMapper {
10
     int deleteByPrimaryKey(Integer id);
12
     int deleteByPrimaryKey(Integer id);
18
     int updateByPrimaryKeySelective(@Param("id")Integer id, @Param("viewCount")Integer viewCount);
20
     int updateByPrimaryKeySelective(@Param("id")Integer id, @Param("viewCount")Integer viewCount);
19
 
21
 
20
     int updateByPrimaryKey(TpAnnouncement record);
22
     int updateByPrimaryKey(TpAnnouncement record);
23
+	
24
+	List<TpAnnouncement> getAnnouncements(@Param("communityId") Integer communityId,@Param("title") String title);
21
 }
25
 }

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

1
 package com.community.huiju.dao;
1
 package com.community.huiju.dao;
2
 
2
 
3
-
4
 import com.community.huiju.model.TpSocialView;
3
 import com.community.huiju.model.TpSocialView;
5
 import org.apache.ibatis.annotations.Mapper;
4
 import org.apache.ibatis.annotations.Mapper;
6
 
5
 

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

1
 package com.community.huiju.service;
1
 package com.community.huiju.service;
2
 
2
 
3
+import com.community.huiju.model.TpActivity;
3
 import com.community.huiju.model.TpAnnouncement;
4
 import com.community.huiju.model.TpAnnouncement;
4
 import com.community.huiju.model.TpSocialView;
5
 import com.community.huiju.model.TpSocialView;
5
 
6
 
7
+import java.util.List;
8
+
6
 /**
9
 /**
7
  * @author weichaochao
10
  * @author weichaochao
8
  * @Title: SocialServiceI
11
  * @Title: SocialServiceI
10
  */
13
  */
11
 public interface SocialServiceI {
14
 public interface SocialServiceI {
12
     TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId);
15
     TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId);
13
-    void insertSocialView(TpSocialView tpSocialView);
16
+
17
+	/**
18
+	 * 分页获取公告列表
19
+	 * @param communityId
20
+	 * @param title
21
+	 * @param pageNum
22
+	 * @param pageSize
23
+	 * @return
24
+	 */
25
+	List<TpAnnouncement> getAnnouncements(Integer communityId, String title, Integer pageNum, Integer pageSize);
26
+	
27
+	/**
28
+	 * 分页获取活动列表
29
+	 * @param communityId
30
+	 * @param title
31
+	 * @param pageNum
32
+	 * @param pageSize
33
+	 * @return
34
+	 */
35
+	List<TpActivity> getActivitys(Integer communityId, String title, Integer pageNum, Integer pageSize);
14
 }
36
 }

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

6
 import com.community.huiju.model.TpAnnouncement;
6
 import com.community.huiju.model.TpAnnouncement;
7
 import com.community.huiju.model.TpSocialView;
7
 import com.community.huiju.model.TpSocialView;
8
 import com.community.huiju.service.SocialServiceI;
8
 import com.community.huiju.service.SocialServiceI;
9
-import io.swagger.models.auth.In;
9
+import com.community.huiju.dao.TpActivityMapper;
10
+import com.community.huiju.dao.TpAnnouncementMapper;
11
+import com.community.huiju.model.TpActivity;
12
+import com.community.huiju.model.TpAnnouncement;
13
+import com.community.huiju.model.TpMessage;
14
+import com.community.huiju.service.SocialServiceI;
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;
12
 import org.springframework.transaction.annotation.Transactional;
18
 import org.springframework.transaction.annotation.Transactional;
13
 
19
 
14
 import java.util.Date;
20
 import java.util.Date;
15
 
21
 
22
+import java.util.List;
23
+
16
 /**
24
 /**
17
  * @author weichaochao
25
  * @author weichaochao
18
  * @Title: SocialServiceImpl
26
  * @Title: SocialServiceImpl
23
 
31
 
24
     @Autowired
32
     @Autowired
25
     private TpAnnouncementMapper tpAnnouncementMapper;
33
     private TpAnnouncementMapper tpAnnouncementMapper;
34
+
26
     @Autowired
35
     @Autowired
27
     private TpSocialViewMapper tpSocialViewMapper;
36
     private TpSocialViewMapper tpSocialViewMapper;
28
 
37
 
38
+    @Autowired
39
+    private TpActivityMapper tpActivityMapper;
40
+    
29
     @Override
41
     @Override
30
     @Transactional
42
     @Transactional
31
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId) {
43
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId) {
47
         return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
59
         return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
48
     }
60
     }
49
 
61
 
62
+    /**
63
+     * 分页获取公告列表
64
+     * @param communityId
65
+     * @param title
66
+     * @param pageNum
67
+     * @param pageSize
68
+     * @return
69
+     */
50
     @Override
70
     @Override
51
-    public void insertSocialView(TpSocialView tpSocialView) {
52
-
71
+    public List<TpAnnouncement> getAnnouncements(Integer communityId,String title, Integer pageNum, Integer pageSize) {
72
+        pageNum = null == pageNum ? 1 : pageNum;
73
+        pageSize = null == pageSize ? 10 : pageSize;
74
+        //使用分页插件
75
+        PageHelper.startPage(pageNum, pageSize);
76
+        // 获取数据
77
+        List<TpAnnouncement> announcementList = tpAnnouncementMapper.getAnnouncements(communityId,title);
78
+        return announcementList;
79
+    }
80
+    
81
+    /**
82
+     * 分页获取活动列表
83
+     * @param communityId
84
+     * @param title
85
+     * @param pageNum
86
+     * @param pageSize
87
+     * @return
88
+     */
89
+    @Override
90
+    public List<TpActivity> getActivitys(Integer communityId, String title, Integer pageNum, Integer pageSize) {
91
+        pageNum = null == pageNum ? 1 : pageNum;
92
+        pageSize = null == pageSize ? 10 : pageSize;
93
+        //使用分页插件
94
+        PageHelper.startPage(pageNum, pageSize);
95
+        // 获取数据
96
+        List<TpActivity> activityList = tpActivityMapper.getActivitys(communityId,title);
97
+        return activityList;
53
     }
98
     }
54
 }
99
 }

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

7
     <result column="announcement_title" property="announcementTitle" jdbcType="VARCHAR" />
7
     <result column="announcement_title" property="announcementTitle" jdbcType="VARCHAR" />
8
     <result column="announcement_carousel_img" property="announcementCarouselImg" jdbcType="VARCHAR" />
8
     <result column="announcement_carousel_img" property="announcementCarouselImg" jdbcType="VARCHAR" />
9
     <result column="announcement_content" property="announcementContent" jdbcType="VARCHAR" />
9
     <result column="announcement_content" property="announcementContent" jdbcType="VARCHAR" />
10
+    <result column="user_name" property="userName" jdbcType="VARCHAR" />
10
     <result column="sort" property="sort" jdbcType="INTEGER" />
11
     <result column="sort" property="sort" jdbcType="INTEGER" />
11
     <result column="view_count" property="viewCount" jdbcType="INTEGER" />
12
     <result column="view_count" property="viewCount" jdbcType="INTEGER" />
12
     <result column="set_up_carousel" property="setUpCarousel" jdbcType="CHAR" />
13
     <result column="set_up_carousel" property="setUpCarousel" jdbcType="CHAR" />
153
       update_date = #{updateDate,jdbcType=TIMESTAMP}
154
       update_date = #{updateDate,jdbcType=TIMESTAMP}
154
     where id = #{id,jdbcType=INTEGER}
155
     where id = #{id,jdbcType=INTEGER}
155
   </update>
156
   </update>
157
+
158
+  <select id="getAnnouncements" resultMap="BaseResultMap">
159
+    SELECT
160
+      a.id,
161
+      a.announcement_title,
162
+      a.announcement_content,
163
+      a.create_date,
164
+      u.user_name as user_name,
165
+      a.sort,
166
+      a.view_count
167
+  FROM
168
+      tp_announcement a
169
+      LEFT JOIN tp_user u ON a.create_user = u.id
170
+      AND u.community_id = #{communityId,jdbcType=INTEGER}
171
+  WHERE
172
+      a.community_id = #{communityId,jdbcType=INTEGER}
173
+      AND ( a.STATUS = 1 OR a.STATUS = 3 )
174
+      and a.announcement_title like concat('%',#{title,jdbcType=VARCHAR},'%')
175
+  ORDER BY
176
+      a.sort,
177
+      a.create_date DESC
178
+  </select>
156
 </mapper>
179
 </mapper>

+ 289
- 277
文档/MYSQL/smartCommunity.pdm
File diff suppressed because it is too large
View File