// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
|
|
package base
|
|
|
|
import (
|
|
model "LAPP_GAAS_GFrame_BACKEND/models/base"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/middleware/jwts"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/models"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/supports"
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/kataras/iris/v12/core/router"
|
|
)
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterOneWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个处理单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterOneWorkShift(party router.Party, httpMethod string, path string, method func(*models.Usertab, *model.WorkShift) 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.WorkShift)
|
|
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 : RegisterIDOfWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个通过主键处理单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterIDOfWorkShift(party router.Party, httpMethod string, path string, method func(*models.Usertab, int) 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
|
|
workShiftNr, err := ctx.Params().GetInt("workShiftNr")
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
|
|
err = method(user, workShiftNr)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, nil)
|
|
})
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterInsertOneWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个插入单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterInsertOneWorkShift(party router.Party, path string, method func(*models.Usertab, *model.WorkShift) error) {
|
|
|
|
RegisterOneWorkShift(party, "POST", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterDeleteOneWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个删除单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterDeleteOneWorkShift(party router.Party, path string, method func(*models.Usertab, int) error) {
|
|
|
|
RegisterIDOfWorkShift(party, "DELETE", path+"/{workShiftNr:int}", method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterSelectOneWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个查找单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterSelectOneWorkShift(party router.Party, path string, method func(*models.Usertab, int) (*model.WorkShift, error)) {
|
|
|
|
party.Get(path+"/{workShiftNr:int}", func(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
workShiftNr, err := ctx.Params().GetInt("workShiftNr")
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
result, err := method(user, workShiftNr)
|
|
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 : RegisterUpdateOneWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个修改单条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterUpdateOneWorkShift(party router.Party, path string, method func(*models.Usertab, *model.WorkShift) error) {
|
|
|
|
RegisterOneWorkShift(party, "PUT", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterMultiWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个处理多条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : HTTP方法
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterMultiWorkShift(party router.Party, httpMethod string, path string, method func(*models.Usertab, *[]model.WorkShift) 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.WorkShift, 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 : RegisterInsertWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个插入多条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterInsertWorkShift(party router.Party, path string, method func(*models.Usertab, *[]model.WorkShift) error) {
|
|
|
|
RegisterMultiWorkShift(party, "POST", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterDeleteWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个删除多条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterDeleteWorkShift(party router.Party, path string, method func(*models.Usertab, *[]model.WorkShift) error) {
|
|
|
|
RegisterMultiWorkShift(party, "DELETE", path, method)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterSelectWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个查询WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterSelectWorkShift(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 : RegisterUpdateWorkShift
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 为一个修改多条WorkShift的方法注册路由
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-18 22:49:12
|
|
*
|
|
******************************************************************************/
|
|
func RegisterUpdateWorkShift(party router.Party, path string, method func(*models.Usertab, *[]model.WorkShift) error) {
|
|
|
|
RegisterMultiWorkShift(party, "PUT", path, method)
|
|
}
|