package models import ( "rdluck_tools/orm" "time" ) type Session struct { SessionId int UserId int OpenId string AccessToken string ExpireTime string CreatedTime time.Time } 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 ` o := orm.NewOrm() o.Using("rddp") err = o.Raw(sql, token).QueryRow(&item) return }