package admin

import "time"

// Admin mirrors a row of the admins table (totp_secret kept encrypted).
type Admin struct {
	ID            int64
	Username      string
	PwHash        string
	TOTPSecretEnc []byte // AES-GCM blob; decrypt with Config.SecretKey
	Status        string // active | disabled
	CreatedAt     time.Time
	LastLoginAt   *time.Time
}

// NodeRow is a node-catalogue row as shown in the admin node list.
type NodeRow struct {
	ID       int64
	UUID     string
	Region   string
	NameZH   string
	NameEN   string
	Role     string
	Tier     string
	Endpoint string
	Status   string
	Weight   int
	Provider string
	// RecentEvents holds the most recent node_events for inline display.
	RecentEvents []NodeEvent
}

// NodeEvent mirrors a node_events row.
type NodeEvent struct {
	ID     int64
	NodeID int64
	Event  string
	Detail string // raw JSON or ""
	At     time.Time
}

// AuditEntry mirrors an audit_log row.
type AuditEntry struct {
	ID     int64
	Actor  string
	Action string
	Target string
	Meta   string // raw JSON or ""
	At     time.Time
}

// AuditFilter narrows an audit_log query. Empty fields are ignored.
type AuditFilter struct {
	Actor  string
	Action string
	Target string
	From   *time.Time
	To     *time.Time
	Limit  int
	Offset int
}

// BatchSummary is a code_batches row with aggregate code counts for the
// batch list view.
type BatchSummary struct {
	ID        int64
	Channel   string
	CreatedBy string
	Note      string
	CreatedAt time.Time
	Total     int
	Redeemed  int
	Void      int
	Unused    int
}
