// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
|
|
package container
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// 会话上下文
|
|
type SessionContext struct {
|
|
// 用户标识
|
|
userId string
|
|
}
|
|
|
|
// 创建会话上下文
|
|
// 参数
|
|
// 1.用户标识
|
|
// 返回值:
|
|
// 1.会话上下文
|
|
// 2.错误
|
|
func NewSessionContext(userId string) (*SessionContext, error) {
|
|
if userId == "" {
|
|
return nil, errors.New(fmt.Sprintf("用户标识不能为空!"))
|
|
}
|
|
return &SessionContext{userId}, nil
|
|
}
|
|
|
|
// 获取用户标识
|
|
// 返回值:
|
|
// 1.用户标识
|
|
func (context *SessionContext) UserId() string {
|
|
return context.userId
|
|
}
|