moved to struct validation;

This commit is contained in:
Alex
2024-11-04 17:21:55 +01:00
parent 0fa57bfe75
commit fa10a0a507
15 changed files with 246 additions and 275 deletions

View File

@@ -2,7 +2,7 @@ package controllers
import (
"GoMembership/internal/services"
"GoMembership/pkg/logger"
"GoMembership/internal/utils"
"net/http"
"github.com/gin-gonic/gin"
@@ -17,14 +17,9 @@ func (lc *LicenceController) GetAllCategories(c *gin.Context) {
categories, err := lc.Service.GetAllCategories()
if err != nil {
logger.Error.Printf("Error retrieving licence categories: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"errors": []gin.H{{
"field": "general",
"key": "validation.internal_server_error",
}}})
utils.RespondWithError(c, err, "Error retrieving licence categories", http.StatusInternalServerError, "general", "server.error.internal_server_error")
return
}
logger.Error.Printf("categories: %v", categories)
c.JSON(http.StatusOK, gin.H{
"licence_categories": categories,
})