package com.bjtdba.userCenter.service.impl;

import com.bjtdba.entity.userCenter.UserVideoShare;
import com.bjtdba.userCenter.dao.UserVideoShareDao;
import com.bjtdba.userCenter.service.UserVideoShareService;
import org.springframework.stereotype.Service;

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

/**
 * 用户分享记录表(UserVideoShare)表服务实现类
 *
 * @author 何海强
 * @since 2022-11-16 17:20:05
 */
@Service("userVideoShareService")
public class UserVideoShareServiceImpl implements UserVideoShareService {
    @Resource
    private UserVideoShareDao userVideoShareDao;

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

    /**
     * 分页查询
     *
     * @param userVideoShare 筛选条件

     * @return 查询结果
     */
//    @Override
//    public Page<UserVideoShare> queryByPage(UserVideoShare userVideoShare, PageRequest pageRequest) {
//        long total = this.userVideoShareDao.count(userVideoShare);
//        return new PageImpl<>(this.userVideoShareDao.queryAllByLimit(userVideoShare, pageRequest), pageRequest, total);
//    }

    public List<UserVideoShare> queryList(UserVideoShare userVideoShare){
        return  this.userVideoShareDao.queryAllByLimit(userVideoShare);
    }

    public  long counts(UserVideoShare userVideoShare){
        return  userVideoShareDao.count(userVideoShare);
    }

    /**
     * 新增数据
     *
     * @param userVideoShare 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoShare insert(UserVideoShare userVideoShare) {
        this.userVideoShareDao.insert(userVideoShare);
        return userVideoShare;
    }

    /**
     * 修改数据
     *
     * @param userVideoShare 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoShare update(UserVideoShare userVideoShare) {
        this.userVideoShareDao.update(userVideoShare);
        return this.queryById(userVideoShare.getSid());
    }

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