Commit d6be621dcc151492574b89cde287bb5fbf8f0820

Authored by liwei2917
1 parent 5a19e943

评论审核禁言功能开发

src/main/java/com/cnlive/shenhe/controller/CommentsController.java
... ... @@ -288,4 +288,13 @@ public class CommentsController extends BaseController {
288 288 }
289 289 return responseBean;
290 290 }
  291 +
  292 + @PostMapping("/notSpeak")
  293 + @ResponseBody
  294 + public ResponseBean notSpeak(String id,Integer type,Integer time, HttpSession session) {
  295 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  296 + String userId = sessionUser.getUserId();
  297 + ResponseBean success = commentsService.notSpeak(id, type, time,userId,"禁言");
  298 + return success;
  299 + }
291 300 }
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
1 1 package com.cnlive.shenhe.serviceImpl;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
  4 +import com.cnlive.shenhe.bean.ErrorEnum;
  5 +import com.cnlive.shenhe.bean.ResponseBean;
4 6 import com.cnlive.shenhe.entity.ShyComments;
5 7 import com.cnlive.shenhe.entity.ShySites;
6 8 import com.cnlive.shenhe.entity.ShyUsers;
... ... @@ -203,6 +205,47 @@ public class CommentsServiceImpl {
203 205 }
204 206 return success;
205 207 }
  208 + public ResponseBean notSpeak(String id, Integer type,Integer time, String userId,String msg) {
  209 + ResponseBean success;
  210 + ShyComments comment = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(id));
  211 + JSONObject json = new JSONObject();
  212 + json.put("userId", comment.getComment_user_id());
  213 + json.put("type", type);
  214 + json.put("time", time);
  215 + json.put("msg", msg);
  216 + JSONObject result = new JSONObject();
  217 + try {
  218 + result = Pass.commentPass(json, comment.getCallback());
  219 + } catch (Exception e) {
  220 + logger.error("评论禁言失败,comments_id:{}", comment.getId());
  221 + success=new ResponseBean(500,"评论禁言调用互动云服务器失败!");
  222 + return success;
  223 + }
  224 + if (result == null) {
  225 + logger.error("评论禁言错误,且无返回信息。comments_id:{}", comment.getId());
  226 + success=new ResponseBean(500,"评论禁言调用互动云返回结果为空!");
  227 + return success;
  228 + } else {
  229 + Integer errorCode = result.getInteger("errorCode");
  230 + String errorMessage = result.getString("errorMessage");
  231 + if (errorCode != 0) {
  232 + logger.error("评论禁言错误,comments_id:{},errorCode:{},errorMessage:{}", comment.getId(), errorCode, errorMessage);
  233 + success=new ResponseBean(500,"评论禁言调用互动云返回结果errorCode不为0!");
  234 + return success;
  235 + }
  236 + comment.setState(CommonConst.AUDIT_REFUSE);
  237 + comment.setMsg(msg);
  238 + comment.setAuditor_id(userId);
  239 + comment.setReceive(1);//已领取
  240 + comment.setReceive_user_id(userId);
  241 + int i = shyCommentsMapper.updateByPrimaryKeySelective(comment);
  242 + if (i != 1) {
  243 + success=new ResponseBean(500,"评论禁言修改当前评论数据失败!");
  244 + return success;
  245 + }
  246 + }
  247 + return new ResponseBean();
  248 + }
206 249  
207 250 public Integer receive(String ids, Integer num, String userId, Integer spid) {
208 251 Integer n = 0;
... ...
src/main/resources/templates/page/comment.html
... ... @@ -296,7 +296,8 @@
296 296 2018-11-28 16:08:00
297 297 </td>
298 298 <td style="text-align: center; width: 22%;">
299   - <a class="detail" th:href="@{'/comments/details/'+${comment.id}}">
  299 + <a th:if="${comment.receive==1 and session.sessionUser.userId==comment.receive_user_id}"
  300 + class="detail" th:href="@{'/comments/details/'+${comment.id}}">
300 301 <button class="btn btn-info btn-sm">查看</button>
301 302 </a>
302 303  
... ... @@ -311,6 +312,9 @@
311 312 th:if="${comment.state==0 and comment.receive==1 and session.sessionUser.userId==comment.receive_user_id}">
312 313 <button class="btn btn-warning btn-sm">退领</button>
313 314 </a>
  315 + <a th:href="@{'javascript:speakModal('+${comment.id}+',\''+${comment.comment_user_name}+'\',\''+${comment.spid_desc}+'\')'}">
  316 + <button class="btn btn-danger btn-sm">禁言</button>
  317 + </a>
314 318  
315 319 <!-- <span th:if="${comment.receive and session.sessionUser.userId==comment.receive_user_id}"> &nbsp;</span> -->
316 320 <!-- <a class="pass_one" -->
... ... @@ -398,7 +402,7 @@
398 402 </section><!-- /.content -->
399 403 </div>
400 404 <!-- /.content-wrapper -->
401   - <!-- 模态框(Modal) -->
  405 + <!-- 模态框,拒绝框(Modal) -->
402 406 <div class="modal fade" id="msgModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
403 407 <div class="modal-dialog">
404 408 <div class="modal-content" style="margin-top: 30%;">
... ... @@ -421,6 +425,48 @@
421 425 </div><!-- /.modal-dialog -->
422 426 </div>
423 427 <!-- /.modal -->
  428 + <!-- 模态框,禁言框(Modal) -->
  429 +<div class="modal fade" id="speakModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  430 + <div class="modal-dialog">
  431 + <div class="modal-content" style="margin-top: 30%;">
  432 + <div class="modal-header">
  433 + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  434 + <h4 class="modal-title" id="myModalLabel">禁言选项</h4>
  435 + </div>
  436 + <div class="modal-body">
  437 + <input type="text" name="comments_id" value="" class="hide" id="comments_id"/>
  438 + <div class="form-group">
  439 + <label class="control-label col-sm-3" style="font-size: 15px;" >用户昵称:</label>
  440 + <div class="col-sm-9" style="margin-top: -5px;margin-bottom: 20px;">
  441 + <input class="form-control" readonly="readonly" style="width:40%;" type="text" value="" id="userName" name="userName">
  442 + </div>
  443 + </div>
  444 + <div class="form-group">
  445 + <label class="control-label col-sm-3" style="font-size: 15px;">发言平台:</label>
  446 + <div class="col-sm-9" style="margin-top: -5px;margin-bottom: 20px;">
  447 + <input class="form-control" readonly="readonly" style="width:40%;" type="text" value="" id="sp_desc" name="sp_desc">
  448 + </div>
  449 + </div>
  450 + <div class="form-group">
  451 + <label class="control-label col-sm-3" style="font-size: 15px;">禁言时长:</label>
  452 + <div class="col-sm-9" style="margin-top: -5px;margin-bottom: 20px;">
  453 + <input class="form-control" onkeyup="value=value.replace(/[^\d]/g,'')" style="display:inline;width:10%;" type="text" value="0" id="noSpeak_days" name="noSpeak_days">
  454 + <span>&nbsp;&nbsp;天&nbsp;&nbsp;</span>
  455 + <input class="form-control" onkeyup="value=value.replace(/[^\d]/g,'')" style="display:inline;width:10%;" type="text" value="0" id="noSpeak_hours" name="noSpeak_hours">
  456 + <span>&nbsp;&nbsp;时&nbsp;&nbsp;</span>
  457 + <input class="form-control" onkeyup="value=value.replace(/[^\d]/g,'')" style="display:inline;width:10%;" type="text" value="0" id="noSpeak_minutes" name="noSpeak_minutes">
  458 + <span>&nbsp;&nbsp;分&nbsp;&nbsp;</span>
  459 + </div>
  460 + </div>
  461 + </div>
  462 + <div class="modal-footer">
  463 + <button type="button" class="btn btn-primary" onclick="javascript:submitSpeak();">提交</button>
  464 + <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  465 + </div>
  466 + </div><!-- /.modal-content -->
  467 + </div><!-- /.modal-dialog -->
  468 +</div>
  469 +<!-- /.modal -->
424 470 <script th:inline="javascript">
425 471 $(function () {
426 472 //按钮颜色设置
... ... @@ -750,6 +796,32 @@
750 796 alert("没有选中的数据!");
751 797 }
752 798 }
  799 + //禁言(弹窗)
  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');
  805 + }
  806 +
  807 + //提交禁言
  808 + function submitSpeak() {
  809 + var comments_id = $("#comments_id").val();
  810 + var noSpeak_days = Number($("#noSpeak_days").val());
  811 + var noSpeak_hours = Number($("#noSpeak_hours").val());
  812 + var noSpeak_minutes = Number($("#noSpeak_minutes").val());
  813 + var time=noSpeak_days*24*60+noSpeak_hours*60+noSpeak_minutes;//单位为分钟
  814 + var type=1;//禁言类型, 1:禁言 2:解禁
  815 +// alert(comments_id);
  816 + $.post("/comments/notSpeak?id=" + comments_id + "&type=" + type+ "&time=" + time, function (data) {
  817 + if (data.errorCode == 0) {
  818 + alert(data.errorMessage);
  819 + location.href = location.href;
  820 + } else {
  821 + alert(data.errorMessage);
  822 + }
  823 + })
  824 + }
753 825 </script>
754 826 <script>
755 827 /*时间插件*/
... ...