-
Notifications
You must be signed in to change notification settings - Fork 0
/
deck.go
62 lines (53 loc) · 1.24 KB
/
deck.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package storage
import (
scryfallcards "github.com/high-creek-software/goscryfall/cards"
"time"
)
type Deck struct {
ID string
Name string
CreatedAt time.Time
CoverImage string
DeckType string
Commander *DeckCard
commanderID string
Sideboard []DeckCard
Main []DeckCard
}
type DeckCard struct {
ID string
Count int
Card scryfallcards.Card
CreatedAt time.Time
AssociationType AssociationType
}
type gormDeck struct {
ID string `gorm:"primaryKey"`
Name string `gorm:"index:idx_deck_name"`
CreateAt time.Time
CoverImage string
DeckType string `gorm:"index:idx_deck_type"`
}
func (gormDeck) TableName() string {
return "decks"
}
type AssociationType int
const (
AssociationUnknown AssociationType = iota
AssociationSideboard
AssociationMain
AssociationCommander
AssociationCompanion
)
type gormDeckCard struct {
ID string `gorm:"primaryKey"`
DeckID string `gorm:"index:idx_deck_card_deck_id"`
CardID string `gorm:"index:idx_deck_card_card_id"`
CardName string
AssociationType AssociationType
Count int
CreatedAt time.Time
}
func (gormDeckCard) TableName() string {
return "deck_cards"
}