dingxin 6 年前
父节点
当前提交
02f137100c

+ 8
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpAnnouncement.java 查看文件

@@ -1,8 +1,15 @@
1 1
 package com.community.huiju.model;
2 2
 
3
+import lombok.Data;
4
+import lombok.EqualsAndHashCode;
5
+import lombok.experimental.Accessors;
6
+
3 7
 import java.util.Date;
4 8
 import java.util.List;
5
-
9
+@Data
10
+@EqualsAndHashCode(callSuper = false)
11
+@Accessors(chain = true)
12
+@TableName("tp_announcement")
6 13
 public class TpAnnouncement {
7 14
     private Integer id;
8 15
 

+ 38
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/TpAnnouncementController.java 查看文件

@@ -0,0 +1,38 @@
1
+package com.community.huiju.controller;
2
+
3
+import com.community.commom.mode.ResponseBean;
4
+import com.community.commom.session.UserElement;
5
+import com.community.huiju.common.base.BaseController;
6
+import com.community.huiju.service.TpAnnouncementService;
7
+import io.swagger.annotations.Api;
8
+import io.swagger.annotations.ApiImplicitParam;
9
+import io.swagger.annotations.ApiImplicitParams;
10
+import io.swagger.annotations.ApiOperation;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.cloud.context.config.annotation.RefreshScope;
13
+import org.springframework.web.bind.annotation.RequestBody;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RequestMethod;
16
+import org.springframework.web.bind.annotation.RestController;
17
+
18
+import javax.servlet.http.HttpSession;
19
+
20
+@RestController
21
+@RefreshScope
22
+@RequestMapping("/")
23
+@Api(value = "公告管理API", description = "公告管理API")
24
+public class TpAnnouncementController extends BaseController {
25
+    @Autowired
26
+    private TpAnnouncementService tpAnnouncementService;
27
+
28
+    @ApiOperation(value = "获取公告管理列表",nickname ="获取公告管理列表")
29
+    @ApiImplicitParams({
30
+            @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value ="id:公告编号,announcementTitle:公告标题 ,current:每页显示多少条,current:每页显示多少条,pageSzie:当前页数")})
31
+            @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
32
+    @RequestMapping(value="/tpAnnouncement",method = RequestMethod.POST)
33
+    public ResponseBean tpAnnouncement(@RequestBody String paramets, HttpSession session){
34
+        UserElement userElement = getUserElement(session);
35
+        ResponseBean tpAnnouncementList=tpAnnouncementService.tpAnnouncemenList(paramets,userElement.getCommunityId());
36
+        return tpAnnouncementList;
37
+    }
38
+}

+ 37
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TpAnnouncementMapper.java 查看文件

@@ -0,0 +1,37 @@
1
+package com.community.huiju.dao;
2
+
3
+
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.community.huiju.model.TpAnnouncement;
8
+import org.apache.ibatis.annotations.Mapper;
9
+import org.apache.ibatis.annotations.Param;
10
+
11
+import java.util.List;
12
+
13
+@Mapper
14
+public interface TpAnnouncementMapper extends BaseMapper<TpAnnouncement> {
15
+    int deleteByPrimaryKey(Integer id);
16
+
17
+    @Override
18
+    int insert(TpAnnouncement record);
19
+
20
+    int insertSelective(TpAnnouncement record);
21
+
22
+    TpAnnouncement selectByPrimaryKey(@Param("id") Integer id, @Param("communityId") Integer communityId);
23
+
24
+    int updateByPrimaryKeySelective(@Param("id") Integer id, @Param("viewCount") Integer viewCount);
25
+
26
+    int updateByPrimaryKey(TpAnnouncement record);
27
+
28
+    IPage<TpAnnouncement> getAnnouncements(Page page ,@Param("communityId") Integer communityId);
29
+
30
+    /**
31
+     * 公告轮播图
32
+     * @param communityId
33
+     * @param sum
34
+     * @return
35
+     */
36
+    List<TpAnnouncement> getAnnouncement(@Param("communityId") Integer communityId, @Param("sum") Integer sum);
37
+}

+ 56
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TpAnnouncement.java 查看文件

@@ -0,0 +1,56 @@
1
+package com.community.huiju.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.io.Serializable;
9
+import java.util.Date;
10
+import java.util.List;
11
+@Data
12
+@EqualsAndHashCode(callSuper = false)
13
+@Accessors(chain = true)
14
+@TableName("tp_announcement")
15
+public class TpAnnouncement implements Serializable {
16
+
17
+    private static final long serialVersionUID = 1L;
18
+
19
+    private Integer id;
20
+
21
+    /** 小区id**/
22
+    private Integer communityId;
23
+
24
+    /**公告标题**/
25
+    private String announcementTitle;
26
+
27
+    /**轮播图**/
28
+    private String announcementCarouselImg;
29
+
30
+    /**公告内容**/
31
+    private String announcementContent;
32
+
33
+    /**排序**/
34
+    private Integer sort;
35
+
36
+    /**查看人数**/
37
+    private Integer viewCount;
38
+
39
+    /**是否设置为轮播  保留字段**/
40
+    private String setUpCarousel;
41
+
42
+    /**0 是已作废 1 是已发布   2 是草稿 3 是已修改**/
43
+    private String status;
44
+
45
+    /**创建人**/
46
+    private Integer createUser;
47
+
48
+    /**创建时间**/
49
+    private Date createDate;
50
+
51
+    /**更新人**/
52
+    private Integer updateUser;
53
+
54
+    /**更新时间**/
55
+    private Date updateDate;
56
+}

+ 24
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/TpAnnouncementService.java 查看文件

@@ -0,0 +1,24 @@
1
+package com.community.huiju.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.community.commom.mode.ResponseBean;
5
+import com.community.huiju.model.TpAnnouncement;
6
+import com.community.huiju.model.User;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * version V1.0
12
+ * class_name: $METHOD_NAME$
13
+ * param: $METHOD_PARAM$
14
+ * describe: TODO
15
+ * creat_user:fannaixi
16
+ * creat_time: 2018/12/28
17
+ **/
18
+public interface TpAnnouncementService extends IService<TpAnnouncement> {
19
+    /**
20
+     * 获取公告列表
21
+     */
22
+    ResponseBean tpAnnouncemenList(String paramets,Integer CommunityId);
23
+
24
+}

+ 58
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpAnnouncementServiceImpl.java 查看文件

@@ -0,0 +1,58 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.community.commom.mode.ResponseBean;
8
+import com.community.huiju.dao.TpAnnouncementMapper;
9
+import com.community.huiju.model.TpAnnouncement;
10
+import com.community.huiju.model.TpBuildingOwnerInfo;
11
+import com.community.huiju.service.TpAnnouncementService;
12
+import com.google.common.collect.Maps;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+
17
+import java.util.List;
18
+import java.util.Map;
19
+
20
+/**
21
+ * version V1.0
22
+ * class_name: $METHOD_NAME$
23
+ * param: $METHOD_PARAM$
24
+ * describe: TODO
25
+ * creat_user:fannaixi
26
+ * creat_time: 2018/12/28
27
+ **/
28
+@Slf4j
29
+@Service
30
+public class TpAnnouncementServiceImpl extends ServiceImpl<TpAnnouncementMapper, TpAnnouncement> implements TpAnnouncementService {
31
+
32
+@Autowired
33
+private  TpAnnouncementMapper tpAnnouncementMapper;
34
+    @Override
35
+    public ResponseBean tpAnnouncemenList(String paramets, Integer CommunityId) {
36
+        ResponseBean responseBean = new ResponseBean();
37
+
38
+        TpAnnouncement   tpAnnouncement= JSONObject.parseObject(paramets, TpAnnouncement.class);
39
+        tpAnnouncement.setCommunityId(CommunityId);
40
+        JSONObject jsonobject = JSONObject.parseObject(paramets);
41
+        Integer pageNum = jsonobject.getInteger("pageNum");
42
+        Integer pageSize = jsonobject.getInteger("pageSize");
43
+        // 分页
44
+        Page<TpBuildingOwnerInfo> page = new Page<>();
45
+        page.setSize(pageSize == null ? 10 : pageSize);
46
+        page.setCurrent(pageNum == null ? 1 : pageNum);
47
+
48
+        IPage<TpAnnouncement> tpAnnouncementList= tpAnnouncementMapper.getAnnouncements(page,CommunityId);
49
+
50
+        Map<String, Object> map = Maps.newHashMap();
51
+        map.put("list", tpAnnouncementList.getRecords());
52
+        map.put("total", tpAnnouncementList.getTotal());
53
+        map.put("pageNum", tpAnnouncementList.getCurrent());
54
+        map.put("pageSize", tpAnnouncementList.getSize());
55
+        responseBean.addSuccess(map);
56
+        return responseBean;
57
+    }
58
+}

+ 172
- 0
CODE/smart-community/property-api/src/main/resources/mapper/TpAnnouncementMapper.xml 查看文件

@@ -0,0 +1,172 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TpAnnouncementMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpAnnouncement" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="community_id" property="communityId" jdbcType="INTEGER" />
7
+    <result column="announcement_title" property="announcementTitle" jdbcType="VARCHAR" />
8
+    <result column="announcement_carousel_img" property="announcementCarouselImg" jdbcType="VARCHAR" />
9
+    <result column="announcement_content" property="announcementContent" jdbcType="VARCHAR" />
10
+    <result column="user_name" property="userName" jdbcType="VARCHAR" />
11
+    <result column="sort" property="sort" jdbcType="INTEGER" />
12
+    <result column="view_count" property="viewCount" jdbcType="INTEGER" />
13
+    <result column="set_up_carousel" property="setUpCarousel" jdbcType="CHAR" />
14
+    <result column="status" property="status" jdbcType="CHAR" />
15
+    <result column="create_user" property="createUser" jdbcType="INTEGER" />
16
+    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
17
+    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
18
+    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
19
+  </resultMap>
20
+  <sql id="Base_Column_List" >
21
+    id, community_id, announcement_title, announcement_carousel_img, announcement_content,
22
+    sort, view_count, set_up_carousel, status, create_user, create_date, update_user,
23
+    update_date
24
+  </sql>
25
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap">
26
+    select
27
+    <include refid="Base_Column_List" />
28
+    from tp_announcement
29
+    where id = #{id,jdbcType=INTEGER} and community_id = #{communityId,jdbcType=INTEGER}
30
+  </select>
31
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
32
+    delete from tp_announcement
33
+    where id = #{id,jdbcType=INTEGER}
34
+  </delete>
35
+  <insert id="insert" parameterType="com.community.huiju.model.TpAnnouncement" >
36
+    insert into tp_announcement (id, community_id, announcement_title,
37
+      announcement_carousel_img, announcement_content,
38
+      sort, view_count, set_up_carousel,
39
+      status, create_user, create_date,
40
+      update_user, update_date)
41
+    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{announcementTitle,jdbcType=VARCHAR},
42
+      #{announcementCarouselImg,jdbcType=VARCHAR}, #{announcementContent,jdbcType=VARCHAR},
43
+      #{sort,jdbcType=INTEGER}, #{viewCount,jdbcType=INTEGER}, #{setUpCarousel,jdbcType=CHAR},
44
+      #{status,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP},
45
+      #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP})
46
+  </insert>
47
+  <insert id="insertSelective" parameterType="com.community.huiju.model.TpAnnouncement" >
48
+    insert into tp_announcement
49
+    <trim prefix="(" suffix=")" suffixOverrides="," >
50
+      <if test="id != null" >
51
+        id,
52
+      </if>
53
+      <if test="communityId != null" >
54
+        community_id,
55
+      </if>
56
+      <if test="announcementTitle != null" >
57
+        announcement_title,
58
+      </if>
59
+      <if test="announcementCarouselImg != null" >
60
+        announcement_carousel_img,
61
+      </if>
62
+      <if test="announcementContent != null" >
63
+        announcement_content,
64
+      </if>
65
+      <if test="sort != null" >
66
+        sort,
67
+      </if>
68
+      <if test="viewCount != null" >
69
+        view_count,
70
+      </if>
71
+      <if test="setUpCarousel != null" >
72
+        set_up_carousel,
73
+      </if>
74
+      <if test="status != null" >
75
+        status,
76
+      </if>
77
+      <if test="createUser != null" >
78
+        create_user,
79
+      </if>
80
+      <if test="createDate != null" >
81
+        create_date,
82
+      </if>
83
+      <if test="updateUser != null" >
84
+        update_user,
85
+      </if>
86
+      <if test="updateDate != null" >
87
+        update_date,
88
+      </if>
89
+    </trim>
90
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
91
+      <if test="id != null" >
92
+        #{id,jdbcType=INTEGER},
93
+      </if>
94
+      <if test="communityId != null" >
95
+        #{communityId,jdbcType=INTEGER},
96
+      </if>
97
+      <if test="announcementTitle != null" >
98
+        #{announcementTitle,jdbcType=VARCHAR},
99
+      </if>
100
+      <if test="announcementCarouselImg != null" >
101
+        #{announcementCarouselImg,jdbcType=VARCHAR},
102
+      </if>
103
+      <if test="announcementContent != null" >
104
+        #{announcementContent,jdbcType=VARCHAR},
105
+      </if>
106
+      <if test="sort != null" >
107
+        #{sort,jdbcType=INTEGER},
108
+      </if>
109
+      <if test="viewCount != null" >
110
+        #{viewCount,jdbcType=INTEGER},
111
+      </if>
112
+      <if test="setUpCarousel != null" >
113
+        #{setUpCarousel,jdbcType=CHAR},
114
+      </if>
115
+      <if test="status != null" >
116
+        #{status,jdbcType=CHAR},
117
+      </if>
118
+      <if test="createUser != null" >
119
+        #{createUser,jdbcType=INTEGER},
120
+      </if>
121
+      <if test="createDate != null" >
122
+        #{createDate,jdbcType=TIMESTAMP},
123
+      </if>
124
+      <if test="updateUser != null" >
125
+        #{updateUser,jdbcType=INTEGER},
126
+      </if>
127
+      <if test="updateDate != null" >
128
+        #{updateDate,jdbcType=TIMESTAMP},
129
+      </if>
130
+    </trim>
131
+  </insert>
132
+  <update id="updateByPrimaryKeySelective" >
133
+    update tp_announcement
134
+    <set >
135
+      <if test="viewCount != null" >
136
+        view_count = #{viewCount,jdbcType=INTEGER},
137
+      </if>
138
+    </set>
139
+    where id = #{id,jdbcType=INTEGER}
140
+  </update>
141
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpAnnouncement" >
142
+    update tp_announcement
143
+    set community_id = #{communityId,jdbcType=INTEGER},
144
+      announcement_title = #{announcementTitle,jdbcType=VARCHAR},
145
+      announcement_carousel_img = #{announcementCarouselImg,jdbcType=VARCHAR},
146
+      announcement_content = #{announcementContent,jdbcType=VARCHAR},
147
+      sort = #{sort,jdbcType=INTEGER},
148
+      view_count = #{viewCount,jdbcType=INTEGER},
149
+      set_up_carousel = #{setUpCarousel,jdbcType=CHAR},
150
+      status = #{status,jdbcType=CHAR},
151
+      create_user = #{createUser,jdbcType=INTEGER},
152
+      create_date = #{createDate,jdbcType=TIMESTAMP},
153
+      update_user = #{updateUser,jdbcType=INTEGER},
154
+      update_date = #{updateDate,jdbcType=TIMESTAMP}
155
+    where id = #{id,jdbcType=INTEGER}
156
+  </update>
157
+
158
+  <select id="getAnnouncements" resultType="com.community.huiju.model.TpAnnouncement" parameterType="map">
159
+    SELECT
160
+    <include refid="Base_Column_List" />
161
+   FROM
162
+      tp_announcement WHERE  community_id = #{communityId,jdbcType=INTEGER}
163
+
164
+  </select>
165
+
166
+  <select id="getAnnouncement" resultMap="BaseResultMap" parameterType="com.community.huiju.model.TpAnnouncement">
167
+    select
168
+    <include refid="Base_Column_List" />
169
+    from tp_announcement
170
+    where community_id = #{communityId,jdbcType=INTEGER}  and status=1  order by create_date DESC limit  #{sum,jdbcType=INTEGER}
171
+  </select>
172
+</mapper>