package com.ruoyi.ems.controller;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
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.EmsDisStaCoal;
import com.ruoyi.ems.service.IEmsDisStaCoalService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 能源折标准煤维表Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/disStaCoal")
@Api(value = "EmsDisStaCoalController", description = "能源折标准煤维表")
public class EmsDisStaCoalController extends BaseController
{
    @Autowired
    private IEmsDisStaCoalService disStaCoalService;

    /**
     * 查询能源折标准煤维列表
     */
    @RequiresPermissions("ems:disStaCoal:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsDisStaCoal disStaCoal)
    {
        startPage();
        List<EmsDisStaCoal> list = disStaCoalService.selectDisStaCoalList(disStaCoal);
        return getDataTable(list);
    }

    /**
     * 获取能源折标准煤维详细信息
     */
    @RequiresPermissions("ems:disStaCoal:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(disStaCoalService.selectDisStaCoalById(id));
    }

    /**
     * 新增能源折标准煤维
     */
    @RequiresPermissions("ems:disStaCoal:add")
    @Log(title = "能源折标准煤维", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsDisStaCoal disStaCoal)
    {
        return toAjax(disStaCoalService.insertDisStaCoal(disStaCoal));
    }

    /**
     * 修改能源折标准煤维
     */
    @RequiresPermissions("ems:disStaCoal:edit")
    @Log(title = "能源折标准煤维", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsDisStaCoal disStaCoal)
    {
        return toAjax(disStaCoalService.updateDisStaCoal(disStaCoal));
    }

    /**
     * 删除能源设施/系统
     */
    @RequiresPermissions("ems:disStaCoal:edit")
    @Log(title = "能源折标准煤维", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long ids) {
        return toAjax(disStaCoalService.deleteDisStaCoalById(ids));
    }
}
