package com.ztmap.project.zhny.lotusydfx.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.lotusydfx.domain.TLotusYdfx;
import com.ztmap.project.zhny.lotusydfx.service.ITLotusYdfxService;
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/lotusydfx")
public class TLotusYdfxController extends BaseController
{
    private String prefix = "zhny/lotusydfx";

    @Autowired
    private ITLotusYdfxService tLotusYdfxService;

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

    /**
     * 查询用电分项统计列表
     */
    @RequiresPermissions("zhny:lotusydfx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TLotusYdfx tLotusYdfx)
    {
        startPage();
        List<TLotusYdfx> list = tLotusYdfxService.selectTLotusYdfxList(tLotusYdfx);
        return getDataTable(list);
    }

    /**
     * 导出用电分项统计列表
     */
    @RequiresPermissions("zhny:lotusydfx:export")
    @Log(title = "用电分项统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TLotusYdfx tLotusYdfx)
    {
        List<TLotusYdfx> list = tLotusYdfxService.selectTLotusYdfxList(tLotusYdfx);
        ExcelUtil<TLotusYdfx> util = new ExcelUtil<TLotusYdfx>(TLotusYdfx.class);
        return util.exportExcel(list, "用电分项统计数据");
    }

    /**
     * 新增用电分项统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用电分项统计
     */
    @RequiresPermissions("zhny:lotusydfx:add")
    @Log(title = "用电分项统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TLotusYdfx tLotusYdfx)
    {
        return toAjax(tLotusYdfxService.insertTLotusYdfx(tLotusYdfx));
    }

    /**
     * 修改用电分项统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TLotusYdfx tLotusYdfx = tLotusYdfxService.selectTLotusYdfxById(id);
        mmap.put("tLotusYdfx", tLotusYdfx);
        return prefix + "/edit";
    }

    /**
     * 修改保存用电分项统计
     */
    @RequiresPermissions("zhny:lotusydfx:edit")
    @Log(title = "用电分项统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TLotusYdfx tLotusYdfx)
    {
        return toAjax(tLotusYdfxService.updateTLotusYdfx(tLotusYdfx));
    }

    /**
     * 删除用电分项统计
     */
    @RequiresPermissions("zhny:lotusydfx:remove")
    @Log(title = "用电分项统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tLotusYdfxService.deleteTLotusYdfxByIds(ids));
    }
}
