// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.

package base

import (
	"LAPP_ACURA_MOM_BACKEND/global"
	"LAPP_ACURA_MOM_BACKEND/grmi"
	model "LAPP_ACURA_MOM_BACKEND/models/base"
	"LAPP_ACURA_MOM_BACKEND/web/middleware/jwts"
	"LAPP_ACURA_MOM_BACKEND/web/supports"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/core/router"
)

/******************************************************************************
 *
 * @Function Name            : RegisterOneWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个处理单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : HTTP方法
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterOneWorkOrderIdentifyRuleDetail(party router.Party, httpMethod string, path string, method func(*global.User, *model.WorkOrderIdentifyRuleDetail) 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.WorkOrderIdentifyRuleDetail)
		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            : RegisterIDOfWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个通过主键处理单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : HTTP方法
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterIDOfWorkOrderIdentifyRuleDetail(party router.Party, httpMethod string, path string, method func(*global.User, string, int, 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
		collerationBasis := ctx.Params().GetString("collerationBasis")
		collerationOperationId, err := ctx.Params().GetInt("collerationOperationId")
		if err != nil {
			supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
			return
		}
		identifyRuleId, err := ctx.Params().GetInt("identifyRuleId")
		if err != nil {
			supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
			return
		}

		err = method(user, collerationBasis, collerationOperationId, identifyRuleId)
		if err != nil {
			supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
			return
		}
		supports.Ok(ctx, supports.OptionSuccess, nil)
	})
}

/******************************************************************************
 *
 * @Function Name            : RegisterInsertOneWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个插入单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterInsertOneWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, *model.WorkOrderIdentifyRuleDetail) error) {

	RegisterOneWorkOrderIdentifyRuleDetail(party, "POST", path, method)
}

/******************************************************************************
 *
 * @Function Name            : RegisterDeleteOneWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个删除单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterDeleteOneWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, string, int, int) error) {

	RegisterIDOfWorkOrderIdentifyRuleDetail(party, "DELETE", path+"/{collerationBasis:string}/{collerationOperationId:int}/{identifyRuleId:int}", method)
}

/******************************************************************************
 *
 * @Function Name            : RegisterSelectOneWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个查找单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterSelectOneWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, string, int, int) (*model.WorkOrderIdentifyRuleDetail, error)) {

	party.Get(path+"/{collerationBasis:string}/{collerationOperationId:int}/{identifyRuleId:int}", func(ctx iris.Context) {
		user, ok := jwts.ParseToken(ctx)
		if !ok {
			supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
			return
		}

		collerationBasis := ctx.Params().GetString("collerationBasis")
		collerationOperationId, err := ctx.Params().GetInt("collerationOperationId")
		if err != nil {
			supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
			return
		}
		identifyRuleId, err := ctx.Params().GetInt("identifyRuleId")
		if err != nil {
			supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
			return
		}
		result, err := method(user, collerationBasis, collerationOperationId, identifyRuleId)
		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            : RegisterUpdateOneWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个修改单条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterUpdateOneWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, *model.WorkOrderIdentifyRuleDetail) error) {

	RegisterOneWorkOrderIdentifyRuleDetail(party, "PUT", path, method)
}

/******************************************************************************
 *
 * @Function Name            : RegisterMultiWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个处理多条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : HTTP方法
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterMultiWorkOrderIdentifyRuleDetail(party router.Party, httpMethod string, path string, method func(*global.User, *[]model.WorkOrderIdentifyRuleDetail) 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.WorkOrderIdentifyRuleDetail, 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            : RegisterInsertWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个插入多条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterInsertWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, *[]model.WorkOrderIdentifyRuleDetail) error) {

	RegisterMultiWorkOrderIdentifyRuleDetail(party, "POST", path, method)
}

/******************************************************************************
 *
 * @Function Name            : RegisterDeleteWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个删除多条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterDeleteWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, *[]model.WorkOrderIdentifyRuleDetail) error) {

	RegisterMultiWorkOrderIdentifyRuleDetail(party, "DELETE", path, method)
}

/******************************************************************************
 *
 * @Function Name            : RegisterSelectWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个查询WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterSelectWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, map[string]string) ([]model.WorkOrderIdentifyRuleDetail, 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            : RegisterQueryWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个查询WorkOrderIdentifyRuleDetail并分页的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterQueryWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, map[string]string) (grmi.PagingResult, 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            : RegisterUpdateWorkOrderIdentifyRuleDetail
 *-----------------------------------------------------------------------------
 *
 * @Description              : 为一个修改多条WorkOrderIdentifyRuleDetail的方法注册路由
 *
 * @Function Parameters      : 路由分组
 *
 * @Function Parameters      : 路径
 *
 * @Function Parameters      : 实际处理请求的方法
 *
 * @Author                   : 代码生成器创建
 *
 * @Date                     : 2021-11-30 14:27:09
 *
 ******************************************************************************/
func RegisterUpdateWorkOrderIdentifyRuleDetail(party router.Party, path string, method func(*global.User, *[]model.WorkOrderIdentifyRuleDetail) error) {

	RegisterMultiWorkOrderIdentifyRuleDetail(party, "PUT", path, method)
}
