Fixed: When updating a book, no title is needed
the build failed
Details
the build failed
Details
This commit is contained in:
parent
7fba68f812
commit
3d1a710ae0
|
@ -20,8 +20,8 @@ sie in die Datenbank eingetragen und mit dem Buch verknüpft.
|
|||
// AddOrUpdateBook adds a new book or updates an existing one, it takes a book struct with author and publisher. Inserts them if they don't already exist
|
||||
func AddOrUpdateBook(book Book) (newBook Book, err error) {
|
||||
|
||||
// Check if we have at least a booktitle
|
||||
if book.Title == "" {
|
||||
// Check if we have at least a booktitle when we're inserting a new book
|
||||
if book.Title == "" && book.ID == 0{
|
||||
return Book{}, fmt.Errorf("the book should at least have a title")
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,6 @@ func AddOrUpdateBook(book Book) (newBook Book, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Println(publisherid)
|
||||
|
||||
_, exists, err = GetPublisherByID(publisherid)
|
||||
if err != nil {
|
||||
return Book{}, err
|
||||
|
|
|
@ -50,7 +50,7 @@ func BookAddOrUpdate(c echo.Context) error {
|
|||
}
|
||||
|
||||
// Check if we have at least a title
|
||||
if datBook.Title == "" {
|
||||
if datBook.Title == "" && datBook.ID == 0 {
|
||||
return c.JSON(http.StatusBadRequest, models.Message{"You need at least a title to insert a new book!"})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue