dingxin 6 年前
父节点
当前提交
67d3f7205c

+ 10
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/CommentController.java 查看文件

@@ -127,4 +127,14 @@ public class CommentController extends BaseController {
127 127
         return responseBean;
128 128
     }
129 129
 
130
+
131
+    @RequestMapping(value = "/comment/{commentId}", method = RequestMethod.GET)
132
+    @ApiOperation(value = "获取评论详情", notes = "获取评论详情")
133
+    @ApiImplicitParams({
134
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "commentId",value = "评论id")
135
+    })
136
+    public ResponseBean selectCommentInfoId(@PathVariable("commentId") String commentId) {
137
+        ResponseBean  responseBean = iCommentService.selectCommentInfoId(commentId);
138
+        return responseBean;
139
+    }
130 140
 }

+ 1
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/WxUserController.java 查看文件

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
14 14
 @RequestMapping("/")
15 15
 @Api(value = "微信小程序 用户 API", description = "微信小程序 用户 API")
16 16
 public class WxUserController extends BaseController {
17
+    
17 18
 
18 19
     @Autowired
19 20
     private ICustomerService iCustomerService;

+ 18
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/CommentMapper.java 查看文件

@@ -1,7 +1,12 @@
1 1
 package com.example.wholeestate.dao;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4 6
 import com.example.wholeestate.model.Comment;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.Map;
5 10
 
6 11
 /**
7 12
  * <p>
@@ -12,5 +17,18 @@ import com.example.wholeestate.model.Comment;
12 17
  * @since 2019-03-20
13 18
  */
14 19
 public interface CommentMapper extends BaseMapper<Comment> {
20
+    /**
21
+     * 根据 类型 查询 评论列表
22
+     * @param page
23
+     * @param comment_type
24
+     * @return
25
+     */
26
+    IPage<Map<String, Object>> selectCommentListByType(Page page, @Param("comment_type") String comment_type);
15 27
 
28
+    /**
29
+     * 根据 评论id查询 评论信息
30
+     * @param commentId
31
+     * @return
32
+     */
33
+    Map<String, Object> selectCommentInfoId(@Param("commentId") String commentId);
16 34
 }

+ 8
- 0
whole-estate/src/main/java/com/example/wholeestate/service/ICommentService.java 查看文件

@@ -49,4 +49,12 @@ public interface ICommentService extends IService<Comment> {
49 49
      * @return
50 50
      */
51 51
     ResponseBean addWxComment(String openid,String parameter);
52
+
53
+    /**
54
+     * 根据 评论评论id 查询
55
+     * @param commentId
56
+     * @return
57
+     */
58
+    ResponseBean selectCommentInfoId(String commentId);
59
+
52 60
 }

+ 42
- 6
whole-estate/src/main/java/com/example/wholeestate/service/impl/CommentServiceImpl.java 查看文件

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
18 18
 
19 19
 import java.time.LocalDateTime;
20 20
 import java.util.List;
21
+import java.util.Map;
21 22
 
22 23
 /**
23 24
  * <p>
@@ -97,24 +98,58 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
97 98
         page.setCurrent(pageNum);
98 99
         page.setSize(pageSize);
99 100
 
100
-        QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<>();
101
-        commentQueryWrapper.eq("comment_type", commentType);
102
-        commentQueryWrapper.eq(StringUtils.isNotBlank(mainId),"main_id", mainId);
103
-        IPage<Comment> commentIPage = commentMapper.selectPage(page, commentQueryWrapper);
101
+//        QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<>();
102
+//        commentQueryWrapper.eq("comment_type", commentType);
103
+//        commentQueryWrapper.eq(StringUtils.isNotBlank(mainId),"main_id", mainId);
104
+        IPage<Map<String, Object>> commentIPage = commentMapper.selectCommentListByType(page, commentType);
105
+//                .selectPage(page, commentQueryWrapper);
104 106
         commentIPage.getRecords().forEach(e -> {
105 107
             // 查询图片
106 108
             QueryWrapper<CommentImg> queryCommentImgWrapper = new QueryWrapper<>();
107
-            queryCommentImgWrapper.eq("comment_id", e.getCommentId());
109
+            queryCommentImgWrapper.eq("comment_id", e.get("comment_id"));
108 110
             queryCommentImgWrapper.eq("status", 1);
109 111
             queryCommentImgWrapper.orderByAsc("order_no");
110 112
             List<CommentImg> commentImgs = commentImgMapper.selectList(queryCommentImgWrapper);
111
-            e.setCommentImgList(commentImgs);
113
+            e.put("img", commentImgs);
112 114
         });
113 115
 
114 116
         responseBean.addSuccess(commentIPage);
115 117
         return responseBean;
116 118
     }
117 119
 
120
+    @Override
121
+    public ResponseBean selectCommentInfoId(String commentId) {
122
+        ResponseBean responseBean = new ResponseBean();
123
+
124
+        Map<String, Object> comment = commentMapper.selectCommentInfoId(commentId);
125
+
126
+            // 查询图片
127
+        QueryWrapper<CommentImg> queryCommentImgWrapper = new QueryWrapper<>();
128
+        queryCommentImgWrapper.eq("comment_id", comment.get("comment_id"));
129
+        queryCommentImgWrapper.eq("status", 1);
130
+        queryCommentImgWrapper.orderByAsc("order_no");
131
+        List<CommentImg> commentImgs = commentImgMapper.selectList(queryCommentImgWrapper);
132
+        comment.put("img", commentImgs);
133
+
134
+        QueryWrapper<Comment> childCommentQuery = new QueryWrapper<>();
135
+        childCommentQuery.eq("parent_id", comment.get("comment_id"));
136
+        childCommentQuery.eq("status", 1);
137
+        List<Comment> childComments = commentMapper.selectList(childCommentQuery);
138
+        childComments.forEach(e -> {
139
+            // 查询图片
140
+            QueryWrapper<CommentImg> queryChildCommentImgWrapper = new QueryWrapper<>();
141
+            queryChildCommentImgWrapper.eq("comment_id", e.getCommentId());
142
+            queryChildCommentImgWrapper.eq("status", 1);
143
+            queryChildCommentImgWrapper.orderByAsc("order_no");
144
+            List<CommentImg> childCommentImgs = commentImgMapper.selectList(queryChildCommentImgWrapper);
145
+            e.setCommentImgList(childCommentImgs);
146
+        });
147
+        comment.put("childComment", childComments);
148
+
149
+        responseBean.addSuccess(comment);
150
+        return responseBean;
151
+    }
152
+
118 153
     @Override
119 154
     public ResponseBean getWxCommentList(String commentType, String mainId, Integer pageNum, Integer pageSize) {
120 155
         ResponseBean responseBean = new ResponseBean();
@@ -131,6 +166,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
131 166
         records.forEach(e -> {
132 167
             QueryWrapper<Comment> childCommentQuery = new QueryWrapper<>();
133 168
             childCommentQuery.eq("parent_id", e.getCommentId());
169
+            childCommentQuery.eq("status", 1);
134 170
             List<Comment> comments = commentMapper.selectList(childCommentQuery);
135 171
             e.setChildComment(comments);
136 172
 

+ 34
- 0
whole-estate/src/main/resources/mapper/CommentMapper.xml 查看文件

@@ -0,0 +1,34 @@
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.example.wholeestate.dao.CommentMapper">
4
+    <select id="selectCommentListByType" resultType="map">
5
+        select a.*
6
+        <if test="comment_type != null and comment_type == 'activity'">
7
+            ,b.title,b.`desc`,b.activity_date as show_date
8
+            from ta_comment a inner join ta_activity b
9
+            on a.comment_type='activity' and a.main_id=b.activity_id
10
+        </if>
11
+        <if test="comment_type != null and comment_type == 'dynamic'">
12
+            ,b.title,b.`desc`,b.publish_date as show_date
13
+            from ta_comment a inner join ta_building_dynamic b
14
+            on a.comment_type='dynamic' and a.main_id=b.dynamic_id
15
+        </if>
16
+        <if test="comment_type == null || comment_type == ''">
17
+            from ta_comment a
18
+        </if>
19
+        <where>
20
+            a.status > -1 and (a.parent_id = '' or a.parent_id is null)
21
+        </where>
22
+    </select>
23
+
24
+    <select id="selectCommentInfoId" resultType="map">
25
+        select a.*,(case when a.comment_type='activity' then b.title else c.title end) as title,
26
+        (case when a.comment_type='activity' then b.desc else c.desc end) as `desc`
27
+         from ta_comment a left join ta_activity b on a.comment_type='activity' and a.main_id = b.activity_id
28
+        left join ta_building_dynamic c on a.comment_type='dynamic' and a.main_id=c.dynamic_id
29
+        <where>
30
+            a.status > -1 and a.comment_id=#{commentId}
31
+        </where>
32
+    </select>
33
+
34
+</mapper>