diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 0feac92..5015030 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -241,6 +241,7 @@ public class CommentController extends BaseController { } String userId = userLoginDto.getUserId(); String avatar = userLoginDto.getAvatar(); + String nickName = userLoginDto.getNickName(); // if(redisTemplate.opsForValue().get("thumbup_"+commentId+"_"+userId)!=null){ // @@ -248,7 +249,7 @@ public class CommentController extends BaseController { // } // 判断当前用户是否已经点赞 - Integer flag = likeService.likePublication(commentId,userId,2,avatar); + Integer flag = likeService.likePublication(commentId,userId,2,avatar,nickName); if (flag==0) { //当前用户已经点过赞,执行取消点赞 likeService.unlikePublication(commentId,userId,2); diff --git a/luoo_comment/src/main/java/com/luoo/comment/service/LikeService.java b/luoo_comment/src/main/java/com/luoo/comment/service/LikeService.java index 73417f9..2e72c6d 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/service/LikeService.java +++ b/luoo_comment/src/main/java/com/luoo/comment/service/LikeService.java @@ -25,7 +25,7 @@ public class LikeService { @Autowired private IdWorker idWorker; - public Integer likePublication(String publicationId, String userId, Integer type,String avatar) { + public Integer likePublication(String publicationId, String userId, Integer type,String avatar,String nickName) { // 构建查询条件 Criteria criteria = Criteria.where("userId").is(userId) .and("type").is(type) @@ -47,6 +47,7 @@ public class LikeService { publicationLike.setLikedItemId(publicationId); publicationLike.setUserId(userId); publicationLike.setAvatar(Constants.RESOURCE_PREFIX + avatar); + publicationLike.setNickName(nickName); publicationLike.setThumbupAt(comment.getUserId()); publicationLike.setCommentContent(comment.getContent()); mongoTemplate.save(publicationLike); diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index b2ea42b..68eab22 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import com.luoo.user.dto.TotalCommentVo; import com.luoo.user.pojo.Feedback; +import com.luoo.user.pojo.PublicationLike; import com.luoo.user.pojo.UserCollectInfo; import com.luoo.user.service.*; import org.springframework.beans.BeanUtils; @@ -321,9 +322,12 @@ public class MyController extends BaseController { return Result.unauthorized(null); } String userId = userLoginDto.getUserId(); - myService.getMyThumbupList(userId); + Page pageList = myService.getMyThumbupList(userId,page,size); - return null; + + + + return Result.success(new PageResult(pageList.getTotalElements(),pageList.getContent())); } // 查询我收到的评论 diff --git a/luoo_user/src/main/java/com/luoo/user/dao/PublicationLikeDao.java b/luoo_user/src/main/java/com/luoo/user/dao/PublicationLikeDao.java index 8c6d3de..c52fc42 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/PublicationLikeDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/PublicationLikeDao.java @@ -1,7 +1,11 @@ package com.luoo.user.dao; import com.luoo.user.pojo.PublicationLike; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.mongodb.repository.MongoRepository; public interface PublicationLikeDao extends MongoRepository { + + public Page findByThumbupAtOrderByCreateTimeDesc(String thumbupAt, Pageable pageable); } diff --git a/luoo_user/src/main/java/com/luoo/user/service/MyService.java b/luoo_user/src/main/java/com/luoo/user/service/MyService.java index a753bcd..fb35398 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/MyService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/MyService.java @@ -1,7 +1,12 @@ package com.luoo.user.service; +import com.luoo.user.dao.PublicationLikeDao; +import com.luoo.user.pojo.PublicationLike; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Service; @@ -11,11 +16,16 @@ public class MyService { @Autowired private MongoTemplate mongoTemplate; + + @Autowired + private PublicationLikeDao publicationLikeDao; /** * 我收到的评论 * @param userId */ public void getMyCommentReplyList(String userId) { + + } @@ -23,8 +33,10 @@ public class MyService { * 我收到的点赞 * @param userId */ - public void getMyThumbupList(String userId) { + public Page getMyThumbupList(String userId, int page, int size) { + Pageable pageable = PageRequest.of(page-1,size); + return publicationLikeDao.findByThumbupAtOrderByCreateTimeDesc(userId,pageable); }