苏州瑞玛APS项目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.

40 lines
967 B

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package container
import (
"errors"
"fmt"
"leit.com/LAPP_CHEERSSON_BACKEND/global"
)
// 会话上下文
type SessionContext struct {
// 用户信息
user *global.User
// 事务句柄工厂
transactionHandlerFactory TransactionHandlerFactory
}
// 创建会话上下文
// 参数
// 1.用户标识
// 返回值:
// 1.会话上下文
// 2.错误
func NewSessionContext(user *global.User, transactionHandlerFactory TransactionHandlerFactory) (*SessionContext, error) {
if user == nil {
return nil, errors.New(fmt.Sprintf("用户信息不能为空!"))
}
if transactionHandlerFactory == nil {
return nil, errors.New(fmt.Sprintf("事务句柄工厂不能为空!"))
}
return &SessionContext{user, transactionHandlerFactory}, nil
}
// 获取用户标识
// 返回值:
// 1.用户信息
func (context *SessionContext) User() *global.User {
return context.user
}