package com.sooka.system.gas.zenner_gas_purchase_infor.controller;

import com.sooka.common.annotation.Log;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;
import com.sooka.system.gas.zenner_gas_purchase_infor.domain.TGuijiZennerGasPurchaseInfor;
import com.sooka.system.gas.zenner_gas_purchase_infor.service.ITGuijiZennerGasPurchaseInforService;
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.*;

import java.util.List;

/**
 * 真兰收费系统-预付费购气信息Controller
 *
 * @author lei
 * @date 2022-08-22
 */
@Controller
@RequestMapping("/system/gas/zenner_gas_purchase_infor")
public class TGuijiZennerGasPurchaseInforController extends BaseController
{
    private String prefix = "system/gas/zenner_gas_purchase_infor";

    @Autowired
    private ITGuijiZennerGasPurchaseInforService service;

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

    /**
     * 查询真兰收费系统-列表
     */
    @RequiresPermissions("system:zenner_gas_purchase_infor:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiZennerGasPurchaseInfor param)
    {
        startPage();
        List<TGuijiZennerGasPurchaseInfor> list = service.selectList(param);
        return getDataTable(list);
    }

    /**
     * 导出真兰收费系统-预付费购气信息列表
     */
    @RequiresPermissions("system:zenner_gas_purchase_infor:export")
    @Log(title = "真兰收费系统-预付费购气信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiZennerGasPurchaseInfor param)
    {
        List<TGuijiZennerGasPurchaseInfor> list = service.selectList(param);
        ExcelUtil<TGuijiZennerGasPurchaseInfor> util = new ExcelUtil<TGuijiZennerGasPurchaseInfor>(TGuijiZennerGasPurchaseInfor.class);
        return util.exportExcel(list, "真兰收费系统-预付费购气信息");
    }

    /**
     * 新增真兰收费系统-预付费购气信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存真兰收费系统-预付费购气信息
     */
    @RequiresPermissions("system:zenner_gas_purchase_infor:add")
    @Log(title = "真兰收费系统-预付费购气信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiZennerGasPurchaseInfor param)
    {
        return toAjax(service.insert(param));
    }

    /**
     * 修改真兰收费系统-预付费购气信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiZennerGasPurchaseInfor param = service.selectById(id);
        mmap.put("param", param);
        return prefix + "/edit";
    }

    /**
     * 修改保存真兰收费系统-预付费购气信息
     */
    @RequiresPermissions("system:zenner_gas_purchase_infor:edit")
    @Log(title = "真兰收费系统-预付费购气信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiZennerGasPurchaseInfor param)
    {
        return toAjax(service.update(param));
    }

    /**
     * 删除真兰收费系统-预付费购气信息
     */
    @RequiresPermissions("system:zenner_gas_purchase_infor:remove")
    @Log(title = "真兰收费系统-预付费购气信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(service.deleteByIds(ids));
    }

    /**
     * 真兰收费系统-预付费购气信息详情
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiZennerGasPurchaseInfor param = service.selectById(id);
        mmap.put("detail", param);
        return prefix + "/detail";
    }
}
