package com.ztmap.project.zhny.netswdl.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.netswdl.domain.TNetSwdl;
import com.ztmap.project.zhny.netswdl.service.ITNetSwdlService;
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/netswdl")
public class TNetSwdlController extends BaseController
{
    private String prefix = "zhny/netswdl";

    @Autowired
    private ITNetSwdlService tNetSwdlService;

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

    /**
     * 查询上网电量列表
     */
    @RequiresPermissions("zhny:netswdl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TNetSwdl tNetSwdl)
    {
        startPage();
        List<TNetSwdl> list = tNetSwdlService.selectTNetSwdlList(tNetSwdl);
        return getDataTable(list);
    }

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

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

    /**
     * 新增保存上网电量
     */
    @RequiresPermissions("zhny:netswdl:add")
    @Log(title = "上网电量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TNetSwdl tNetSwdl)
    {
        return toAjax(tNetSwdlService.insertTNetSwdl(tNetSwdl));
    }

    /**
     * 修改上网电量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TNetSwdl tNetSwdl = tNetSwdlService.selectTNetSwdlById(id);
        mmap.put("tNetSwdl", tNetSwdl);
        return prefix + "/edit";
    }

    /**
     * 修改保存上网电量
     */
    @RequiresPermissions("zhny:netswdl:edit")
    @Log(title = "上网电量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TNetSwdl tNetSwdl)
    {
        return toAjax(tNetSwdlService.updateTNetSwdl(tNetSwdl));
    }

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