tariffs/internal/controller/privilege_internal/controller.go

75 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package privilege_internal
import (
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"hub_admin_backend_service/internal/repository/privilege"
"net/http"
)
type Deps struct {
Repo *privilege.Privilege
Logger *zap.Logger
}
type PrivilegeInternal struct {
repo *privilege.Privilege
logger *zap.Logger
}
func NewPrivilegeInternal(deps Deps) *PrivilegeInternal {
return &PrivilegeInternal{
repo: deps.Repo,
logger: deps.Logger,
}
}
// хаб нода getAllPrivileges
func (p *PrivilegeInternal) Get(c *fiber.Ctx) error {
privileges, err := p.repo.GetAllPrivileges(c.Context())
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": err.Error()})
}
return c.Status(fiber.StatusOK).JSON(privileges)
}
// хаб нода registerPrivilege
func (p *PrivilegeInternal) Create(c *fiber.Ctx) error {
return c.SendStatus(http.StatusCreated)
}
// хаб нода replacePrivilege
func (p *PrivilegeInternal) Update(c *fiber.Ctx) error {
return c.SendStatus(http.StatusOK)
}
// хаб нода removePrivilege
func (p *PrivilegeInternal) Delete(c *fiber.Ctx) error {
return c.SendStatus(http.StatusNoContent)
}
// хаб нода getPrivilege
func (p *PrivilegeInternal) GetByID(c *fiber.Ctx) error {
return c.SendStatus(http.StatusOK)
}
// хаб нода getServicePrivileges
func (p *PrivilegeInternal) GetByService(c *fiber.Ctx) error {
return c.SendStatus(http.StatusOK)
}
// хаб нода registerPrivileges
func (p *PrivilegeInternal) PostMany(c *fiber.Ctx) error {
return c.SendStatus(http.StatusCreated)
}
// хаб нода replacePrivileges
func (p *PrivilegeInternal) UpdateMany(c *fiber.Ctx) error {
return c.SendStatus(http.StatusOK)
}
// хаб нода restorePrivilege
func (p *PrivilegeInternal) Restore(c *fiber.Ctx) error {
return c.SendStatus(http.StatusOK)
}