-
-
Notifications
You must be signed in to change notification settings - Fork 794
/
artist.go
58 lines (50 loc) 路 2.18 KB
/
artist.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
package model
import "time"
type Artist struct {
Annotations `structs:"-"`
ID string `structs:"id" json:"id" orm:"column(id)"`
Name string `structs:"name" json:"name"`
AlbumCount int `structs:"album_count" json:"albumCount"`
SongCount int `structs:"song_count" json:"songCount"`
Genres Genres `structs:"-" json:"genres"`
FullText string `structs:"full_text" json:"fullText"`
SortArtistName string `structs:"sort_artist_name" json:"sortArtistName,omitempty"`
OrderArtistName string `structs:"order_artist_name" json:"orderArtistName"`
Size int64 `structs:"size" json:"size"`
MbzArtistID string `structs:"mbz_artist_id" json:"mbzArtistId,omitempty" orm:"column(mbz_artist_id)"`
Biography string `structs:"biography" json:"biography,omitempty"`
SmallImageUrl string `structs:"small_image_url" json:"smallImageUrl,omitempty"`
MediumImageUrl string `structs:"medium_image_url" json:"mediumImageUrl,omitempty"`
LargeImageUrl string `structs:"large_image_url" json:"largeImageUrl,omitempty"`
ExternalUrl string `structs:"external_url" json:"externalUrl,omitempty" orm:"column(external_url)"`
SimilarArtists Artists `structs:"-" json:"-" orm:"-"`
ExternalInfoUpdatedAt time.Time `structs:"external_info_updated_at" json:"externalInfoUpdatedAt"`
}
func (a Artist) ArtistImageUrl() string {
if a.LargeImageUrl != "" {
return a.LargeImageUrl
}
if a.MediumImageUrl != "" {
return a.MediumImageUrl
}
return a.SmallImageUrl
}
func (a Artist) CoverArtID() ArtworkID {
return artworkIDFromArtist(a)
}
type Artists []Artist
type ArtistIndex struct {
ID string
Artists Artists
}
type ArtistIndexes []ArtistIndex
type ArtistRepository interface {
CountAll(options ...QueryOptions) (int64, error)
Exists(id string) (bool, error)
Put(m *Artist) error
Get(id string) (*Artist, error)
GetAll(options ...QueryOptions) (Artists, error)
Search(q string, offset int, size int) (Artists, error)
GetIndex() (ArtistIndexes, error)
AnnotatedRepository
}