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

/**
 * 入库Controller
 * 
 * @author fs
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/company/companyProductInstock")
public class CompanyProductInstockController extends BaseController
{
    @Autowired
    private ICompanyProductInstockService companyProductInstockService;

    /**
     * 查询入库列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductInstock:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyProductInstock companyProductInstock)
    {
        startPage();
        List<CompanyProductInstock> list = companyProductInstockService.selectCompanyProductInstockList(companyProductInstock);
        return getDataTable(list);
    }

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

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

    /**
     * 新增入库
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductInstock:add')")
    @Log(title = "入库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyProductInstock companyProductInstock)
    {
        return toAjax(companyProductInstockService.insertCompanyProductInstock(companyProductInstock));
    }

    /**
     * 修改入库
     */
    @PreAuthorize("@ss.hasPermi('company:companyProductInstock:edit')")
    @Log(title = "入库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyProductInstock companyProductInstock)
    {
        return toAjax(companyProductInstockService.updateCompanyProductInstock(companyProductInstock));
    }

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