38 lines
776 B
Go
38 lines
776 B
Go
package user
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type ModelSession struct {
|
|
modules.MCompModel
|
|
module *User
|
|
}
|
|
|
|
func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = comm.TableSession
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*User)
|
|
return
|
|
}
|
|
|
|
//获取用户
|
|
func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) {
|
|
var sl []*pb.CacheUser
|
|
|
|
if err := this.GetList("online", sl); err != nil {
|
|
this.module.Errorf("GetUserSession err:%v", err)
|
|
return
|
|
}
|
|
|
|
for _, v := range sl {
|
|
if v.Uid == uid {
|
|
return v
|
|
}
|
|
}
|
|
return
|
|
}
|