package com.ztmap.project.zhny.energystorageoverview.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.energystorageoverview.domain.TEnergyStorageOverview;
import com.ztmap.project.zhny.energystorageoverview.service.ITEnergyStorageOverviewService;
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/energystorageoverview")
public class TEnergyStorageOverviewController extends BaseController
{
    private String prefix = "zhny/energystorageoverview";

    @Autowired
    private ITEnergyStorageOverviewService tEnergyStorageOverviewService;

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

    /**
     * 查询储能总览列表
     */
    @RequiresPermissions("zhny:energystorageoverview:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEnergyStorageOverview tEnergyStorageOverview)
    {
        startPage();
        List<TEnergyStorageOverview> list = tEnergyStorageOverviewService.selectTEnergyStorageOverviewList(tEnergyStorageOverview);
        return getDataTable(list);
    }

    /**
     * 导出储能总览列表
     */
    @RequiresPermissions("zhny:energystorageoverview:export")
    @Log(title = "储能总览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEnergyStorageOverview tEnergyStorageOverview)
    {
        List<TEnergyStorageOverview> list = tEnergyStorageOverviewService.selectTEnergyStorageOverviewList(tEnergyStorageOverview);
        ExcelUtil<TEnergyStorageOverview> util = new ExcelUtil<TEnergyStorageOverview>(TEnergyStorageOverview.class);
        return util.exportExcel(list, "储能总览数据");
    }

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

    /**
     * 新增保存储能总览
     */
    @RequiresPermissions("zhny:energystorageoverview:add")
    @Log(title = "储能总览", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEnergyStorageOverview tEnergyStorageOverview)
    {
        return toAjax(tEnergyStorageOverviewService.insertTEnergyStorageOverview(tEnergyStorageOverview));
    }

    /**
     * 修改储能总览
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TEnergyStorageOverview tEnergyStorageOverview = tEnergyStorageOverviewService.selectTEnergyStorageOverviewById(id);
        mmap.put("tEnergyStorageOverview", tEnergyStorageOverview);
        return prefix + "/edit";
    }

    /**
     * 修改保存储能总览
     */
    @RequiresPermissions("zhny:energystorageoverview:edit")
    @Log(title = "储能总览", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEnergyStorageOverview tEnergyStorageOverview)
    {
        return toAjax(tEnergyStorageOverviewService.updateTEnergyStorageOverview(tEnergyStorageOverview));
    }

    /**
     * 删除储能总览
     */
    @RequiresPermissions("zhny:energystorageoverview:remove")
    @Log(title = "储能总览", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEnergyStorageOverviewService.deleteTEnergyStorageOverviewByIds(ids));
    }
}
