package com.nbclass.activity.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nbclass.activity.mapper.CommentMapper;
import com.nbclass.activity.model.*;
import com.nbclass.activity.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public Content getComment(Long contentId,Long userId) {
        return commentMapper.getComment(contentId,userId);
    }

    @Override
    public Comment getCommentReplyList(Long commentId, Long userId) {
        return commentMapper.getCommentReplyList(commentId,userId);
    }

    @Override
    public void saveComment(Comment comment) {
        commentMapper.saveComment(comment);
    }

    @Override
    public Comment getCommentUserId(Long commentId) {
        return commentMapper.getCommentUserId(commentId);
    }

    @Override
    public void savePraiseNo(Praise praise) {
        commentMapper.savePraiseNo(praise);
    }

    @Override
    public void updateContentPraiseNo(Long contentId) {
        commentMapper.updateContentPraiseNo(contentId);
    }

    @Override
    public void updatePraiseno(Long commentId) {
        commentMapper.updatePraiseno(commentId);
    }

    @Override
    public void saveUserReply(Comment comment) {
        commentMapper.saveUserReply(comment);
    }

    @Override
    public void saveReport(Report report) {
        commentMapper.saveReport(report);
    }

    @Override
    public PageInfo<Report> getReport(Integer page, Integer pageSize, String userId) {
        PageHelper.startPage(page,pageSize);
        List<Report> list = commentMapper.getReport(userId);
        return new PageInfo<>(list);
    }

    @Override
    public void saveLabelLogger(LabelLogger labelLogger) {
        commentMapper.saveLabelLogger(labelLogger);
    }

    @Override
    public void saveFavorites(FavoritesFolder favoritesFolder) {
        commentMapper.saveFavorites(favoritesFolder);
    }

    @Override
    public PageInfo<FavoritesFolder> getUserFolder(Long userId, Integer page, Integer pageSize,Long commentId) {
        PageHelper.startPage(page,pageSize);
        List<FavoritesFolder> list = commentMapper.getUserFolder(userId,commentId);
        return new PageInfo<>(list);
    }

    @Override
    public void saveFolder(Long folderId,Long contentId) {
        commentMapper.saveFolder(folderId,contentId);
    }

    @Override
    public void saveFolderTotal(Long folderId) {
        commentMapper.saveFolderTotal(folderId);
    }

    @Override
    public int getFolderExistence(Long folderId, Long contentId) {
        return commentMapper.getFolderExistence(folderId,contentId);
    }

    @Override
    public int getFavoritesName(String name) {
        return commentMapper.getFavoritesName(name);
    }

    @Override
    public void deleteFolderResources(Long folderId, Long contentId) {
        commentMapper.deleteFolderResources(folderId,contentId);
    }

    @Override
    public PageInfo<Content> getMyCollection(Long userId, Integer page, Integer pageSize,Long folderId) {
        PageHelper.startPage(page,pageSize);
        List<Content> list = commentMapper.getMyCollection(userId,folderId);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<FavoritesFolder> getUserFolderList(Long userId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<FavoritesFolder> list = commentMapper.getUserFolderList(userId);
        return new PageInfo<>(list);
    }

    @Override
    public void deletePraise(Long commentId, Long userId) {
        commentMapper.deletePraise(commentId,userId);
    }

    @Override
    public void updatePraiseNoONE(Long commentId) {
        commentMapper.updatePraiseNoONE(commentId);
    }

    @Override
    public void updateReplyNumberONE(Long commentId) {
        commentMapper.updateReplyNumberONE(commentId);
    }

    @Override
    public PageInfo<Comment> getReplyList(Long userId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Comment> list = commentMapper.getReplyList(userId);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<Comment> getFabulousList(Long userId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Comment> list = commentMapper.getFabulousList(userId);
        return new PageInfo<>(list);
    }

    @Override
    public void updateCollectionNumber(Long contentId) {
        commentMapper.updateCollectionNumber(contentId);
    }

    @Override
    public void updateCollectionNumberReduce(Long contentId) {
        commentMapper.updateCollectionNumberReduce(contentId);
    }

    @Override
    public PageInfo<LabelLogger> getLabelLogger(Integer page, Integer pageSize, Long userId) {
        PageHelper.startPage(page,pageSize);
        List<LabelLogger> list = commentMapper.getLabelLogger(userId);
        return new PageInfo<>(list);
    }

    @Override
    public void saveScoring(Scoring scoring) {
        commentMapper.saveScoring(scoring);
    }

}
