package com.ruoyi.project.monitor.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.monitor.domain.TPfd;
import com.ruoyi.project.monitor.service.ITPfdService;
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;

/**
 * PFD管理Controller
 *
 * @author ssy
 * @date 2024-06-24
 */
@RestController
@RequestMapping("/monitor/pfdmgr")
public class TPfdController extends BaseController
{
    @Autowired
    private ITPfdService tPfdService;

    /**
     * 查询PFD管理列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPfd tPfd)
    {
        startPage();
        List<TPfd> list = tPfdService.selectTPfdList(tPfd);
        return getDataTable(list);
    }

    /**
     * 导出PFD管理列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:export')")
    @Log(title = "PFD管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPfd tPfd)
    {
        List<TPfd> list = tPfdService.selectTPfdList(tPfd);
        ExcelUtil<TPfd> util = new ExcelUtil<TPfd>(TPfd.class);
        return util.exportExcel(list, "pfdmgr");
    }

    /**
     * 获取PFD管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:query')")
    @GetMapping(value = "/getInfoByCode/{code}")
    public AjaxResult getInfoByCode(@PathVariable("code") String code)
    {
        return AjaxResult.success(tPfdService.selectTPfdByCode(code));
    }


    /**
     * 获取PFD管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPfdService.selectTPfdById(id));
    }

    /**
     * 新增PFD管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:add')")
    @Log(title = "PFD管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPfd tPfd)
    {
        return toAjax(tPfdService.insertTPfd(tPfd));
    }

    /**
     * 修改PFD管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:edit')")
    @Log(title = "PFD管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPfd tPfd)
    {
        return toAjax(tPfdService.updateTPfd(tPfd));
    }

    /**
     * 删除PFD管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:pfdmgr:remove')")
    @Log(title = "PFD管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPfdService.deleteTPfdByIds(ids));
    }
}
