CommentService.java 1.01 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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;

刘基明's avatar
刘基明 committed
17
    public void insertComment(CommentEntity commentEntity) {
刘基明's avatar
刘基明 committed
18 19 20 21
        commentMapper.insert(commentEntity);
    }


刘基明's avatar
刘基明 committed
22 23
    public List<CommentEntity> selectByUserId(String userId) {
        return commentMapper.selectList(new LambdaQueryWrapper<CommentEntity>().eq(CommentEntity::getAuthorId, userId));
刘基明's avatar
刘基明 committed
24
    }
刘基明's avatar
刘基明 committed
25 26

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