cloudroam
2025-06-04 ed0dc655e6732f15d30f399c0d460ad7b9fe42da
src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java
@@ -1,6 +1,7 @@
package com.mzl.flower.service.film.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.film.CommentLikesDTO;
import com.mzl.flower.dto.request.film.CommentLikesQueryDTO;
import com.mzl.flower.dto.response.film.CommentLikesVO;
@@ -10,12 +11,17 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * @author generator@Fang
 * @since 2025-05-29
 */
@Service
public class CommentLikesServiceImpl extends ServiceImpl<CommentLikesMapper, CommentLikes> implements CommentLikesService {
    @Resource
    private CommentLikesMapper commentLikesMapper;
    @Override
    public void saveCommentLikes(CommentLikesDTO commentLikesDTO) {
@@ -24,7 +30,20 @@
    @Override
    public void updateCommentLikes(CommentLikesDTO commentLikesDTO) {
        //查询有没有对应人员的点赞信息
        CommentLikes commentLikes = commentLikesMapper.getCommentLikeByUserIdAndCommentId(SecurityUtils.getUserId(), commentLikesDTO.getCommentId());
        if (commentLikes == null) {
            CommentLikes commentLikes1 = new CommentLikes();
            commentLikes1.setCommentId(commentLikesDTO.getCommentId());
            commentLikes1.setStatus(true);
            commentLikes1.create();
            commentLikesMapper.insert(commentLikes1);
        } else {
            // 状态取反
            commentLikes.setStatus(!commentLikes.getStatus());
            commentLikes.update(SecurityUtils.getUserId());
            commentLikesMapper.updateById(commentLikes);
        }
    }
    @Override
@@ -36,4 +55,14 @@
    public Page<CommentLikesVO> queryPage(CommentLikesQueryDTO commentLikesQueryDTO, Page page) {
        return null;
    }
    @Override
    public Long getLikeCountCommentId(Integer id) {
        return commentLikesMapper.getLikeCountCommentId(id);
    }
    @Override
    public Boolean isLike(Integer commentId, String userId) {
        return commentLikesMapper.isLike(commentId,userId);
    }
}