package com.bjtdba.userCenter.service.impl;

import com.bjtdba.entity.userCenter.UserVideo;
import com.bjtdba.userCenter.dao.UserVideoDao;
import com.bjtdba.userCenter.service.UserVideoService;
import org.springframework.stereotype.Service;

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

/**
 * 用户视频表(UserVideo)表服务实现类
 *
 * @author makejava
 * @since 2022-11-12 09:33:39
 */
@Service("userVideoService")
public class UserVideoServiceImpl implements UserVideoService {
    @Resource
    private UserVideoDao userVideoDao;

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

    /**
     * 分页查询
     *
     * @param userVideo 筛选条件
     * @return 查询结果
     */
    @Override
//    public Page<UserVideo> queryByPage(UserVideo userVideo, PageRequest pageRequest) {
//        long total = this.userVideoDao.count(userVideo);
//        return new PageImpl<>(this.userVideoDao.queryAllByLimit(userVideo, pageRequest), pageRequest, total);
//    }


    public List<UserVideo> queryList(UserVideo userVideo){
        return userVideoDao.queryAllByLimit(userVideo);
    }

    public long count(UserVideo userVideo){
        return userVideoDao.count(userVideo);
    }

    /**
     * 新增数据
     *
     * @param userVideo 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideo insert(UserVideo userVideo) {
        this.userVideoDao.insert(userVideo);
        return userVideo;
    }

    /**
     * 修改数据
     *
     * @param userVideo 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideo update(UserVideo userVideo) {
        this.userVideoDao.update(userVideo);
        return this.queryById(userVideo.getId());
    }

    /**
     * 通过主键删除数据
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String[] ids) {
        return this.userVideoDao.deleteById(ids) > 0;
    }

    public List<UserVideo> queryAllByLike(UserVideo userVideo){
        return userVideoDao.queryAllByLike(userVideo);
    }
}
