LAPP标准接口程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
11 KiB

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package etl
import (
model "LAPP_ETL/models/etl"
"LAPP_ETL/web/supports"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/core/router"
)
/******************************************************************************
*
* @Function Name : RegisterOneShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个处理单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : HTTP方法
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterOneShellParam(party router.Party, httpMethod string, path string, method func(*model.ShellParam) error) {
party.Handle(httpMethod, path, func(ctx iris.Context) {
var err error = nil
entity := new(model.ShellParam)
if ctx.GetContentLength() > 0 {
err := ctx.ReadJSON(entity)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
} else {
entity = nil
}
err = method(entity)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, nil)
})
}
/******************************************************************************
*
* @Function Name : RegisterIDOfShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个通过主键处理单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : HTTP方法
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterIDOfShellParam(party router.Party, httpMethod string, path string, method func(int, string, string) error) {
party.Handle(httpMethod, path, func(ctx iris.Context) {
var err error = nil
taskId, err := ctx.Params().GetInt("taskId")
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
shellName := ctx.Params().GetString("shellName")
paramName := ctx.Params().GetString("paramName")
err = method(taskId, shellName, paramName)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, nil)
})
}
/******************************************************************************
*
* @Function Name : RegisterInsertOneShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个插入单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterInsertOneShellParam(party router.Party, path string, method func(*model.ShellParam) error) {
RegisterOneShellParam(party, "POST", path, method)
}
/******************************************************************************
*
* @Function Name : RegisterDeleteOneShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个删除单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterDeleteOneShellParam(party router.Party, path string, method func(int, string, string) error) {
RegisterIDOfShellParam(party, "DELETE", path+"/{taskId:int}/{shellName:string}/{paramName:string}", method)
}
/******************************************************************************
*
* @Function Name : RegisterSelectOneShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个查找单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterSelectOneShellParam(party router.Party, path string, method func(int, string, string) (*model.ShellParam, error)) {
party.Get(path+"/{taskId:int}/{shellName:string}/{paramName:string}", func(ctx iris.Context) {
taskId, err := ctx.Params().GetInt("taskId")
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
shellName := ctx.Params().GetString("shellName")
paramName := ctx.Params().GetString("paramName")
result, err := method(taskId, shellName, paramName)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
if result == nil {
supports.Error(ctx, iris.StatusNotFound, supports.NotFound, nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
})
}
/******************************************************************************
*
* @Function Name : RegisterUpdateOneShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个修改单条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterUpdateOneShellParam(party router.Party, path string, method func(*model.ShellParam) error) {
RegisterOneShellParam(party, "PUT", path, method)
}
/******************************************************************************
*
* @Function Name : RegisterMultiShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个处理多条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : HTTP方法
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterMultiShellParam(party router.Party, httpMethod string, path string, method func(*[]model.ShellParam) error) {
party.Handle(httpMethod, path, func(ctx iris.Context) {
entities := make([]model.ShellParam, 0, 10)
err := ctx.ReadJSON(&entities)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
err = method(&entities)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, nil)
})
}
/******************************************************************************
*
* @Function Name : RegisterInsertShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个插入多条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterInsertShellParam(party router.Party, path string, method func(*[]model.ShellParam) error) {
RegisterMultiShellParam(party, "POST", path, method)
}
/******************************************************************************
*
* @Function Name : RegisterDeleteShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个删除多条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterDeleteShellParam(party router.Party, path string, method func(*[]model.ShellParam) error) {
RegisterMultiShellParam(party, "DELETE", path, method)
}
/******************************************************************************
*
* @Function Name : RegisterSelectShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个查询ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterSelectShellParam(party router.Party, path string, method func(map[string]string) (interface{}, error)) {
party.Get(path, func(ctx iris.Context) {
result, err := method(ctx.URLParams())
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
})
}
/******************************************************************************
*
* @Function Name : RegisterUpdateShellParam
*-----------------------------------------------------------------------------
*
* @Description : 为一个修改多条ShellParam的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 代码生成器创建
*
* @Date : 2021-05-26 17:44:22
*
******************************************************************************/
func RegisterUpdateShellParam(party router.Party, path string, method func(*[]model.ShellParam) error) {
RegisterMultiShellParam(party, "PUT", path, method)
}