CommentsController.java
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.bean.SessionUser;
import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
@Controller
@RequestMapping("/comments")
public class CommentsController {
@Autowired
AuditPass Pass;
@Autowired
CommentsServiceImpl commentsService;
/**
* 评论修改状态接口
*
* @param json
* @return
*/
@PostMapping("/shenheComment")
@ResponseBody
public ResponseBean shenheInfo(@RequestBody JSONObject json, Integer id, HttpSession session) {
JSONObject result = Pass.commentPass(json);
Integer code = result.getInteger("errorCode");
if (code != 0) {
return new ResponseBean(code, result.getString("errorMessage"));
}
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
String userId = sessionUser.getUserId();
int i = commentsService.updateComment(json, id, userId);
if (i == 0) {
return new ResponseBean(ErrorEnum.ERROR);
} else {
return new ResponseBean(ErrorEnum.SUCCESS);
}
}
/**
* 评论列表页
*
* @param activity_id
* @param content
* @param is_hot
* @param start_date
* @param end_date
* @param state
* @param auditor
* @param page
* @param pageSize
* @param orderByClause
* @return
*/
@RequestMapping("/page")
@ResponseBody
public Object getListComments(String activity_id, String content, Integer is_hot, String start_date, String end_date, Integer state, String auditor, Integer page, Integer pageSize, String orderByClause, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
Integer spid = sessionUser.getSpid();
if (CommonUtils.isNull(page)) page = 1;
if (CommonUtils.isNull(pageSize)) pageSize = 10;
return commentsService.getListComments(activity_id, content, is_hot, start_date, end_date, state, auditor, page, pageSize, orderByClause, spid);
}
/**
* 评论查看接口
*
* @param id
* @return
*/
@RequestMapping("/details")
@ResponseBody
public Object getDetailsComments(Integer id) {
return commentsService.getDetailsComment(id);
}
}