package com.ztmap.project.zhny.lotusnhtj.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.lotusnhtj.domain.TLotusNhtj;
import com.ztmap.project.zhny.lotusnhtj.service.ITLotusNhtjService;
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/lotusnhtj")
public class TLotusNhtjController extends BaseController
{
    private String prefix = "zhny/lotusnhtj";

    @Autowired
    private ITLotusNhtjService tLotusNhtjService;

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

    /**
     * 查询能耗统计列表
     */
    @RequiresPermissions("zhny:lotusnhtj:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TLotusNhtj tLotusNhtj)
    {
        startPage();
        List<TLotusNhtj> list = tLotusNhtjService.selectTLotusNhtjList(tLotusNhtj);
        return getDataTable(list);
    }

    /**
     * 导出能耗统计列表
     */
    @RequiresPermissions("zhny:lotusnhtj:export")
    @Log(title = "能耗统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TLotusNhtj tLotusNhtj)
    {
        List<TLotusNhtj> list = tLotusNhtjService.selectTLotusNhtjList(tLotusNhtj);
        ExcelUtil<TLotusNhtj> util = new ExcelUtil<TLotusNhtj>(TLotusNhtj.class);
        return util.exportExcel(list, "能耗统计数据");
    }

    /**
     * 新增能耗统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存能耗统计
     */
    @RequiresPermissions("zhny:lotusnhtj:add")
    @Log(title = "能耗统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TLotusNhtj tLotusNhtj)
    {
        return toAjax(tLotusNhtjService.insertTLotusNhtj(tLotusNhtj));
    }

    /**
     * 修改能耗统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TLotusNhtj tLotusNhtj = tLotusNhtjService.selectTLotusNhtjById(id);
        mmap.put("tLotusNhtj", tLotusNhtj);
        return prefix + "/edit";
    }

    /**
     * 修改保存能耗统计
     */
    @RequiresPermissions("zhny:lotusnhtj:edit")
    @Log(title = "能耗统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TLotusNhtj tLotusNhtj)
    {
        return toAjax(tLotusNhtjService.updateTLotusNhtj(tLotusNhtj));
    }

    /**
     * 删除能耗统计
     */
    @RequiresPermissions("zhny:lotusnhtj:remove")
    @Log(title = "能耗统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tLotusNhtjService.deleteTLotusNhtjByIds(ids));
    }
}
