Move json struct in a new module

This commit is contained in:
2026-01-23 18:26:47 +01:00
parent e1fd12e233
commit 4ac0f4243d
10 changed files with 80 additions and 86 deletions

View File

@@ -5,16 +5,12 @@ import (
"strconv"
"git.artlef.fr/PersonalLibraryManager/internal/appcontext"
"git.artlef.fr/PersonalLibraryManager/internal/dto"
"git.artlef.fr/PersonalLibraryManager/internal/model"
"git.artlef.fr/PersonalLibraryManager/internal/myvalidator"
"github.com/gin-gonic/gin"
)
type AuthorGet struct {
Name string `json:"name" binding:"required,max=100"`
Description string `json:"description"`
}
func GetAuthorHandler(ac appcontext.AppContext) {
authorId, err := strconv.ParseUint(ac.C.Param("id"), 10, 64)
if err != nil {
@@ -32,7 +28,7 @@ func GetAuthorHandler(ac appcontext.AppContext) {
myvalidator.ReturnErrorsAsJsonResponse(&ac, res.Error)
return
}
ac.C.JSON(http.StatusOK, AuthorGet{
ac.C.JSON(http.StatusOK, dto.AuthorGet{
Name: author.Name,
Description: author.Description})
}