2025-02-21 17:05:37 +00:00
|
|
|
package queryservice
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
|
)
|
|
|
|
|
|
2025-03-11 16:31:06 +00:00
|
|
|
func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId string) error {
|
|
|
|
|
documents, err := s.svc.Document.ListByClientExternalId(ctx.Request().Context(), clientId)
|
2025-02-21 17:05:37 +00:00
|
|
|
if err != nil {
|
2025-03-04 16:44:18 +00:00
|
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err))
|
2025-02-21 17:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
docs := make([]Document, len(documents))
|
|
|
|
|
for i, doc := range documents {
|
|
|
|
|
docs[i] = Document{
|
|
|
|
|
Id: doc.ID,
|
|
|
|
|
Bucket: doc.Bucket,
|
|
|
|
|
Key: doc.Key,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ctx.JSON(http.StatusOK, docs)
|
|
|
|
|
}
|