|
|
- // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
-
- package container
-
- import (
- "errors"
- "fmt"
- )
-
- // 无会话(XORM会话)代理创建器
- // @Implement LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder
- type NoSessionBrokerBuilder struct {
- }
-
- // 创建无会话代理创建器
- // 返回值:
- // 1.无会话代理创建器
- func NewNoSessionBrokerBuilder() *NoSessionBrokerBuilder {
- return &NoSessionBrokerBuilder{}
- }
-
- // @Reference LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder.Check
- func (builder *NoSessionBrokerBuilder) Check(methodType Method) error {
- if methodType == nil {
- return errors.New(fmt.Sprintf("方法类型不能为空!"))
- }
- // 从接口类型获取方法类型,Receiver不算作入参
- if methodType.NumIn() < 1 {
- return errors.New(fmt.Sprintf("参数太少!实际数量:%d", methodType.NumIn()))
- }
- if methodType.In(0) != RequestContextType {
- return errors.New(fmt.Sprintf("第一个参数必须是*RequestContext"))
- }
- for i := 1; i < methodType.NumIn(); i++ {
- if methodType.In(i) == RequestContextType {
- return errors.New(fmt.Sprintf("第%d个参数不能是*RequestContext", i+1))
- }
- }
- return nil
- }
-
- // @Reference LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder.Build
- func (builder *NoSessionBrokerBuilder) Build(_ *SessionContext, caller Caller) (Caller, error) {
- if caller == nil {
- return nil, errors.New(fmt.Sprintf("调用器不能为空!"))
- }
- return caller, nil
- }
|