|
@@ -2,6 +2,8 @@ package com.example.wholeestate.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
4
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
6
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
5
|
7
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
6
|
8
|
import com.example.wholeestate.common.resp.ResponseBean;
|
7
|
9
|
import com.example.wholeestate.dao.CommentMapper;
|
|
@@ -35,7 +37,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
35
|
37
|
private CustomerMapper customerMapper;
|
36
|
38
|
|
37
|
39
|
@Override
|
38
|
|
- public ResponseBean addComment(SysUser user, String parameter) {
|
|
40
|
+ public ResponseBean addComment(String parameter) {
|
39
|
41
|
ResponseBean responseBean = new ResponseBean();
|
40
|
42
|
Comment comment = JSONObject.parseObject(parameter, Comment.class);
|
41
|
43
|
comment.setCreateDate(LocalDateTime.now());
|
|
@@ -45,10 +47,13 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
45
|
47
|
customerQueryWrapper.eq("customer_id", comment.getCustomerId());
|
46
|
48
|
Customer customer = customerMapper.selectOne(customerQueryWrapper);
|
47
|
49
|
if (null == customer) {
|
48
|
|
- responseBean.addError("用户不存在!");
|
|
50
|
+ responseBean.addError("评论用户不存在!");
|
49
|
51
|
return responseBean;
|
50
|
52
|
}
|
51
|
53
|
|
|
54
|
+ comment.setCustomerName(customer.getCustomerName());
|
|
55
|
+ comment.setAvatar(customer.getAvatar());
|
|
56
|
+
|
52
|
57
|
int insert = commentMapper.insert(comment);
|
53
|
58
|
if (insert <= 0) {
|
54
|
59
|
responseBean.addError("评论失败!");
|
|
@@ -57,4 +62,21 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
57
|
62
|
responseBean.addSuccess("评论成功!");
|
58
|
63
|
return responseBean;
|
59
|
64
|
}
|
|
65
|
+
|
|
66
|
+ @Override
|
|
67
|
+ public ResponseBean getCommentList(String commentType, String mainId, Integer pageNum, Integer pageSize) {
|
|
68
|
+ ResponseBean responseBean = new ResponseBean();
|
|
69
|
+
|
|
70
|
+ Page<Comment> page = new Page<>();
|
|
71
|
+ page.setCurrent(pageNum);
|
|
72
|
+ page.setSize(pageSize);
|
|
73
|
+
|
|
74
|
+ QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<>();
|
|
75
|
+ commentQueryWrapper.eq("comment_type", commentType);
|
|
76
|
+ commentQueryWrapper.eq("main_id", mainId);
|
|
77
|
+ IPage<Comment> commentIPage = commentMapper.selectPage(page, commentQueryWrapper);
|
|
78
|
+
|
|
79
|
+ responseBean.addSuccess(commentIPage);
|
|
80
|
+ return responseBean;
|
|
81
|
+ }
|
60
|
82
|
}
|