Simplify query code to get start read date

This commit is contained in:
2025-11-21 11:36:41 +01:00
parent 0bfd0dc231
commit 8abf8e2ff7
2 changed files with 1 additions and 19 deletions

View File

@@ -3,7 +3,6 @@ package routes
import (
"net/http"
"strconv"
"time"
"git.artlef.fr/PersonalLibraryManager/internal/appcontext"
"git.artlef.fr/PersonalLibraryManager/internal/model"
@@ -33,22 +32,5 @@ func GetBookHandler(ac appcontext.AppContext) {
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
return
}
err = fixBookGetDateFields(&book)
if err != nil {
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
return
}
ac.C.JSON(http.StatusOK, book)
}
func fixBookGetDateFields(book *query.BookGet) error {
if book.StartReadDate == "" {
return nil
}
startDate, err := time.Parse(time.RFC3339, book.StartReadDate)
if err != nil {
return err
}
book.StartReadDate = startDate.Format(time.DateOnly)
return nil
}