Update API Documentation and Enhance Tender Query Parameters
- Changed references in API documentation from `main.HealthResponse` to `bootstrap.HealthResponse` for consistency. - Added new query parameters `publication_from` and `publication_to` to the tender listing and recommendation endpoints to allow filtering by publication date. - Updated the `ListTendersRequest` struct to include optional fields for `from` and `to` timestamps. - Modified the `TenderRepository` and `TenderService` interfaces to support the new filtering parameters in the tender listing functionality. - Enhanced the service and handler layers to process the new query parameters, improving the flexibility of tender retrieval.
This commit is contained in:
@@ -19,7 +19,7 @@ type TenderRepository interface {
|
||||
GetByNoticePublicationID(ctx context.Context, noticePublicationID string) (*Tender, error)
|
||||
Update(ctx context.Context, tender *Tender) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
List(ctx context.Context, criteria TenderSearchCriteria, limit, offset int) ([]Tender, int64, error)
|
||||
List(ctx context.Context, criteria TenderSearchCriteria, limit, offset int, from *int64, to *int64) ([]Tender, int64, error)
|
||||
|
||||
// Bulk operations
|
||||
CreateBatch(ctx context.Context, tenders []Tender) error
|
||||
@@ -214,7 +214,7 @@ func (r *tenderRepository) Delete(ctx context.Context, id string) error {
|
||||
}
|
||||
|
||||
// List retrieves tenders with pagination and filtering
|
||||
func (r *tenderRepository) List(ctx context.Context, criteria TenderSearchCriteria, limit, offset int) ([]Tender, int64, error) {
|
||||
func (r *tenderRepository) List(ctx context.Context, criteria TenderSearchCriteria, limit, offset int, from *int64, to *int64) ([]Tender, int64, error) {
|
||||
filter := r.buildSearchFilter(criteria)
|
||||
|
||||
pagination := mongopkg.Pagination{
|
||||
@@ -224,6 +224,14 @@ func (r *tenderRepository) List(ctx context.Context, criteria TenderSearchCriter
|
||||
SortOrder: -1,
|
||||
}
|
||||
|
||||
if from != nil {
|
||||
filter["publication_date"] = bson.M{"$gte": *from}
|
||||
}
|
||||
|
||||
if to != nil {
|
||||
filter["publication_date"] = bson.M{"$lte": *to}
|
||||
}
|
||||
|
||||
result, err := r.ormRepo.FindAll(ctx, filter, pagination)
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to list tenders", map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user