package com.ruoyi.project.sems.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.sems.domain.TReportThird;
import com.ruoyi.project.sems.service.ITReportThirdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 压力容器第三方数据文件Controller
 *
 * @author ruoyi
 * @date 2021-11-16
 */
@RestController
@RequestMapping("/third/tReportThird")
public class TReportThirdController extends BaseController {

    @Autowired
    private ITReportThirdService tReportThirdService;

    /**
     * 查询压力容器第三方数据文件列表
     */
    //@PreAuthorize("@ss.hasPermi('third:tReportYlrqThird:list')")
    @GetMapping("/list")
    public AjaxResult list(TReportThird tReportYlrqThird) {
        List<TReportThird> list = tReportThirdService.selectTReportThirdList(tReportYlrqThird);
        return AjaxResult.success(list);
    }

    /**
     * 导出压力容器第三方数据文件列表
     */
    @PreAuthorize("@ss.hasPermi('third:tReportYlrqThird:export')")
    @Log(title = "压力容器第三方数据文件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TReportThird tReportYlrqThird) {
        List<TReportThird> list = tReportThirdService.selectTReportThirdList(tReportYlrqThird);
        ExcelUtil<TReportThird> util = new ExcelUtil<TReportThird>(TReportThird.class);
        return util.exportExcel(list, "tReportYlrqThird");
    }

    /**
     * 获取压力容器第三方数据文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('third:tReportYlrqThird:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tReportThirdService.selectTReportThirdById(id));
    }

    /**
     * 新增压力容器第三方数据文件
     */
    @PreAuthorize("@ss.hasPermi('third:tReportYlrqThird:add')")
    @Log(title = "压力容器第三方数据文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TReportThird tReportYlrqThird) {
        return toAjax(tReportThirdService.insertTReportThird(tReportYlrqThird));
    }

    /**
     * 修改压力容器第三方数据文件
     */
    @PreAuthorize("@ss.hasPermi('third:tReportYlrqThird:edit')")
    @Log(title = "压力容器第三方数据文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TReportThird tReportYlrqThird) {
        return toAjax(tReportThirdService.updateTReportThird(tReportYlrqThird));
    }

    /**
     * 删除压力容器第三方数据文件
     */
    @PreAuthorize("@ss.hasPermi('sems:reportYlgd:remove')")
    @Log(title = "压力容器第三方数据文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tReportThirdService.deleteTReportThirdByIds(ids));
    }
}
