Commit 7958beb8693f3a09fe4a2417e750e25b7442d3a4

Authored by 徐近程
1 parent da43c6d9

评论sid搜索

src/main/java/com/cnlive/shenhe/controller/CommentsController.java
@@ -78,10 +78,10 @@ public class CommentsController extends BaseController { @@ -78,10 +78,10 @@ public class CommentsController extends BaseController {
78 @GetMapping("/page") 78 @GetMapping("/page")
79 public String getPage(Model model, String activity_id, String content, Integer is_hot, 79 public String getPage(Model model, String activity_id, String content, Integer is_hot,
80 String start_date, String end_date, Integer state, Integer receive, 80 String start_date, String end_date, Integer state, Integer receive,
81 - Integer page, Integer pageSize, String orderByClause, HttpSession session,Integer type) { 81 + Integer page, Integer pageSize, String orderByClause, HttpSession session, Integer type, Integer comment_user_id) {
82 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); 82 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
83 - if(CommonUtils.isNull(sessionUser)){  
84 - return "redirect:/users/login"; 83 + if (CommonUtils.isNull(sessionUser)) {
  84 + return "redirect:/users/login";
85 } 85 }
86 Integer spid = sessionUser.getSpid(); 86 Integer spid = sessionUser.getSpid();
87 String userId = sessionUser.getUserId(); 87 String userId = sessionUser.getUserId();
@@ -103,56 +103,56 @@ public class CommentsController extends BaseController { @@ -103,56 +103,56 @@ public class CommentsController extends BaseController {
103 } catch (Exception e) { 103 } catch (Exception e) {
104 } 104 }
105 } 105 }
106 - PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state, receive, null, page, pageSize, orderByClause, spid, userId,type); 106 + PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state, receive, null, page, pageSize, orderByClause, spid, userId, type, comment_user_id);
107 List<ShyComments> list = commentPage.getList(); 107 List<ShyComments> list = commentPage.getList();
108 if (!list.isEmpty()) { 108 if (!list.isEmpty()) {
109 for (ShyComments comment : list) { 109 for (ShyComments comment : list) {
110 if (comment.getState() != CommonConst.AUDIT_INTT) { 110 if (comment.getState() != CommonConst.AUDIT_INTT) {
111 - String updater = CommonUtils.isEmpty(comment.getUpdater()) || "null".equals(comment.getUpdater())? "白名单":comment.getUpdater(); 111 + String updater = CommonUtils.isEmpty(comment.getUpdater()) || "null".equals(comment.getUpdater()) ? "白名单" : comment.getUpdater();
112 String auditor_id = comment.getAuditor_id(); 112 String auditor_id = comment.getAuditor_id();
113 if (CommonUtils.isNotEmpty(auditor_id)) { 113 if (CommonUtils.isNotEmpty(auditor_id)) {
114 ShyUsers user = new ShyUsers(); 114 ShyUsers user = new ShyUsers();
115 user.setUser_id(auditor_id); 115 user.setUser_id(auditor_id);
116 user = usersService.select(user); 116 user = usersService.select(user);
117 if (CommonUtils.isNotNull(user)) { 117 if (CommonUtils.isNotNull(user)) {
118 - String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail()) ? "" : user.getEmail(); 118 + String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail()) ? "" : user.getEmail();
119 String userName = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername(); 119 String userName = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername();
120 - updater = userName ; 120 + updater = userName;
121 } 121 }
122 } 122 }
123 comment.setUpdater(updater); 123 comment.setUpdater(updater);
124 } 124 }
125 - if(null!=comment.getSpid()){  
126 - //显示spid简称  
127 - ShySites shySites = sitesService.findspidDescByspid(comment.getSpid());  
128 - if (CommonUtils.isNotNull(shySites)) {  
129 - comment.setSpid_desc(shySites.getName());  
130 - }  
131 - }else{  
132 - comment.setSpid_desc("sp无法显示"); 125 + if (null != comment.getSpid()) {
  126 + //显示spid简称
  127 + ShySites shySites = sitesService.findspidDescByspid(comment.getSpid());
  128 + if (CommonUtils.isNotNull(shySites)) {
  129 + comment.setSpid_desc(shySites.getName());
  130 + }
  131 + } else {
  132 + comment.setSpid_desc("sp无法显示");
133 } 133 }
134 - 134 +
135 //获取朋友圈的评论内容 135 //获取朋友圈的评论内容
136 - if(comment.getProgram_id().split("_").length==1  
137 - && comment.getProgram_id().split(":").length==3){  
138 - ShyContent shyContent=new ShyContent();  
139 - shyContent.setSp_id(comment.getSpid());  
140 - shyContent.setContent_id(comment.getProgram_id());  
141 - shyContent =contentService.getShyContent(shyContent);  
142 - if(CommonUtils.isNotNull(shyContent)&& shyContent.getId()!=null){  
143 - String title=CommonUtils.isEmpty(shyContent.getTitle())?"朋友圈发布无标题内容":shyContent.getTitle();  
144 - comment.setComment_title(title);  
145 - comment.setComment_original_url(shyContent.getContent_url());  
146 - } 136 + if (comment.getProgram_id().split("_").length == 1
  137 + && comment.getProgram_id().split(":").length == 3) {
  138 + ShyContent shyContent = new ShyContent();
  139 + shyContent.setSp_id(comment.getSpid());
  140 + shyContent.setContent_id(comment.getProgram_id());
  141 + shyContent = contentService.getShyContent(shyContent);
  142 + if (CommonUtils.isNotNull(shyContent) && shyContent.getId() != null) {
  143 + String title = CommonUtils.isEmpty(shyContent.getTitle()) ? "朋友圈发布无标题内容" : shyContent.getTitle();
  144 + comment.setComment_title(title);
  145 + comment.setComment_original_url(shyContent.getContent_url());
  146 + }
147 } 147 }
148 -  
149 - //评论的类型  
150 - if(CommonConst.CATEGORY_TOPIC.equals(comment.getType())){  
151 - comment.setType("话题");  
152 - }else{  
153 - comment.setType("其他"); 148 +
  149 + //评论的类型
  150 + if (CommonConst.CATEGORY_TOPIC.equals(comment.getType())) {
  151 + comment.setType("话题");
  152 + } else {
  153 + comment.setType("其他");
154 } 154 }
155 - 155 +
156 } 156 }
157 } 157 }
158 /* 获取参数值给前台 用来判断是否需要把查看显示出来 state recive*/ 158 /* 获取参数值给前台 用来判断是否需要把查看显示出来 state recive*/
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
@@ -78,7 +78,7 @@ public class CommentsServiceImpl { @@ -78,7 +78,7 @@ public class CommentsServiceImpl {
78 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments); 78 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
79 } 79 }
80 80
81 - public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, Integer states, Integer receive, String updater, Integer page, Integer pageSize, String orderByClause, Integer spid, String userId,Integer type) { 81 + public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, Integer states, Integer receive, String updater, Integer page, Integer pageSize, String orderByClause, Integer spid, String userId, Integer type, Integer comment_user_id) {
82 Example example = new Example(ShyComments.class); 82 Example example = new Example(ShyComments.class);
83 Example.Criteria criteria = example.createCriteria(); 83 Example.Criteria criteria = example.createCriteria();
84 if (CommonUtils.isNotEmpty(orderByClause)) { 84 if (CommonUtils.isNotEmpty(orderByClause)) {
@@ -102,17 +102,20 @@ public class CommentsServiceImpl { @@ -102,17 +102,20 @@ public class CommentsServiceImpl {
102 if (CommonUtils.isNotNull(is_hot)) { 102 if (CommonUtils.isNotNull(is_hot)) {
103 criteria.andEqualTo("is_hot", is_hot); 103 criteria.andEqualTo("is_hot", is_hot);
104 } 104 }
105 - if (CommonUtils.isNotNull(type)&&type==0) {  
106 - criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC);  
107 - }else if(CommonUtils.isNotNull(type)&&type==1){  
108 - criteria.andEqualTo("type", CommonConst.CATEGORY_ELSE); 105 + if (CommonUtils.isNotNull(comment_user_id)) {
  106 + criteria.andEqualTo("comment_user_id", comment_user_id);
  107 + }
  108 + if (CommonUtils.isNotNull(type) && type == 0) {
  109 + criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC);
  110 + } else if (CommonUtils.isNotNull(type) && type == 1) {
  111 + criteria.andEqualTo("type", CommonConst.CATEGORY_ELSE);
109 } 112 }
110 if (CommonUtils.isNotEmpty(activity_id)) { 113 if (CommonUtils.isNotEmpty(activity_id)) {
111 criteria.andLike("activity_id", "%" + activity_id + "%"); 114 criteria.andLike("activity_id", "%" + activity_id + "%");
112 } 115 }
113 if (CommonUtils.isNotNull(receive)) { 116 if (CommonUtils.isNotNull(receive)) {
114 criteria.andEqualTo("receive", receive); 117 criteria.andEqualTo("receive", receive);
115 - if (receive==CommonConst.RECEIVE_AFTER) { 118 + if (receive == CommonConst.RECEIVE_AFTER) {
116 criteria.andEqualTo("receive_user_id", userId); 119 criteria.andEqualTo("receive_user_id", userId);
117 } 120 }
118 } 121 }
@@ -125,14 +128,14 @@ public class CommentsServiceImpl { @@ -125,14 +128,14 @@ public class CommentsServiceImpl {
125 // } 128 // }
126 // example.and(criteria1); 129 // example.and(criteria1);
127 // } 130 // }
128 - 131 +
129 if (CommonUtils.isNotNull(states) && states != 3) { 132 if (CommonUtils.isNotNull(states) && states != 3) {
130 criteria.andEqualTo("state", states); 133 criteria.andEqualTo("state", states);
131 } else if (CommonUtils.isNotNull(states) && states == 3) { 134 } else if (CommonUtils.isNotNull(states) && states == 3) {
132 - Example.Criteria criteria1 = example.createCriteria();  
133 - criteria1.orEqualTo("state", 1);  
134 - criteria1.orEqualTo("state", 2);  
135 - example.and(criteria1); 135 + Example.Criteria criteria1 = example.createCriteria();
  136 + criteria1.orEqualTo("state", 1);
  137 + criteria1.orEqualTo("state", 2);
  138 + example.and(criteria1);
136 } 139 }
137 140
138 PageHelper.startPage(page, pageSize, true); 141 PageHelper.startPage(page, pageSize, true);
src/main/resources/templates/page/comment.html
@@ -91,20 +91,28 @@ @@ -91,20 +91,28 @@
91 <div class="form-horizontal form-group-sm" id="forms" style="display: none;"> 91 <div class="form-horizontal form-group-sm" id="forms" style="display: none;">
92 <form id="commentForm"> 92 <form id="commentForm">
93 <div class="btn-group margin-bottom col-md-6" style="padding: 0;"> 93 <div class="btn-group margin-bottom col-md-6" style="padding: 0;">
94 - <div class="col-md-4" style="padding: 0"> 94 + <div class="col-md-3" style="padding: 0">
95 <label for="activity_id" class="control-label cb-toolbar">活动id:</label> 95 <label for="activity_id" class="control-label cb-toolbar">活动id:</label>
96 <div class="col-sm-8" style="padding: 0;"> 96 <div class="col-sm-8" style="padding: 0;">
97 <input class="form-control" name="activity_id" type="text" 97 <input class="form-control" name="activity_id" type="text"
98 id="activity_id" > 98 id="activity_id" >
99 </div> 99 </div>
100 </div> 100 </div>
  101 + <div class="col-md-2" style="padding: 0">
  102 + <label for="comment_user_id" class="control-label cb-toolbar">sid:</label>
  103 + <div class="col-sm-8" style="padding: 0;">
  104 + <input class="form-control" name="comment_user_id" type="text"
  105 + id="comment_user_id" >
  106 + </div>
  107 + </div>
  108 +
101 <div class="col-md-5" style="padding: 0"> 109 <div class="col-md-5" style="padding: 0">
102 <label for="content" class="control-label cb-toolbar">内容:</label> 110 <label for="content" class="control-label cb-toolbar">内容:</label>
103 <div class="col-sm-9" style="padding: 0;"> 111 <div class="col-sm-9" style="padding: 0;">
104 <input class="form-control" name="content" type="text" id="content"> 112 <input class="form-control" name="content" type="text" id="content">
105 </div> 113 </div>
106 </div> 114 </div>
107 - <div class="col-md-3" style="padding: 0"> 115 + <div class="col-md-2" style="padding: 0">
108 <label for="state" class="control-label cb-toolbar">状态:</label> 116 <label for="state" class="control-label cb-toolbar">状态:</label>
109 <div class="col-sm-8" style="padding: 0;"> 117 <div class="col-sm-8" style="padding: 0;">
110 <select class="form-control col-sm-2" id="state" name="state"> 118 <select class="form-control col-sm-2" id="state" name="state">
@@ -576,7 +584,8 @@ @@ -576,7 +584,8 @@
576 var count = "";//每页显示数量 584 var count = "";//每页显示数量
577 var receive ="";//领取状态 585 var receive ="";//领取状态
578 var type="";//类型,topic:话题 586 var type="";//类型,topic:话题
579 - 587 + var comment_user_id="";//sid
  588 +
580 function query(){ 589 function query(){
581 activity_id = $("#activity_id").val(); 590 activity_id = $("#activity_id").val();
582 content = $("#content").val(); 591 content = $("#content").val();
@@ -584,7 +593,8 @@ @@ -584,7 +593,8 @@
584 end_date = $("#end_date").val(); 593 end_date = $("#end_date").val();
585 count = $("#pageSize").val(); 594 count = $("#pageSize").val();
586 type = $("#topic").val(); 595 type = $("#topic").val();
587 - window.location.href = "/comments/page?activity_id=" + activity_id + "&start_date=" + start_date + "&end_date=" + end_date + "&content=" + content + "&pageSize="+count+"&state="+state+"&receive="+receive+"&type="+type; 596 + comment_user_id = $("#comment_user_id").val();
  597 + window.location.href = "/comments/page?activity_id=" + activity_id + "&start_date=" + start_date + "&end_date=" + end_date + "&content=" + content + "&pageSize="+count+"&state="+state+"&receive="+receive+"&type="+type+"&comment_user_id="+comment_user_id;
588 } 598 }
589 599
590 //全部 600 //全部