package com.quinn.service.impl;

import com.quinn.common.Category;
import com.quinn.pojo.Comment;
import com.quinn.mapper.CommentMapper;
import com.quinn.pojo.CommentWithUser;
import com.quinn.service.CommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author limqsh
 * @since 2020-06-30
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Resource
    CommentMapper commentMapper;

    @Override
    public List<CommentWithUser> getCommentList(String topicId, Category category) {
        if (Category.SOURCE.equals(category)){
            return commentMapper.getSourceCommentList(topicId);
        }
        return commentMapper.getBlogCommentList(topicId);
    }
}
