初始化
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AdminUser struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Username string `json:"username"`
|
||||
PasswordHash string `json:"-"`
|
||||
Enabled bool `json:"enabled"`
|
||||
LastLoginAt *time.Time `json:"last_login_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"-"`
|
||||
}
|
||||
|
||||
type AdminRefreshToken struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey"`
|
||||
AdminID uuid.UUID `gorm:"type:uuid"`
|
||||
TokenHash string
|
||||
ExpiresAt time.Time
|
||||
RevokedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type AdminAuditLog struct {
|
||||
ID int64 `json:"id"`
|
||||
AdminID *uuid.UUID `gorm:"type:uuid" json:"admin_id"`
|
||||
AdminUsername string `json:"admin_username"`
|
||||
Action string `json:"action"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID string `json:"resource_id"`
|
||||
Reason string `json:"reason"`
|
||||
Detail string `gorm:"type:jsonb" json:"detail"`
|
||||
IPAddress string `gorm:"type:inet" json:"ip_address"`
|
||||
TraceID string `json:"trace_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (AdminUser) TableName() string { return "admin_users" }
|
||||
func (AdminRefreshToken) TableName() string { return "admin_refresh_tokens" }
|
||||
func (AdminAuditLog) TableName() string { return "admin_audit_logs" }
|
||||
Reference in New Issue
Block a user