dingxin 6 years ago
parent
commit
b952ae3de1

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/controller/AppointmentController.java View File

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

+ 2
- 2
whole-estate/src/main/java/com/example/wholeestate/controller/CommentController.java View File

73
     @RequestMapping(value = "/comment/add", method = RequestMethod.POST)
73
     @RequestMapping(value = "/comment/add", method = RequestMethod.POST)
74
     @ApiOperation(value = "添加评论", notes = "添加评论")
74
     @ApiOperation(value = "添加评论", notes = "添加评论")
75
     @ApiImplicitParams({
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
     public ResponseBean addComment(@RequestBody String parameter) {
78
     public ResponseBean addComment(@RequestBody String parameter) {
79
         ResponseBean responseBean = new ResponseBean();
79
         ResponseBean responseBean = new ResponseBean();
119
     @RequestMapping(value = "/wx/comment/add/{openid}", method = RequestMethod.POST)
119
     @RequestMapping(value = "/wx/comment/add/{openid}", method = RequestMethod.POST)
120
     @ApiOperation(value = "微信小程序添加评论", notes = "微信小程序添加评论")
120
     @ApiOperation(value = "微信小程序添加评论", notes = "微信小程序添加评论")
121
     @ApiImplicitParams({
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
     public ResponseBean addWxComment(@PathVariable("openid") String openid,@RequestBody String parameter) {
124
     public ResponseBean addWxComment(@PathVariable("openid") String openid,@RequestBody String parameter) {
125
         ResponseBean responseBean = new ResponseBean();
125
         ResponseBean responseBean = new ResponseBean();

+ 6
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Comment.java View File

82
     @TableField(exist = false)
82
     @TableField(exist = false)
83
     private List<Comment> childComment;
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 View File

29
      * @param parameter
29
      * @param parameter
30
      * @return
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 View File

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

+ 3
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/BuildingServiceImpl.java View File

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

+ 63
- 6
whole-estate/src/main/java/com/example/wholeestate/service/impl/CommentServiceImpl.java View File

7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.example.wholeestate.common.resp.ResponseBean;
8
 import com.example.wholeestate.common.resp.ResponseBean;
9
 import com.example.wholeestate.common.uuid.IdGen;
9
 import com.example.wholeestate.common.uuid.IdGen;
10
+import com.example.wholeestate.dao.CommentImgMapper;
10
 import com.example.wholeestate.dao.CommentMapper;
11
 import com.example.wholeestate.dao.CommentMapper;
11
 import com.example.wholeestate.dao.CustomerMapper;
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
 import com.example.wholeestate.service.ICommentService;
14
 import com.example.wholeestate.service.ICommentService;
17
 import org.apache.commons.lang.StringUtils;
15
 import org.apache.commons.lang.StringUtils;
18
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
38
     @Autowired
36
     @Autowired
39
     private CustomerMapper customerMapper;
37
     private CustomerMapper customerMapper;
40
 
38
 
39
+    @Autowired
40
+    private CommentImgMapper commentImgMapper;
41
+
41
     private IdGen idGen = IdGen.get();
42
     private IdGen idGen = IdGen.get();
42
 
43
 
43
     @Override
44
     @Override
44
     public ResponseBean addComment(String parameter) {
45
     public ResponseBean addComment(String parameter) {
45
         ResponseBean responseBean = new ResponseBean();
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
         comment.setCreateDate(LocalDateTime.now());
54
         comment.setCreateDate(LocalDateTime.now());
48
         comment.setStatus(1);
55
         comment.setStatus(1);
49
 
56
 
64
             responseBean.addError("评论失败!");
71
             responseBean.addError("评论失败!");
65
             return responseBean;
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
         responseBean.addSuccess("评论成功!");
88
         responseBean.addSuccess("评论成功!");
68
         return responseBean;
89
         return responseBean;
69
     }
90
     }
80
         commentQueryWrapper.eq("comment_type", commentType);
101
         commentQueryWrapper.eq("comment_type", commentType);
81
         commentQueryWrapper.eq(StringUtils.isNotBlank(mainId),"main_id", mainId);
102
         commentQueryWrapper.eq(StringUtils.isNotBlank(mainId),"main_id", mainId);
82
         IPage<Comment> commentIPage = commentMapper.selectPage(page, commentQueryWrapper);
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
         responseBean.addSuccess(commentIPage);
114
         responseBean.addSuccess(commentIPage);
85
         return responseBean;
115
         return responseBean;
103
             childCommentQuery.eq("parent_id", e.getCommentId());
133
             childCommentQuery.eq("parent_id", e.getCommentId());
104
             List<Comment> comments = commentMapper.selectList(childCommentQuery);
134
             List<Comment> comments = commentMapper.selectList(childCommentQuery);
105
             e.setChildComment(comments);
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
         responseBean.addSuccess(commentIPage);
146
         responseBean.addSuccess(commentIPage);
112
     @Override
150
     @Override
113
     public ResponseBean addWxComment(String openid, String parameter) {
151
     public ResponseBean addWxComment(String openid, String parameter) {
114
         ResponseBean responseBean = new ResponseBean();
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
         comment.setCreateDate(LocalDateTime.now());
160
         comment.setCreateDate(LocalDateTime.now());
117
         comment.setStatus(1);
161
         comment.setStatus(1);
118
 
162
 
134
             responseBean.addError("评论失败!");
178
             responseBean.addError("评论失败!");
135
             return responseBean;
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
         responseBean.addSuccess("评论成功!");
194
         responseBean.addSuccess("评论成功!");
138
         return responseBean;
195
         return responseBean;
139
     }
196
     }