chore(storage): run gorm gen
This commit is contained in:
parent
3f5df241db
commit
427675f38e
22 changed files with 554 additions and 174 deletions
|
@ -35,6 +35,19 @@ func newAccessToken(db *gorm.DB, opts ...gen.DOOption) accessToken {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -245,6 +258,12 @@ type accessTokenBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -440,15 +459,15 @@ type IAccessTokenDo interface {
|
|||
GetTokenIfValid(token string) (result *models.AccessToken, err error)
|
||||
}
|
||||
|
||||
// Get the data for a token if it hasn't expired yet
|
||||
// Get the data for a token
|
||||
//
|
||||
// SELECT * FROM @@table WHERE token = @token AND expires_at < NOW() LIMIT 1
|
||||
// SELECT * FROM @@table WHERE token = @token
|
||||
func (a accessTokenDo) GetTokenIfValid(token string) (result *models.AccessToken, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, token)
|
||||
generateSQL.WriteString("SELECT * FROM access_tokens WHERE token = ? AND expires_at < NOW() LIMIT 1 ")
|
||||
generateSQL.WriteString("SELECT * FROM access_tokens WHERE token = ? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = a.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue