Files
bl/logic/service/login/LoginSidInfo.go
昔念 738a897c4d refactor(login): 重构登录模块代码
- 移除未使用的 in.go 和 out.go 文件
- 优化 login.go 中的代码结构
- 添加新的 go.mod 依赖
2025-07-02 22:02:56 +08:00

35 lines
960 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package login
import (
"blazing/common/socket/handler"
"blazing/cool"
"context"
"encoding/hex"
"fmt"
"strings"
)
// LoginSidInfo 登录携带的凭证结构体
type LoginSidInfo struct { //这里直接使用组合来实现将传入的原始头部数据和结构体参数序列化
Head handler.TomeeHeader `cmd:"1001" struc:"[0]pad"`
Sid []byte `struc:"[16]byte"` // 登录会话ID固定长度16字节
// NotLogin uint32 `error="10001"|struc:"[0]pad"` //返回错误码 ,不序列化,仅作为错误码
// ErrorPassWord uint32 `struc:"[0]pad"`
}
func (l *LoginSidInfo) CheakSession() bool {
// tt, _ := cool.CacheManager.Keys(context.Background())
//g.Dump(tt)
t1 := hex.EncodeToString(l.Sid)
t2 := strings.Trim(t1, " ")
t, err := cool.CacheManager.Get(context.Background(), t2)
fmt.Println("后端获取", string(l.Sid), t, err)
if t.Uint32() == l.Head.UserID {
return true
}
return false
}