CommentController.java
5.81 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package com.server.web.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.server.shiro.persistent.bean.SysUser;
import com.server.utils.DateUtils;
import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyCommentMapper;
import com.server.web.common.mapper.TKzyCourseMapper;
import com.server.web.common.model.PageModel;
import com.server.web.common.model.TBaseSecondClass;
import com.server.web.common.model.TKzyComment;
import com.server.web.common.model.TKzyCourse;
import com.server.web.common.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 评论管理
*/
@RestController
@RequestMapping(BaseController.OSS_NAMESPACE + "/comment")
public class CommentController extends BaseController {
@Autowired
private TKzyCommentMapper commentMapper;
/**
* 课程评论列表
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping(path = "/commentCourseList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map commentList(Long id,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
try {
Map paramMap = new HashMap<>();
paramMap.put("id",id);
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.commentCourseList",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 资讯评论列表
* @param id
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping(path = "/commentInformationList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map commentInformationList(Long id,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
try {
Map paramMap = new HashMap<>();
paramMap.put("id",id);
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.commentInformationList",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 删除评论
* @param id
* @return
*/
@ResponseBody
@RequestMapping(path = "/deleteComment", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map deleteComment(@RequestParam long id) {
try {
TKzyComment comment = new TKzyComment();
comment.setId(id);
comment.setIsDelete(1);
commentMapper.updateByPrimaryKeySelective(comment);
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 审核评论
* @param id
* @param status
* @return
*/
@ResponseBody
@RequestMapping(path = "/authComment", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map authComment(@RequestParam long id,Integer status) {
try {
TKzyComment comment = commentMapper.selectByPrimaryKey(id);
if(comment.getAuthStatus()!=1){
return error("0","评论已审核","评论已审核");
}
comment.setId(id);
comment.setAuthDt(new Date());
comment.setAuthStatus(status);
commentMapper.updateByPrimaryKeySelective(comment);
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 评论列表
* @param pageNo
* @param pageSize
* @param authStatus
* @param name
* @return
*/
@ResponseBody
@RequestMapping(path = "/queryCommentList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map queryCommentList(@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize,
@RequestParam(defaultValue ="-1")Integer authStatus,@RequestParam(defaultValue ="")String name) {
try {
Map paramMap = new HashMap<>();
if(authStatus!=-1){
paramMap.put("authStatus",authStatus);
}
if(!("").equals(name)){
paramMap.put("name","%"+name+"%");
}
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCommentList",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
}