package com.bjtdba.userCenter.service.impl;

import com.bjtdba.entity.userCenter.UserVideoComment;
import com.bjtdba.userCenter.dao.UserVideoCommentDao;
import com.bjtdba.userCenter.service.UserVideoCommentService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

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

/**
 * 视频评论表(UserVideoComment)表服务实现类
 *
 * @author 何海强
 * @since 2022-11-16 10:42:03
 */
@Service("userVideoCommentService")
public class UserVideoCommentServiceImpl implements UserVideoCommentService {
    @Resource
    private UserVideoCommentDao userVideoCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param mid 主键
     * @return 实例对象
     */
    @Override
    public UserVideoComment queryById(Integer mid) {
        return this.userVideoCommentDao.queryById(mid);
    }


    /**
     * 分页查询
     *
     * @param userVideoComment 筛选条件
     * @return 查询结果
     */

//    @Override
//    public Page<UserVideoComment> queryByPage(UserVideoComment userVideoComment, PageRequest pageRequest) {
//        long total = this.userVideoCommentDao.count(userVideoComment);
//        return new PageImpl<>(this.userVideoCommentDao.queryAllByLimit(userVideoComment, pageRequest), pageRequest, total);
//    }

    @Override
    public Page<UserVideoComment> queryByPage(UserVideoComment userVideoComment) {
        return null;
    }

    @Override
    public List<UserVideoComment> quertList(UserVideoComment userVideoComment) {
        return this.userVideoCommentDao.queryAllByLimit(userVideoComment);
    }

    @Override
    public long counts(UserVideoComment userVideoComment) {
        return this.userVideoCommentDao.count(userVideoComment);
    }


    /**
     * 新增数据
     *
     * @param userVideoComment 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoComment insert(UserVideoComment userVideoComment) {
        this.userVideoCommentDao.insert(userVideoComment);
        return userVideoComment;
    }

    /**
     * 修改数据
     *
     * @param userVideoComment 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoComment update(UserVideoComment userVideoComment) {
        this.userVideoCommentDao.update(userVideoComment);
        return this.queryById(userVideoComment.getMid());
    }

    /**
     * 通过主键删除数据
     *
     * @param mid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer mid) {
        return this.userVideoCommentDao.deleteById(mid) > 0;
    }
}
