dingxin 6 年 前
コミット
b952ae3de1

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/controller/AppointmentController.java ファイルの表示

@@ -48,7 +48,7 @@ public class AppointmentController extends BaseController {
48 48
     })
49 49
     public ResponseBean openidAppointementList(@PathVariable("openid") String openid, @RequestBody String parameter) {
50 50
         ResponseBean responseBean = new ResponseBean();
51
-        responseBean = iAppointmentService.addAppointment(openid, parameter);
51
+        responseBean = iAppointmentService.addWxAppointment(openid, parameter);
52 52
         return responseBean;
53 53
     }
54 54
 

+ 2
- 2
whole-estate/src/main/java/com/example/wholeestate/controller/CommentController.java ファイルの表示

@@ -73,7 +73,7 @@ public class CommentController extends BaseController {
73 73
     @RequestMapping(value = "/comment/add", method = RequestMethod.POST)
74 74
     @ApiOperation(value = "添加评论", notes = "添加评论")
75 75
     @ApiImplicitParams({
76
-            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "customerId用户ID;commentType评论类型;mainId评论类型;parentId父级;commentContent评论内容")
76
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "customerId用户ID;commentType评论类型;mainId评论类型;parentId父级;commentContent评论内容;imgArray图片URL数组")
77 77
     })
78 78
     public ResponseBean addComment(@RequestBody String parameter) {
79 79
         ResponseBean responseBean = new ResponseBean();
@@ -119,7 +119,7 @@ public class CommentController extends BaseController {
119 119
     @RequestMapping(value = "/wx/comment/add/{openid}", method = RequestMethod.POST)
120 120
     @ApiOperation(value = "微信小程序添加评论", notes = "微信小程序添加评论")
121 121
     @ApiImplicitParams({
122
-            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "commentType评论类型;mainId评论类型;parentId父级;commentContent评论内容")
122
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "commentType评论类型;mainId评论类型;parentId父级;commentContent评论内容;imgArray图片URL数组")
123 123
     })
124 124
     public ResponseBean addWxComment(@PathVariable("openid") String openid,@RequestBody String parameter) {
125 125
         ResponseBean responseBean = new ResponseBean();

+ 6
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Comment.java ファイルの表示

@@ -82,4 +82,10 @@ public class Comment implements Serializable {
82 82
     @TableField(exist = false)
83 83
     private List<Comment> childComment;
84 84
 
85
+    /**
86
+     * 评论的图片
87
+     */
88
+    @TableField(exist = false)
89
+    private List<CommentImg> commentImgList;
90
+
85 91
 }

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/service/IAppointmentService.java ファイルの表示

@@ -29,6 +29,6 @@ public interface IAppointmentService extends IService<Appointment> {
29 29
      * @param parameter
30 30
      * @return
31 31
      */
32
-    ResponseBean addAppointment(String openid, String parameter);
32
+    ResponseBean addWxAppointment(String openid, String parameter);
33 33
 
34 34
 }

+ 2
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/AppointmentServiceImpl.java ファイルの表示

@@ -49,7 +49,7 @@ public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appoi
49 49
     }
50 50
 
51 51
     @Override
52
-    public ResponseBean addAppointment(String openid, String parameter) {
52
+    public ResponseBean addWxAppointment(String openid, String parameter) {
53 53
         ResponseBean responseBean = new ResponseBean();
54 54
         Appointment appointment = JSONObject.parseObject(parameter, Appointment.class);
55 55
 
@@ -59,6 +59,7 @@ public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appoi
59 59
 
60 60
         appointment.setCustomerId(customer.getCustomerId());
61 61
         appointment.setAppointmentId(idGen.nextId() + "");
62
+        appointment.setStatus(1);
62 63
         appointmentMapper.insert(appointment);
63 64
         responseBean.addSuccess("操作成功!");
64 65
         return responseBean;

+ 3
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/BuildingServiceImpl.java ファイルの表示

@@ -261,7 +261,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
261 261
          //插入户型图片
262 262
         for (BuildingImg img:buildingImgs){
263 263
             BuildingImg Images = new BuildingImg();
264
-            Images.setImgId(img.getBuildingId());
264
+            Images.setImgId(idGen.nextId() + "");
265 265
             Images.setBuildingId(building.getBuildingId());
266 266
             Images.setImgType(img.getImgType());
267 267
             Images.setUrl(img.getUrl());
@@ -278,6 +278,8 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
278 278
 
279 279
         }
280 280
         building.setStatus(1);
281
+        building.setCreateDate(LocalDateTime.now());
282
+        building.setApartmentId(idGen.nextId() + "");
281 283
         buildingApartmentMapper.insert(building);
282 284
         responseBean.addSuccess("成功");
283 285
         return responseBean;

+ 63
- 6
whole-estate/src/main/java/com/example/wholeestate/service/impl/CommentServiceImpl.java ファイルの表示

@@ -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
     }