Add License
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"furtuna-be/internal/common/errors"
|
||||
"furtuna-be/internal/handlers/request"
|
||||
"furtuna-be/internal/handlers/response"
|
||||
"furtuna-be/internal/middlewares"
|
||||
"furtuna-be/internal/services"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
@@ -16,11 +17,12 @@ type Handler struct {
|
||||
|
||||
func (h *Handler) Route(group *gin.RouterGroup, jwt gin.HandlerFunc) {
|
||||
route := group.Group("/license")
|
||||
isAdmin := middlewares.IsAdminMiddleware()
|
||||
|
||||
route.POST("/", jwt, h.Create)
|
||||
route.GET("/", jwt, h.GetAll)
|
||||
route.PUT("/:id", jwt, h.Update)
|
||||
route.GET("/:id", jwt, h.GetByID)
|
||||
route.POST("/", jwt, isAdmin, h.Create)
|
||||
route.GET("/", jwt, isAdmin, h.GetAll)
|
||||
route.PUT("/:id", jwt, isAdmin, h.Update)
|
||||
route.GET("/:id", jwt, isAdmin, h.GetByID)
|
||||
}
|
||||
|
||||
func NewHandler(service services.License) *Handler {
|
||||
@@ -115,7 +117,9 @@ func (h *Handler) GetAll(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
licenses, total, err := h.service.GetAll(c.Request.Context(), req.Limit, req.Offset)
|
||||
ctx := request.GetMyContext(c)
|
||||
|
||||
licenses, total, err := h.service.GetAll(ctx, req.Limit, req.Offset, req.Status)
|
||||
if err != nil {
|
||||
response.ErrorWrapper(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user