This commit is contained in:
Pablu23
2024-05-21 15:17:29 +02:00
parent 20ad56b155
commit c1fa18fead
7 changed files with 300 additions and 160 deletions

View File

@@ -3,7 +3,6 @@ package database
type MangaDefinition struct {
Id int `gorm:"primary_key;AUTO_INCREMENT"`
Title string
TimeStampUnix int64
Thumbnail []byte
LastChapterNum string
// Chapters []Chapter
@@ -13,21 +12,31 @@ type MangaDefinition struct {
type Manga struct {
Id int `gorm:"primary_key;AUTO_INCREMENT"`
MangaDefinitionId int
Definition MangaDefinition `gorm:"foreignKey:MangaDefinitionId"`
Definition MangaDefinition `gorm:"foreignKey:MangaDefinitionId"`
UserId int
User User
TimeStampUnix int64
Chapters []Chapter `gorm:"foreignKey:MangaId"`
}
func NewMangaDefinition(id int, title string, timeStampUnix int64) MangaDefinition {
func NewMangaDefinition(id int, title string) MangaDefinition {
return MangaDefinition{
Id: id,
Title: title,
TimeStampUnix: timeStampUnix,
LastChapterNum: "",
}
}
func NewManga(def MangaDefinition, user User, timeStampUnix int64) Manga {
return Manga{
MangaDefinitionId: def.Id,
Definition: def,
UserId: user.Id,
User: user,
TimeStampUnix: timeStampUnix,
}
}
// GetLatestChapter TODO: Cache this somehow
func (m *Manga) GetLatestChapter() (*Chapter, bool) {
// highest := int64(0)