Move json struct in a new module
This commit is contained in:
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user