30 lines
1018 B
Go
30 lines
1018 B
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type Application struct {
|
|
ID uint32 `gorm:"primaryKey" json:"id"`
|
|
UserID uint64 `json:"user_id"`
|
|
User User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"user"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
APIKey string `gorm:"unique;not null" json:"api_key"`
|
|
Active bool `json:"active"`
|
|
// Many-to-many relation with Permission
|
|
Permissions []Permission `gorm:"many2many:application_permissions;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"permissions"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type ApplicationCache struct {
|
|
Name string `json:"name"`
|
|
UserID uint64 `json:"user_id"`
|
|
APIKey string `json:"api_key"`
|
|
Permissions []Permission `json:"permissions"`
|
|
Active bool `json:"active"`
|
|
UserActive bool `json:"user_active"`
|
|
RateLimit RateLimit `json:"rate_limit"`
|
|
}
|