修改session缓存
This commit is contained in:
parent
b4ec3d86fb
commit
494502ed5e
@ -95,7 +95,16 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
SessionId: cache_user.SessionId,
|
SessionId: cache_user.SessionId,
|
||||||
GatewayServiceId: cache_user.GatewayServiceId,
|
GatewayServiceId: cache_user.GatewayServiceId,
|
||||||
}
|
}
|
||||||
return this.module.modelUser.SetObj(cache_user.Uid, data, true, true)
|
err = this.module.modelSession.SetObj(cache_user.Uid, data, true, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = this.module.modelUser.SetObj(cache_user.Uid, user, true, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
session.Bind(db_user.Uid, this.service.GetId())
|
session.Bind(db_user.Uid, this.service.GetId())
|
||||||
data := &pb.Cache_UserData{
|
data := &pb.Cache_UserData{
|
||||||
@ -107,6 +116,18 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
// "sessionId": cache_user.SessionId,
|
// "sessionId": cache_user.SessionId,
|
||||||
// "gatewayServiceId": cache_user.GatewayServiceId,
|
// "gatewayServiceId": cache_user.GatewayServiceId,
|
||||||
// }
|
// }
|
||||||
return this.module.modelUser.SetObj(cache_user.Uid, data, false, false)
|
err = this.module.modelSession.SetObj(db_user.Uid, data, false, false)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = this.module.modelUser.SetObj(db_user.Uid, db_user, false, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
16
modules/user/model_session.go
Normal file
16
modules/user/model_session.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModelSession struct {
|
||||||
|
modules.Model_Comp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.Model_Comp.Init(service, module, comp, options)
|
||||||
|
this.Prefix = "session"
|
||||||
|
return
|
||||||
|
}
|
@ -16,6 +16,7 @@ type User struct {
|
|||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
user_comp *Api_Comp
|
user_comp *Api_Comp
|
||||||
modelUser *ModelUser
|
modelUser *ModelUser
|
||||||
|
modelSession *ModelSession
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) GetType() core.M_Modules {
|
func (this *User) GetType() core.M_Modules {
|
||||||
@ -32,4 +33,5 @@ func (this *User) OnInstallComp() {
|
|||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.user_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
this.user_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||||
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
|
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
|
||||||
|
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user