new licenceController, moved api handling & renaming things

This commit is contained in:
Alex
2024-10-10 20:54:20 +02:00
parent fca5af2c9a
commit d54f2ae2e6
18 changed files with 259 additions and 220 deletions

View File

@@ -0,0 +1,31 @@
package controllers
import (
"GoMembership/internal/services"
"GoMembership/pkg/logger"
"net/http"
"github.com/gin-gonic/gin"
)
type LicenceController struct {
Service services.LicenceService
}
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",
}}})
return
}
logger.Error.Printf("categories: %v", categories)
c.JSON(http.StatusOK, gin.H{
"licence_categories": categories,
})
}