package com.evobms.project.bms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.evobms.framework.aspectj.lang.annotation.Log;
import com.evobms.framework.aspectj.lang.enums.BusinessType;
import com.evobms.project.bms.domain.BmsVoltageChannelData;
import com.evobms.project.bms.service.IBmsVoltageChannelDataService;
import com.evobms.framework.web.controller.BaseController;
import com.evobms.framework.web.domain.AjaxResult;
import com.evobms.common.utils.poi.ExcelUtil;
import com.evobms.framework.web.page.TableDataInfo;

/**
 * BMS电压通道数据Controller
 *
 * @author tzy
 * @date 2026-02-23
 */
@RestController
@RequestMapping("/bms/voltagechannel/data")
public class BmsVoltageChannelDataController extends BaseController
{
    @Autowired
    private IBmsVoltageChannelDataService bmsVoltageChannelDataService;

    /**
     * 查询BMS电压通道数据列表
     */
    @PreAuthorize("@ss.hasPermi('bms:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsVoltageChannelData bmsVoltageChannelData)
    {
        startPage();
        List<BmsVoltageChannelData> list = bmsVoltageChannelDataService.selectBmsVoltageChannelDataList(bmsVoltageChannelData);
        return getDataTable(list);
    }

    /**
     * 导出BMS电压通道数据列表
     */
    @PreAuthorize("@ss.hasPermi('bms:data:export')")
    @Log(title = "BMS电压通道数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmsVoltageChannelData bmsVoltageChannelData)
    {
        List<BmsVoltageChannelData> list = bmsVoltageChannelDataService.selectBmsVoltageChannelDataList(bmsVoltageChannelData);
        ExcelUtil<BmsVoltageChannelData> util = new ExcelUtil<BmsVoltageChannelData>(BmsVoltageChannelData.class);
        util.exportExcel(response, list, "BMS电压通道数据数据");
    }

    /**
     * 获取BMS电压通道数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('bms:data:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bmsVoltageChannelDataService.selectBmsVoltageChannelDataById(id));
    }

    /**
     * 新增BMS电压通道数据
     */
    @PreAuthorize("@ss.hasPermi('bms:data:add')")
    @Log(title = "BMS电压通道数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsVoltageChannelData bmsVoltageChannelData)
    {
        return toAjax(bmsVoltageChannelDataService.insertBmsVoltageChannelData(bmsVoltageChannelData));
    }

    /**
     * 修改BMS电压通道数据
     */
    @PreAuthorize("@ss.hasPermi('bms:data:edit')")
    @Log(title = "BMS电压通道数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsVoltageChannelData bmsVoltageChannelData)
    {
        return toAjax(bmsVoltageChannelDataService.updateBmsVoltageChannelData(bmsVoltageChannelData));
    }

    /**
     * 删除BMS电压通道数据
     */
    @PreAuthorize("@ss.hasPermi('bms:data:remove')")
    @Log(title = "BMS电压通道数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmsVoltageChannelDataService.deleteBmsVoltageChannelDataByIds(ids));
    }
}
