6648cdf1cb
Client External ID * normalizeexternalid * cleanopenapi * cleanopenapi * changingpublic * noprecommit * testing * precommit * processtest * nodb * tests * tests
27 lines
594 B
Go
27 lines
594 B
Go
package queryservice
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId string) error {
|
|
documents, err := s.svc.Document.ListByClientExternalId(ctx.Request().Context(), clientId)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err))
|
|
}
|
|
|
|
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)
|
|
}
|