refactor: rewrite backend in Go, replacing Python FastAPI
Port the FastAPI backend to Go 1.26, preserving all API functionality: - auth (register/login/guest/logout/profile/history) with JWT + bcrypt - scripts (list/detail) backed by embedded sample_data.json - games (create/join/start/chat/phase/clue/vote/state/replay) + WebSocket - rule-based NPC agent plus DeepSeek/Ollama AI backends - SQLite persistence via modernc.org/sqlite (pure Go, no cgo) Frontend and documents are unchanged.
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
RolePlayer = "player"
|
||||
RoleCreator = "creator"
|
||||
RoleAdmin = "admin"
|
||||
|
||||
ScriptSourceBuiltin = "builtin"
|
||||
ScriptSourceAIGenerated = "ai_generated"
|
||||
ScriptSourceUploaded = "uploaded"
|
||||
ScriptSourceCreator = "creator"
|
||||
|
||||
ScriptStatusDraft = "draft"
|
||||
ScriptStatusPublished = "published"
|
||||
ScriptStatusDisabled = "disabled"
|
||||
|
||||
GameStatusWaiting = "waiting"
|
||||
GameStatusPlaying = "playing"
|
||||
GameStatusPaused = "paused"
|
||||
GameStatusCompleted = "completed"
|
||||
|
||||
PlayerStatusActive = "active"
|
||||
PlayerStatusLeft = "left"
|
||||
PlayerStatusEliminated = "eliminated"
|
||||
|
||||
MessageTypePublic = "public"
|
||||
MessageTypePrivate = "private"
|
||||
MessageTypeSystem = "system"
|
||||
MessageTypeClue = "clue"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Email *string
|
||||
Nickname *string
|
||||
AvatarURL *string
|
||||
PasswordHash *string
|
||||
Role string
|
||||
IsGuest bool
|
||||
GameCount int
|
||||
TokenVersion int
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type GameSession struct {
|
||||
ID string
|
||||
ScriptID string
|
||||
Status string
|
||||
Phase string
|
||||
PhaseIndex int
|
||||
StartedAt *time.Time
|
||||
CompletedAt *time.Time
|
||||
Config string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SessionPlayer struct {
|
||||
ID string
|
||||
SessionID string
|
||||
UserID *string
|
||||
RoleID string
|
||||
RoleName string
|
||||
IsHuman bool
|
||||
IsReady bool
|
||||
AvatarURL *string
|
||||
Status string
|
||||
JoinedAt time.Time
|
||||
}
|
||||
|
||||
type ChatMessage struct {
|
||||
ID string
|
||||
SessionID string
|
||||
SenderRoleID string
|
||||
SenderName string
|
||||
MessageType string
|
||||
Content string
|
||||
TargetRoleID *string
|
||||
ClueID *string
|
||||
PhaseIndex int
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type ClueState struct {
|
||||
ID string
|
||||
SessionID string
|
||||
ClueID string
|
||||
Status string
|
||||
RevealedBy *string
|
||||
ReleasedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Vote struct {
|
||||
ID string
|
||||
SessionID string
|
||||
Round int
|
||||
VoterID string
|
||||
TargetID string
|
||||
Reason *string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user