package com.ruoyi.web.controller.ems;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ems.domain.EmsObjFlowRel;
import com.ruoyi.ems.service.IEmsObjFlowRelService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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-07-10
 */
@RestController
@RequestMapping("/ems/object/flowrel")
@Api(value = "EmsObjFlowRelController", description = "对象能流关系管理")
public class EmsObjFlowRelController extends BaseController
{
    @Autowired
    private IEmsObjFlowRelService facsFlowRelService;

    /**
     * 查询能源设施能流关系列表
     */
    @PreAuthorize("@ss.hasPermi('basecfg:flowrel:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmsObjFlowRel flowRel)
    {
        startPage();
        List<EmsObjFlowRel> list = facsFlowRelService.selectFlowRelList(flowRel);
        return getDataTable(list);
    }

    /**
     * 获取能源设施能流关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('basecfg:flowrel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(facsFlowRelService.selectFlowRelById(id));
    }

    /**
     * 新增能源设施能流关系
     */
    @PreAuthorize("@ss.hasPermi('basecfg:flowrel:add')")
    @Log(title = "能源设施能流关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsObjFlowRel facsFlowRel)
    {
        return toAjax(facsFlowRelService.insertFlowRel(facsFlowRel));
    }

    /**
     * 修改能源设施能流关系
     */
    @PreAuthorize("@ss.hasPermi('basecfg:flowrel:edit')")
    @Log(title = "能源设施能流关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsObjFlowRel flowRel)
    {
        return toAjax(facsFlowRelService.updateFlowRel(flowRel));
    }

    /**
     * 删除能源设施能流关系
     */
    @PreAuthorize("@ss.hasPermi('basecfg:flowrel:remove')")
    @Log(title = "能源设施能流关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(facsFlowRelService.deleteFlowRelByIds(ids));
    }
}
