hybrid pagination
This commit is contained in:
@@ -321,17 +321,16 @@ func (s *companyService) Delete(ctx context.Context, id string) error {
|
||||
func (s *companyService) SearchCompanies(ctx context.Context, form *SearchForm, pagination *response.Pagination) (*CompanyListResponse, error) {
|
||||
|
||||
// Get companies using search
|
||||
companies, total, err := s.repository.Search(ctx, form, pagination)
|
||||
page, err := s.repository.Search(ctx, form, pagination)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to search companies", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return nil, errors.New("failed to search companies")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert to responses
|
||||
var companyResponses []*CompanyResponse
|
||||
for _, company := range companies {
|
||||
for _, company := range page.Items {
|
||||
// Get category details for response
|
||||
categoryDetails, err := s.categoryService.GetByIDs(ctx, company.Tags.Categories)
|
||||
if err != nil {
|
||||
@@ -354,7 +353,7 @@ func (s *companyService) SearchCompanies(ctx context.Context, form *SearchForm,
|
||||
|
||||
return &CompanyListResponse{
|
||||
Companies: companyResponses,
|
||||
Meta: pagination.Response(total),
|
||||
Meta: pagination.ListMeta(page.TotalCount, page.NextCursor, page.HasMore, page.PageOffset),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user