Feat: add journal [wip]
This commit is contained in:
		| @@ -76,3 +76,13 @@ CREATE TABLE sessions( | |||||||
|     username TEXT NOT NULL, |     username TEXT NOT NULL, | ||||||
|     FOREIGN KEY (username) REFERENCES players(username) ON DELETE CASCADE |     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 | ||||||
|  | ); | ||||||
|   | |||||||
| @@ -130,6 +130,14 @@ type CardMark struct { | |||||||
| 	Username string `db:"username"` | 	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 { | type Room struct { | ||||||
| 	ID             string    `json:"id" db:"id"` | 	ID             string    `json:"id" db:"id"` | ||||||
| 	CreatedAt      time.Time `json:"created_at" db:"created_at"` | 	CreatedAt      time.Time `json:"created_at" db:"created_at"` | ||||||
| @@ -151,7 +159,7 @@ type Room struct { | |||||||
| 	BlueTeam      Team                 `db:"-"` | 	BlueTeam      Team                 `db:"-"` | ||||||
| 	Cards         []WordCard           `db:"-"` | 	Cards         []WordCard           `db:"-"` | ||||||
| 	BotMap        map[string]BotPlayer `db:"-"` | 	BotMap        map[string]BotPlayer `db:"-"` | ||||||
| 	LogJournal    []string             `db:"-"` | 	LogJournal    []Journal            `db:"-"` | ||||||
| 	Settings      GameSettings         `db:"-"` | 	Settings      GameSettings         `db:"-"` | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								repos/journal.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								repos/journal.go
									
									
									
									
									
										Normal 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 | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder