refactor(login): 重构登录服务中的会话管理
- 移除 LoginSidInfo 中的 CacheManager 调用,改为使用 session 包 - 更新 BlazingController 中的 SaveSession 调用,使用 session 包 - 删除 LoginService 中的 SaveSessionId 方法,简化会话管理逻辑 - 优化代码结构,提高可维护性和可测试性
This commit is contained in:
@@ -3,15 +3,12 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -27,16 +24,6 @@ func NewLoginServiceService() *LoginService {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *LoginService) SaveSessionId(session string, userid string) error {
|
||||
|
||||
cool.CacheManager.Set(gctx.New(), strings.Trim(session, " "), userid, time.Hour*24)
|
||||
// gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
||||
t, err := cool.CacheManager.Contains(context.Background(), strings.Trim(session, " "))
|
||||
|
||||
fmt.Println("前端获取", session, t, err)
|
||||
|
||||
return nil
|
||||
}
|
||||
func (s *LoginService) GetSessionId(accountID uint) (string, string, error) {
|
||||
|
||||
t1, _ := uuid.NewV7()
|
||||
|
||||
Reference in New Issue
Block a user