package com.wsk.travelf.service;

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

@Service
public class CategoryService {

    @Autowired
    CategoryMapper categoryMapper;

    //分页查询
    public Page<Category> findPage(int page,int size) {
        return categoryMapper.selectPage(new Page<>(page,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);
    }

    //根据ID删除分类
    public void deleteById(Integer cid) {
        categoryMapper.deleteById(cid);
    }

}
