GAAS GFrame项目web后台
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.

42 lines
1.2 KiB

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