package com.ruoyi.ems.controller;

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.ElecStoreIndex;
import com.ruoyi.ems.service.IElecStoreIndexService;
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 com.huashe.common.domain.AjaxResult;
import java.util.List;

/**
 * 储能设施指标Controller
 * 
 * @author ruoyi
 * @date 2026-01-28
 */
@RestController
@RequestMapping("/elec/store/index")
public class ElecStoreIndexController extends BaseController
{
    @Autowired
    private IElecStoreIndexService elecStoreIndexService;

    /**
     * 查询储能设施指标列表
     */
    @RequiresPermissions("ems:ElecStoreIndex:list")
    @GetMapping("/list")
    public TableDataInfo list(ElecStoreIndex elecStoreIndex)
    {
        startPage();
        List<ElecStoreIndex> list = elecStoreIndexService.selectElecStoreIndexList(elecStoreIndex);
        return getDataTable(list);
    }

    @RequiresPermissions("ems:ElecStoreIndex:list")
    @GetMapping("/latest")
    public AjaxResult latest(ElecStoreIndex elecStoreIndex)
    {
        List<ElecStoreIndex> list = elecStoreIndexService.selectLatestByDevice(elecStoreIndex);
        return success(list);
    }

    @RequiresPermissions("ems:ElecStoreIndex:list")
    @GetMapping("/listAll")
    public AjaxResult listAll(ElecStoreIndex elecStoreIndex)
    {
        List<ElecStoreIndex> list = elecStoreIndexService.selectElecStoreIndexList(elecStoreIndex);
        return success(list);
    }

    /**
     * 新增储能设施指标
     */
    @RequiresPermissions("ems:ElecStoreIndex:add")
    @Log(title = "储能设施指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecStoreIndex elecStoreIndex)
    {
        return toAjax(elecStoreIndexService.insertElecStoreIndex(elecStoreIndex));
    }

    /**
     * 修改储能设施指标
     */
    @RequiresPermissions("ems:ElecStoreIndex:edit")
    @Log(title = "储能设施指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecStoreIndex elecStoreIndex)
    {
        return toAjax(elecStoreIndexService.updateElecStoreIndex(elecStoreIndex));
    }

    /**
     * 删除储能设施指标
     */
    @RequiresPermissions("ems:ElecStoreIndex:remove")
    @Log(title = "储能设施指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elecStoreIndexService.deleteElecStoreIndexByIds(ids));
    }
}
