package cn.feast.coding.service.stock.impl;

import cn.feast.coding.mapper.stock.StockMapper;
import cn.feast.coding.model.stock.Stock;
import cn.feast.coding.service.stock.StockService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * Created By FeastCoding.
 */
@Service
public class StockServiceImpl implements StockService {
    @Autowired
    private StockMapper mapper;

    public int insert(Stock model){
        return mapper.insert(model);
    }

    public int update(Stock model){
        return mapper.update(model);
    }

    public int deleteByPrimaryKey(Integer id){
        return mapper.deleteByPrimaryKey(id);
    }

    public List<Stock> selectAll(Stock model){
        return mapper.selectAll(model);
    }

    public PageInfo<Stock> queryPage(Stock model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Stock> list = mapper.selectAll(model);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    public Stock selectByPrimaryKey(Integer id){
        return mapper.selectByPrimaryKey(id);
    }

    public List<Stock> queryAll(){
        return mapper.queryAll();
    }
}
