package com.example.service;

import com.example.entity.Audits;
import com.example.mapper.AuditsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 申请审核表业务处理
 **/
@Service
public class AuditsService {

    @Resource
    private AuditsMapper auditsMapper;

    /**
     * 新增
     */
    public void add(Audits audits) {
        auditsMapper.insert(audits);
    }

    /**
     * 删除
     */
    public void deleteById(Integer id) {
        auditsMapper.deleteById(id);
    }

    /**
     * 批量删除
     */
    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            auditsMapper.deleteById(id);
        }
    }

    /**
     * 修改
     */
    public void updateById(Audits audits) {
        auditsMapper.updateById(audits);
    }

    /**
     * 根据ID查询
     */
    public Audits selectById(Integer id) {
        return auditsMapper.selectById(id);
    }

    /**
     * 查询所有
     */
    public List<Audits> selectAll(Audits audits) {
        return auditsMapper.selectAll(audits);
    }

    /**
     * 分页查询
     */
    public PageInfo<Audits> selectPage(Audits audits, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Audits> list = auditsMapper.selectAll(audits);
        return PageInfo.of(list);
    }

}