Commit 221e5b8be456db6f6434b677445d49f2f700b6ee

Authored by 陈浩
2 parents b8ef8f4a 130d8296
src/main/java/com/cnlive/shenhe/controller/CommentsController.java
@@ -48,10 +48,11 @@ public class CommentsController { @@ -48,10 +48,11 @@ public class CommentsController {
48 */ 48 */
49 @GetMapping("/page") 49 @GetMapping("/page")
50 public String getPage(Model model, String activity_id, String content, Integer is_hot, 50 public String getPage(Model model, String activity_id, String content, Integer is_hot,
51 - String start_date, String end_date, String state, 51 + String start_date, String end_date, String state,Boolean receive,
52 Integer page, Integer pageSize, String orderByClause, HttpSession session) { 52 Integer page, Integer pageSize, String orderByClause, HttpSession session) {
53 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); 53 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
54 Integer spid = sessionUser.getSpid(); 54 Integer spid = sessionUser.getSpid();
  55 + String userId = sessionUser.getUserId();
55 if (spid == 0) spid = null; 56 if (spid == 0) spid = null;
56 if (CommonUtils.isNull(page)) page = 1; 57 if (CommonUtils.isNull(page)) page = 1;
57 if (CommonUtils.isNull(pageSize)) pageSize = 10; 58 if (CommonUtils.isNull(pageSize)) pageSize = 10;
@@ -70,7 +71,7 @@ public class CommentsController { @@ -70,7 +71,7 @@ public class CommentsController {
70 } catch (Exception e) { 71 } catch (Exception e) {
71 } 72 }
72 } 73 }
73 - PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state, null, page, pageSize, orderByClause, spid); 74 + PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state,receive, null, page, pageSize, orderByClause, spid,userId);
74 List<ShyComments> list = commentPage.getList(); 75 List<ShyComments> list = commentPage.getList();
75 if (!list.isEmpty()) { 76 if (!list.isEmpty()) {
76 for (ShyComments comment : list) { 77 for (ShyComments comment : list) {
@@ -148,4 +149,36 @@ public class CommentsController { @@ -148,4 +149,36 @@ public class CommentsController {
148 149
149 } 150 }
150 151
  152 +
  153 + /**
  154 + * 认领
  155 + * @param ids 根据id认领
  156 + * @param num 认领条数
  157 + * @param session
  158 + * @return
  159 + */
  160 + @PostMapping("/receive")
  161 + @ResponseBody
  162 + public ResponseBean receive(String ids, Integer num,HttpSession session) {
  163 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  164 + String userId = sessionUser.getUserId();
  165 + Integer spid = sessionUser.getSpid();
  166 + Integer n = commentsService.receive(ids, num, userId,spid);
  167 + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(),"认领到"+n+"条内容");
  168 + }
  169 +
  170 +
  171 + @PostMapping("/retReceive")
  172 + @ResponseBody
  173 + public ResponseBean retReceive(String ids,HttpSession session) {
  174 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  175 + String userId = sessionUser.getUserId();
  176 + boolean n = commentsService.retReceive(ids, userId);
  177 + if(n){
  178 + return new ResponseBean();
  179 + }else{
  180 + return new ResponseBean(ErrorEnum.ERROR);
  181 + }
  182 + }
  183 +
151 } 184 }
src/main/java/com/cnlive/shenhe/entity/ShyComments.java
1 package com.cnlive.shenhe.entity; 1 package com.cnlive.shenhe.entity;
2 2
  3 +import javax.persistence.Id;
  4 +import javax.persistence.Table;
  5 +import javax.persistence.Transient;
3 import java.util.Date; 6 import java.util.Date;
4 -import javax.persistence.*;  
5 7
6 @Table(name = "shy_comments") 8 @Table(name = "shy_comments")
7 public class ShyComments { 9 public class ShyComments {
@@ -64,11 +66,6 @@ public class ShyComments { @@ -64,11 +66,6 @@ public class ShyComments {
64 * 审核员id 66 * 审核员id
65 */ 67 */
66 private String auditor_id; 68 private String auditor_id;
67 - /**  
68 - * 审核员  
69 - */  
70 - @Transient  
71 - private String auditor;  
72 69
73 /** 70 /**
74 * 回调函数 71 * 回调函数
@@ -110,6 +107,22 @@ public class ShyComments { @@ -110,6 +107,22 @@ public class ShyComments {
110 private Date updated_at; 107 private Date updated_at;
111 108
112 /** 109 /**
  110 + * 领取状态。0:未领取;1:已领取
  111 + */
  112 + private Boolean receive;
  113 +
  114 + /**
  115 + * 领取人id
  116 + */
  117 + private String receive_user_id;
  118 +
  119 + /**
  120 + * 审核员
  121 + */
  122 + @Transient
  123 + private String auditor;
  124 +
  125 + /**
113 * @return id 126 * @return id
114 */ 127 */
115 public Integer getId() { 128 public Integer getId() {
@@ -489,6 +502,42 @@ public class ShyComments { @@ -489,6 +502,42 @@ public class ShyComments {
489 this.updated_at = updated_at; 502 this.updated_at = updated_at;
490 } 503 }
491 504
  505 + /**
  506 + * 获取领取状态。0:未领取;1:已领取
  507 + *
  508 + * @return receive - 领取状态。0:未领取;1:已领取
  509 + */
  510 + public Boolean getReceive() {
  511 + return receive;
  512 + }
  513 +
  514 + /**
  515 + * 设置领取状态。0:未领取;1:已领取
  516 + *
  517 + * @param receive 领取状态。0:未领取;1:已领取
  518 + */
  519 + public void setReceive(Boolean receive) {
  520 + this.receive = receive;
  521 + }
  522 +
  523 + /**
  524 + * 获取领取人id
  525 + *
  526 + * @return receive_user_id - 领取人id
  527 + */
  528 + public String getReceive_user_id() {
  529 + return receive_user_id;
  530 + }
  531 +
  532 + /**
  533 + * 设置领取人id
  534 + *
  535 + * @param receive_user_id 领取人id
  536 + */
  537 + public void setReceive_user_id(String receive_user_id) {
  538 + this.receive_user_id = receive_user_id;
  539 + }
  540 +
492 public String getAuditor() { 541 public String getAuditor() {
493 return auditor; 542 return auditor;
494 } 543 }
src/main/java/com/cnlive/shenhe/entity/ShyUsers.java
1 package com.cnlive.shenhe.entity; 1 package com.cnlive.shenhe.entity;
2 2
  3 +import javax.persistence.Id;
  4 +import javax.persistence.Table;
3 import java.util.Date; 5 import java.util.Date;
4 -import javax.persistence.*;  
5 6
6 @Table(name = "shy_users") 7 @Table(name = "shy_users")
7 public class ShyUsers { 8 public class ShyUsers {
@@ -63,19 +64,6 @@ public class ShyUsers { @@ -63,19 +64,6 @@ public class ShyUsers {
63 private Long tm; 64 private Long tm;
64 65
65 private String user_logo; 66 private String user_logo;
66 - /**  
67 - * 审核员  
68 - */  
69 - @Transient  
70 - private String auditor;  
71 -  
72 - public String getAuditor() {  
73 - return auditor;  
74 - }  
75 -  
76 - public void setAuditor(String auditor) {  
77 - this.auditor = auditor;  
78 - }  
79 67
80 /** 68 /**
81 * @return id 69 * @return id
src/main/java/com/cnlive/shenhe/entity/ShyVideos.java
1 package com.cnlive.shenhe.entity; 1 package com.cnlive.shenhe.entity;
2 2
  3 +import javax.persistence.Id;
  4 +import javax.persistence.Table;
  5 +import javax.persistence.Transient;
3 import java.util.Date; 6 import java.util.Date;
4 -import javax.persistence.*;  
5 7
6 @Table(name = "shy_videos") 8 @Table(name = "shy_videos")
7 public class ShyVideos { 9 public class ShyVideos {
@@ -45,7 +47,7 @@ public class ShyVideos { @@ -45,7 +47,7 @@ public class ShyVideos {
45 private String callback; 47 private String callback;
46 48
47 /** 49 /**
48 - * 优先级 50 + * 优先级,1:热点,0:非热点
49 */ 51 */
50 private String video_priority; 52 private String video_priority;
51 53
@@ -82,20 +84,38 @@ public class ShyVideos { @@ -82,20 +84,38 @@ public class ShyVideos {
82 private Date created_at; 84 private Date created_at;
83 85
84 private Date updated_at; 86 private Date updated_at;
  87 +
  88 + /**
  89 + * 领取状态。0:未领取;1:已领取
  90 + */
  91 + private Boolean receive;
  92 +
  93 + /**
  94 + * 领取人id
  95 + */
  96 + private String receive_user_id;
  97 +
  98 + /**
  99 + * 是否抽帧
  100 + */
  101 + private Boolean avsample;
  102 +
  103 + /**
  104 + * 抽帧图片地址
  105 + */
  106 + private String avsample_imgs;
  107 +
  108 + /**
  109 + * 抽帧返回信息(主要找问题时使用)
  110 + */
  111 + private String avsample_msg;
  112 +
85 /** 113 /**
86 * 审核员 114 * 审核员
87 */ 115 */
88 @Transient 116 @Transient
89 private String auditor; 117 private String auditor;
90 118
91 - public String getAuditor() {  
92 - return auditor;  
93 - }  
94 -  
95 - public void setAuditor(String auditor) {  
96 - this.auditor = auditor;  
97 - }  
98 -  
99 /** 119 /**
100 * @return id 120 * @return id
101 */ 121 */
@@ -261,18 +281,18 @@ public class ShyVideos { @@ -261,18 +281,18 @@ public class ShyVideos {
261 } 281 }
262 282
263 /** 283 /**
264 - * 获取优先级 284 + * 获取优先级,1:热点,0:非热点
265 * 285 *
266 - * @return video_priority - 优先级 286 + * @return video_priority - 优先级,1:热点,0:非热点
267 */ 287 */
268 public String getVideo_priority() { 288 public String getVideo_priority() {
269 return video_priority; 289 return video_priority;
270 } 290 }
271 291
272 /** 292 /**
273 - * 设置优先级 293 + * 设置优先级,1:热点,0:非热点
274 * 294 *
275 - * @param video_priority 优先级 295 + * @param video_priority 优先级,1:热点,0:非热点
276 */ 296 */
277 public void setVideo_priority(String video_priority) { 297 public void setVideo_priority(String video_priority) {
278 this.video_priority = video_priority; 298 this.video_priority = video_priority;
@@ -413,4 +433,102 @@ public class ShyVideos { @@ -413,4 +433,102 @@ public class ShyVideos {
413 public void setUpdated_at(Date updated_at) { 433 public void setUpdated_at(Date updated_at) {
414 this.updated_at = updated_at; 434 this.updated_at = updated_at;
415 } 435 }
  436 +
  437 + /**
  438 + * 获取领取状态。0:未领取;1:已领取
  439 + *
  440 + * @return receive - 领取状态。0:未领取;1:已领取
  441 + */
  442 + public Boolean getReceive() {
  443 + return receive;
  444 + }
  445 +
  446 + /**
  447 + * 设置领取状态。0:未领取;1:已领取
  448 + *
  449 + * @param receive 领取状态。0:未领取;1:已领取
  450 + */
  451 + public void setReceive(Boolean receive) {
  452 + this.receive = receive;
  453 + }
  454 +
  455 + /**
  456 + * 获取领取人id
  457 + *
  458 + * @return receive_user_id - 领取人id
  459 + */
  460 + public String getReceive_user_id() {
  461 + return receive_user_id;
  462 + }
  463 +
  464 + /**
  465 + * 设置领取人id
  466 + *
  467 + * @param receive_user_id 领取人id
  468 + */
  469 + public void setReceive_user_id(String receive_user_id) {
  470 + this.receive_user_id = receive_user_id;
  471 + }
  472 +
  473 + /**
  474 + * 获取是否抽帧
  475 + *
  476 + * @return avsample - 是否抽帧
  477 + */
  478 + public Boolean getAvsample() {
  479 + return avsample;
  480 + }
  481 +
  482 + /**
  483 + * 设置是否抽帧
  484 + *
  485 + * @param avsample 是否抽帧
  486 + */
  487 + public void setAvsample(Boolean avsample) {
  488 + this.avsample = avsample;
  489 + }
  490 +
  491 + /**
  492 + * 获取抽帧图片地址
  493 + *
  494 + * @return avsample_imgs - 抽帧图片地址
  495 + */
  496 + public String getAvsample_imgs() {
  497 + return avsample_imgs;
  498 + }
  499 +
  500 + /**
  501 + * 设置抽帧图片地址
  502 + *
  503 + * @param avsample_imgs 抽帧图片地址
  504 + */
  505 + public void setAvsample_imgs(String avsample_imgs) {
  506 + this.avsample_imgs = avsample_imgs;
  507 + }
  508 +
  509 + /**
  510 + * 获取抽帧返回信息(主要找问题时使用)
  511 + *
  512 + * @return avsample_msg - 抽帧返回信息(主要找问题时使用)
  513 + */
  514 + public String getAvsample_msg() {
  515 + return avsample_msg;
  516 + }
  517 +
  518 + /**
  519 + * 设置抽帧返回信息(主要找问题时使用)
  520 + *
  521 + * @param avsample_msg 抽帧返回信息(主要找问题时使用)
  522 + */
  523 + public void setAvsample_msg(String avsample_msg) {
  524 + this.avsample_msg = avsample_msg;
  525 + }
  526 +
  527 + public String getAuditor() {
  528 + return auditor;
  529 + }
  530 +
  531 + public void setAuditor(String auditor) {
  532 + this.auditor = auditor;
  533 + }
416 } 534 }
417 \ No newline at end of file 535 \ No newline at end of file
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
@@ -47,7 +47,7 @@ public class CommentsServiceImpl { @@ -47,7 +47,7 @@ public class CommentsServiceImpl {
47 47
48 //************************************** 48 //**************************************
49 public List<ShyComments> findshyComments(ShyComments shyComments) { 49 public List<ShyComments> findshyComments(ShyComments shyComments) {
50 - List<ShyComments> commentsList = shyCommentsMapper.selectByRowBounds(shyComments,new RowBounds(0,100)); 50 + List<ShyComments> commentsList = shyCommentsMapper.selectByRowBounds(shyComments, new RowBounds(0, 100));
51 return commentsList; 51 return commentsList;
52 } 52 }
53 53
@@ -74,7 +74,7 @@ public class CommentsServiceImpl { @@ -74,7 +74,7 @@ public class CommentsServiceImpl {
74 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments); 74 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
75 } 75 }
76 76
77 - public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, String states, String auditor, Integer page, Integer pageSize, String orderByClause, Integer spid) { 77 + public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, String states,Boolean receive, String auditor, Integer page, Integer pageSize, String orderByClause, Integer spid,String userId) {
78 Example example = new Example(ShyComments.class); 78 Example example = new Example(ShyComments.class);
79 Example.Criteria criteria = example.createCriteria(); 79 Example.Criteria criteria = example.createCriteria();
80 if (CommonUtils.isNotEmpty(orderByClause)) { 80 if (CommonUtils.isNotEmpty(orderByClause)) {
@@ -101,6 +101,13 @@ public class CommentsServiceImpl { @@ -101,6 +101,13 @@ public class CommentsServiceImpl {
101 if (CommonUtils.isNotEmpty(activity_id)) { 101 if (CommonUtils.isNotEmpty(activity_id)) {
102 criteria.andLike("activity_id", "%" + activity_id + "%"); 102 criteria.andLike("activity_id", "%" + activity_id + "%");
103 } 103 }
  104 + if(CommonUtils.isNotNull(receive)){
  105 + criteria.andEqualTo("receive",receive);
  106 + if(receive){
  107 + criteria.andEqualTo("receive_user_id",userId);
  108 + }
  109 + }
  110 +
104 if (CommonUtils.isNotEmpty(states)) { 111 if (CommonUtils.isNotEmpty(states)) {
105 Example.Criteria criteria1 = example.createCriteria(); 112 Example.Criteria criteria1 = example.createCriteria();
106 String[] stas = states.split(","); 113 String[] stas = states.split(",");
@@ -109,6 +116,7 @@ public class CommentsServiceImpl { @@ -109,6 +116,7 @@ public class CommentsServiceImpl {
109 } 116 }
110 example.and(criteria1); 117 example.and(criteria1);
111 } 118 }
  119 +
112 PageHelper.startPage(page, pageSize, true); 120 PageHelper.startPage(page, pageSize, true);
113 List<ShyComments> commentsList = shyCommentsMapper.selectByExample(example); 121 List<ShyComments> commentsList = shyCommentsMapper.selectByExample(example);
114 PageInfo<ShyComments> pageInfo = new PageInfo<>(commentsList); 122 PageInfo<ShyComments> pageInfo = new PageInfo<>(commentsList);
@@ -124,8 +132,8 @@ public class CommentsServiceImpl { @@ -124,8 +132,8 @@ public class CommentsServiceImpl {
124 ShyUsers user = new ShyUsers(); 132 ShyUsers user = new ShyUsers();
125 user.setUser_id(auditor_id); 133 user.setUser_id(auditor_id);
126 user = shyUsersMapper.selectOne(user); 134 user = shyUsersMapper.selectOne(user);
127 - String userName = CommonUtils.isEmpty(user.getUsername())?"":user.getUsername();  
128 - String email = CommonUtils.isEmpty(user.getEmail())?"":user.getEmail(); 135 + String userName = CommonUtils.isEmpty(user.getUsername()) ? "" : user.getUsername();
  136 + String email = CommonUtils.isEmpty(user.getEmail()) ? "" : user.getEmail();
129 auditorName = userName + email; 137 auditorName = userName + email;
130 } 138 }
131 comment.setAuditor(auditorName); 139 comment.setAuditor(auditorName);
@@ -138,6 +146,12 @@ public class CommentsServiceImpl { @@ -138,6 +146,12 @@ public class CommentsServiceImpl {
138 String[] commentIds = ids.split(","); 146 String[] commentIds = ids.split(",");
139 for (String commentId : commentIds) { 147 for (String commentId : commentIds) {
140 ShyComments comment = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(commentId)); 148 ShyComments comment = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(commentId));
  149 + if(!comment.getReceive() || CommonUtils.isEmpty(comment.getReceive_user_id()) || !userId.equals(comment.getReceive_user_id())){
  150 + logger.error("领取逻辑不符,不能审核,activity_id:{}", comment.getActivity_id());
  151 + success = false;
  152 + break;
  153 + }
  154 +
141 JSONObject json = new JSONObject(); 155 JSONObject json = new JSONObject();
142 json.put("activity_id", comment.getActivity_id()); 156 json.put("activity_id", comment.getActivity_id());
143 json.put("state", state + 2); 157 json.put("state", state + 2);
@@ -173,6 +187,55 @@ public class CommentsServiceImpl { @@ -173,6 +187,55 @@ public class CommentsServiceImpl {
173 } 187 }
174 return success; 188 return success;
175 } 189 }
  190 +
  191 + public Integer receive(String ids, Integer num, String userId, Integer spid) {
  192 + Integer n = 0;
  193 + if (CommonUtils.isNotEmpty(ids)) {
  194 + String[] cids = ids.split(",");
  195 + for (String cid : cids) {
  196 + ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(cid));
  197 + if (CommonUtils.isNotNull(shyComments) && shyComments.getState() == CommonConst.AUDIT_INTT && !shyComments.getReceive()) {
  198 + shyComments.setReceive_user_id(userId);
  199 + shyComments.setReceive(true);
  200 + shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
  201 + n++;
  202 + }
  203 + }
  204 + } else if (CommonUtils.isNotNull(num) && num > 0) {
  205 + Example example = new Example(ShyComments.class);
  206 + example.setOrderByClause("created_at desc");
  207 + example.and().andEqualTo("state", CommonConst.AUDIT_INTT);
  208 + example.and().andEqualTo("receive", CommonConst.RECEIVE_AFTER);
  209 + if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
  210 + List<ShyComments> shyCommentsList = shyCommentsMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
  211 + if(!shyCommentsList.isEmpty()){
  212 + for (ShyComments shyComments:shyCommentsList) {
  213 + shyComments.setReceive_user_id(userId);
  214 + shyComments.setReceive(true);
  215 + shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
  216 + n++;
  217 + }
  218 + }
  219 + }
  220 + return n;
  221 + }
  222 +
  223 + public boolean retReceive(String ids, String userId) {
  224 + boolean result = true;
  225 + String[] cids = ids.split(",");
  226 + for (String cid:cids) {
  227 + ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(cid));
  228 + if(shyComments.getState()==CommonConst.AUDIT_INTT && shyComments.getReceive() && shyComments.getReceive_user_id()==userId){
  229 + shyComments.setReceive(CommonConst.RECEIVE_BEFORE);
  230 + shyComments.setReceive_user_id(null);
  231 + int i = shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
  232 + if(i!=1)result = false;
  233 + }else{
  234 + result = false;
  235 + }
  236 + }
  237 + return result;
  238 + }
176 } 239 }
177 240
178 241
src/main/java/com/cnlive/shenhe/utils/CommonConst.java
@@ -25,6 +25,15 @@ public class CommonConst { @@ -25,6 +25,15 @@ public class CommonConst {
25 25
26 26
27 /** 27 /**
  28 + * 领取状态:未领
  29 + */
  30 + public static Boolean RECEIVE_BEFORE = false;
  31 + /**
  32 + * 领取状态:已领
  33 + */
  34 + public static Boolean RECEIVE_AFTER= true;
  35 +
  36 + /**
28 * 用户状态:可用 37 * 用户状态:可用
29 */ 38 */
30 public static Integer USER_STATUS_USE = 1; 39 public static Integer USER_STATUS_USE = 1;
src/main/resources/mapper/ShyCommentsMapper.xml
@@ -27,5 +27,7 @@ @@ -27,5 +27,7 @@
27 <result column="comment_user_ip" jdbcType="CHAR" property="comment_user_ip" /> 27 <result column="comment_user_ip" jdbcType="CHAR" property="comment_user_ip" />
28 <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> 28 <result column="created_at" jdbcType="TIMESTAMP" property="created_at" />
29 <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" /> 29 <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" />
  30 + <result column="receive" jdbcType="BIT" property="receive" />
  31 + <result column="receive_user_id" jdbcType="VARCHAR" property="receive_user_id" />
30 </resultMap> 32 </resultMap>
31 </mapper> 33 </mapper>
32 \ No newline at end of file 34 \ No newline at end of file
src/main/resources/mapper/ShyVideosMapper.xml
@@ -24,5 +24,10 @@ @@ -24,5 +24,10 @@
24 <result column="video_id" jdbcType="VARCHAR" property="video_id" /> 24 <result column="video_id" jdbcType="VARCHAR" property="video_id" />
25 <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> 25 <result column="created_at" jdbcType="TIMESTAMP" property="created_at" />
26 <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" /> 26 <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" />
  27 + <result column="receive" jdbcType="BIT" property="receive" />
  28 + <result column="receive_user_id" jdbcType="VARCHAR" property="receive_user_id" />
  29 + <result column="avsample" jdbcType="BIT" property="avsample" />
  30 + <result column="avsample_imgs" jdbcType="VARCHAR" property="avsample_imgs" />
  31 + <result column="avsample_msg" jdbcType="VARCHAR" property="avsample_msg" />
27 </resultMap> 32 </resultMap>
28 </mapper> 33 </mapper>
29 \ No newline at end of file 34 \ No newline at end of file
src/main/resources/templates/page/comment.html
@@ -25,25 +25,30 @@ @@ -25,25 +25,30 @@
25 <div class="box-body"> 25 <div class="box-body">
26 <div class="clearfix"> 26 <div class="clearfix">
27 <div class="btn-group margin-bottom pull-left"> 27 <div class="btn-group margin-bottom pull-left">
28 - <input type="hidden" name="state" id="state" value="2">  
29 - <div class="btn-group margin-bottom" id="hide_select_area" style=""> 28 + <div class="btn-group margin-bottom hide" id="hide_select_area">
30 <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom" 29 <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom"
31 - value="2" data="claim" data-toggle="modal" data-target="#modal"  
32 id="more_pass">批量通过 30 id="more_pass">批量通过
33 </button> 31 </button>
34 <button type="button" class="btn btn-danger btn-sm margin-r-5 action_bottom" 32 <button type="button" class="btn btn-danger btn-sm margin-r-5 action_bottom"
35 - value="2" data="claim" data-toggle="modal" data-target="#modal"  
36 id="more_reject">批量拒绝 33 id="more_reject">批量拒绝
37 </button> 34 </button>
38 </div> 35 </div>
39 36
  37 + <div class="btn-group margin-bottom" id="receive_select" >
  38 + <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom" onclick="receive(0);">认领</button>
  39 + <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom" onclick="receive(100);">认领100条</button>
  40 + <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom" onclick="receive(1000);">认领1000条</button>
  41 + <button type="button" class="btn btn-warning btn-sm margin-r-5 action_bottom" onclick="retReceive();">退领</button>
  42 + </div>
  43 +
40 </div> 44 </div>
41 45
42 <div class="btn-group margin-bottom pull-right"> 46 <div class="btn-group margin-bottom pull-right">
43 - <div class="btn-group margin-bottom" style="">  
44 - <button type="button" class="btn btn-info btn-sm margin-r-5 action_bottom" onclick="searchStatus('')">全部</button>  
45 - <button type="button" class="btn btn-success btn-sm margin-r-5 action_bottom" onclick="searchStatus('1,2')">已审</button>  
46 - <button type="button" class="btn btn-danger btn-sm margin-r-5 action_bottom" onclick="searchStatus('0')">未审</button> 47 + <div class="btn-group margin-bottom">
  48 + <button type="button" th:class="${param.state==null and param.receive==null}?'btn btn-info btn-sm margin-r-5 action_bottom':'btn btn-sm margin-r-5 action_bottom'" onclick="searchStatus('','')">全部</button>
  49 + <button type="button" th:class="${param.state==0 and param.receive==null}?'btn btn-warning btn-sm margin-r-5 action_bottom':'btn btn-sm margin-r-5 action_bottom'" onclick="searchStatus('0','')">全部待审</button>
  50 + <button type="button" th:class="${param.state!=null and param.state!=0 and param.receive==true}?'btn btn-success btn-sm margin-r-5 action_bottom':'btn btn-sm margin-r-5 action_bottom'" onclick="searchStatus('1,2',true)">我的已审</button>
  51 + <button type="button" th:class="${param.state==0 and param.receive==true}?'btn btn-danger btn-sm margin-r-5 action_bottom':'btn btn-sm margin-r-5 action_bottom'" onclick="searchStatus('0',true)">我的未审</button>
47 </div> 52 </div>
48 <button type="button" class="btn btn-primary btn-sm margin-r-5" id="query" 53 <button type="button" class="btn btn-primary btn-sm margin-r-5" id="query"
49 onclick="openOrClose(&#39;forms&#39;)">高级查询 54 onclick="openOrClose(&#39;forms&#39;)">高级查询
@@ -234,12 +239,24 @@ @@ -234,12 +239,24 @@
234 <a class="detail" th:href="@{'/comments/details/'+${comment.id}}"> 239 <a class="detail" th:href="@{'/comments/details/'+${comment.id}}">
235 <button class="btn btn-info btn-sm">查看</button> 240 <button class="btn btn-info btn-sm">查看</button>
236 </a> 241 </a>
237 - <span> &nbsp;</span>  
238 - <a class="pass_one" th:href="@{'javascript:comment('+${comment.id}+',1)'}"> 242 +
  243 + <span th:if="${comment.state==0 and !comment.receive}"> &nbsp;</span>
  244 + <a th:href="@{'javascript:applyReceive('+${comment.id}+')'}" th:if="${comment.state==0 and !comment.receive}">
  245 + <button class="btn btn-primary btn-sm">认领</button>
  246 + </a>
  247 +
  248 + <span th:if="${comment.state==0 and comment.receive and session.sessionUser.userId==comment.receive_user_id}"> &nbsp;</span>
  249 + <a th:href="@{'javascript:applyRetReceive('+${comment.id}+')'}" th:if="${comment.state==0 and comment.receive and session.sessionUser.userId==comment.receive_user_id}">
  250 + <button class="btn btn-warning btn-sm">退领</button>
  251 + </a>
  252 +
  253 + <span th:if="${comment.receive and session.sessionUser.userId==comment.receive_user_id}"> &nbsp;</span>
  254 + <a class="pass_one" th:href="@{'javascript:comment('+${comment.id}+',1)'}" th:if="${comment.receive and session.sessionUser.userId==comment.receive_user_id}">
239 <button class="btn btn-success btn-sm">通过</button> 255 <button class="btn btn-success btn-sm">通过</button>
240 </a> 256 </a>
241 - <span> &nbsp;</span>  
242 - <a class="failed_one" th:href="@{'javascript:comment('+${comment.id}+',2)'}"> 257 +
  258 + <span th:if="${comment.receive and session.sessionUser.userId==comment.receive_user_id}"> &nbsp;</span>
  259 + <a class="failed_one" th:href="@{'javascript:comment('+${comment.id}+',2)'}" th:if="${comment.receive and session.sessionUser.userId==comment.receive_user_id}">
243 <button class="btn btn-danger btn-sm">拒绝</button> 260 <button class="btn btn-danger btn-sm">拒绝</button>
244 </a> 261 </a>
245 </td> 262 </td>
@@ -321,11 +338,11 @@ @@ -321,11 +338,11 @@
321 } 338 }
322 }) 339 })
323 //已审、未审、全部,状态切换 340 //已审、未审、全部,状态切换
324 - function searchStatus(commentStatus){ 341 + function searchStatus(commentStatus,receive){
325 var href = location.href; 342 var href = location.href;
326 if(sea==""){//没有参数 343 if(sea==""){//没有参数
327 if(href.endsWith("?"))href = href.substring(0,href.length-1); 344 if(href.endsWith("?"))href = href.substring(0,href.length-1);
328 - href = href+"?state="+commentStatus; 345 + if($.trim(commentStatus)!='')href = href+"?state="+commentStatus;
329 }else if(sea.indexOf("state=")<0){//没有参数state 346 }else if(sea.indexOf("state=")<0){//没有参数state
330 var se = sea.replace("?","");//去掉问号,防止问号和要去掉的参数相连 347 var se = sea.replace("?","");//去掉问号,防止问号和要去掉的参数相连
331 if(sea.indexOf("page=")>=0){//有参数page,去掉 348 if(sea.indexOf("page=")>=0){//有参数page,去掉
@@ -337,7 +354,7 @@ @@ -337,7 +354,7 @@
337 } 354 }
338 se = h.substring(1); 355 se = h.substring(1);
339 } 356 }
340 - href = location.origin+location.pathname+"?"+se+"&state="+commentStatus; 357 + if($.trim(commentStatus)!='')href = location.origin+location.pathname+"?"+se+"&state="+commentStatus;
341 }else{//有参数state 358 }else{//有参数state
342 if(href.indexOf("&")>=0){//有其他参数,去掉page和旧的state 359 if(href.indexOf("&")>=0){//有其他参数,去掉page和旧的state
343 var se = sea.replace("?","");//去掉问号 360 var se = sea.replace("?","");//去掉问号
@@ -349,7 +366,22 @@ @@ -349,7 +366,22 @@
349 } 366 }
350 href =location.origin+location.pathname+"?"+ h.substring(1); 367 href =location.origin+location.pathname+"?"+ h.substring(1);
351 }else{//只有state参数,直接拼接链接 368 }else{//只有state参数,直接拼接链接
352 - href = location.origin+location.pathname+"?state="+commentStatus; 369 + if($.trim(commentStatus)!='')href = location.origin+location.pathname+"?state="+commentStatus;
  370 + }
  371 + }
  372 + //去掉领取参数
  373 + if(href.indexOf("receive")>=0){
  374 + href = href.replace("receive=true","");
  375 + }
  376 + href = href.replace("&&","&");
  377 + href = href.replace("?&","?");
  378 + if(href.endsWith("&"))href = href.substring(0,href.length-1);
  379 + if(href.endsWith("?"))href = href.substring(0,href.length-1);
  380 + if(receive==true){
  381 + if(href.indexOf("=")>0){//有其他参数
  382 + href+="&receive=true";
  383 + }else{
  384 + href+="?receive=true";
353 } 385 }
354 } 386 }
355 location.href = href; 387 location.href = href;
@@ -442,6 +474,80 @@ @@ -442,6 +474,80 @@
442 $('#a_down').show(); 474 $('#a_down').show();
443 } 475 }
444 } 476 }
  477 +
  478 + /**
  479 + * 认领
  480 + */
  481 + function receive(n) {
  482 + if(n>0){
  483 + applyReceiveNum(n);
  484 + } else{
  485 + var rows = $("[name=btSelectItem]:checkbox:checked");
  486 + if (rows.length > 0) {
  487 + var ids = "";
  488 + rows.each(function(i,e){
  489 + ids = ids + "," + e.value;
  490 + })
  491 + ids = ids.substring(1);
  492 + applyReceive(ids);
  493 + }else{
  494 + alert("请选择要认领的内容!");
  495 + }
  496 + }
  497 + }
  498 +
  499 + //认领选中请求
  500 + function applyReceive(ids){
  501 + $.post("/comments/receive?ids="+ids,function (data) {
  502 + if (data.errorCode==0){
  503 + alert(data.errorMessage);
  504 + location.href = location.href;
  505 + } else{
  506 + alert(data.errorMessage);
  507 + }
  508 + })
  509 + }
  510 + //认领多条请求
  511 + function applyReceiveNum(num){
  512 + $.post("/comments/receive?num="+num,function (data) {
  513 + if (data.errorCode==0){
  514 + alert(data.errorMessage);
  515 + location.href = location.href;
  516 + } else{
  517 + alert(data.errorMessage);
  518 + }
  519 + })
  520 + }
  521 +
  522 + //退领选中内容
  523 + function retReceive(){
  524 + var rows = $("[name=btSelectItem]:checkbox:checked");
  525 + if (rows.length > 0) {
  526 + var r=confirm("您确定退领选中的"+rows.length+"条评论吗?");
  527 + if(r == true){
  528 + var ids = "";
  529 + rows.each(function(i,e){
  530 + ids = ids + "," + e.value;
  531 + })
  532 + ids = ids.substring(1);
  533 + applyRetReceive(ids);
  534 + }
  535 + } else {
  536 + alert("没有选中的数据!");
  537 + }
  538 + }
  539 +
  540 + //退领
  541 + function applyRetReceive(ids){
  542 + $.post("/comments/retReceive?ids="+ids,function (data) {
  543 + if (data.errorCode==0){
  544 + alert(data.errorMessage);
  545 + location.href = location.href;
  546 + } else{
  547 + alert(data.errorMessage);
  548 + }
  549 + })
  550 + }
445 </script> 551 </script>
446 <script> 552 <script>
447 /*时间插件*/ 553 /*时间插件*/