package com.example.service;

import com.example.entity.SaleStatement;
import com.example.mapper.SaleStatementMapper;
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 SaleStatementService {

    @Resource
    private SaleStatementMapper saleStatementMapper;

    /**
     * 新增
     */
    public void add(SaleStatement saleStatement) {
        saleStatementMapper.insert(saleStatement);
    }

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

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

    /**
     * 修改
     */
    public void updateById(SaleStatement saleStatement) {
        saleStatementMapper.updateById(saleStatement);
    }

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

    /**
     * 查询所有
     */
    public List<SaleStatement> selectAll(SaleStatement saleStatement) {
        return saleStatementMapper.selectAll(saleStatement);
    }

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

}