package com.evobms.project.summary.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.summary.domain.ChargeDischargeSummary;
import com.evobms.project.summary.service.IChargeDischargeSummaryService;
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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 累计充放电量Controller
 * 
 * @author 田志阳
 * @date 2026-01-09
 */
@RestController
@RequestMapping("/summary/summary")
@Api(tags = "充放电统计")
public class ChargeDischargeSummaryController extends BaseController
{
    @Autowired
    private IChargeDischargeSummaryService chargeDischargeSummaryService;

    /**
     * 查询累计充放电量列表
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:list')")
    @GetMapping("/list")
    @ApiOperation("查询累计充放电量列表")
    public TableDataInfo list(ChargeDischargeSummary chargeDischargeSummary)
    {
        startPage();
        List<ChargeDischargeSummary> list = chargeDischargeSummaryService.selectChargeDischargeSummaryList(chargeDischargeSummary);
        return getDataTable(list);
    }

    /**
     * 导出累计充放电量列表
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:export')")
    @Log(title = "累计充放电量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出累计充放电量列表")
    public void export(HttpServletResponse response, ChargeDischargeSummary chargeDischargeSummary)
    {
        List<ChargeDischargeSummary> list = chargeDischargeSummaryService.selectChargeDischargeSummaryList(chargeDischargeSummary);
        ExcelUtil<ChargeDischargeSummary> util = new ExcelUtil<ChargeDischargeSummary>(ChargeDischargeSummary.class);
        util.exportExcel(response, list, "累计充放电量数据");
    }

    /**
     * 获取累计充放电量详细信息
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取累计充放电量详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(chargeDischargeSummaryService.selectChargeDischargeSummaryById(id));
    }

    /**
     * 新增累计充放电量
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:add')")
    @Log(title = "累计充放电量", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增累计充放电量")
    public AjaxResult add(@RequestBody ChargeDischargeSummary chargeDischargeSummary)
    {
        return toAjax(chargeDischargeSummaryService.insertChargeDischargeSummary(chargeDischargeSummary));
    }

    /**
     * 修改累计充放电量
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:edit')")
    @Log(title = "累计充放电量", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改累计充放电量")
    public AjaxResult edit(@RequestBody ChargeDischargeSummary chargeDischargeSummary)
    {
        return toAjax(chargeDischargeSummaryService.updateChargeDischargeSummary(chargeDischargeSummary));
    }

    /**
     * 删除累计充放电量
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:remove')")
    @Log(title = "累计充放电量", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除累计充放电量")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chargeDischargeSummaryService.deleteChargeDischargeSummaryByIds(ids));
    }
}
