package com.ruoyi.zhushi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.zhushi.entity.Category;
import com.ruoyi.zhushi.mapper.RankingCategoryMapper;
import com.ruoyi.zhushi.service.RankingCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RankingCategoryServiceImpl implements RankingCategoryService {

    @Autowired
    private RankingCategoryMapper rankingCategoryMapper;

    @Override
    public boolean add(Category category) {
        int i = rankingCategoryMapper.insert(category);
        return i==0?false:true;
    }

    @Override
    public boolean update(Category category) {
        int i = rankingCategoryMapper.updateById(category);
        return i==0?false:true;
    }

    @Override
    public TableDataInfo<Category> query(String type, PageQuery pageQuery) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", type);
        return TableDataInfo.build(rankingCategoryMapper.selectPage(pageQuery.build(),queryWrapper));
    }

    @Override
    public Category queryById(String id) {
        return rankingCategoryMapper.selectById(id);
    }
}
