package com.ztmap.project.zhny.netfdswl.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.netfdswl.domain.TNetFdswl;
import com.ztmap.project.zhny.netfdswl.service.ITNetFdswlService;
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-11-16
 */
@Controller
@RequestMapping("/zhny/netfdswl")
public class TNetFdswlController extends BaseController
{
    private String prefix = "zhny/netfdswl";

    @Autowired
    private ITNetFdswlService tNetFdswlService;

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

    /**
     * 查询风电上网量列表
     */
    @RequiresPermissions("zhny:netfdswl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TNetFdswl tNetFdswl)
    {
        startPage();
        List<TNetFdswl> list = tNetFdswlService.selectTNetFdswlList(tNetFdswl);
        return getDataTable(list);
    }

    /**
     * 导出风电上网量列表
     */
    @RequiresPermissions("zhny:netfdswl:export")
    @Log(title = "风电上网量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TNetFdswl tNetFdswl)
    {
        List<TNetFdswl> list = tNetFdswlService.selectTNetFdswlList(tNetFdswl);
        ExcelUtil<TNetFdswl> util = new ExcelUtil<TNetFdswl>(TNetFdswl.class);
        return util.exportExcel(list, "风电上网量数据");
    }

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

    /**
     * 新增保存风电上网量
     */
    @RequiresPermissions("zhny:netfdswl:add")
    @Log(title = "风电上网量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TNetFdswl tNetFdswl)
    {
        return toAjax(tNetFdswlService.insertTNetFdswl(tNetFdswl));
    }

    /**
     * 修改风电上网量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TNetFdswl tNetFdswl = tNetFdswlService.selectTNetFdswlById(id);
        mmap.put("tNetFdswl", tNetFdswl);
        return prefix + "/edit";
    }

    /**
     * 修改保存风电上网量
     */
    @RequiresPermissions("zhny:netfdswl:edit")
    @Log(title = "风电上网量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TNetFdswl tNetFdswl)
    {
        return toAjax(tNetFdswlService.updateTNetFdswl(tNetFdswl));
    }

    /**
     * 删除风电上网量
     */
    @RequiresPermissions("zhny:netfdswl:remove")
    @Log(title = "风电上网量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tNetFdswlService.deleteTNetFdswlByIds(ids));
    }
}
