WIP
This commit is contained in:
@@ -8,9 +8,10 @@ type Chapter struct {
|
||||
Number string
|
||||
TimeStampUnix int64
|
||||
MangaId int
|
||||
UserId int
|
||||
}
|
||||
|
||||
func NewChapter(id int, mangaId int, url string, name string, number string, timeStampUnix int64) Chapter {
|
||||
func NewChapter(id int, mangaId int, userId int, url string, name string, number string, timeStampUnix int64) Chapter {
|
||||
return Chapter{
|
||||
ChapterId: id,
|
||||
Url: url,
|
||||
@@ -18,5 +19,6 @@ func NewChapter(id int, mangaId int, url string, name string, number string, tim
|
||||
Number: number,
|
||||
TimeStampUnix: timeStampUnix,
|
||||
MangaId: mangaId,
|
||||
UserId: userId,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -6,7 +6,6 @@ type User struct {
|
||||
LoginName string
|
||||
PwdHash []byte
|
||||
Salt []byte
|
||||
Mangas []Manga `gorm:"foreignKey:UserId"`
|
||||
}
|
||||
|
||||
// type UserManga struct {
|
||||
|
||||
Reference in New Issue
Block a user