/** 朋友圈 喜欢功能* *//** * 喜欢 * */@GetMapping(“/{id}/love”)public ResponseEntity loveComment(@PathVariable(“id”) String publishId) { try { Long loveCount = this.quanZiService.loveComment(publishId); if (null != loveCount) { return ResponseEntity.ok(loveCount); } } catch (Exception e) { e.printStackTrace(); } return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();}/** * 取消喜欢 * */@GetMapping(“/{id}/unlove”)public ResponseEntity disLoveComment(@PathVariable(“id”) String publishId) { try { Long loveCount = this.quanZiService.disLoveComment(publishId); if (null != loveCount) { return ResponseEntity.ok(loveCount); } } catch (Exception e) { e.printStackTrace(); } return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();}
朋友圈 喜欢功能 service
/** 朋友圈 喜欢功能* */public Long loveComment(String publishId) { User user = UserThreadLocal.get(); //喜欢 Boolean result = this.quanZiApi.loveComment(user.getId(), publishId); if(result){ //查询喜欢数 return this.quanZiApi.queryLoveCount(publishId); } return null;}public Long disLoveComment(String publishId) { User user = UserThreadLocal.get(); //取消喜欢 Boolean result = this.quanZiApi.disLoveComment(user.getId(), publishId); if(result){ //查询喜欢数 return this.quanZiApi.queryLoveCount(publishId); } return null;}/** * 填充 户信息 * * @param userInfo * @param quanZiVo */private void fillUserInfoToQuanZiVo(UserInfo userInfo, QuanZiVo quanZiVo) { BeanUtil.copyProperties(userInfo, quanZiVo, “id”); quanZiVo.setGender(userInfo.getSex().name().toLowerCase()); quanZiVo.setTags(StringUtils.split(userInfo.getTags(), ‘,’)); //当前 户 User user = UserThreadLocal.get(); quanZiVo.setCommentCount(0); //TODO 评论数 quanZiVo.setDistance(“1.2公 “); //TODO 距离 quanZiVo.setHasLiked(this.quanZiApi.queryUserIsLike(user.getId(), quanZiVo.getId()) ? 1 : 0); //是否点赞(1是,0否) quanZiVo.setLikeCount(Convert.toInt(this.quanZiApi.queryLikeCount(quanZiVo.getId()))); //点赞数 quanZiVo.setHasLoved(this.quanZiApi.queryUserIsLove(user.getId(), quanZiVo.getId()) ? 1 : 0); //是否喜欢(1是,0否) quanZiVo.setLoveCount(Convert.toInt(this.quanZiApi.queryLoveCount(quanZiVo.getId()))); //喜欢数}