// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
|
|
package api
|
|
|
|
import (
|
|
model "LAPP_LF_MOM_BACKEND/models/api"
|
|
"LAPP_LF_MOM_BACKEND/web/middleware/jwts"
|
|
"LAPP_LF_MOM_BACKEND/web/models"
|
|
"LAPP_LF_MOM_BACKEND/web/supports"
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/kataras/iris/v12/core/router"
|
|
)
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterOneACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个处理单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterOneACCUNITID(party router.Party, httpMethod string, path string, method func(*models.Usertab, *model.ACCUNITID) error) {
|
|
|
|
party.Handle(httpMethod, path, func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
var err error = nil
|
|
|
|
entity := new(model.ACCUNITID)
|
|
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(user, entity)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, nil)
|
|
})
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterIDOfACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个通过主键处理单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterIDOfACCUNITID(party router.Party, httpMethod string, path string, method func(*models.Usertab, int64) error) {
|
|
|
|
party.Handle(httpMethod, path, func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
var err error = nil
|
|
rECID, err := ctx.Params().GetInt64("rECID")
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
|
|
err = method(user, rECID)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, nil)
|
|
})
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterInsertOneACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个插入单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterInsertOneACCUNITID(party router.Party, path string, method func(*models.Usertab, *model.ACCUNITID) error) {
|
|
|
|
RegisterOneACCUNITID(party, "POST", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterDeleteOneACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个删除单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterDeleteOneACCUNITID(party router.Party, path string, method func(*models.Usertab, int64) error) {
|
|
|
|
RegisterIDOfACCUNITID(party, "DELETE", path+"/{rECID:int64}", method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterSelectOneACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个查找单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterSelectOneACCUNITID(party router.Party, path string, method func(*models.Usertab, int64) (*model.ACCUNITID, error)) {
|
|
|
|
party.Get(path+"/{rECID:int64}", func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
rECID, err := ctx.Params().GetInt64("rECID")
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
result, err := method(user, rECID)
|
|
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 : RegisterSelectInfoACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个查找单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterSelectInfoACCUNITID(party router.Party, path string, method func(*models.Usertab, string) (*model.ReclinerResult, error)) {
|
|
|
|
party.Get(path, func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
reclinerNr := ctx.URLParam("reclinerNr")
|
|
result, err := method(user, reclinerNr)
|
|
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 : RegisterUpdateOneACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个修改单条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterUpdateOneACCUNITID(party router.Party, path string, method func(*models.Usertab, *model.ACCUNITID) error) {
|
|
|
|
RegisterOneACCUNITID(party, "PUT", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterMultiACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个处理多条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterMultiACCUNITID(party router.Party, httpMethod string, path string, method func(*models.Usertab, *[]model.ACCUNITID) error) {
|
|
|
|
party.Handle(httpMethod, path, func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
entities := make([]model.ACCUNITID, 0, 10)
|
|
err := ctx.ReadJSON(&entities)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
|
|
err = method(user, &entities)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, nil)
|
|
})
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterInsertACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个插入多条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterInsertACCUNITID(party router.Party, path string, method func(*models.Usertab, *[]model.ACCUNITID) error) {
|
|
|
|
RegisterMultiACCUNITID(party, "POST", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterDeleteACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个删除多条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterDeleteACCUNITID(party router.Party, path string, method func(*models.Usertab, *[]model.ACCUNITID) error) {
|
|
|
|
RegisterMultiACCUNITID(party, "DELETE", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterSelectACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个查询ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterSelectACCUNITID(party router.Party, path string, method func(*models.Usertab, map[string]string) (interface{}, error)) {
|
|
|
|
party.Get(path, func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
result, err := method(user, ctx.URLParams())
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, result)
|
|
})
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterUpdateACCUNITID
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个修改多条ACCUNITID的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-07-12 10:08:28
|
|
*
|
|
******************************************************************************/
|
|
func RegisterUpdateACCUNITID(party router.Party, path string, method func(*models.Usertab, *[]model.ACCUNITID) error) {
|
|
|
|
RegisterMultiACCUNITID(party, "PUT", path, method)
|
|
}
|