package com.example.service;

import com.example.entity.Productype;
import com.example.mapper.ProductypeMapper;
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 ProductypeService {

    @Resource
    private ProductypeMapper productypeMapper;

    /**
     * 新增
     */
    public void add(Productype productype) {
        productypeMapper.insert(productype);
    }

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

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

    /**
     * 修改
     */
    public void updateById(Productype productype) {
        productypeMapper.updateById(productype);
    }

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

    /**
     * 查询所有
     */
    public List<Productype> selectAll(Productype productype) {
        return productypeMapper.selectAll(productype);
    }

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

}