package com.sooka.system.gas.sc_user_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.sc_user_infor.domain.TGuijiSCUserInfor;
import com.sooka.system.gas.sc_user_infor.service.ITGuijiSCUserInforService;
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/sc_user_infor")
public class TGuijSCUserInforController extends BaseController
{
    private String prefix = "system/gas/sc_user_infor";

    @Autowired
    private ITGuijiSCUserInforService service;

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

    /**
     * 查询思凯收费系统-用户信息列表
     */
    @RequiresPermissions("system:sc_user_infor:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiSCUserInfor param)
    {
        startPage();
        List<TGuijiSCUserInfor> list = service.selectList(param);
        return getDataTable(list);
    }

    /**
     * 导出思凯收费系统-用户信息列表
     */
    @RequiresPermissions("system:sc_user_infor:export")
    @Log(title = "思凯收费系统-用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiSCUserInfor param)
    {
        List<TGuijiSCUserInfor> list = service.selectList(param);
        ExcelUtil<TGuijiSCUserInfor> util = new ExcelUtil<TGuijiSCUserInfor>(TGuijiSCUserInfor.class);
        return util.exportExcel(list, "思凯收费系统-用户信息");
    }

    /**
     * 新增思凯收费系统-用户信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存思凯收费系统-用户信息
     */
    @RequiresPermissions("system:sc_user_infor:add")
    @Log(title = "思凯收费系统-用户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiSCUserInfor param)
    {
        return toAjax(service.insert(param));
    }

    /**
     * 修改思凯收费系统-用户信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiSCUserInfor param = service.selectById(id);
        mmap.put("param", param);
        return prefix + "/edit";
    }

    /**
     * 修改保存思凯收费系统-用户信息
     */
    @RequiresPermissions("system:sc_user_infor:edit")
    @Log(title = "思凯收费系统-用户信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiSCUserInfor param)
    {
        return toAjax(service.update(param));
    }

    /**
     * 删除思凯收费系统-用户信息
     */
    @RequiresPermissions("system:sc_user_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)
    {
        TGuijiSCUserInfor param = service.selectById(id);
        mmap.put("detail", param);
        return prefix + "/detail";
    }
}
