package com.ztmap.project.zhny.netgfswl.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.netgfswl.domain.TNetGfswl;
import com.ztmap.project.zhny.netgfswl.service.ITNetGfswlService;
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/netgfswl")
public class TNetGfswlController extends BaseController
{
    private String prefix = "zhny/netgfswl";

    @Autowired
    private ITNetGfswlService tNetGfswlService;

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

    /**
     * 查询光伏上网量列表
     */
    @RequiresPermissions("zhny:netgfswl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TNetGfswl tNetGfswl)
    {
        startPage();
        List<TNetGfswl> list = tNetGfswlService.selectTNetGfswlList(tNetGfswl);
        return getDataTable(list);
    }

    /**
     * 导出光伏上网量列表
     */
    @RequiresPermissions("zhny:netgfswl:export")
    @Log(title = "光伏上网量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TNetGfswl tNetGfswl)
    {
        List<TNetGfswl> list = tNetGfswlService.selectTNetGfswlList(tNetGfswl);
        ExcelUtil<TNetGfswl> util = new ExcelUtil<TNetGfswl>(TNetGfswl.class);
        return util.exportExcel(list, "光伏上网量数据");
    }

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

    /**
     * 新增保存光伏上网量
     */
    @RequiresPermissions("zhny:netgfswl:add")
    @Log(title = "光伏上网量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TNetGfswl tNetGfswl)
    {
        return toAjax(tNetGfswlService.insertTNetGfswl(tNetGfswl));
    }

    /**
     * 修改光伏上网量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TNetGfswl tNetGfswl = tNetGfswlService.selectTNetGfswlById(id);
        mmap.put("tNetGfswl", tNetGfswl);
        return prefix + "/edit";
    }

    /**
     * 修改保存光伏上网量
     */
    @RequiresPermissions("zhny:netgfswl:edit")
    @Log(title = "光伏上网量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TNetGfswl tNetGfswl)
    {
        return toAjax(tNetGfswlService.updateTNetGfswl(tNetGfswl));
    }

    /**
     * 删除光伏上网量
     */
    @RequiresPermissions("zhny:netgfswl:remove")
    @Log(title = "光伏上网量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tNetGfswlService.deleteTNetGfswlByIds(ids));
    }
}
