package com.itbaizhan.trave.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itbaizhan.trave.mapper.CategoryMapper;
import com.itbaizhan.trave.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    //分页查询
    public Page<Category> findPages(Integer pages,Integer size){
        return categoryMapper.selectPage(new Page(pages,size),null);
    }

    //增
    public void add(Category category){
        categoryMapper.insert(category);
    }

    //根据Id查
    public Category findById(Integer cid){
        return categoryMapper.selectById(cid);
    }

    //修改
    public void update(Category category){
        categoryMapper.updateById(category);
    }

    //删
    public void delete(Integer cid){
        categoryMapper.deleteById(cid);
    }

    //查询所有
    public List<Category> findAll(){
        return categoryMapper.selectList(null);
    }


}
