package system import ( "hongze/fms_api/global" "hongze/fms_api/models/base" "time" ) type SysSession struct { SessionId int64 `gorm:"primaryKey;column:session_id" json:"_"` AdminId uint64 `gorm:"column:admin_id" json:"admin_id"` //账号ID OpenId string `gorm:"column:open_id" json:"open_id"` //openid AccessToken string `gorm:"column:access_token" json:"access_token"` //登录token ExpireTime time.Time `gorm:"column:expire_time" json:"expire_time"` //超时时间 base.TimeBase } type LoginTokenContent struct { AdminId uint64 Password string IsRemember bool `description:"是否属于受信设备"` } // TableName get sql table name.获取数据库表名 func (s *SysSession) TableName() string { return "sys_session" } // Add 新增 func (s *SysSession) Add() (err error) { err = global.DEFAULT_MYSQL.Create(s).Error return } func (s *SysSession) GetSessionByToken(token string) (item *SysSession, err error) { err = global.DEFAULT_MYSQL.Model(s).Where("access_token = ? ", token).Order("session_id DESC").First(&item).Error return }