package com.ztmap.project.zhny.energystoragecncfdl.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.energystoragecncfdl.domain.TEnergyStorageCncfdl;
import com.ztmap.project.zhny.energystoragecncfdl.service.ITEnergyStorageCncfdlService;
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/energystoragecncfdl")
public class TEnergyStorageCncfdlController extends BaseController
{
    private String prefix = "zhny/energystoragecncfdl";

    @Autowired
    private ITEnergyStorageCncfdlService tEnergyStorageCncfdlService;

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

    /**
     * 查询储能充放电量列表
     */
    @RequiresPermissions("zhny:energystoragecncfdl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEnergyStorageCncfdl tEnergyStorageCncfdl)
    {
        startPage();
        List<TEnergyStorageCncfdl> list = tEnergyStorageCncfdlService.selectTEnergyStorageCncfdlList(tEnergyStorageCncfdl);
        return getDataTable(list);
    }

    /**
     * 导出储能充放电量列表
     */
    @RequiresPermissions("zhny:energystoragecncfdl:export")
    @Log(title = "储能充放电量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEnergyStorageCncfdl tEnergyStorageCncfdl)
    {
        List<TEnergyStorageCncfdl> list = tEnergyStorageCncfdlService.selectTEnergyStorageCncfdlList(tEnergyStorageCncfdl);
        ExcelUtil<TEnergyStorageCncfdl> util = new ExcelUtil<TEnergyStorageCncfdl>(TEnergyStorageCncfdl.class);
        return util.exportExcel(list, "储能充放电量数据");
    }

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

    /**
     * 新增保存储能充放电量
     */
    @RequiresPermissions("zhny:energystoragecncfdl:add")
    @Log(title = "储能充放电量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEnergyStorageCncfdl tEnergyStorageCncfdl)
    {
        return toAjax(tEnergyStorageCncfdlService.insertTEnergyStorageCncfdl(tEnergyStorageCncfdl));
    }

    /**
     * 修改储能充放电量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TEnergyStorageCncfdl tEnergyStorageCncfdl = tEnergyStorageCncfdlService.selectTEnergyStorageCncfdlById(id);
        mmap.put("tEnergyStorageCncfdl", tEnergyStorageCncfdl);
        return prefix + "/edit";
    }

    /**
     * 修改保存储能充放电量
     */
    @RequiresPermissions("zhny:energystoragecncfdl:edit")
    @Log(title = "储能充放电量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEnergyStorageCncfdl tEnergyStorageCncfdl)
    {
        return toAjax(tEnergyStorageCncfdlService.updateTEnergyStorageCncfdl(tEnergyStorageCncfdl));
    }

    /**
     * 删除储能充放电量
     */
    @RequiresPermissions("zhny:energystoragecncfdl:remove")
    @Log(title = "储能充放电量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEnergyStorageCncfdlService.deleteTEnergyStorageCncfdlByIds(ids));
    }
}
