package com.ztmap.project.zhny.energystoragefdsdycs.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.energystoragefdsdycs.domain.TEnergyStorageFdsdycs;
import com.ztmap.project.zhny.energystoragefdsdycs.service.ITEnergyStorageFdsdycsService;
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/energystoragefdsdycs")
public class TEnergyStorageFdsdycsController extends BaseController
{
    private String prefix = "zhny/energystoragefdsdycs";

    @Autowired
    private ITEnergyStorageFdsdycsService tEnergyStorageFdsdycsService;

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

    /**
     * 查询放电深度与次数列表
     */
    @RequiresPermissions("zhny:energystoragefdsdycs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEnergyStorageFdsdycs tEnergyStorageFdsdycs)
    {
        startPage();
        List<TEnergyStorageFdsdycs> list = tEnergyStorageFdsdycsService.selectTEnergyStorageFdsdycsList(tEnergyStorageFdsdycs);
        return getDataTable(list);
    }

    /**
     * 导出放电深度与次数列表
     */
    @RequiresPermissions("zhny:energystoragefdsdycs:export")
    @Log(title = "放电深度与次数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEnergyStorageFdsdycs tEnergyStorageFdsdycs)
    {
        List<TEnergyStorageFdsdycs> list = tEnergyStorageFdsdycsService.selectTEnergyStorageFdsdycsList(tEnergyStorageFdsdycs);
        ExcelUtil<TEnergyStorageFdsdycs> util = new ExcelUtil<TEnergyStorageFdsdycs>(TEnergyStorageFdsdycs.class);
        return util.exportExcel(list, "放电深度与次数数据");
    }

    /**
     * 新增放电深度与次数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存放电深度与次数
     */
    @RequiresPermissions("zhny:energystoragefdsdycs:add")
    @Log(title = "放电深度与次数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEnergyStorageFdsdycs tEnergyStorageFdsdycs)
    {
        return toAjax(tEnergyStorageFdsdycsService.insertTEnergyStorageFdsdycs(tEnergyStorageFdsdycs));
    }

    /**
     * 修改放电深度与次数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TEnergyStorageFdsdycs tEnergyStorageFdsdycs = tEnergyStorageFdsdycsService.selectTEnergyStorageFdsdycsById(id);
        mmap.put("tEnergyStorageFdsdycs", tEnergyStorageFdsdycs);
        return prefix + "/edit";
    }

    /**
     * 修改保存放电深度与次数
     */
    @RequiresPermissions("zhny:energystoragefdsdycs:edit")
    @Log(title = "放电深度与次数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEnergyStorageFdsdycs tEnergyStorageFdsdycs)
    {
        return toAjax(tEnergyStorageFdsdycsService.updateTEnergyStorageFdsdycs(tEnergyStorageFdsdycs));
    }

    /**
     * 删除放电深度与次数
     */
    @RequiresPermissions("zhny:energystoragefdsdycs:remove")
    @Log(title = "放电深度与次数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEnergyStorageFdsdycsService.deleteTEnergyStorageFdsdycsByIds(ids));
    }
}
