package com.sooka.system.controller;

import java.util.List;

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 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.sooka.system.domain.TUParamspublic;
import com.sooka.system.service.ITUParamspublicService;


/**
 * 公共请求参数Controller
 *
 * @author lei
 * @date 2021-07-01
 */
@Controller
@RequestMapping("/system/paramspublic")
public class TUParamspublicController extends BaseController
{
    private String prefix = "system/paramspublic";

    @Autowired
    private ITUParamspublicService tUParamspublicService;

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

    /**
     * 查询公共请求参数列表
     */
    @RequiresPermissions("system:paramspublic:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TUParamspublic tUParamspublic)
    {
        startPage();
        List<TUParamspublic> list = tUParamspublicService.selectTUParamspublicList(tUParamspublic);
        return getDataTable(list);
    }

    /**
     * 导出公共请求参数列表
     */
    @RequiresPermissions("system:paramspublic:export")
    @Log(title = "公共请求参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TUParamspublic tUParamspublic)
    {
        List<TUParamspublic> list = tUParamspublicService.selectTUParamspublicList(tUParamspublic);
        ExcelUtil<TUParamspublic> util = new ExcelUtil<TUParamspublic>(TUParamspublic.class);
        return util.exportExcel(list, "paramspublic");
    }

    /**
     * 新增公共请求参数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存公共请求参数
     */
    @RequiresPermissions("system:paramspublic:add")
    @Log(title = "公共请求参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TUParamspublic tUParamspublic)
    {
        return toAjax(tUParamspublicService.insertTUParamspublic(tUParamspublic));
    }

    /**
     * 修改公共请求参数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TUParamspublic tUParamspublic = tUParamspublicService.selectTUParamspublicById(id);
        mmap.put("tUParamspublic", tUParamspublic);
        return prefix + "/edit";
    }

    /**
     * 修改保存公共请求参数
     */
    @RequiresPermissions("system:paramspublic:edit")
    @Log(title = "公共请求参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TUParamspublic tUParamspublic)
    {
        return toAjax(tUParamspublicService.updateTUParamspublic(tUParamspublic));
    }

    /**
     * 删除公共请求参数
     */
    @RequiresPermissions("system:paramspublic:remove")
    @Log(title = "公共请求参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tUParamspublicService.deleteTUParamspublicByIds(ids));
    }
}
