Commit 7447828e1c28366551d8d7a28d81a7e861959373

Authored by liwei2917
1 parent bd56fe9d

修改禁言管理

src/main/java/com/cnlive/shenhe/controller/NotSpeakController.java
@@ -103,9 +103,6 @@ public class NotSpeakController extends BaseController { @@ -103,9 +103,6 @@ public class NotSpeakController extends BaseController {
103 } 103 }
104 } 104 }
105 } 105 }
106 - /* 获取参数值给前台 用来判断是否需要把查看显示出来 state recive*/  
107 - String state1 = state == null ? "" : state.toString();  
108 - model.addAttribute("state1", state1);  
109 model.addAttribute("pageSize", pageSize); 106 model.addAttribute("pageSize", pageSize);
110 model.addAttribute("notspeakPage", shyNotspeakPage); 107 model.addAttribute("notspeakPage", shyNotspeakPage);
111 return "page/notspeak.html"; 108 return "page/notspeak.html";
@@ -129,6 +126,22 @@ public class NotSpeakController extends BaseController { @@ -129,6 +126,22 @@ public class NotSpeakController extends BaseController {
129 return success; 126 return success;
130 } 127 }
131 /** 128 /**
  129 + * 查询禁言状态(通过评论进入)
  130 + * @param commentId
  131 + * @param type
  132 + * @param time
  133 + * @param session
  134 + * @return
  135 + */
  136 + @PostMapping("/querySpeakState")
  137 + @ResponseBody
  138 + public ResponseBean querySpeakState(Integer commentId, HttpSession session) {
  139 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  140 + String userId = sessionUser.getUserId();
  141 + ResponseBean success = notSpeakService.querySpeakState(commentId,userId);
  142 + return success;
  143 + }
  144 + /**
132 * 禁言(通过禁言管理进入) 145 * 禁言(通过禁言管理进入)
133 * @param notSpeakId 146 * @param notSpeakId
134 * @param type 147 * @param type
src/main/java/com/cnlive/shenhe/controller/TopicController.java
@@ -131,7 +131,7 @@ public class TopicController extends BaseController { @@ -131,7 +131,7 @@ public class TopicController extends BaseController {
131 topic.setSp_desc(shySites.getName()); 131 topic.setSp_desc(shySites.getName());
132 } 132 }
133 }else{ 133 }else{
134 - topic.setSp_desc("sp_id未收到"); 134 + topic.setSp_desc("sp无法显示");
135 } 135 }
136 } 136 }
137 } 137 }
src/main/java/com/cnlive/shenhe/job/NotSpeakJob.java 0 → 100644
  1 +package com.cnlive.shenhe.job;
  2 +
  3 +import com.cnlive.shenhe.bean.ResponseBean;
  4 +import com.cnlive.shenhe.entity.ShyComments;
  5 +import com.cnlive.shenhe.entity.ShyNotspeak;
  6 +import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
  7 +import com.cnlive.shenhe.serviceImpl.NotspeakServiceImpl;
  8 +import com.cnlive.shenhe.serviceImpl.SitesServiceImpl;
  9 +import com.cnlive.shenhe.serviceImpl.UsersServiceImpl;
  10 +import com.cnlive.shenhe.utils.AuditPass;
  11 +import com.cnlive.shenhe.utils.CommonConst;
  12 +import com.cnlive.shenhe.utils.CommonUtils;
  13 +
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.scheduling.annotation.Scheduled;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.util.List;
  21 +
  22 +@Component
  23 +public class NotSpeakJob {
  24 + private static Logger logger = LoggerFactory.getLogger(NotSpeakJob.class);
  25 + @Autowired
  26 + SitesServiceImpl sitesService;
  27 + @Autowired
  28 + AuditPass Pass;
  29 + @Autowired
  30 + CommentsServiceImpl commentsService;
  31 +
  32 + @Autowired
  33 + UsersServiceImpl usersService;
  34 +
  35 + @Autowired
  36 + NotspeakServiceImpl notSpeakService;
  37 +
  38 +
  39 + /**
  40 + * 自动解除禁言
  41 + */
  42 + @Scheduled(cron="0 0/1 * * * ? ")//每分钟一次
  43 + public void autoRetReceive() {
  44 + List<ShyNotspeak> shyNotspeakList = notSpeakService.getNotSpeakByTime();
  45 + if (shyNotspeakList.size() > 0) {
  46 + for (ShyNotspeak shyNotspeak : shyNotspeakList) {
  47 + logger.info("自动解除禁言的的speak_id:"+shyNotspeak.getId());
  48 + notSpeakService.speak(shyNotspeak.getId(), CommonConst.SPEAK_YES, 0, null);
  49 + }
  50 + }
  51 + }
  52 +
  53 +
  54 +
  55 +}
src/main/java/com/cnlive/shenhe/serviceImpl/NotspeakServiceImpl.java
@@ -153,6 +153,19 @@ public class NotspeakServiceImpl { @@ -153,6 +153,19 @@ public class NotspeakServiceImpl {
153 } 153 }
154 return new ResponseBean(); 154 return new ResponseBean();
155 } 155 }
  156 +
  157 + public ResponseBean querySpeakState(Integer commentId, String userId) {
  158 + ShyComments comment = shyCommentsMapper.selectByPrimaryKey(commentId);
  159 + ShyNotspeak shyNotspeak=new ShyNotspeak();
  160 + shyNotspeak.setUser_id(comment.getComment_user_id());
  161 + shyNotspeak.setState(CommonConst.SPEAK_NOT);
  162 + List<ShyNotspeak> shyNotspeakList = findshyNotspeak(shyNotspeak);
  163 + if(shyNotspeakList.size()>0){
  164 + shyNotspeak =shyNotspeakList.get(0);
  165 + return new ResponseBean(500,"当前用户已被禁言,禁言剩余时长:"+(shyNotspeak.getEnd_time().getTime()-new Date().getTime())/(1000*60)+"分钟,解禁时间:"+CommonUtils.formatDate(shyNotspeak.getEnd_time(), "yyyy-MM-dd HH:mm:ss"));
  166 + }
  167 + return new ResponseBean();
  168 + }
156 public ResponseBean speak(Integer notSpeakId, Integer type,Integer time, String userId) { 169 public ResponseBean speak(Integer notSpeakId, Integer type,Integer time, String userId) {
157 ResponseBean success; 170 ResponseBean success;
158 ShyNotspeak shyNotspeak=selectByPrimaryKey(notSpeakId); 171 ShyNotspeak shyNotspeak=selectByPrimaryKey(notSpeakId);
@@ -192,6 +205,9 @@ public class NotspeakServiceImpl { @@ -192,6 +205,9 @@ public class NotspeakServiceImpl {
192 if(CommonUtils.isNotEmpty(userId)){ 205 if(CommonUtils.isNotEmpty(userId)){
193 shyNotspeak.setAuditor(userId); 206 shyNotspeak.setAuditor(userId);
194 shyNotspeak.setUpdater(""); 207 shyNotspeak.setUpdater("");
  208 + }else{
  209 + shyNotspeak.setAuditor(null);
  210 + shyNotspeak.setUpdater("自动解除");
195 } 211 }
196 shyNotspeak.setUpdated_at(CommonUtils.getCurrentTime()); 212 shyNotspeak.setUpdated_at(CommonUtils.getCurrentTime());
197 shyNotspeak.setMsg(shyNotspeak.getMsg()+"\n"+msg); 213 shyNotspeak.setMsg(shyNotspeak.getMsg()+"\n"+msg);
@@ -285,6 +301,16 @@ public class NotspeakServiceImpl { @@ -285,6 +301,16 @@ public class NotspeakServiceImpl {
285 public int updateByPrimaryKeySelective(ShyNotspeak shyNotspeak) { 301 public int updateByPrimaryKeySelective(ShyNotspeak shyNotspeak) {
286 return shyNotspeakMapper.updateByPrimaryKeySelective(shyNotspeak); 302 return shyNotspeakMapper.updateByPrimaryKeySelective(shyNotspeak);
287 } 303 }
  304 +
  305 + public List<ShyNotspeak> getNotSpeakByTime() {
  306 + Example example = new Example(ShyNotspeak.class);
  307 + Example.Criteria criteria = example.createCriteria();
  308 + criteria.andEqualTo("state", CommonConst.SPEAK_NOT);
  309 + criteria.andLessThan("end_time", CommonUtils.getCurrentTime());
  310 +
  311 + List<ShyNotspeak> shyNotspeakList = shyNotspeakMapper.selectByExample(example);
  312 + return shyNotspeakList;
  313 + }
288 314
289 315
290 } 316 }
src/main/resources/templates/common/frame.html
@@ -91,9 +91,9 @@ line-height: 2em; margin: 0 auto;font-size: 2em&quot; th:text=&quot;${session.sessionUser. @@ -91,9 +91,9 @@ line-height: 2em; margin: 0 auto;font-size: 2em&quot; th:text=&quot;${session.sessionUser.
91 <ul class="treeview-menu"> 91 <ul class="treeview-menu">
92 <li><a href="/users/page" id="/users/page"> 审核云用户管理</a></li> 92 <li><a href="/users/page" id="/users/page"> 审核云用户管理</a></li>
93 <li><a href="/sites/page" id="/sites/page"> SP白名单管理</a></li> 93 <li><a href="/sites/page" id="/sites/page"> SP白名单管理</a></li>
94 - <li><a href="/usersFree/page" id="/usersFree/page"> 网++白名单管理</a></li>  
95 <li><a href="/email/page" id="/email/page"> 邮件消息管理</a></li> 94 <li><a href="/email/page" id="/email/page"> 邮件消息管理</a></li>
96 - <li><a href="/notSpeak/page?state=1" id="/notSpeak/page"> 禁言管理</a></li> 95 + <li><a href="/usersFree/page" id="/usersFree/page"> 网++白名单管理</a></li>
  96 + <li><a href="/notSpeak/page" id="/notSpeak/page"> 网++禁言管理</a></li>
97 </ul> 97 </ul>
98 </li> 98 </li>
99 </ul> 99 </ul>
src/main/resources/templates/page/comment.html
@@ -798,10 +798,19 @@ @@ -798,10 +798,19 @@
798 } 798 }
799 //禁言(弹窗) 799 //禁言(弹窗)
800 function speakModal(comments_id,userName,sp_desc) { 800 function speakModal(comments_id,userName,sp_desc) {
801 - $('#comments_id').val(comments_id);  
802 - $('#userName').val(userName);  
803 - $('#sp_desc').val(sp_desc);  
804 - $('#speakModal').modal('show'); 801 +
  802 + $.post("/notSpeak/querySpeakState?commentId=" + comments_id, function (data) {
  803 + if (data.errorCode != 0) {
  804 + alert(data.errorMessage);
  805 +// location.href = location.href;
  806 + } else {
  807 + $('#comments_id').val(comments_id);
  808 + $('#userName').val(userName);
  809 + $('#sp_desc').val(sp_desc);
  810 + $('#speakModal').modal('show');
  811 + }
  812 + })
  813 +
805 } 814 }
806 815
807 //提交禁言 816 //提交禁言
src/main/resources/templates/page/notspeak.html
@@ -402,62 +402,18 @@ input:checked + .slider:before { @@ -402,62 +402,18 @@ input:checked + .slider:before {
402 var state = [[${param.state}]] ? [[${param.state}]][0] : null; 402 var state = [[${param.state}]] ? [[${param.state}]][0] : null;
403 var stateIsNull = $.trim(state) == ""; 403 var stateIsNull = $.trim(state) == "";
404 if ( stateIsNull) { 404 if ( stateIsNull) {
405 - $("#quanbu").addClass("btn-info"); 405 + $("#quanbu").addClass("btn-success");
406 } else if (state == '1') { 406 } else if (state == '1') {
407 - $("#jinyan").addClass("btn-warning"); 407 + $("#jinyan").addClass("btn-danger");
408 } else if (state == '0') { 408 } else if (state == '0') {
409 - $("#jiejin").addClass("btn-success"); 409 + $("#jiejin").addClass("btn-info");
410 } 410 }
411 // else if (!stateIsNull && state != '0' && receive == '1') { 411 // else if (!stateIsNull && state != '0' && receive == '1') {
412 -// $("#yishen").addClass("btn-danger"); 412 +// $("#yishen").addClass("btn-warning");
413 // } 413 // }
414 414
415 }) 415 })
416 - //打开编辑窗口  
417 - function edit(Id,notspeak,remark,write_business){  
418 - $("#myModalLabel").text("编辑邮件消息");  
419 - $("#id").val(Id);  
420 - $("#notspeak_edit").val(notspeak);  
421 - $("#notspeak_edit").attr("readonly","true");  
422 - $("#remark_edit").val(remark);  
423 - $("#redirect_url").val(location.pathname+location.search);  
424 - $(".write_check input").prop("checked",false);  
425 - if($.trim(write_business)!=''){  
426 - var array = write_business.split(",")  
427 - for (var i=0;i<array.length;i++){  
428 - $("#write_check_"+array[i]).prop("checked",true);  
429 - }  
430 - }  
431 - $('#editModal').modal('show');  
432 - }  
433 416
434 - //打开添加窗口  
435 - function add(){  
436 - $("#id").val("");  
437 - $("#notspeak_edit").val("");  
438 - $("#notspeak_edit").removeAttr("readonly");  
439 - $("#remark_edit").val("");  
440 - $(".write_check input").prop("checked",false);  
441 -  
442 - $("#redirect_url").val(location.pathname+location.search);  
443 - $("#myModalLabel").text("添加邮件消息");  
444 - $('#editModal').modal('show');  
445 - }  
446 -  
447 - //删除操作  
448 -// function deleted(id){  
449 -// var r = confirm("您确定删除本条内容吗?");  
450 -// if (r == true) {  
451 -// $.post("/notspeak/deleted?id=" + id, function (data) {  
452 -// if (data.errorCode == 0) {  
453 -// alert(data.errorMessage);  
454 -// location.href = location.href;  
455 -// } else {  
456 -// alert(data.errorMessage);  
457 -// }  
458 -// })  
459 -// }  
460 -// }  
461 417
462 var user_id ="";//活动id 418 var user_id ="";//活动id
463 var user_name = "";//内容 419 var user_name = "";//内容
@@ -590,7 +546,51 @@ input:checked + .slider:before { @@ -590,7 +546,51 @@ input:checked + .slider:before {
590 // $("#notspeakQuery").trigger("click"); 546 // $("#notspeakQuery").trigger("click");
591 // } 547 // }
592 // }); 548 // });
593 - 549 + //打开编辑窗口
  550 +// function edit(Id,notspeak,remark,write_business){
  551 +// $("#myModalLabel").text("编辑邮件消息");
  552 +// $("#id").val(Id);
  553 +// $("#notspeak_edit").val(notspeak);
  554 +// $("#notspeak_edit").attr("readonly","true");
  555 +// $("#remark_edit").val(remark);
  556 +// $("#redirect_url").val(location.pathname+location.search);
  557 +// $(".write_check input").prop("checked",false);
  558 +// if($.trim(write_business)!=''){
  559 +// var array = write_business.split(",")
  560 +// for (var i=0;i<array.length;i++){
  561 +// $("#write_check_"+array[i]).prop("checked",true);
  562 +// }
  563 +// }
  564 +// $('#editModal').modal('show');
  565 +// }
  566 +
  567 + //打开添加窗口
  568 +// function add(){
  569 +// $("#id").val("");
  570 +// $("#notspeak_edit").val("");
  571 +// $("#notspeak_edit").removeAttr("readonly");
  572 +// $("#remark_edit").val("");
  573 +// $(".write_check input").prop("checked",false);
  574 +
  575 +// $("#redirect_url").val(location.pathname+location.search);
  576 +// $("#myModalLabel").text("添加邮件消息");
  577 +// $('#editModal').modal('show');
  578 +// }
  579 +
  580 + //删除操作
  581 +// function deleted(id){
  582 +// var r = confirm("您确定删除本条内容吗?");
  583 +// if (r == true) {
  584 +// $.post("/notspeak/deleted?id=" + id, function (data) {
  585 +// if (data.errorCode == 0) {
  586 +// alert(data.errorMessage);
  587 +// location.href = location.href;
  588 +// } else {
  589 +// alert(data.errorMessage);
  590 +// }
  591 +// })
  592 +// }
  593 +// }
594 594
595 /*查询样式*/ 595 /*查询样式*/
596 function openOrClose(id_name_str) { 596 function openOrClose(id_name_str) {