package com.ztmap.project.zhny.electricpowergeneration.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.electricpowergeneration.domain.TElectricPowerGeneration;
import com.ztmap.project.zhny.electricpowergeneration.service.ITElectricPowerGenerationService;
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/electricpowergeneration")
public class TElectricPowerGenerationController extends BaseController
{
    private String prefix = "zhny/electricpowergeneration";

    @Autowired
    private ITElectricPowerGenerationService tElectricPowerGenerationService;

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

    /**
     * 查询发电量列表
     */
    @RequiresPermissions("zhny:electricpowergeneration:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TElectricPowerGeneration tElectricPowerGeneration)
    {
        startPage();
        List<TElectricPowerGeneration> list = tElectricPowerGenerationService.selectTElectricPowerGenerationList(tElectricPowerGeneration);
        return getDataTable(list);
    }

    /**
     * 导出发电量列表
     */
    @RequiresPermissions("zhny:electricpowergeneration:export")
    @Log(title = "发电量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TElectricPowerGeneration tElectricPowerGeneration)
    {
        List<TElectricPowerGeneration> list = tElectricPowerGenerationService.selectTElectricPowerGenerationList(tElectricPowerGeneration);
        ExcelUtil<TElectricPowerGeneration> util = new ExcelUtil<TElectricPowerGeneration>(TElectricPowerGeneration.class);
        return util.exportExcel(list, "发电量数据");
    }

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

    /**
     * 新增保存发电量
     */
    @RequiresPermissions("zhny:electricpowergeneration:add")
    @Log(title = "发电量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TElectricPowerGeneration tElectricPowerGeneration)
    {
        return toAjax(tElectricPowerGenerationService.insertTElectricPowerGeneration(tElectricPowerGeneration));
    }

    /**
     * 修改发电量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TElectricPowerGeneration tElectricPowerGeneration = tElectricPowerGenerationService.selectTElectricPowerGenerationById(id);
        mmap.put("tElectricPowerGeneration", tElectricPowerGeneration);
        return prefix + "/edit";
    }

    /**
     * 修改保存发电量
     */
    @RequiresPermissions("zhny:electricpowergeneration:edit")
    @Log(title = "发电量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TElectricPowerGeneration tElectricPowerGeneration)
    {
        return toAjax(tElectricPowerGenerationService.updateTElectricPowerGeneration(tElectricPowerGeneration));
    }

    /**
     * 删除发电量
     */
    @RequiresPermissions("zhny:electricpowergeneration:remove")
    @Log(title = "发电量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tElectricPowerGenerationService.deleteTElectricPowerGenerationByIds(ids));
    }
}
