package com.ruoyi.project.intact.controller;

import java.util.Date;
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.intact.domain.TIntactGyl;
import com.ruoyi.project.intact.service.ITIntactGylService;
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;

/**
 * 设备完整性工业炉台账Controller
 *
 * @author ruoyi
 * @date 2022-06-21
 */
@RestController
@RequestMapping("/intact/gyl")
public class TIntactGylController extends BaseController
{
    @Autowired
    private ITIntactGylService tIntactGylService;

    /**
     * 查询设备完整性工业炉台账列表
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIntactGyl tIntactGyl)
    {
        startPage();
        List<TIntactGyl> list = tIntactGylService.selectTIntactGylList(tIntactGyl);
        return getDataTable(list);
    }

    /**
     * 导出设备完整性工业炉台账列表
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:export')")
    @Log(title = "设备完整性工业炉台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TIntactGyl tIntactGyl)
    {
        List<TIntactGyl> list = tIntactGylService.selectTIntactGylList(tIntactGyl);
        ExcelUtil<TIntactGyl> util = new ExcelUtil<TIntactGyl>(TIntactGyl.class);
        return util.exportExcel(list, "gyl");
    }

    /**
     * 获取设备完整性工业炉台账详细信息
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tIntactGylService.selectTIntactGylById(id));
    }

    /**
     * 新增设备完整性工业炉台账
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:add')")
    @Log(title = "设备完整性工业炉台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIntactGyl tIntactGyl)
    {
        //获取操作人员ID
        Long userId = getUserId();
        tIntactGyl.setCreaterCode(userId.toString());
        tIntactGyl.setCreatedate(new Date());
        return toAjax(tIntactGylService.insertTIntactGyl(tIntactGyl));
    }

    /**
     * 修改设备完整性工业炉台账
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:edit')")
    @Log(title = "设备完整性工业炉台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIntactGyl tIntactGyl)
    {
        return toAjax(tIntactGylService.updateTIntactGyl(tIntactGyl));
    }

    /**
     * 删除设备完整性工业炉台账
     */
    @PreAuthorize("@ss.hasPermi('intact:gyl:remove')")
    @Log(title = "设备完整性工业炉台账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tIntactGylService.deleteTIntactGylByIds(ids));
    }
}
