package com.ruoyi.ems.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.ems.domain.AdmEmsElecPgIndex;
import com.ruoyi.ems.service.IAdmEmsElecPgIndexService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 电网设施指标Controller
 * 
 * @author ruoyi
 * @date 2024-08-30
 */
@RestController
@RequestMapping("/elecPgIndex")
public class AdmEmsElecPgIndexController extends BaseController
{
    @Autowired
    private IAdmEmsElecPgIndexService admEmsElecPgIndexService;

    /**
     * 查询电网设施指标列表
     */
    @RequiresPermissions("ems:elecPgIndex:list")
    @GetMapping("/list")
    public TableDataInfo list(AdmEmsElecPgIndex admEmsElecPgIndex)
    {
        startPage();
        List<AdmEmsElecPgIndex> list = admEmsElecPgIndexService.selectAdmEmsElecPgIndexList(admEmsElecPgIndex);
        return getDataTable(list);
    }

    /**
     * 导出电网设施指标列表
     */
    @RequiresPermissions("ems:elecPgIndex:export")
    @Log(title = "电网设施指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdmEmsElecPgIndex admEmsElecPgIndex)
    {
        List<AdmEmsElecPgIndex> list = admEmsElecPgIndexService.selectAdmEmsElecPgIndexList(admEmsElecPgIndex);
        ExcelUtil<AdmEmsElecPgIndex> util = new ExcelUtil<AdmEmsElecPgIndex>(AdmEmsElecPgIndex.class);
        util.exportExcel(response, list, "电网设施指标数据");
    }

    /**
     * 获取电网设施指标详细信息
     */
    @RequiresPermissions("ems:elecPgIndex:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(admEmsElecPgIndexService.selectAdmEmsElecPgIndexById(id));
    }

    /**
     * 新增电网设施指标
     */
    @RequiresPermissions("ems:elecPgIndex:add")
    @Log(title = "电网设施指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdmEmsElecPgIndex admEmsElecPgIndex)
    {
        return toAjax(admEmsElecPgIndexService.insertAdmEmsElecPgIndex(admEmsElecPgIndex));
    }

    /**
     * 修改电网设施指标
     */
    @RequiresPermissions("ems:elecPgIndex:edit")
    @Log(title = "电网设施指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdmEmsElecPgIndex admEmsElecPgIndex)
    {
        return toAjax(admEmsElecPgIndexService.updateAdmEmsElecPgIndex(admEmsElecPgIndex));
    }

    /**
     * 删除电网设施指标
     */
    @RequiresPermissions("ems:elecPgIndex:remove")
    @Log(title = "电网设施指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(admEmsElecPgIndexService.deleteAdmEmsElecPgIndexByIds(ids));
    }
}
