32 lines
686 B
Go
32 lines
686 B
Go
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,
|
|
})
|
|
}
|