package com.ztmap.project.zhny.lotusxnyxnqk.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.lotusxnyxnqk.domain.TLotusXnyxnqk;
import com.ztmap.project.zhny.lotusxnyxnqk.service.ITLotusXnyxnqkService;
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/lotusxnyxnqk")
public class TLotusXnyxnqkController extends BaseController
{
    private String prefix = "zhny/lotusxnyxnqk";

    @Autowired
    private ITLotusXnyxnqkService tLotusXnyxnqkService;

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

    /**
     * 查询新能源消纳情况列表
     */
    @RequiresPermissions("zhny:lotusxnyxnqk:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TLotusXnyxnqk tLotusXnyxnqk)
    {
        startPage();
        List<TLotusXnyxnqk> list = tLotusXnyxnqkService.selectTLotusXnyxnqkList(tLotusXnyxnqk);
        return getDataTable(list);
    }

    /**
     * 导出新能源消纳情况列表
     */
    @RequiresPermissions("zhny:lotusxnyxnqk:export")
    @Log(title = "新能源消纳情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TLotusXnyxnqk tLotusXnyxnqk)
    {
        List<TLotusXnyxnqk> list = tLotusXnyxnqkService.selectTLotusXnyxnqkList(tLotusXnyxnqk);
        ExcelUtil<TLotusXnyxnqk> util = new ExcelUtil<TLotusXnyxnqk>(TLotusXnyxnqk.class);
        return util.exportExcel(list, "新能源消纳情况数据");
    }

    /**
     * 新增新能源消纳情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存新能源消纳情况
     */
    @RequiresPermissions("zhny:lotusxnyxnqk:add")
    @Log(title = "新能源消纳情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TLotusXnyxnqk tLotusXnyxnqk)
    {
        return toAjax(tLotusXnyxnqkService.insertTLotusXnyxnqk(tLotusXnyxnqk));
    }

    /**
     * 修改新能源消纳情况
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TLotusXnyxnqk tLotusXnyxnqk = tLotusXnyxnqkService.selectTLotusXnyxnqkById(id);
        mmap.put("tLotusXnyxnqk", tLotusXnyxnqk);
        return prefix + "/edit";
    }

    /**
     * 修改保存新能源消纳情况
     */
    @RequiresPermissions("zhny:lotusxnyxnqk:edit")
    @Log(title = "新能源消纳情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TLotusXnyxnqk tLotusXnyxnqk)
    {
        return toAjax(tLotusXnyxnqkService.updateTLotusXnyxnqk(tLotusXnyxnqk));
    }

    /**
     * 删除新能源消纳情况
     */
    @RequiresPermissions("zhny:lotusxnyxnqk:remove")
    @Log(title = "新能源消纳情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tLotusXnyxnqkService.deleteTLotusXnyxnqkByIds(ids));
    }
}
