Add description when importing from inventaire
This commit is contained in:
@@ -4,15 +4,16 @@ import "gorm.io/gorm"
|
||||
|
||||
type Book struct {
|
||||
gorm.Model
|
||||
Title string `json:"title" gorm:"not null"`
|
||||
ISBN string `json:"isbn"`
|
||||
InventaireID string `json:"inventaireid"`
|
||||
OpenLibraryId string `json:"openlibraryid"`
|
||||
Summary string `json:"summary"`
|
||||
Author Author
|
||||
AuthorID uint
|
||||
AddedBy User
|
||||
AddedByID uint
|
||||
Cover StaticFile
|
||||
CoverID uint
|
||||
Title string `json:"title" gorm:"not null"`
|
||||
ISBN string `json:"isbn"`
|
||||
InventaireID string `json:"inventaireid"`
|
||||
OpenLibraryId string `json:"openlibraryid"`
|
||||
SmallDescription string
|
||||
Summary string `json:"summary"`
|
||||
Author Author
|
||||
AuthorID uint
|
||||
AddedBy User
|
||||
AddedByID uint
|
||||
Cover StaticFile
|
||||
CoverID uint
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type BookSearchGet struct {
|
||||
ID uint `json:"id"`
|
||||
Title string `json:"title" binding:"required,max=300"`
|
||||
Author string `json:"author" binding:"max=100"`
|
||||
Description string `json:"description"`
|
||||
InventaireID string `json:"inventaireid"`
|
||||
Rating int `json:"rating"`
|
||||
Read bool `json:"read"`
|
||||
@@ -70,7 +71,7 @@ func fetchBookSearchQuery(db *gorm.DB, userId uint, searchterm string) *gorm.DB
|
||||
|
||||
func fetchBookSearchQueryBuilder(db *gorm.DB, userId uint) *gorm.DB {
|
||||
query := db.Model(&model.Book{})
|
||||
query = query.Select("books.id, books.title, authors.name as author, books.inventaire_id, user_books.rating, user_books.read, user_books.want_read, " + selectStaticFilesPath())
|
||||
query = query.Select("books.id, books.title, authors.name as author, books.small_description as description, books.inventaire_id, user_books.rating, user_books.read, user_books.want_read, " + selectStaticFilesPath())
|
||||
query = joinAuthors(query)
|
||||
query = query.Joins("left join user_books on (user_books.book_id = books.id and user_books.user_id = ?)", userId)
|
||||
query = joinStaticFiles(query)
|
||||
|
||||
@@ -49,11 +49,11 @@ func saveInventaireBookToDb(ac appcontext.AppContext, inventaireBook inventaire.
|
||||
return nil, err
|
||||
}
|
||||
book := model.Book{
|
||||
Title: inventaireBook.Title,
|
||||
Summary: inventaireBook.Description,
|
||||
InventaireID: inventaireBook.ID,
|
||||
Author: *author,
|
||||
AddedBy: *user,
|
||||
Title: inventaireBook.Title,
|
||||
SmallDescription: inventaireBook.Description,
|
||||
InventaireID: inventaireBook.ID,
|
||||
Author: *author,
|
||||
AddedBy: *user,
|
||||
}
|
||||
err = ac.Db.Save(&book).Error
|
||||
return &book, err
|
||||
|
||||
@@ -70,6 +70,7 @@ func InventaireBooksToBookSearchGet(inventairebooks []inventaire.InventaireSearc
|
||||
ID: 0,
|
||||
Title: b.Label,
|
||||
Author: "",
|
||||
Description: b.Description,
|
||||
InventaireID: b.ID,
|
||||
Rating: 0,
|
||||
Read: false,
|
||||
|
||||
Reference in New Issue
Block a user