rdluck 4 years ago
parent
commit
7cd5f3e903
1 changed files with 4 additions and 2 deletions
  1. 4 2
      models/session.go

+ 4 - 2
models/session.go

@@ -16,15 +16,17 @@ type Session struct {
 }
 
 func GetSessionByToken(token string) (item *Session, err error) {
-	sql := `SELECT * FROM session WHERE access_token=? AND expired_time> NOW() ORDER BY expired_time DESC LIMIT 1 `
+	sql := `SELECT * FROM session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
+	o.Using("rddp")
 	err = o.Raw(sql, token).QueryRow(&item)
 	return
 }
 
-//添加用户信息
+//添加用户session信息
 func AddSession(item *Session) (err error) {
 	o := orm.NewOrm()
+	o.Using("rddp")
 	_, err = o.Insert(item)
 	return
 }