package com.ruoyi.project.aspen.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.aspen.domain.TElecdashboardAlarm;
import com.ruoyi.project.aspen.service.ITElecdashboardAlarmService;
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-09-19
 */
@RestController
@RequestMapping("/aspen/alarm")
public class TElecdashboardAlarmController extends BaseController
{
    @Autowired
    private ITElecdashboardAlarmService tElecdashboardAlarmService;

    /**
     * 查询电厂大屏预警列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TElecdashboardAlarm tElecdashboardAlarm)
    {
        startPage();
        List<TElecdashboardAlarm> list = tElecdashboardAlarmService.selectTElecdashboardAlarmList(tElecdashboardAlarm);
        return getDataTable(list);
    }

    /**
     * 导出电厂大屏预警列表
     */
    @Log(title = "电厂大屏预警", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TElecdashboardAlarm tElecdashboardAlarm)
    {
        List<TElecdashboardAlarm> list = tElecdashboardAlarmService.selectTElecdashboardAlarmList(tElecdashboardAlarm);
        ExcelUtil<TElecdashboardAlarm> util = new ExcelUtil<TElecdashboardAlarm>(TElecdashboardAlarm.class);
        return util.exportExcel(list, "alarm");
    }

    /**
     * 获取电厂大屏预警详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tElecdashboardAlarmService.selectTElecdashboardAlarmById(id));
    }

    /**
     * 新增电厂大屏预警
     */
    @Log(title = "电厂大屏预警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TElecdashboardAlarm tElecdashboardAlarm)
    {
        return toAjax(tElecdashboardAlarmService.insertTElecdashboardAlarm(tElecdashboardAlarm));
    }

    /**
     * 修改电厂大屏预警
     */
    @Log(title = "电厂大屏预警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TElecdashboardAlarm tElecdashboardAlarm)
    {
        return toAjax(tElecdashboardAlarmService.updateTElecdashboardAlarm(tElecdashboardAlarm));
    }

    /**
     * 删除电厂大屏预警
     */
    @Log(title = "电厂大屏预警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tElecdashboardAlarmService.deleteTElecdashboardAlarmByIds(ids));
    }
}
