package com.ruoyi.zhushi.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.zhushi.entity.InventoryBase;
import com.ruoyi.zhushi.service.InventoryBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/inventorybase")
@Slf4j
public class InventoryBaseController {

    @Autowired
    private InventoryBaseService inventoryBaseService;

    @PostMapping
    public boolean addInventoryBase(@RequestBody InventoryBase inventoryBase) {
        return inventoryBaseService.saveInventoryBase(inventoryBase);
    }

    @DeleteMapping("/{id}")
    public boolean deleteInventoryBase(@PathVariable String id) {
        return inventoryBaseService.deleteInventoryBaseById(id);
    }

    @PutMapping
    public boolean updateInventoryBase(@RequestBody InventoryBase inventoryBase) {
        return inventoryBaseService.updateInventoryBase(inventoryBase);
    }

    @GetMapping("/{id}")
    public InventoryBase getInventoryBaseById(@PathVariable String id) {
        return inventoryBaseService.getInventoryBaseById(id);
    }

    @SaIgnore
    @GetMapping("/list")
    public TableDataInfo<InventoryBase> getAllInventoryBases(@RequestParam("type") String type, PageQuery pageQuery) {
        return inventoryBaseService.getAllInventoryBases(type,pageQuery);
    }
}
