package com.ztmap.project.zhny.electricpowerquota.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.electricpowerquota.domain.TElectricPowerQuota;
import com.ztmap.project.zhny.electricpowerquota.service.ITElectricPowerQuotaService;
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/electricpowerquota")
public class TElectricPowerQuotaController extends BaseController
{
    private String prefix = "zhny/electricpowerquota";

    @Autowired
    private ITElectricPowerQuotaService tElectricPowerQuotaService;

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

    /**
     * 查询发电量指标列表
     */
    @RequiresPermissions("zhny:electricpowerquota:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TElectricPowerQuota tElectricPowerQuota)
    {
        startPage();
        List<TElectricPowerQuota> list = tElectricPowerQuotaService.selectTElectricPowerQuotaList(tElectricPowerQuota);
        return getDataTable(list);
    }

    /**
     * 导出发电量指标列表
     */
    @RequiresPermissions("zhny:electricpowerquota:export")
    @Log(title = "发电量指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TElectricPowerQuota tElectricPowerQuota)
    {
        List<TElectricPowerQuota> list = tElectricPowerQuotaService.selectTElectricPowerQuotaList(tElectricPowerQuota);
        ExcelUtil<TElectricPowerQuota> util = new ExcelUtil<TElectricPowerQuota>(TElectricPowerQuota.class);
        return util.exportExcel(list, "发电量指标数据");
    }

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

    /**
     * 新增保存发电量指标
     */
    @RequiresPermissions("zhny:electricpowerquota:add")
    @Log(title = "发电量指标", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TElectricPowerQuota tElectricPowerQuota)
    {
        return toAjax(tElectricPowerQuotaService.insertTElectricPowerQuota(tElectricPowerQuota));
    }

    /**
     * 修改发电量指标
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TElectricPowerQuota tElectricPowerQuota = tElectricPowerQuotaService.selectTElectricPowerQuotaById(id);
        mmap.put("tElectricPowerQuota", tElectricPowerQuota);
        return prefix + "/edit";
    }

    /**
     * 修改保存发电量指标
     */
    @RequiresPermissions("zhny:electricpowerquota:edit")
    @Log(title = "发电量指标", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TElectricPowerQuota tElectricPowerQuota)
    {
        return toAjax(tElectricPowerQuotaService.updateTElectricPowerQuota(tElectricPowerQuota));
    }

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