package com.ruoyi.project.document.controller;

import java.io.IOException;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.document.domain.TPlantproglistFile;
import com.ruoyi.project.document.service.ITPlantproglistFileService;
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;
import org.springframework.web.multipart.MultipartFile;

/**
 * 装置程序清单附件Controller
 *
 * @author ruoyi
 * @date 2020-12-05
 */
@RestController
@RequestMapping("/document/plantproglistfile")
public class TPlantproglistFileController extends BaseController
{
    @Autowired
    private ITPlantproglistFileService tPlantproglistFileService;

    /**
     * 文件上传
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:edit')")
    @Log(title = "装置程序清单附件", businessType = BusinessType.UPDATE)
    @PostMapping("/importDoc")
    public AjaxResult importDoc(@RequestParam("id") String id) throws IOException {
        logger.info("id:" + id);
        return null;
    }

    /**
     * 查询装置程序清单附件列表
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPlantproglistFile tPlantproglistFile)
    {
        startPage();
        List<TPlantproglistFile> list = tPlantproglistFileService.selectTPlantproglistFileList(tPlantproglistFile);
        return getDataTable(list);
    }

    /**
     * 导出装置程序清单附件列表
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:export')")
    @Log(title = "装置程序清单附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPlantproglistFile tPlantproglistFile)
    {
        List<TPlantproglistFile> list = tPlantproglistFileService.selectTPlantproglistFileList(tPlantproglistFile);
        ExcelUtil<TPlantproglistFile> util = new ExcelUtil<TPlantproglistFile>(TPlantproglistFile.class);
        return util.exportExcel(list, "plantproglistfile");
    }

    /**
     * 获取装置程序清单附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPlantproglistFileService.selectTPlantproglistFileById(id));
    }

    /**
     * 新增装置程序清单附件
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:add')")
    @Log(title = "装置程序清单附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPlantproglistFile tPlantproglistFile)
    {
        return toAjax(tPlantproglistFileService.insertTPlantproglistFile(tPlantproglistFile));
    }

    /**
     * 修改装置程序清单附件
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:edit')")
    @Log(title = "装置程序清单附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPlantproglistFile tPlantproglistFile)
    {
        return toAjax(tPlantproglistFileService.updateTPlantproglistFile(tPlantproglistFile));
    }

    /**
     * 删除装置程序清单附件
     */
    @PreAuthorize("@ss.hasPermi('document:plantproglist:remove')")
    @Log(title = "装置程序清单附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPlantproglistFileService.deleteTPlantproglistFileByIds(ids));
    }
}
