fix error -- my thumbup list

main
wangqing 10 months ago
parent c5eda488c4
commit dcbc48cbce

@ -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);

@ -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);

@ -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<PublicationLike> pageList = myService.getMyThumbupList(userId,page,size);
return null;
return Result.success(new PageResult<PublicationLike>(pageList.getTotalElements(),pageList.getContent()));
}
// 查询我收到的评论

@ -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<PublicationLike,String> {
public Page<PublicationLike> findByThumbupAtOrderByCreateTimeDesc(String thumbupAt, Pageable pageable);
}

@ -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<PublicationLike> getMyThumbupList(String userId, int page, int size) {
Pageable pageable = PageRequest.of(page-1,size);
return publicationLikeDao.findByThumbupAtOrderByCreateTimeDesc(userId,pageable);
}

Loading…
Cancel
Save