package com.ruoyi.project.intact.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.intact.domain.TIntactPump;
import com.ruoyi.project.intact.service.ITIntactPumpService;
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-22
 */
@RestController
@RequestMapping("/intact/pump")
public class TIntactPumpController extends BaseController
{
    @Autowired
    private ITIntactPumpService tIntactPumpService;

    /**
     * 查询设备完整性泵台账列表
     */
    @PreAuthorize("@ss.hasPermi('intact:pump:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIntactPump tIntactPump)
    {
        startPage();
        List<TIntactPump> list = tIntactPumpService.selectTIntactPumpList(tIntactPump);
        return getDataTable(list);
    }

    /**
     * 导出设备完整性泵台账列表
     */
    @PreAuthorize("@ss.hasPermi('intact:pump:export')")
    @Log(title = "设备完整性泵台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TIntactPump tIntactPump)
    {
        List<TIntactPump> list = tIntactPumpService.selectTIntactPumpList(tIntactPump);
        ExcelUtil<TIntactPump> util = new ExcelUtil<TIntactPump>(TIntactPump.class);
        return util.exportExcel(list, "pump");
    }

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

    /**
     * 新增设备完整性泵台账
     */
    @PreAuthorize("@ss.hasPermi('intact:pump:add')")
    @Log(title = "设备完整性泵台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIntactPump tIntactPump)
    {
        return toAjax(tIntactPumpService.insertTIntactPump(tIntactPump));
    }

    /**
     * 修改设备完整性泵台账
     */
    @PreAuthorize("@ss.hasPermi('intact:pump:edit')")
    @Log(title = "设备完整性泵台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIntactPump tIntactPump)
    {
        return toAjax(tIntactPumpService.updateTIntactPump(tIntactPump));
    }

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