"refactor(base): 移除用户模型中的SocketID字段并重构登录会话管理"

This commit is contained in:
1
2025-07-15 19:27:27 +00:00
parent 45fd8535e1
commit a1e45e526e
2 changed files with 5 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ type BaseSysUser struct {
Email *string `gorm:"column:email;type:varchar(255)" json:"email"` // 邮箱
Status *int32 `gorm:"column:status;not null;default:1" json:"status"` // 状态 0:禁用 1启用
Remark *string `gorm:"column:remark;type:varchar(255)" json:"remark"` // 备注
SocketID *string `gorm:"column:socketId;type:varchar(255)" json:"socketId"` // socketId
//SocketID *string `gorm:"column:socketId;type:varchar(255)" json:"socketId"` // socketId
}
// TableName BaseSysUser's table name

View File

@@ -1,7 +1,7 @@
package admin
import (
"blazing/common/data/cache"
"blazing/common/data/share"
"blazing/cool"
baseservice "blazing/modules/base/service"
"blazing/modules/blazing/service"
@@ -10,7 +10,6 @@ import (
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
type SessionReq struct {
@@ -58,15 +57,12 @@ func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (re
}
res1, err := baseservice.NewBaseSysUserService().GetSession(req.Email, req.Password)
if err != nil {
res.Code = 400
res.Msg = err.Error()
}
if res1 == nil {
if err != nil || res1 == nil {
res.Code = 400
res.Msg = err.Error()
return
}
accountID := res1.ID
retsid, sid, err := biazing_service.GetSessionId(accountID)
if err != nil {
@@ -77,7 +73,7 @@ func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (re
res.Session = retsid
if err := cache.NewSessionManager().SaveSession(sid, gconv.String(accountID)); err != nil {
if err := share.ShareManager.SaveSession(sid, uint32(accountID)); err != nil {
res.Code = 400
res.Msg = err.Error()
}