|
@@ -7,12 +7,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
7
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
8
|
8
|
import com.example.wholeestate.common.resp.ResponseBean;
|
9
|
9
|
import com.example.wholeestate.common.uuid.IdGen;
|
|
10
|
+import com.example.wholeestate.dao.CommentImgMapper;
|
10
|
11
|
import com.example.wholeestate.dao.CommentMapper;
|
11
|
12
|
import com.example.wholeestate.dao.CustomerMapper;
|
12
|
|
-import com.example.wholeestate.model.Activity;
|
13
|
|
-import com.example.wholeestate.model.Comment;
|
14
|
|
-import com.example.wholeestate.model.Customer;
|
15
|
|
-import com.example.wholeestate.model.SysUser;
|
|
13
|
+import com.example.wholeestate.model.*;
|
16
|
14
|
import com.example.wholeestate.service.ICommentService;
|
17
|
15
|
import org.apache.commons.lang.StringUtils;
|
18
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -38,12 +36,21 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
38
|
36
|
@Autowired
|
39
|
37
|
private CustomerMapper customerMapper;
|
40
|
38
|
|
|
39
|
+ @Autowired
|
|
40
|
+ private CommentImgMapper commentImgMapper;
|
|
41
|
+
|
41
|
42
|
private IdGen idGen = IdGen.get();
|
42
|
43
|
|
43
|
44
|
@Override
|
44
|
45
|
public ResponseBean addComment(String parameter) {
|
45
|
46
|
ResponseBean responseBean = new ResponseBean();
|
46
|
|
- Comment comment = JSONObject.parseObject(parameter, Comment.class);
|
|
47
|
+
|
|
48
|
+ JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
49
|
+
|
|
50
|
+ // 评论的图片
|
|
51
|
+ String [] imgArray = jsonObject.getJSONArray("imgArray").toArray(new String[]{});
|
|
52
|
+
|
|
53
|
+ Comment comment = jsonObject.toJavaObject(Comment.class);
|
47
|
54
|
comment.setCreateDate(LocalDateTime.now());
|
48
|
55
|
comment.setStatus(1);
|
49
|
56
|
|
|
@@ -64,6 +71,20 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
64
|
71
|
responseBean.addError("评论失败!");
|
65
|
72
|
return responseBean;
|
66
|
73
|
}
|
|
74
|
+
|
|
75
|
+ // 插入评论
|
|
76
|
+ for (int i =0; i < imgArray.length; i++) {
|
|
77
|
+ CommentImg commentImg = new CommentImg();
|
|
78
|
+ commentImg.setImgId(idGen.nextId() + "");
|
|
79
|
+ commentImg.setCommentId(comment.getCommentId());
|
|
80
|
+ commentImg.setImgUrl(imgArray[i]);
|
|
81
|
+ commentImg.setOrderNo(i);
|
|
82
|
+ commentImg.setStatus(1);
|
|
83
|
+
|
|
84
|
+ commentImgMapper.insert(commentImg);
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+
|
67
|
88
|
responseBean.addSuccess("评论成功!");
|
68
|
89
|
return responseBean;
|
69
|
90
|
}
|
|
@@ -80,6 +101,15 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
80
|
101
|
commentQueryWrapper.eq("comment_type", commentType);
|
81
|
102
|
commentQueryWrapper.eq(StringUtils.isNotBlank(mainId),"main_id", mainId);
|
82
|
103
|
IPage<Comment> commentIPage = commentMapper.selectPage(page, commentQueryWrapper);
|
|
104
|
+ commentIPage.getRecords().forEach(e -> {
|
|
105
|
+ // 查询图片
|
|
106
|
+ QueryWrapper<CommentImg> queryCommentImgWrapper = new QueryWrapper<>();
|
|
107
|
+ queryCommentImgWrapper.eq("comment_id", e.getCommentId());
|
|
108
|
+ queryCommentImgWrapper.eq("status", 1);
|
|
109
|
+ queryCommentImgWrapper.orderByAsc("order_no");
|
|
110
|
+ List<CommentImg> commentImgs = commentImgMapper.selectList(queryCommentImgWrapper);
|
|
111
|
+ e.setCommentImgList(commentImgs);
|
|
112
|
+ });
|
83
|
113
|
|
84
|
114
|
responseBean.addSuccess(commentIPage);
|
85
|
115
|
return responseBean;
|
|
@@ -103,6 +133,14 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
103
|
133
|
childCommentQuery.eq("parent_id", e.getCommentId());
|
104
|
134
|
List<Comment> comments = commentMapper.selectList(childCommentQuery);
|
105
|
135
|
e.setChildComment(comments);
|
|
136
|
+
|
|
137
|
+ // 查询图片
|
|
138
|
+ QueryWrapper<CommentImg> queryCommentImgWrapper = new QueryWrapper<>();
|
|
139
|
+ queryCommentImgWrapper.eq("comment_id", e.getCommentId());
|
|
140
|
+ queryCommentImgWrapper.eq("status", 1);
|
|
141
|
+ queryCommentImgWrapper.orderByAsc("order_no");
|
|
142
|
+ List<CommentImg> commentImgs = commentImgMapper.selectList(queryCommentImgWrapper);
|
|
143
|
+ e.setCommentImgList(commentImgs);
|
106
|
144
|
});
|
107
|
145
|
|
108
|
146
|
responseBean.addSuccess(commentIPage);
|
|
@@ -112,7 +150,13 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
112
|
150
|
@Override
|
113
|
151
|
public ResponseBean addWxComment(String openid, String parameter) {
|
114
|
152
|
ResponseBean responseBean = new ResponseBean();
|
115
|
|
- Comment comment = JSONObject.parseObject(parameter, Comment.class);
|
|
153
|
+
|
|
154
|
+ JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
155
|
+
|
|
156
|
+ // 评论的图片
|
|
157
|
+ String [] imgArray = jsonObject.getJSONArray("imgArray").toArray(new String[]{});
|
|
158
|
+
|
|
159
|
+ Comment comment = jsonObject.toJavaObject(Comment.class);
|
116
|
160
|
comment.setCreateDate(LocalDateTime.now());
|
117
|
161
|
comment.setStatus(1);
|
118
|
162
|
|
|
@@ -134,6 +178,19 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
134
|
178
|
responseBean.addError("评论失败!");
|
135
|
179
|
return responseBean;
|
136
|
180
|
}
|
|
181
|
+
|
|
182
|
+ // 插入评论
|
|
183
|
+ for (int i =0; i < imgArray.length; i++) {
|
|
184
|
+ CommentImg commentImg = new CommentImg();
|
|
185
|
+ commentImg.setImgId(idGen.nextId() + "");
|
|
186
|
+ commentImg.setCommentId(comment.getCommentId());
|
|
187
|
+ commentImg.setImgUrl(imgArray[i]);
|
|
188
|
+ commentImg.setOrderNo(i);
|
|
189
|
+ commentImg.setStatus(1);
|
|
190
|
+
|
|
191
|
+ commentImgMapper.insert(commentImg);
|
|
192
|
+ }
|
|
193
|
+
|
137
|
194
|
responseBean.addSuccess("评论成功!");
|
138
|
195
|
return responseBean;
|
139
|
196
|
}
|