fix: migrate remaining models to BaseModel (lowercase id JSON)
This commit is contained in:
1 parent
48da56065d
commit
211e2b600f
5 files changed
+13
-38
No files matched your search
@@ -1,15 +1,10 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
import "time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// AccessToken grants a client access to one Listener's generated node
|
||||
// configuration. Listener is the single source of truth for client exports.
|
||||
// AccessToken grants a client access to one Listener's generated node configuration.
|
||||
type AccessToken struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Token string `gorm:"uniqueIndex;not null" json:"-"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// ListenerUser is the explicit many-to-many join between ProxyUser and Listener.
|
||||
// Username/Password are retained for database compatibility with the Phase 1/2 schema;
|
||||
// new code uses ProxyUserID and never stores proxy credentials in this join table.
|
||||
type ListenerUser struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
|
||||
ListenerID uint `gorm:"not null;index;uniqueIndex:idx_listener_proxy_user,priority:1" json:"listener_id"`
|
||||
ProxyUserID uint `gorm:"not null;index;uniqueIndex:idx_listener_proxy_user,priority:2" json:"proxy_user_id"`
|
||||
|
||||
// Deprecated legacy fields. They are not used for Phase 6 authentication generation.
|
||||
// Deprecated legacy fields. They are not used for authentication generation.
|
||||
Username string `gorm:"size:100;not null;default:''" json:"-"`
|
||||
Password string `gorm:"type:text;not null;default:''" json:"-"`
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
import "time"
|
||||
|
||||
// ProxyUser is a user account used to authenticate against Mihomo server nodes.
|
||||
// It is deliberately separate from User, which represents a 3m-ui administrator.
|
||||
type ProxyUser struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
|
||||
Username string `gorm:"size:100;not null;uniqueIndex" json:"username"`
|
||||
// PasswordEncrypted contains an AES-GCM encrypted password. It is never serialized to API responses.
|
||||
@@ -23,6 +19,4 @@ type ProxyUser struct {
|
||||
Online bool `gorm:"not null;default:false" json:"online"`
|
||||
ExpireTime time.Time `json:"expire_time"`
|
||||
Enabled bool `gorm:"not null;default:true" json:"enabled"`
|
||||
// TelegramID links a proxy user to one Telegram account for self-service commands.
|
||||
TelegramID *int64 `gorm:"uniqueIndex" json:"telegram_id"`
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
import "time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// RemoteServer registers an external 3m-ui / Mihomo host managed from this
|
||||
// panel. Multi-node is metadata + health check first; full remote config
|
||||
// push is a later phase (agent/token based).
|
||||
// RemoteServer registers an external 3m-ui / Mihomo host managed from this panel.
|
||||
type RemoteServer struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
|
||||
Name string `gorm:"size:100;not null" json:"name"`
|
||||
BaseURL string `gorm:"size:512;not null" json:"base_url"`
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
import "time"
|
||||
|
||||
type Subscription struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
UserID uint `gorm:"not null;index" json:"user_id"`
|
||||
Token string `gorm:"uniqueIndex;not null" json:"token"`
|
||||
Format string `gorm:"not null" json:"format"` // e.g., "clash", "sing-box"
|
||||
Format string `gorm:"not null" json:"format"`
|
||||
ExpireTime *time.Time `json:"expire_time"`
|
||||
}
|
||||
Reference in new issue
Block a user