Feat: add journal [wip]

This commit is contained in:
Grail Finder
2025-07-05 14:15:31 +03:00
parent 5b24378956
commit 27e31603da
3 changed files with 31 additions and 1 deletions

View File

@ -76,3 +76,13 @@ CREATE TABLE sessions(
username TEXT NOT NULL,
FOREIGN KEY (username) REFERENCES players(username) ON DELETE CASCADE
);
CREATE TABLE journal(
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
entry TEXT NOT NULL DEFAULT '',
username TEXT NOT NULL,
room_id TEXT NOT NULL,
FOREIGN KEY (username) REFERENCES players(username) ON DELETE CASCADE,
FOREIGN KEY (room_id) REFERENCES rooms(id) ON DELETE CASCADE
);

View File

@ -130,6 +130,14 @@ type CardMark struct {
Username string `db:"username"`
}
type Journal struct {
ID uint32 `db:"id"`
Username string `db:"username"`
RoomID string `db:"room_id"`
Entry string `db:"entry"`
CreatedAt time.Time `db:"created_at"`
}
type Room struct {
ID string `json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
@ -151,7 +159,7 @@ type Room struct {
BlueTeam Team `db:"-"`
Cards []WordCard `db:"-"`
BotMap map[string]BotPlayer `db:"-"`
LogJournal []string `db:"-"`
LogJournal []Journal `db:"-"`
Settings GameSettings `db:"-"`
}

12
repos/journal.go Normal file
View File

@ -0,0 +1,12 @@
package repos
import (
"context"
"gralias/models"
)
type JournalRepo interface {
JournalByRoomID(ctx context.Context, roomID string) ([]models.Journal, error)
JournalCreate(ctx context.Context, action *models.Journal) error
JournalDeleteByRoomID(ctx context.Context, roomID string) error
}