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.CompanyProductOutstock;
import com.fs.company.service.ICompanyProductOutstockService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 出库Controller
 * 
 * @author fs
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/company/companyProductOutstock")
public class CompanyProductOutstockController extends BaseController
{
    @Autowired
    private ICompanyProductOutstockService companyProductOutstockService;

    /**
     * 查询出库列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductOutstock:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyProductOutstock companyProductOutstock)
    {
        startPage();
        List<CompanyProductOutstock> list = companyProductOutstockService.selectCompanyProductOutstockList(companyProductOutstock);
        return getDataTable(list);
    }

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

    /**
     * 获取出库详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductOutstock:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyProductOutstockService.selectCompanyProductOutstockById(id));
    }

    /**
     * 新增出库
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductOutstock:add')")
    @Log(title = "出库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyProductOutstock companyProductOutstock)
    {
        return toAjax(companyProductOutstockService.insertCompanyProductOutstock(companyProductOutstock));
    }

    /**
     * 修改出库
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductOutstock:edit')")
    @Log(title = "出库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyProductOutstock companyProductOutstock)
    {
        return toAjax(companyProductOutstockService.updateCompanyProductOutstock(companyProductOutstock));
    }

    /**
     * 删除出库
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductOutstock:remove')")
    @Log(title = "出库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyProductOutstockService.deleteCompanyProductOutstockByIds(ids));
    }
}
