package com.evobms.project.Battery.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.Battery.domain.ExtremeValues;
import com.evobms.project.Battery.service.IExtremeValuesService;
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;

/**
 * 电池极值数据Controller
 * 
 * @author 田志阳
 * @date 2025-10-14
 */
@RestController
@RequestMapping("/BatteryData/BatteryData")
public class ExtremeValuesController extends BaseController
{
    @Autowired
    private IExtremeValuesService extremeValuesService;

    /**
     * 查询电池极值数据列表
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExtremeValues extremeValues)
    {
        startPage();
        List<ExtremeValues> list = extremeValuesService.selectExtremeValuesList(extremeValues);
        return getDataTable(list);
    }

    /**
     * 导出电池极值数据列表
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:export')")
    @Log(title = "电池极值数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExtremeValues extremeValues)
    {
        List<ExtremeValues> list = extremeValuesService.selectExtremeValuesList(extremeValues);
        ExcelUtil<ExtremeValues> util = new ExcelUtil<ExtremeValues>(ExtremeValues.class);
        util.exportExcel(response, list, "电池极值数据数据");
    }

    /**
     * 获取电池极值数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(extremeValuesService.selectExtremeValuesById(id));
    }

    /**
     * 新增电池极值数据
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:add')")
    @Log(title = "电池极值数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExtremeValues extremeValues)
    {
        return toAjax(extremeValuesService.insertExtremeValues(extremeValues));
    }

    /**
     * 修改电池极值数据
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:edit')")
    @Log(title = "电池极值数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExtremeValues extremeValues)
    {
        return toAjax(extremeValuesService.updateExtremeValues(extremeValues));
    }

    /**
     * 删除电池极值数据
     */
    @PreAuthorize("@ss.hasPermi('BatteryData:BatteryData:remove')")
    @Log(title = "电池极值数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(extremeValuesService.deleteExtremeValuesByIds(ids));
    }
}
