NotSpeakController.java
5.26 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
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSON;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.bean.SessionUser;
import com.cnlive.shenhe.dto.NotSpeakDTO;
import com.cnlive.shenhe.entity.ShyNotspeak;
import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.entity.ShyUsers;
import com.cnlive.shenhe.service.NotspeakService;
import com.cnlive.shenhe.service.SitesService;
import com.cnlive.shenhe.service.UsersService;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.List;
/**
* @author Administrator
*/
@Controller
@RequestMapping("/notSpeak")
public class NotSpeakController extends BaseController {
private static Logger logger = LoggerFactory.getLogger(NotSpeakController.class);
@Autowired
NotspeakService notSpeakService;
@Autowired
UsersService usersService;
@Autowired
SitesService sitesService;
/**
* 禁言列表页
*
* @param notSpeakDTO
* @return
*/
@GetMapping("/page")
public String getPage(Model model, NotSpeakDTO notSpeakDTO, HttpSession session) {
logger.info("列表请求参数:{}", JSON.toJSONString(notSpeakDTO));
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
if (CommonUtils.isNull(sessionUser)) {
return "redirect:/users/login";
}
String userId = sessionUser.getUserId();
notSpeakDTO.setUserId(userId);
PageInfo<ShyNotspeak> shyNotspeakPage = notSpeakService.getPage(notSpeakDTO);
List<ShyNotspeak> list = shyNotspeakPage.getList();
if (!list.isEmpty()) {
for (ShyNotspeak notspeak : list) {
String updater = CommonUtils.isEmpty(notspeak.getUpdater()) || "null".equals(notspeak.getUpdater()) ? "无" : notspeak.getUpdater();
String auditorId = notspeak.getAuditor();
if (CommonUtils.isNotEmpty(auditorId)) {
ShyUsers user = new ShyUsers();
user.setUser_id(auditorId);
user = usersService.select(user);
if (CommonUtils.isNotNull(user)) {
String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail()) ? "" : user.getEmail();
updater = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername();
}
}
notspeak.setUpdater(updater);
if (null != notspeak.getSp_id()) {
//显示spid简称
ShySites shySites = sitesService.findspidDescByspid(notspeak.getSp_id());
if (CommonUtils.isNotNull(shySites)) {
notspeak.setSpid_desc(shySites.getName());
}
} else {
notspeak.setSpid_desc("sp无法显示");
}
}
}
model.addAttribute("pageSize", notSpeakDTO.getPageSize());
model.addAttribute("notspeakPage", shyNotspeakPage);
model.addAttribute("User_id", notSpeakDTO.getUser_id());
model.addAttribute("User_name", notSpeakDTO.getUser_name());
return "page/notspeak.html";
}
/**
* 禁言(通过评论进入)
*
* @param commentId
* @param
* @param time
* @param session
* @return
*/
@PostMapping("/notSpeakByComment")
@ResponseBody
public ResponseBean notSpeakByComment(Integer commentId, Integer time, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
String userId = sessionUser.getUserId();
return notSpeakService.notSpeakByComment(commentId, time, userId);
}
/**
* 查询禁言状态(通过评论进入)
*
* @param commentId
* @param
* @param
* @param session
* @return
*/
@PostMapping("/querySpeakState")
@ResponseBody
public ResponseBean querySpeakState(Integer commentId, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
String userId = sessionUser.getUserId();
return notSpeakService.querySpeakState(commentId, userId);
}
/**
* 禁言(通过禁言管理进入)
*
* @param notSpeakId
* @param type
* @param time
* @param session
* @return
*/
@PostMapping("/speak")
@ResponseBody
public ResponseBean speak(Integer notSpeakId, Integer type, Integer time, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
String userId = sessionUser.getUserId();
return notSpeakService.speak(notSpeakId, type, time, userId);
}
}