Commit 221e5b8be456db6f6434b677445d49f2f700b6ee
Merge branch 'dev' of http://bj.gitlab.cnlive.com/zhouweipeng/cnlive_shenhe into dev
Showing
9 changed files
with
429 additions
and
56 deletions
src/main/java/com/cnlive/shenhe/controller/CommentsController.java
| ... | ... | @@ -48,10 +48,11 @@ public class CommentsController { |
| 48 | 48 | */ |
| 49 | 49 | @GetMapping("/page") |
| 50 | 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 | 52 | Integer page, Integer pageSize, String orderByClause, HttpSession session) { |
| 53 | 53 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 54 | 54 | Integer spid = sessionUser.getSpid(); |
| 55 | + String userId = sessionUser.getUserId(); | |
| 55 | 56 | if (spid == 0) spid = null; |
| 56 | 57 | if (CommonUtils.isNull(page)) page = 1; |
| 57 | 58 | if (CommonUtils.isNull(pageSize)) pageSize = 10; |
| ... | ... | @@ -70,7 +71,7 @@ public class CommentsController { |
| 70 | 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 | 75 | List<ShyComments> list = commentPage.getList(); |
| 75 | 76 | if (!list.isEmpty()) { |
| 76 | 77 | for (ShyComments comment : list) { |
| ... | ... | @@ -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 | 1 | package com.cnlive.shenhe.entity; |
| 2 | 2 | |
| 3 | +import javax.persistence.Id; | |
| 4 | +import javax.persistence.Table; | |
| 5 | +import javax.persistence.Transient; | |
| 3 | 6 | import java.util.Date; |
| 4 | -import javax.persistence.*; | |
| 5 | 7 | |
| 6 | 8 | @Table(name = "shy_comments") |
| 7 | 9 | public class ShyComments { |
| ... | ... | @@ -64,11 +66,6 @@ public class ShyComments { |
| 64 | 66 | * 审核员id |
| 65 | 67 | */ |
| 66 | 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 | 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 | 126 | * @return id |
| 114 | 127 | */ |
| 115 | 128 | public Integer getId() { |
| ... | ... | @@ -489,6 +502,42 @@ public class ShyComments { |
| 489 | 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 | 541 | public String getAuditor() { |
| 493 | 542 | return auditor; |
| 494 | 543 | } | ... | ... |
src/main/java/com/cnlive/shenhe/entity/ShyUsers.java
| 1 | 1 | package com.cnlive.shenhe.entity; |
| 2 | 2 | |
| 3 | +import javax.persistence.Id; | |
| 4 | +import javax.persistence.Table; | |
| 3 | 5 | import java.util.Date; |
| 4 | -import javax.persistence.*; | |
| 5 | 6 | |
| 6 | 7 | @Table(name = "shy_users") |
| 7 | 8 | public class ShyUsers { |
| ... | ... | @@ -63,19 +64,6 @@ public class ShyUsers { |
| 63 | 64 | private Long tm; |
| 64 | 65 | |
| 65 | 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 | 69 | * @return id | ... | ... |
src/main/java/com/cnlive/shenhe/entity/ShyVideos.java
| 1 | 1 | package com.cnlive.shenhe.entity; |
| 2 | 2 | |
| 3 | +import javax.persistence.Id; | |
| 4 | +import javax.persistence.Table; | |
| 5 | +import javax.persistence.Transient; | |
| 3 | 6 | import java.util.Date; |
| 4 | -import javax.persistence.*; | |
| 5 | 7 | |
| 6 | 8 | @Table(name = "shy_videos") |
| 7 | 9 | public class ShyVideos { |
| ... | ... | @@ -45,7 +47,7 @@ public class ShyVideos { |
| 45 | 47 | private String callback; |
| 46 | 48 | |
| 47 | 49 | /** |
| 48 | - * 优先级 | |
| 50 | + * 优先级,1:热点,0:非热点 | |
| 49 | 51 | */ |
| 50 | 52 | private String video_priority; |
| 51 | 53 | |
| ... | ... | @@ -82,20 +84,38 @@ public class ShyVideos { |
| 82 | 84 | private Date created_at; |
| 83 | 85 | |
| 84 | 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 | 116 | @Transient |
| 89 | 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 | 120 | * @return id |
| 101 | 121 | */ |
| ... | ... | @@ -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 | 288 | public String getVideo_priority() { |
| 269 | 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 | 297 | public void setVideo_priority(String video_priority) { |
| 278 | 298 | this.video_priority = video_priority; |
| ... | ... | @@ -413,4 +433,102 @@ public class ShyVideos { |
| 413 | 433 | public void setUpdated_at(Date updated_at) { |
| 414 | 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 | 535 | \ No newline at end of file | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
| ... | ... | @@ -47,7 +47,7 @@ public class CommentsServiceImpl { |
| 47 | 47 | |
| 48 | 48 | //************************************** |
| 49 | 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 | 51 | return commentsList; |
| 52 | 52 | } |
| 53 | 53 | |
| ... | ... | @@ -74,7 +74,7 @@ public class CommentsServiceImpl { |
| 74 | 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 | 78 | Example example = new Example(ShyComments.class); |
| 79 | 79 | Example.Criteria criteria = example.createCriteria(); |
| 80 | 80 | if (CommonUtils.isNotEmpty(orderByClause)) { |
| ... | ... | @@ -101,6 +101,13 @@ public class CommentsServiceImpl { |
| 101 | 101 | if (CommonUtils.isNotEmpty(activity_id)) { |
| 102 | 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 | 111 | if (CommonUtils.isNotEmpty(states)) { |
| 105 | 112 | Example.Criteria criteria1 = example.createCriteria(); |
| 106 | 113 | String[] stas = states.split(","); |
| ... | ... | @@ -109,6 +116,7 @@ public class CommentsServiceImpl { |
| 109 | 116 | } |
| 110 | 117 | example.and(criteria1); |
| 111 | 118 | } |
| 119 | + | |
| 112 | 120 | PageHelper.startPage(page, pageSize, true); |
| 113 | 121 | List<ShyComments> commentsList = shyCommentsMapper.selectByExample(example); |
| 114 | 122 | PageInfo<ShyComments> pageInfo = new PageInfo<>(commentsList); |
| ... | ... | @@ -124,8 +132,8 @@ public class CommentsServiceImpl { |
| 124 | 132 | ShyUsers user = new ShyUsers(); |
| 125 | 133 | user.setUser_id(auditor_id); |
| 126 | 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 | 137 | auditorName = userName + email; |
| 130 | 138 | } |
| 131 | 139 | comment.setAuditor(auditorName); |
| ... | ... | @@ -138,6 +146,12 @@ public class CommentsServiceImpl { |
| 138 | 146 | String[] commentIds = ids.split(","); |
| 139 | 147 | for (String commentId : commentIds) { |
| 140 | 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 | 155 | JSONObject json = new JSONObject(); |
| 142 | 156 | json.put("activity_id", comment.getActivity_id()); |
| 143 | 157 | json.put("state", state + 2); |
| ... | ... | @@ -173,6 +187,55 @@ public class CommentsServiceImpl { |
| 173 | 187 | } |
| 174 | 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 | 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 | 39 | public static Integer USER_STATUS_USE = 1; | ... | ... |
src/main/resources/mapper/ShyCommentsMapper.xml
| ... | ... | @@ -27,5 +27,7 @@ |
| 27 | 27 | <result column="comment_user_ip" jdbcType="CHAR" property="comment_user_ip" /> |
| 28 | 28 | <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> |
| 29 | 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 | 32 | </resultMap> |
| 31 | 33 | </mapper> |
| 32 | 34 | \ No newline at end of file | ... | ... |
src/main/resources/mapper/ShyVideosMapper.xml
| ... | ... | @@ -24,5 +24,10 @@ |
| 24 | 24 | <result column="video_id" jdbcType="VARCHAR" property="video_id" /> |
| 25 | 25 | <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> |
| 26 | 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 | 32 | </resultMap> |
| 28 | 33 | </mapper> |
| 29 | 34 | \ No newline at end of file | ... | ... |
src/main/resources/templates/page/comment.html
| ... | ... | @@ -25,25 +25,30 @@ |
| 25 | 25 | <div class="box-body"> |
| 26 | 26 | <div class="clearfix"> |
| 27 | 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 | 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 | 30 | id="more_pass">批量通过 |
| 33 | 31 | </button> |
| 34 | 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 | 33 | id="more_reject">批量拒绝 |
| 37 | 34 | </button> |
| 38 | 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 | 44 | </div> |
| 41 | 45 | |
| 42 | 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 | 52 | </div> |
| 48 | 53 | <button type="button" class="btn btn-primary btn-sm margin-r-5" id="query" |
| 49 | 54 | onclick="openOrClose('forms')">高级查询 |
| ... | ... | @@ -234,12 +239,24 @@ |
| 234 | 239 | <a class="detail" th:href="@{'/comments/details/'+${comment.id}}"> |
| 235 | 240 | <button class="btn btn-info btn-sm">查看</button> |
| 236 | 241 | </a> |
| 237 | - <span> </span> | |
| 238 | - <a class="pass_one" th:href="@{'javascript:comment('+${comment.id}+',1)'}"> | |
| 242 | + | |
| 243 | + <span th:if="${comment.state==0 and !comment.receive}"> </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}"> </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}"> </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 | 255 | <button class="btn btn-success btn-sm">通过</button> |
| 240 | 256 | </a> |
| 241 | - <span> </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}"> </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 | 260 | <button class="btn btn-danger btn-sm">拒绝</button> |
| 244 | 261 | </a> |
| 245 | 262 | </td> |
| ... | ... | @@ -321,11 +338,11 @@ |
| 321 | 338 | } |
| 322 | 339 | }) |
| 323 | 340 | //已审、未审、全部,状态切换 |
| 324 | - function searchStatus(commentStatus){ | |
| 341 | + function searchStatus(commentStatus,receive){ | |
| 325 | 342 | var href = location.href; |
| 326 | 343 | if(sea==""){//没有参数 |
| 327 | 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 | 346 | }else if(sea.indexOf("state=")<0){//没有参数state |
| 330 | 347 | var se = sea.replace("?","");//去掉问号,防止问号和要去掉的参数相连 |
| 331 | 348 | if(sea.indexOf("page=")>=0){//有参数page,去掉 |
| ... | ... | @@ -337,7 +354,7 @@ |
| 337 | 354 | } |
| 338 | 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 | 358 | }else{//有参数state |
| 342 | 359 | if(href.indexOf("&")>=0){//有其他参数,去掉page和旧的state |
| 343 | 360 | var se = sea.replace("?","");//去掉问号 |
| ... | ... | @@ -349,7 +366,22 @@ |
| 349 | 366 | } |
| 350 | 367 | href =location.origin+location.pathname+"?"+ h.substring(1); |
| 351 | 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 | 387 | location.href = href; |
| ... | ... | @@ -442,6 +474,80 @@ |
| 442 | 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 | 551 | </script> |
| 446 | 552 | <script> |
| 447 | 553 | /*时间插件*/ | ... | ... |