package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysSupplies;
import com.ruoyi.system.service.ISysSuppliesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物资管理Controller
 *
 * @author
 * @date
 */
@RestController
@RequestMapping("/system/supplies")
public class SysSuppliesController extends BaseController
{

    @Autowired
    private ISysSuppliesService iSysSuppliesService;

    /**
     * 物资管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:supplies:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSupplies sysSupplies)
    {
        startPage();
        List<SysSupplies> list = iSysSuppliesService.list();
        return getDataTable(list);
    }
    /**
     * 保存物资管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:supplies:save')")
    @Log(title = "模板详情", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody SysSupplies sysSupplies)
    {
        return toAjax(iSysSuppliesService.save(sysSupplies));
    }

    /**
     * 获取模板详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:supplies:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        System.out.println("从前端接收到的id是"+id);
        return AjaxResult.success(iSysSuppliesService.selectExcelById(id));
    }

}
