andrew 4 anos atrás
pai
commit
f188af558a

+ 65
- 0
src/main/java/com/huiju/estateagents/property/controller/SocialController.java Ver arquivo

1
+package com.huiju.estateagents.property.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.huiju.estateagents.base.BaseController;
5
+import com.huiju.estateagents.base.ResponseBean;
6
+import com.huiju.estateagents.center.taUser.entity.TaUser;
7
+import com.huiju.estateagents.property.common.Constant;
8
+import com.huiju.estateagents.property.common.UserElement;
9
+import com.huiju.estateagents.property.model.TpActivity;
10
+import com.huiju.estateagents.property.model.TpAnnouncement;
11
+import com.huiju.estateagents.property.model.TpTicket;
12
+import com.huiju.estateagents.property.model.TpTransaction;
13
+import com.huiju.estateagents.property.service.SocialServiceI;
14
+import io.swagger.annotations.Api;
15
+import io.swagger.annotations.ApiImplicitParam;
16
+import io.swagger.annotations.ApiImplicitParams;
17
+import io.swagger.annotations.ApiOperation;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.web.bind.annotation.*;
20
+
21
+import javax.servlet.http.HttpServletRequest;
22
+/**
23
+ * @author weichaochao11
24
+ * @Title: SocialController
25
+ * @date 2018/10/23
26
+ */
27
+@RestController
28
+@RequestMapping("/api")
29
+@Api(value = "公告相关的API", tags = "公告相关的API")
30
+public class SocialController extends BaseController {
31
+
32
+    @Autowired
33
+    private SocialServiceI socialServiceI;
34
+
35
+    @RequestMapping(value = "/wx/announcement/{orgId}", method = RequestMethod.GET)
36
+    @ApiOperation(value = "论坛公告帖子详情", notes = "获取论坛公告帖子详情")
37
+    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", dataType = "integer", name = "orgId", value = "小区Id"),
38
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "id", value = "公告帖子id")})
39
+    public ResponseBean findAnnouncementDetail(@PathVariable(value = "orgId") Integer orgId, @RequestParam("id") Integer id, HttpServletRequest request) {
40
+        TaUser userElement = getTaUser(request);
41
+        Integer userId = userElement.getUserId();
42
+        ResponseBean responseBean = new ResponseBean();
43
+
44
+        TpAnnouncement tpAnnouncement = socialServiceI.findAnnouncementDetail(id, orgId, userId);
45
+        responseBean.addSuccess(tpAnnouncement);
46
+        return responseBean;
47
+    }
48
+
49
+    @ApiOperation(value = "按小区获取分页公告列表", notes = "按小区获取分页公告列表,公告标题模糊查询")
50
+    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", dataType = "String", name = "orgId", value = "小区Id"),
51
+            @ApiImplicitParam(paramType = "query", dataType = "String", name = "title", value = "公告标题"),
52
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
53
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度")})
54
+    @RequestMapping(value = "/wx/announcements/{orgId}", method = RequestMethod.GET)
55
+    public ResponseBean getAnnouncements(@PathVariable Integer orgId,
56
+                                         @RequestParam(required = false) String title,
57
+                                         @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
58
+                                         @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
59
+        ResponseBean responseBean = new ResponseBean();
60
+
61
+        ResponseBean announcementList = socialServiceI.getAnnouncements(orgId, title, pageNum, pageSize);
62
+        return announcementList;
63
+    }
64
+
65
+}

+ 2
- 0
src/main/java/com/huiju/estateagents/property/dao/TpAnnouncementMapper.java Ver arquivo

33
      * @return
33
      * @return
34
      */
34
      */
35
     List<TpAnnouncement> getAnnouncement(@Param("orgId") Integer orgId, @Param("sum") Integer sum);
35
     List<TpAnnouncement> getAnnouncement(@Param("orgId") Integer orgId, @Param("sum") Integer sum);
36
+
37
+    IPage<TpAnnouncement> getWxAnnouncements(Page page, @Param("orgId") Integer orgId,@Param("title") String title);
36
 }
38
 }

+ 21
- 0
src/main/java/com/huiju/estateagents/property/dao/TpSocialViewMapper.java Ver arquivo

1
+package com.huiju.estateagents.property.dao;
2
+
3
+import com.huiju.estateagents.property.model.TpSocialView;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface TpSocialViewMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(TpSocialView record);
11
+
12
+    int insertSelective(TpSocialView record);
13
+
14
+    TpSocialView selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(TpSocialView record);
17
+
18
+    int updateByPrimaryKey(TpSocialView record);
19
+
20
+    Integer selectViewNum(TpSocialView tpSocialView);
21
+}

+ 19
- 0
src/main/java/com/huiju/estateagents/property/model/TpAnnouncement.java Ver arquivo

1
 package com.huiju.estateagents.property.model;
1
 package com.huiju.estateagents.property.model;
2
 import com.baomidou.mybatisplus.annotation.IdType;
2
 import com.baomidou.mybatisplus.annotation.IdType;
3
+import com.baomidou.mybatisplus.annotation.TableField;
3
 import com.baomidou.mybatisplus.annotation.TableId;
4
 import com.baomidou.mybatisplus.annotation.TableId;
4
 import com.baomidou.mybatisplus.annotation.TableName;
5
 import com.baomidou.mybatisplus.annotation.TableName;
5
 import lombok.Data;
6
 import lombok.Data;
8
 
9
 
9
 import java.io.Serializable;
10
 import java.io.Serializable;
10
 import java.util.Date;
11
 import java.util.Date;
12
+import java.util.List;
11
 
13
 
12
 @Data
14
 @Data
13
 @EqualsAndHashCode(callSuper = false)
15
 @EqualsAndHashCode(callSuper = false)
55
 
57
 
56
     /**更新时间**/
58
     /**更新时间**/
57
     private Date updateDate;
59
     private Date updateDate;
60
+
61
+
62
+    /**
63
+     * 报名状态
64
+     */
65
+    @TableField(exist = false)
66
+    private String signStatus;
67
+    /**
68
+     * 签到状态
69
+     * 0已签到,1未签到
70
+     */
71
+    @TableField(exist = false)
72
+    private  Integer signType;
73
+
74
+    @TableField(exist = false)
75
+    private List<String> imgList;
76
+
58
 }
77
 }

+ 75
- 0
src/main/java/com/huiju/estateagents/property/model/TpSocialView.java Ver arquivo

1
+package com.huiju.estateagents.property.model;
2
+
3
+import java.util.Date;
4
+
5
+public class TpSocialView {
6
+    private Integer id;
7
+
8
+    private Integer communityId;
9
+
10
+    private Integer uuid;
11
+
12
+    private String socialType;
13
+
14
+    private Integer taUserId;
15
+
16
+    private String remark;
17
+
18
+    private Date createDate;
19
+
20
+    public Integer getId() {
21
+        return id;
22
+    }
23
+
24
+    public void setId(Integer id) {
25
+        this.id = id;
26
+    }
27
+
28
+    public Integer getCommunityId() {
29
+        return communityId;
30
+    }
31
+
32
+    public void setCommunityId(Integer communityId) {
33
+        this.communityId = communityId;
34
+    }
35
+
36
+    public Integer getUuid() {
37
+        return uuid;
38
+    }
39
+
40
+    public void setUuid(Integer uuid) {
41
+        this.uuid = uuid;
42
+    }
43
+
44
+    public String getSocialType() {
45
+        return socialType;
46
+    }
47
+
48
+    public void setSocialType(String socialType) {
49
+        this.socialType = socialType == null ? null : socialType.trim();
50
+    }
51
+
52
+    public Integer getTaUserId() {
53
+        return taUserId;
54
+    }
55
+
56
+    public void setTaUserId(Integer taUserId) {
57
+        this.taUserId = taUserId;
58
+    }
59
+
60
+    public String getRemark() {
61
+        return remark;
62
+    }
63
+
64
+    public void setRemark(String remark) {
65
+        this.remark = remark == null ? null : remark.trim();
66
+    }
67
+
68
+    public Date getCreateDate() {
69
+        return createDate;
70
+    }
71
+
72
+    public void setCreateDate(Date createDate) {
73
+        this.createDate = createDate;
74
+    }
75
+}

+ 40
- 0
src/main/java/com/huiju/estateagents/property/service/SocialServiceI.java Ver arquivo

1
+package com.huiju.estateagents.property.service;
2
+
3
+
4
+import com.huiju.estateagents.base.ResponseBean;
5
+import com.huiju.estateagents.property.common.UserElement;
6
+import com.huiju.estateagents.property.model.TpActivity;
7
+import com.huiju.estateagents.property.model.TpAnnouncement;
8
+import com.huiju.estateagents.property.model.TpTicket;
9
+import com.huiju.estateagents.property.model.TpTransaction;
10
+
11
+import java.util.List;
12
+import java.util.Map;
13
+
14
+/**
15
+ * @author weichaochao
16
+ * @Title: SocialServiceI
17
+ * @date 2018/10/23
18
+ */
19
+public interface SocialServiceI {
20
+
21
+	/**
22
+	 * 查看公告详情
23
+	 * @param id
24
+	 * @param orgId
25
+	 * @param userId
26
+	 * @return
27
+	 */
28
+    TpAnnouncement findAnnouncementDetail(Integer id, Integer orgId, Integer userId);
29
+
30
+
31
+	/**
32
+	 * 分页获取公告列表
33
+	 * @param orgId
34
+	 * @param title
35
+	 * @param pageNum
36
+	 * @param pageSize
37
+	 * @return
38
+	 */
39
+	ResponseBean getAnnouncements(Integer orgId, String title, Integer pageNum, Integer pageSize);
40
+}

+ 120
- 0
src/main/java/com/huiju/estateagents/property/service/impl/SocialServiceImpl.java Ver arquivo

1
+package com.huiju.estateagents.property.service.impl;
2
+
3
+import com.alibaba.fastjson.JSONArray;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.google.common.collect.Maps;
8
+import com.huiju.estateagents.base.ResponseBean;
9
+import com.huiju.estateagents.center.taUser.entity.TaUser;
10
+import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
11
+import com.huiju.estateagents.center.taUser.service.ITaUserService;
12
+import com.huiju.estateagents.property.common.Constant;
13
+import com.huiju.estateagents.property.common.UserElement;
14
+import com.huiju.estateagents.property.dao.*;
15
+import com.huiju.estateagents.property.model.*;
16
+import com.huiju.estateagents.property.service.SocialServiceI;
17
+import com.huiju.estateagents.property.vo.TpTicketVO;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.context.ApplicationContext;
20
+import org.springframework.stereotype.Service;
21
+import org.springframework.transaction.annotation.Transactional;
22
+import org.springframework.util.StringUtils;
23
+
24
+import java.io.IOException;
25
+import java.util.*;
26
+import java.util.stream.Collectors;
27
+
28
+/**
29
+ * @author weichaochao
30
+ * @Title: SocialServiceImpl
31
+ * @date 2018/10/23
32
+ */
33
+@Service("SocialService")
34
+@Transactional
35
+public class SocialServiceImpl implements SocialServiceI {
36
+
37
+    @Autowired
38
+    private TpAnnouncementMapper tpAnnouncementMapper;
39
+
40
+    @Autowired
41
+    private TpSocialViewMapper tpSocialViewMapper;
42
+
43
+    @Autowired
44
+    private TdImagesMapper tdImagesMapper;
45
+
46
+    @Override
47
+    @Transactional
48
+    public TpAnnouncement findAnnouncementDetail(Integer id, Integer orgId, Integer userId) {
49
+        //更新此用户的查看次数操作
50
+        Integer allViewNum = updateSocialView(userId, Constant.ANNOUNCEMENT, orgId, id);
51
+        if (null != allViewNum) {
52
+            tpAnnouncementMapper.updateByPrimaryKeySelective(id, allViewNum);
53
+        }
54
+        TpAnnouncement tpAnnouncement = tpAnnouncementMapper.selectByPrimaryKey(id, orgId);
55
+//        tpAnnouncement.setUserName(tpUserMapper.selectByPrimaryKey(tpAnnouncement.getCreateUser()).getUserName());
56
+//        tpAnnouncement.setUserName(tpUserMapper.selectByPrimaryKey(tpAnnouncement.getCreateUser()).getUserName());
57
+
58
+        Map<String, Object> map = Maps.newHashMap();
59
+        map.put("uuid", tpAnnouncement.getId());
60
+        map.put("type", Constant.ANNOUNCEMENT);
61
+        // 查询图片
62
+        List<TdImages> tdImagesList = tdImagesMapper.getByUUIDAndByType(map);
63
+        List<String> imgList = tdImagesList.stream().map(e -> new String(e.getImageUrl())).collect(Collectors.toList());
64
+        tpAnnouncement.setImgList(imgList);
65
+        return tpAnnouncement;
66
+    }
67
+
68
+    /**
69
+     * 分页获取公告列表
70
+     *
71
+     * @param orgId
72
+     * @param title
73
+     * @param pageNum
74
+     * @param pageSize
75
+     * @return
76
+     */
77
+    @Override
78
+    public ResponseBean getAnnouncements(Integer orgId, String title, Integer pageNum, Integer pageSize) {
79
+        ResponseBean responseBean = new ResponseBean();
80
+        Map<String, Object> parameter = Maps.newHashMap();
81
+        //使用分页插件
82
+        Page<TpAnnouncement> page = new Page<>(pageNum, pageSize);
83
+        // 获取数据
84
+        IPage<TpAnnouncement> wxAnnouncementsPage = tpAnnouncementMapper.getWxAnnouncements(page, orgId, title);
85
+        parameter.put("total", wxAnnouncementsPage.getTotal());
86
+        parameter.put("list", wxAnnouncementsPage.getRecords());
87
+        responseBean.addSuccess(parameter);
88
+        return responseBean;
89
+    }
90
+
91
+
92
+
93
+    /**
94
+     * 更新此用户的查看次数操作
95
+     *
96
+     * @param userId
97
+     * @param socialType
98
+     * @param orgId
99
+     * @param uuid
100
+     */
101
+    private Integer updateSocialView(Integer userId, String socialType, Integer orgId, Integer uuid) {
102
+        //检查是否查看过这个帖子
103
+        TpSocialView tpSocialView = new TpSocialView();
104
+        tpSocialView.setTaUserId(userId);
105
+        tpSocialView.setSocialType(socialType);
106
+        tpSocialView.setCommunityId(orgId);
107
+        tpSocialView.setUuid(uuid);
108
+        Integer viewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
109
+
110
+        //查看过的话查看次数加一
111
+        if (viewNum == 0) {
112
+            tpSocialView.setCreateDate(new Date());
113
+            tpSocialViewMapper.insertSelective(tpSocialView);
114
+            tpSocialView.setTaUserId(null);
115
+            Integer allViewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
116
+            return allViewNum;
117
+        }
118
+        return null;
119
+    }
120
+}

+ 26
- 0
src/main/resources/mapper/property/TpAnnouncementMapper.xml Ver arquivo

75
     </set>
75
     </set>
76
     where id = #{id,jdbcType=INTEGER}
76
     where id = #{id,jdbcType=INTEGER}
77
   </update>
77
   </update>
78
+
79
+
80
+  <select id="getWxAnnouncements" resultType="com.huiju.estateagents.property.model.TpAnnouncement">
81
+    SELECT
82
+    a.id,
83
+    a.announcement_title,
84
+    a.announcement_content,
85
+    a.create_date,
86
+    u.user_name as user_name,
87
+    a.sort,
88
+    a.view_count
89
+    FROM
90
+    tp_announcement a
91
+    LEFT JOIN tp_user u ON a.create_user = u.id
92
+    AND u.community_id = #{communityId,jdbcType=INTEGER}
93
+    WHERE
94
+    a.community_id = #{communityId,jdbcType=INTEGER}
95
+    AND ( a.STATUS = 1 OR a.STATUS = 3 )
96
+    <if test="title != null and title != ''">
97
+      and a.announcement_title like concat('%',#{title,jdbcType=VARCHAR},'%')
98
+    </if>
99
+    ORDER BY
100
+    a.sort DESC,
101
+    a.update_date DESC,
102
+    a.create_date DESC
103
+  </select>
78
 </mapper>
104
 </mapper>

+ 128
- 0
src/main/resources/mapper/property/TpSocialViewMapper.xml Ver arquivo

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.huiju.estateagents.property.dao.TpSocialViewMapper" >
4
+  <resultMap id="BaseResultMap" type="com.huiju.estateagents.property.model.TpSocialView" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="community_id" property="communityId" jdbcType="INTEGER" />
7
+    <result column="uuid" property="uuid" jdbcType="INTEGER" />
8
+    <result column="social_type" property="socialType" jdbcType="VARCHAR" />
9
+    <result column="ta_user_id" property="taUserId" jdbcType="INTEGER" />
10
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
11
+    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
12
+  </resultMap>
13
+  <sql id="Base_Column_List" >
14
+    id, community_id, uuid, social_type, ta_user_id, remark, create_date
15
+  </sql>
16
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
17
+    select 
18
+    <include refid="Base_Column_List" />
19
+    from tp_social_view
20
+    where id = #{id,jdbcType=INTEGER}
21
+  </select>
22
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
23
+    delete from tp_social_view
24
+    where id = #{id,jdbcType=INTEGER}
25
+  </delete>
26
+  <insert id="insert" parameterType="com.huiju.estateagents.property.model.TpSocialView" >
27
+    insert into tp_social_view (id, community_id, uuid, 
28
+      social_type, ta_user_id, remark, 
29
+      create_date)
30
+    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{uuid,jdbcType=INTEGER}, 
31
+      #{socialType,jdbcType=VARCHAR}, #{taUserId,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, 
32
+      #{createDate,jdbcType=TIMESTAMP})
33
+  </insert>
34
+  <insert id="insertSelective" parameterType="com.huiju.estateagents.property.model.TpSocialView" >
35
+    insert into tp_social_view
36
+    <trim prefix="(" suffix=")" suffixOverrides="," >
37
+      <if test="id != null" >
38
+        id,
39
+      </if>
40
+      <if test="communityId != null" >
41
+        community_id,
42
+      </if>
43
+      <if test="uuid != null" >
44
+        uuid,
45
+      </if>
46
+      <if test="socialType != null" >
47
+        social_type,
48
+      </if>
49
+      <if test="taUserId != null" >
50
+        ta_user_id,
51
+      </if>
52
+      <if test="remark != null" >
53
+        remark,
54
+      </if>
55
+      <if test="createDate != null" >
56
+        create_date,
57
+      </if>
58
+    </trim>
59
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
60
+      <if test="id != null" >
61
+        #{id,jdbcType=INTEGER},
62
+      </if>
63
+      <if test="communityId != null" >
64
+        #{communityId,jdbcType=INTEGER},
65
+      </if>
66
+      <if test="uuid != null" >
67
+        #{uuid,jdbcType=INTEGER},
68
+      </if>
69
+      <if test="socialType != null" >
70
+        #{socialType,jdbcType=VARCHAR},
71
+      </if>
72
+      <if test="taUserId != null" >
73
+        #{taUserId,jdbcType=INTEGER},
74
+      </if>
75
+      <if test="remark != null" >
76
+        #{remark,jdbcType=VARCHAR},
77
+      </if>
78
+      <if test="createDate != null" >
79
+        #{createDate,jdbcType=TIMESTAMP},
80
+      </if>
81
+    </trim>
82
+  </insert>
83
+  <update id="updateByPrimaryKeySelective" parameterType="com.huiju.estateagents.property.model.TpSocialView" >
84
+    update tp_social_view
85
+    <set >
86
+      <if test="communityId != null" >
87
+        community_id = #{communityId,jdbcType=INTEGER},
88
+      </if>
89
+      <if test="uuid != null" >
90
+        uuid = #{uuid,jdbcType=INTEGER},
91
+      </if>
92
+      <if test="socialType != null" >
93
+        social_type = #{socialType,jdbcType=VARCHAR},
94
+      </if>
95
+      <if test="taUserId != null" >
96
+        ta_user_id = #{taUserId,jdbcType=INTEGER},
97
+      </if>
98
+      <if test="remark != null" >
99
+        remark = #{remark,jdbcType=VARCHAR},
100
+      </if>
101
+      <if test="createDate != null" >
102
+        create_date = #{createDate,jdbcType=TIMESTAMP},
103
+      </if>
104
+    </set>
105
+    where id = #{id,jdbcType=INTEGER}
106
+  </update>
107
+  <update id="updateByPrimaryKey" parameterType="com.huiju.estateagents.property.model.TpSocialView" >
108
+    update tp_social_view
109
+    set community_id = #{communityId,jdbcType=INTEGER},
110
+      uuid = #{uuid,jdbcType=INTEGER},
111
+      social_type = #{socialType,jdbcType=VARCHAR},
112
+      ta_user_id = #{taUserId,jdbcType=INTEGER},
113
+      remark = #{remark,jdbcType=VARCHAR},
114
+      create_date = #{createDate,jdbcType=TIMESTAMP}
115
+    where id = #{id,jdbcType=INTEGER}
116
+  </update>
117
+
118
+  <select id="selectViewNum" resultType="java.lang.Integer" parameterType="com.huiju.estateagents.property.model.TpSocialView">
119
+    select count(*) from tp_social_view
120
+    where 1=1
121
+    <if test="taUserId != null" >
122
+      and ta_user_id = #{taUserId}
123
+    </if>
124
+    and uuid = #{uuid}
125
+    and community_id = #{communityId}
126
+    and social_type = #{socialType}
127
+  </select>
128
+</mapper>