package com.zd.exam.service.impl;

import java.util.List;

import com.zd.common.core.utils.DateUtils;
import com.zd.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.exam.mapper.ElUserBookMapper;
import com.zd.exam.domain.ElUserBook;
import com.zd.exam.service.IElUserBookService;

/**
 * 错题本Service业务层处理
 *
 * @author zd
 * @date 2021-09-01
 */
@Service
public class ElUserBookServiceImpl implements IElUserBookService {
    @Autowired
    private ElUserBookMapper elUserBookMapper;

    /**
     * 查询错题本
     *
     * @param id 错题本主键
     * @return 错题本
     */
    @Override
    public ElUserBook selectElUserBookById(Long id) {
        return elUserBookMapper.selectElUserBookById(id);
    }

    /**
     * 查询错题本列表
     *
     * @param elUserBook 错题本
     * @return 错题本
     */
    @Override
    @DataScope(deptAlias = "ub")
    public List<ElUserBook> selectElUserBookList(ElUserBook elUserBook) {
        return elUserBookMapper.selectElUserBookList(elUserBook);
    }

    /**
     * 新增错题本
     *
     * @param elUserBook 错题本
     * @return 结果
     */
    @Override
    public int insertElUserBook(ElUserBook elUserBook) {
        elUserBook.setCreateTime(DateUtils.getNowDate());
        return elUserBookMapper.insertElUserBook(elUserBook);
    }

    /**
     * 修改错题本
     *
     * @param elUserBook 错题本
     * @return 结果
     */
    @Override
    public int updateElUserBook(ElUserBook elUserBook) {
        elUserBook.setUpdateTime(DateUtils.getNowDate());
        return elUserBookMapper.updateElUserBook(elUserBook);
    }

    /**
     * 批量删除错题本
     *
     * @param ids 需要删除的错题本主键
     * @return 结果
     */
    @Override
    public int deleteElUserBookByIds(Long[] ids) {
        return elUserBookMapper.deleteElUserBookByIds(ids);
    }

    /**
     * 删除错题本信息
     *
     * @param id 错题本主键
     * @return 结果
     */
    @Override
    public int deleteElUserBookById(Long id) {
        return elUserBookMapper.deleteElUserBookById(id);
    }
}
