package com.ruoyi.zhushi.controller;

import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.zhushi.entity.Category;
import com.ruoyi.zhushi.service.RankingCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ranking/category")
@Slf4j
public class RankingCategoryController {

    @Autowired
    private RankingCategoryService rankingCategoryService;

    @PostMapping
    public boolean addRankingBase(@RequestBody Category category) {
        return rankingCategoryService.add(category);
    }

    @PutMapping
    public boolean updateRankingBase(@RequestBody Category category) {
        return rankingCategoryService.update(category);
    }
    @GetMapping("/list")
    public TableDataInfo<Category> query(@RequestParam("type") String type, PageQuery pageQuery) {
        System.out.println(1);
        return rankingCategoryService.query(type,pageQuery);
    }
    @GetMapping("/{id}")
    public R<Category> queryById(@PathVariable String id) {

        return R.ok(rankingCategoryService.queryById(id));
    }

}
