package com.ruoyi.ems.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
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.EmsFacsAbility;
import com.ruoyi.ems.service.IEmsFacsAbilityService;
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-22
 */
@RestController
@RequestMapping("/basecfg/emsfacs/ability")
@Api(value = "EmsFacsAbilityController", description = "能源设施能力特性管理")
public class EmsFacsAbilityController extends BaseController
{
    @Autowired
    private IEmsFacsAbilityService emsFacsAbilityService;

    /**
     * 查询能源设施能力列表
     */
    @RequiresPermissions("ems:ability:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsFacsAbility admEmsFacsAbility)
    {
        startPage();
        List<EmsFacsAbility> list = emsFacsAbilityService.selectEmsFacsAbilityList(admEmsFacsAbility);
        return getDataTable(list);
    }

    /**
     * 导出能源设施能力列表
     */
    @RequiresPermissions("ems:ability:export")
    @Log(title = "能源设施能力", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsFacsAbility admEmsFacsAbility)
    {
        List<EmsFacsAbility> list = emsFacsAbilityService.selectEmsFacsAbilityList(admEmsFacsAbility);
        ExcelUtil<EmsFacsAbility> util = new ExcelUtil<EmsFacsAbility>(EmsFacsAbility.class);
        util.exportExcel(response, list, "能源设施能力数据");
    }

    /**
     * 获取能源设施能力详细信息
     */
    @RequiresPermissions("ems:ability:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(emsFacsAbilityService.selectEmsFacsAbilityById(id));
    }

    /**
     * 新增能源设施能力
     */
    @RequiresPermissions("ems:ability:add")
    @Log(title = "能源设施能力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsFacsAbility admEmsFacsAbility)
    {
        return toAjax(emsFacsAbilityService.insertEmsFacsAbility(admEmsFacsAbility));
    }

    /**
     * 修改能源设施能力
     */
    @RequiresPermissions("ems:ability:edit")
    @Log(title = "能源设施能力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsFacsAbility admEmsFacsAbility)
    {
        return toAjax(emsFacsAbilityService.updateEmsFacsAbility(admEmsFacsAbility));
    }

    /**
     * 删除能源设施能力
     */
    @RequiresPermissions("ems:ability:remove")
    @Log(title = "能源设施能力", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emsFacsAbilityService.deleteEmsFacsAbilityByIds(ids));
    }
}
