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
968 B

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package container
import (
"LAPP_LF_MOM_BACKEND/web/models"
"errors"
"fmt"
)
// 会话上下文
type SessionContext struct {
// 用户信息
user *models.Usertab
// 事务句柄工厂
transactionHandlerFactory TransactionHandlerFactory
}
// 创建会话上下文
// 参数
// 1.用户标识
// 返回值:
// 1.会话上下文
// 2.错误
func NewSessionContext(user *models.Usertab, 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() *models.Usertab {
return context.user
}