/** 朋友圈 喜歡功能* *//** * 喜歡 * */@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){ //查詢喜歡數(shù) 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){ //查詢喜歡數(shù) 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(), ‘,’)); //當(dāng)前 戶 User user = UserThreadLocal.get(); quanZiVo.setCommentCount(0); //TODO 評(píng)論數(shù) quanZiVo.setDistance(“1.2公 “); //TODO 距離 quanZiVo.setHasLiked(this.quanZiApi.queryUserIsLike(user.getId(), quanZiVo.getId()) ? 1 : 0); //是否點(diǎn)贊(1是,0否) quanZiVo.setLikeCount(Convert.toInt(this.quanZiApi.queryLikeCount(quanZiVo.getId()))); //點(diǎn)贊數(shù) quanZiVo.setHasLoved(this.quanZiApi.queryUserIsLove(user.getId(), quanZiVo.getId()) ? 1 : 0); //是否喜歡(1是,0否) quanZiVo.setLoveCount(Convert.toInt(this.quanZiApi.queryLoveCount(quanZiVo.getId()))); //喜歡數(shù)}