CommentsController.java
5.19 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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.entity.AcpComments;
import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonConst;
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 java.util.Arrays;
import java.util.List;
/**
* @Auther: chenhao
* @Date: 2018/12/4 17:30
* @Description:评论内容送审接口
*/
@Controller
@RequestMapping("/comments")
public class CommentsController {
@Autowired
AuditPass Pass;
@Autowired
CommentsServiceImpl commentsService;
/**
* 评论送审接口
* @param json
* @return
*/
@PostMapping("/import")
@ResponseBody
public ResponseBean impotComment(@RequestBody JSONObject json){
AcpComments acpComments = new AcpComments();
ShySites shySites = new ShySites();
acpComments.setState(CommonConst.AUDIT_INTT);
//判断是否白名单
shySites.setSpid(json.getInteger("spId"));
List<ShySites> shySitesList = commentsService.getBusiness(shySites);
if(!shySitesList.isEmpty()){
if(CommonUtils.isNotEmpty(shySitesList.get(0).getWrite_business())){
String write_business = shySitesList.get(0).getWrite_business();
String[] business = write_business.split(",");
List<String> asList = Arrays.asList(business);
if(asList.contains(CommonConst.BUSINESS_COMMENT+"")){
acpComments.setState(CommonConst.AUDIT_SUCCESS);
//封装json数据传参进行回调
JSONObject json1 = new JSONObject();
json1.put("activity_id",json.getString("activityId"));
json1.put("state",CommonConst.AUDIT_SUCCESS);
json1.put("attr_tags","");
json1.put("msg","");
Pass.commentPass(json1);
}else {
acpComments.setState(CommonConst.AUDIT_INTT);
}
}
}
//封装数据入库
acpComments.setProgram_id(json.getInteger("programId"));
acpComments.setComment_original_url(json.getString("originalUrl"));
acpComments.setComment_title(json.getString("commentTitle"));
acpComments.setComment_user_id(json.getInteger("commentUserId"));
acpComments.setComment_user_name(json.getString("commentUserName"));
acpComments.setComment_user_avatar(json.getString("commentUserAvatar"));
acpComments.setComment_user_ip(json.getString("commentUserIP"));
acpComments.setComment_content(json.getString("commentContent"));
acpComments.setComment_time(json.getDate("commentTime"));
acpComments.setSpid(json.getInteger("spId"));
acpComments.setApp_id(json.getString("appId"));
acpComments.setPlatform(json.getString("platform"));
acpComments.setActivity_id(json.getString("activityId"));
acpComments.setIs_hot(json.getBoolean("priority"));
acpComments.setCallback(json.getString("callback"));
int i = commentsService.impotComments(acpComments);
if(i>0){
return new ResponseBean(ErrorEnum.SUCCESS);
}else {
return new ResponseBean(ErrorEnum.ERROR);
}
}
/**
* 评论修改状态接口
* @param json
* @return
*/
@PostMapping("/shenheComment")
@ResponseBody
public ResponseBean shenheInfo(@RequestBody JSONObject json){
Pass.commentPass(json);
int i = commentsService.updateComment(json);
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("/table")
@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){
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);
}
/**
* 评论查看接口
* @param id
* @return
*/
@RequestMapping("/Details")
@ResponseBody
public Object getDetailsComments(Integer id){
return commentsService.getDetailsComment(id);
}
}