package com.fs.company.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.company.domain.CompanyProductStock;
import com.fs.company.service.ICompanyProductStockService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 产品库存Controller
 * 
 * @author fs
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/company/companyProductStock")
public class CompanyProductStockController extends BaseController
{
    @Autowired
    private ICompanyProductStockService companyProductStockService;

    /**
     * 查询产品库存列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyProductStock companyProductStock)
    {
        startPage();
        List<CompanyProductStock> list = companyProductStockService.selectCompanyProductStockList(companyProductStock);
        return getDataTable(list);
    }

    /**
     * 导出产品库存列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:export')")
    @Log(title = "产品库存", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyProductStock companyProductStock)
    {
        List<CompanyProductStock> list = companyProductStockService.selectCompanyProductStockList(companyProductStock);
        ExcelUtil<CompanyProductStock> util = new ExcelUtil<CompanyProductStock>(CompanyProductStock.class);
        return util.exportExcel(list, "产品库存数据");
    }

    /**
     * 获取产品库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyProductStockService.selectCompanyProductStockById(id));
    }

    /**
     * 新增产品库存
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:add')")
    @Log(title = "产品库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyProductStock companyProductStock)
    {
        return toAjax(companyProductStockService.insertCompanyProductStock(companyProductStock));
    }

    /**
     * 修改产品库存
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:edit')")
    @Log(title = "产品库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyProductStock companyProductStock)
    {
        return toAjax(companyProductStockService.updateCompanyProductStock(companyProductStock));
    }

    /**
     * 删除产品库存
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductStock:remove')")
    @Log(title = "产品库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyProductStockService.deleteCompanyProductStockByIds(ids));
    }
}
