123456789101112131415161718192021222324 |
- package session
- import (
- "gorm.io/gorm"
- "hongze/hongze_yb_en_api/global"
- "time"
- )
- // GetTokenByToken 根据token获取信息
- func GetTokenByToken(token string) (item *EnglishYbSession, err error) {
- err = getDb().Where("access_token = ? and expire_time> ? ", token, time.Now()).Order("session_id DESC").First(&item).Error
- return
- }
- // 获取数据库链接
- func getDb() *gorm.DB {
- return global.MYSQL["rddp"]
- }
- // GetTokenByUid 根据用户id获取token
- func GetTokenByUid(userId int) (item *EnglishYbSession, err error) {
- err = getDb().Where("user_id = ? ", userId).First(&item).Error
- return
- }
|