Simplify all the context link.
This commit is contained in:
@ -11,10 +11,10 @@ type SessionDao struct {
|
||||
}
|
||||
|
||||
//构造函数
|
||||
func NewSessionDao(context *Context) *SessionDao {
|
||||
func NewSessionDao() *SessionDao {
|
||||
|
||||
var sessionDao = &SessionDao{}
|
||||
sessionDao.Init(context)
|
||||
sessionDao.Init()
|
||||
return sessionDao
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ func (this *SessionDao) FindByUuid(uuid string) *Session {
|
||||
|
||||
// Read
|
||||
var session = &Session{}
|
||||
db := this.context.DB.Where(&Session{Base: Base{Uuid: uuid}}).First(session)
|
||||
db := CONTEXT.DB.Where(&Session{Base: Base{Uuid: uuid}}).First(session)
|
||||
if db.Error != nil {
|
||||
return nil
|
||||
}
|
||||
@ -35,7 +35,7 @@ func (this *SessionDao) CheckByUuid(uuid string) *Session {
|
||||
|
||||
// Read
|
||||
var session = &Session{}
|
||||
db := this.context.DB.Where(&Session{Base: Base{Uuid: uuid}}).First(session)
|
||||
db := CONTEXT.DB.Where(&Session{Base: Base{Uuid: uuid}}).First(session)
|
||||
this.PanicError(db.Error)
|
||||
return session
|
||||
}
|
||||
@ -44,7 +44,7 @@ func (this *SessionDao) CheckByUuid(uuid string) *Session {
|
||||
func (this *SessionDao) FindByAuthentication(authentication string) *Session {
|
||||
|
||||
var session = &Session{}
|
||||
db := this.context.DB.Where(&Session{Authentication: authentication}).First(session)
|
||||
db := CONTEXT.DB.Where(&Session{Authentication: authentication}).First(session)
|
||||
if db.Error != nil {
|
||||
return nil
|
||||
}
|
||||
@ -57,7 +57,7 @@ func (this *SessionDao) Create(session *Session) *Session {
|
||||
|
||||
timeUUID, _ := uuid.NewV4()
|
||||
session.Uuid = string(timeUUID.String())
|
||||
db := this.context.DB.Create(session)
|
||||
db := CONTEXT.DB.Create(session)
|
||||
this.PanicError(db.Error)
|
||||
|
||||
return session
|
||||
@ -68,7 +68,7 @@ func (this *SessionDao) Delete(uuid string) {
|
||||
session := this.CheckByUuid(uuid)
|
||||
|
||||
session.ExpireTime = time.Now()
|
||||
db := this.context.DB.Delete(session)
|
||||
db := CONTEXT.DB.Delete(session)
|
||||
|
||||
this.PanicError(db.Error)
|
||||
|
||||
|
Reference in New Issue
Block a user