|
|
- // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
-
- package container
-
- import (
- "errors"
- "fmt"
- "LEIT_PM/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
- }
|