package staffhttp import ( authmiddleware "legalgo-BE-go/internal/api/http/middleware/auth" staffsvc "legalgo-BE-go/internal/services/staff" "legalgo-BE-go/internal/utilities/response" "legalgo-BE-go/internal/utilities/utils" "net/http" "github.com/go-chi/chi/v5" ) func GetStaffs( router chi.Router, staffSvc staffsvc.Auth, ) { router.With(authmiddleware.Authorize()).Get("/staff/get-all", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() staffDetail, err := utils.GetTokenDetail(r) if err != nil { response.RespondJsonErrorWithCode( ctx, w, err, response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, "failed to get staff token", ) return } if staffDetail.Role != "staff" { response.RespondJsonErrorWithCode( ctx, w, err, response.ErrUnauthorized.Code, response.ErrUnauthorized.HttpCode, "unauthorized", ) return } staffs, err := staffSvc.GetStaffs() if err != nil { response.RespondJsonErrorWithCode( ctx, w, err, response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, err.Error(), ) return } response.RespondJsonSuccess(ctx, w, staffs) }) }