package com.ztmap.project.zhny.lotusydqs.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.lotusydqs.domain.TLotusYdqs;
import com.ztmap.project.zhny.lotusydqs.service.ITLotusYdqsService;
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/lotusydqs")
public class TLotusYdqsController extends BaseController
{
    private String prefix = "zhny/lotusydqs";

    @Autowired
    private ITLotusYdqsService tLotusYdqsService;

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

    /**
     * 查询用电趋势列表
     */
    @RequiresPermissions("zhny:lotusydqs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TLotusYdqs tLotusYdqs)
    {
        startPage();
        List<TLotusYdqs> list = tLotusYdqsService.selectTLotusYdqsList(tLotusYdqs);
        return getDataTable(list);
    }

    /**
     * 导出用电趋势列表
     */
    @RequiresPermissions("zhny:lotusydqs:export")
    @Log(title = "用电趋势", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TLotusYdqs tLotusYdqs)
    {
        List<TLotusYdqs> list = tLotusYdqsService.selectTLotusYdqsList(tLotusYdqs);
        ExcelUtil<TLotusYdqs> util = new ExcelUtil<TLotusYdqs>(TLotusYdqs.class);
        return util.exportExcel(list, "用电趋势数据");
    }

    /**
     * 新增用电趋势
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用电趋势
     */
    @RequiresPermissions("zhny:lotusydqs:add")
    @Log(title = "用电趋势", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TLotusYdqs tLotusYdqs)
    {
        return toAjax(tLotusYdqsService.insertTLotusYdqs(tLotusYdqs));
    }

    /**
     * 修改用电趋势
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TLotusYdqs tLotusYdqs = tLotusYdqsService.selectTLotusYdqsById(id);
        mmap.put("tLotusYdqs", tLotusYdqs);
        return prefix + "/edit";
    }

    /**
     * 修改保存用电趋势
     */
    @RequiresPermissions("zhny:lotusydqs:edit")
    @Log(title = "用电趋势", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TLotusYdqs tLotusYdqs)
    {
        return toAjax(tLotusYdqsService.updateTLotusYdqs(tLotusYdqs));
    }

    /**
     * 删除用电趋势
     */
    @RequiresPermissions("zhny:lotusydqs:remove")
    @Log(title = "用电趋势", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tLotusYdqsService.deleteTLotusYdqsByIds(ids));
    }
}
