package com.fizz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.fizz.business.service.IPdiSetupService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.fizz.business.domain.PdiSetups;
import com.fizz.business.service.IPdiSetupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产计划的参数详情Controller
 * 
 * @author Joshi
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/business/setup")
public class PdiSetupController extends BaseController
{
    @Autowired
    private IPdiSetupService pdiSetupService;

    /**
     * 查询生产计划的参数详情列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody PdiSetups pdiSetup)
    {
        startPage();
        List<PdiSetups> list = pdiSetupService.selectPdiSetupList(pdiSetup);
        return getDataTable(list);
    }

    /**
     * 导出生产计划的参数详情列表
     */
    @Log(title = "生产计划的参数详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdiSetups pdiSetup)
    {
        List<PdiSetups> list = pdiSetupService.selectPdiSetupList(pdiSetup);
        ExcelUtil<PdiSetups> util = new ExcelUtil<PdiSetups>(PdiSetups.class);
        util.exportExcel(response, list, "生产计划的参数详情数据");
    }

    /**
     * 获取生产计划的参数详情详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdiSetupService.selectPdiSetupByid(id));
    }

    /**
     * 新增生产计划的参数详情
     */
    @Log(title = "生产计划的参数详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdiSetups pdiSetup)
    {
        return toAjax(pdiSetupService.insertPdiSetup(pdiSetup));
    }

    /**
     * 修改生产计划的参数详情
     */
    @Log(title = "生产计划的参数详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PdiSetups pdiSetup)
    {
        return toAjax(pdiSetupService.updatePdiSetup(pdiSetup));
    }

    /**
     * 删除生产计划的参数详情
     */
    @Log(title = "生产计划的参数详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdiSetupService.deletePdiSetupByids(ids));
    }
}
