package com.ztmap.project.zhny.energystoragestatus.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.energystoragestatus.domain.TEnergyStorageStatus;
import com.ztmap.project.zhny.energystoragestatus.service.ITEnergyStorageStatusService;
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/energystoragestatus")
public class TEnergyStorageStatusController extends BaseController
{
    private String prefix = "zhny/energystoragestatus";

    @Autowired
    private ITEnergyStorageStatusService tEnergyStorageStatusService;

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

    /**
     * 查询储能状态列表
     */
    @RequiresPermissions("zhny:energystoragestatus:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEnergyStorageStatus tEnergyStorageStatus)
    {
        startPage();
        List<TEnergyStorageStatus> list = tEnergyStorageStatusService.selectTEnergyStorageStatusList(tEnergyStorageStatus);
        return getDataTable(list);
    }

    /**
     * 导出储能状态列表
     */
    @RequiresPermissions("zhny:energystoragestatus:export")
    @Log(title = "储能状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEnergyStorageStatus tEnergyStorageStatus)
    {
        List<TEnergyStorageStatus> list = tEnergyStorageStatusService.selectTEnergyStorageStatusList(tEnergyStorageStatus);
        ExcelUtil<TEnergyStorageStatus> util = new ExcelUtil<TEnergyStorageStatus>(TEnergyStorageStatus.class);
        return util.exportExcel(list, "储能状态数据");
    }

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

    /**
     * 新增保存储能状态
     */
    @RequiresPermissions("zhny:energystoragestatus:add")
    @Log(title = "储能状态", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEnergyStorageStatus tEnergyStorageStatus)
    {
        return toAjax(tEnergyStorageStatusService.insertTEnergyStorageStatus(tEnergyStorageStatus));
    }

    /**
     * 修改储能状态
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TEnergyStorageStatus tEnergyStorageStatus = tEnergyStorageStatusService.selectTEnergyStorageStatusById(id);
        mmap.put("tEnergyStorageStatus", tEnergyStorageStatus);
        return prefix + "/edit";
    }

    /**
     * 修改保存储能状态
     */
    @RequiresPermissions("zhny:energystoragestatus:edit")
    @Log(title = "储能状态", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEnergyStorageStatus tEnergyStorageStatus)
    {
        return toAjax(tEnergyStorageStatusService.updateTEnergyStorageStatus(tEnergyStorageStatus));
    }

    /**
     * 删除储能状态
     */
    @RequiresPermissions("zhny:energystoragestatus:remove")
    @Log(title = "储能状态", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEnergyStorageStatusService.deleteTEnergyStorageStatusByIds(ids));
    }
}
