package com.ruoyi.project.production.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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.production.domain.TSaiApproveFile;
import com.ruoyi.project.production.service.ITSaiApproveFileService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * SAI审批附件Controller
 *
 * @author ruoyi
 * @date 2023-04-06
 */
@RestController
@RequestMapping("/production/saiApproveFile")
public class TSaiApproveFileController extends BaseController
{
    @Autowired
    private ITSaiApproveFileService tSaiApproveFileService;

    /**
     * 查询SAI审批附件列表
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:list')")
    @GetMapping("/list")
    public List<TSaiApproveFile> list(TSaiApproveFile tSaiApproveFile)
    {
        return tSaiApproveFileService.selectTSaiApproveFileList(tSaiApproveFile);
    }

    /**
     * 导出SAI审批附件列表
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:export')")
    @Log(title = "SAI审批附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSaiApproveFile tSaiApproveFile)
    {
        List<TSaiApproveFile> list = tSaiApproveFileService.selectTSaiApproveFileList(tSaiApproveFile);
        ExcelUtil<TSaiApproveFile> util = new ExcelUtil<TSaiApproveFile>(TSaiApproveFile.class);
        return util.exportExcel(list, "saiApproveFile");
    }

    /**
     * 获取SAI审批附件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tSaiApproveFileService.selectTSaiApproveFileById(id));
    }

    /**
     * 新增SAI审批附件
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:add')")
    @Log(title = "SAI审批附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSaiApproveFile tSaiApproveFile)
    {
        return toAjax(tSaiApproveFileService.insertTSaiApproveFile(tSaiApproveFile));
    }

    /**
     * 修改SAI审批附件
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:edit')")
    @Log(title = "SAI审批附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSaiApproveFile tSaiApproveFile)
    {
        return toAjax(tSaiApproveFileService.updateTSaiApproveFile(tSaiApproveFile));
    }

    /**
     * 删除SAI审批附件
     */
//    @PreAuthorize("@ss.hasPermi('production:saiApproveFile:remove')")
    @Log(title = "SAI审批附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tSaiApproveFileService.deleteTSaiApproveFileByIds(ids));
    }
}
