-
Notifications
You must be signed in to change notification settings - Fork 2
/
collection.go
33 lines (29 loc) · 873 Bytes
/
collection.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
package entity
import (
"fmt"
"strings"
"time"
"github.com/HardDie/DeckBuilder/internal/config"
"github.com/HardDie/DeckBuilder/internal/utils"
)
type CollectionInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Image string `json:"image"`
CachedImage string `json:"cachedImage,omitempty"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
func (i *CollectionInfo) GetName() string {
return strings.ToLower(i.Name)
}
func (i *CollectionInfo) GetCreatedAt() time.Time {
if i.CreatedAt != nil {
return *i.CreatedAt
}
return time.Time{}
}
func (i *CollectionInfo) FillCachedImage(cfg *config.Config, gameID string) {
i.CachedImage = fmt.Sprintf(cfg.CollectionImagePath+"?%s", gameID, i.ID, utils.HashForTime(i.UpdatedAt))
}