package com.ztmap.project.zhny.energystoragecount.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ztmap.framework.aspectj.lang.annotation.Log;
import com.ztmap.framework.aspectj.lang.enums.BusinessType;
import com.ztmap.project.zhny.energystoragecount.domain.TEnergyStorageChargeCount;
import com.ztmap.project.zhny.energystoragecount.service.ITEnergyStorageChargeCountService;
import com.ztmap.framework.web.controller.BaseController;
import com.ztmap.framework.web.domain.AjaxResult;
import com.ztmap.common.utils.poi.ExcelUtil;
import com.ztmap.framework.web.page.TableDataInfo;

/**
 * 储能充能统计Controller
 * 
 * @author ztmap
 * @date 2023-10-09
 */
@Controller
@RequestMapping("/zhny/energystoragecount")
public class TEnergyStorageChargeCountController extends BaseController
{
    private String prefix = "zhny/energystoragecount";

    @Autowired
    private ITEnergyStorageChargeCountService tEnergyStorageChargeCountService;

    @RequiresPermissions("zhny:energystoragecount:view")
    @GetMapping()
    public String energystoragecount()
    {
        return prefix + "/energystoragecount";
    }

    /**
     * 查询储能充能统计列表
     */
    @RequiresPermissions("zhny:energystoragecount:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEnergyStorageChargeCount tEnergyStorageChargeCount)
    {
        startPage();
        List<TEnergyStorageChargeCount> list = tEnergyStorageChargeCountService.selectTEnergyStorageChargeCountList(tEnergyStorageChargeCount);
        return getDataTable(list);
    }

    /**
     * 导出储能充能统计列表
     */
    @RequiresPermissions("zhny:energystoragecount:export")
    @Log(title = "储能充能统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEnergyStorageChargeCount tEnergyStorageChargeCount)
    {
        List<TEnergyStorageChargeCount> list = tEnergyStorageChargeCountService.selectTEnergyStorageChargeCountList(tEnergyStorageChargeCount);
        ExcelUtil<TEnergyStorageChargeCount> util = new ExcelUtil<TEnergyStorageChargeCount>(TEnergyStorageChargeCount.class);
        return util.exportExcel(list, "储能充能统计数据");
    }

    /**
     * 新增储能充能统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存储能充能统计
     */
    @RequiresPermissions("zhny:energystoragecount:add")
    @Log(title = "储能充能统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEnergyStorageChargeCount tEnergyStorageChargeCount)
    {
        return toAjax(tEnergyStorageChargeCountService.insertTEnergyStorageChargeCount(tEnergyStorageChargeCount));
    }

    /**
     * 修改储能充能统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TEnergyStorageChargeCount tEnergyStorageChargeCount = tEnergyStorageChargeCountService.selectTEnergyStorageChargeCountById(id);
        mmap.put("tEnergyStorageChargeCount", tEnergyStorageChargeCount);
        return prefix + "/edit";
    }

    /**
     * 修改保存储能充能统计
     */
    @RequiresPermissions("zhny:energystoragecount:edit")
    @Log(title = "储能充能统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEnergyStorageChargeCount tEnergyStorageChargeCount)
    {
        return toAjax(tEnergyStorageChargeCountService.updateTEnergyStorageChargeCount(tEnergyStorageChargeCount));
    }

    /**
     * 删除储能充能统计
     */
    @RequiresPermissions("zhny:energystoragecount:remove")
    @Log(title = "储能充能统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEnergyStorageChargeCountService.deleteTEnergyStorageChargeCountByIds(ids));
    }
}
