CommentService.java 1 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package com.tanpu.community.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.mapper.community.CommentMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentService {

    @Resource
    private CommentMapper commentMapper;

    public void insertComment(CommentEntity commentEntity){
        commentMapper.insert(commentEntity);
    }




    public List<CommentEntity> selectByUserId(String userId){
        return commentMapper.selectList(new LambdaQueryWrapper<CommentEntity>().eq(CommentEntity::getAuthorId,userId));
    }
刘基明's avatar
刘基明 committed
27 28 29 30 31 32 33

    //统计主题集合的评论量
    public Long getCommentAmountByThemeIds(List<String> themeIds){
        return (long) commentMapper.selectList((new LambdaQueryWrapper<CommentEntity>()
                .in(CommentEntity::getTargetId, themeIds)))
                .size();
    }
刘基明's avatar
刘基明 committed
34
}