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.TUParamsbusiness;
import com.sooka.system.service.ITUParamsbusinessService;


/**
 * 业务请求参数Controller
 *
 * @author lei
 * @date 2021-07-01
 */
@Controller
@RequestMapping("/system/paramsbusiness")
public class TUParamsbusinessController extends BaseController
{
    private String prefix = "system/paramsbusiness";

    @Autowired
    private ITUParamsbusinessService tUParamsbusinessService;

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

    /**
     * 查询业务请求参数列表
     */
    @RequiresPermissions("system:paramsbusiness:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TUParamsbusiness tUParamsbusiness)
    {
        startPage();
        List<TUParamsbusiness> list = tUParamsbusinessService.selectTUParamsbusinessList(tUParamsbusiness);
        return getDataTable(list);
    }

    /**
     * 导出业务请求参数列表
     */
    @RequiresPermissions("system:paramsbusiness:export")
    @Log(title = "业务请求参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TUParamsbusiness tUParamsbusiness)
    {
        List<TUParamsbusiness> list = tUParamsbusinessService.selectTUParamsbusinessList(tUParamsbusiness);
        ExcelUtil<TUParamsbusiness> util = new ExcelUtil<TUParamsbusiness>(TUParamsbusiness.class);
        return util.exportExcel(list, "paramsbusiness");
    }

    /**
     * 新增业务请求参数
     */
    @GetMapping("/add/{interfaceinfo_id}")
    public String add(@PathVariable("interfaceinfo_id") String id,ModelMap mmap)
    {

        return prefix + "/add";
    }

    /**
     * 新增保存业务请求参数
     */
    @RequiresPermissions("system:paramsbusiness:add")
    @Log(title = "业务请求参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TUParamsbusiness tUParamsbusiness)
    {
        return toAjax(tUParamsbusinessService.insertTUParamsbusiness(tUParamsbusiness));
    }

    /**
     * 修改业务请求参数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TUParamsbusiness tUParamsbusiness = tUParamsbusinessService.selectTUParamsbusinessById(id);
        mmap.put("tUParamsbusiness", tUParamsbusiness);
        return prefix + "/edit";
    }

    /**
     * 修改保存业务请求参数
     */
    @RequiresPermissions("system:paramsbusiness:edit")
    @Log(title = "业务请求参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TUParamsbusiness tUParamsbusiness)
    {
        return toAjax(tUParamsbusinessService.updateTUParamsbusiness(tUParamsbusiness));
    }

    /**
     * 删除业务请求参数
     */
    @RequiresPermissions("system:paramsbusiness:remove")
    @Log(title = "业务请求参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tUParamsbusinessService.deleteTUParamsbusinessByIds(ids));
    }
}
