UPDATE: Fix bug
All checks were successful
Build and Release / release (push) Successful in 1m8s

This commit is contained in:
2026-04-27 20:31:01 +07:00
parent eb08c16232
commit 17aafacbfd
36 changed files with 842 additions and 447 deletions

View File

@@ -11,8 +11,8 @@ import (
)
type RoleService interface {
GetRoleByID(ctx context.Context, id string) (*response.RoleResponse, error)
GetAllRole(ctx context.Context) ([]*response.RoleResponse, error)
GetRoleByID(ctx context.Context, id string) (*response.RoleResponse, *fiber.Error)
GetAllRole(ctx context.Context) ([]*response.RoleResponse, *fiber.Error)
}
type roleService struct {
@@ -27,19 +27,19 @@ func NewRoleService(
}
}
func (r *roleService) GetAllRole(ctx context.Context) ([]*response.RoleResponse, error) {
func (r *roleService) GetAllRole(ctx context.Context) ([]*response.RoleResponse, *fiber.Error) {
roles, err := r.roleRepo.All(ctx)
if err != nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, err.Error())
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to fetch roles")
}
return models.RolesEntityToResponse(roles), nil
}
func (r *roleService) GetRoleByID(ctx context.Context, id string) (*response.RoleResponse, error) {
func (r *roleService) GetRoleByID(ctx context.Context, id string) (*response.RoleResponse, *fiber.Error) {
roleId, err := convert.StringToUUID(id)
if err != nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, err.Error())
return nil, fiber.NewError(fiber.StatusBadRequest, "Invalid role ID format")
}
role, err := r.roleRepo.GetByID(ctx, roleId)
if err != nil {