package com.zg.project.Inventory.Visualization.controller;

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

import com.zg.project.Inventory.Visualization.domain.vo.OdtlVO;
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.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.project.Inventory.Visualization.domain.Odtl;
import com.zg.project.Inventory.Visualization.service.IOdtlService;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;

/**
 * 借料出库 明细Controller
 * 
 * @author zg
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/Visual/odtl")
public class OdtlController extends BaseController
{
    @Autowired
    private IOdtlService odtlService;

    /**
     * 查询借料出库 明细列表
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Odtl odtl)
    {
        startPage();
        List<Odtl> list = odtlService.selectOdtlList(odtl);
        return getDataTable(list);
    }

    /**
     * 查询全部出入库明细
     * @return
     */
    @GetMapping("/odtlQueryAll")
    public AjaxResult queryAll()     {
        List<OdtlVO> list = odtlService.queryAll();
        return AjaxResult.success(list);
    }

    /**
     * 导出借料出库 明细列表
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:export')")
    @Log(title = "借料出库 明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Odtl odtl)
    {
        List<Odtl> list = odtlService.selectOdtlList(odtl);
        ExcelUtil<Odtl> util = new ExcelUtil<Odtl>(Odtl.class);
        util.exportExcel(response, list, "借料出库 明细数据");
    }

    /**
     * 获取借料出库 明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:query')")
    @GetMapping(value = "/{Id}")
    public AjaxResult getInfo(@PathVariable("Id") Long Id)
    {
        return success(odtlService.selectOdtlById(Id));
    }

    /**
     * 新增借料出库 明细
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:add')")
    @Log(title = "借料出库 明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Odtl odtl)
    {
        return toAjax(odtlService.insertOdtl(odtl));
    }

    /**
     * 修改借料出库 明细
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:edit')")
    @Log(title = "借料出库 明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Odtl odtl)
    {
        return toAjax(odtlService.updateOdtl(odtl));
    }

    /**
     * 删除借料出库 明细
     */
    @PreAuthorize("@ss.hasPermi('Visualization:odtl:remove')")
    @Log(title = "借料出库 明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Ids}")
    public AjaxResult remove(@PathVariable Long[] Ids)
    {
        return toAjax(odtlService.deleteOdtlByIds(Ids));
    }
}
