package com.bjtdba.userCenter.service.impl;

import com.bjtdba.entity.userCenter.UserVideoLike;
import com.bjtdba.userCenter.dao.UserVideoLikeDao;
import com.bjtdba.userCenter.service.UserVideoLikeService;
import org.springframework.stereotype.Service;

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

/**
 * 用户点赞记录表(UserVideoLike)表服务实现类
 *
 * @author makejava
 * @since 2022-11-12 14:14:10
 */
@Service("userVideoLikeService")
public class UserVideoLikeServiceImpl implements UserVideoLikeService {
    @Resource
    private UserVideoLikeDao userVideoLikeDao;

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

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

   public List<UserVideoLike> queryList(UserVideoLike userVideoLike){
        return this.userVideoLikeDao.queryAllByLimit(userVideoLike);
    }
   public long count(UserVideoLike userVideoLike){
      return userVideoLikeDao.count(userVideoLike);
    }

    /**
     * 新增数据
     *
     * @param userVideoLike 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoLike insert(UserVideoLike userVideoLike) {
        this.userVideoLikeDao.insert(userVideoLike);
        return userVideoLike;
    }

    /**
     * 修改数据
     *
     * @param userVideoLike 实例对象
     * @return 实例对象
     */
    @Override
    public UserVideoLike update(UserVideoLike userVideoLike) {
        this.userVideoLikeDao.update(userVideoLike);
        return this.queryById(userVideoLike.getLid());
    }

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