Refactor Tender Management API Endpoints and Update Documentation

- Renamed and restructured tender-related API endpoints for improved clarity and consistency, including changing the route from `/admin/tenders` to `/admin/v1/companies` and updating the associated methods.
- Introduced a new SearchForm structure for listing tenders with advanced filtering capabilities, enhancing the API's search functionality.
- Updated the service and repository layers to align with the new endpoint structure, ensuring proper handling of tender data.
- Enhanced Swagger and YAML documentation to reflect the changes in endpoint structure, including detailed descriptions and examples for the new search functionality.
- Improved error handling and response structures to provide clearer feedback to API consumers, ensuring a more robust and user-friendly experience.
This commit is contained in:
n.nakhostin
2025-09-08 14:20:50 +03:30
parent 3b265e567d
commit 3911180486
11 changed files with 1216 additions and 1382 deletions
+24 -12
View File
@@ -13,20 +13,32 @@ type UpdateTenderRequest struct {
TenderDeadline *int64 `json:"tender_deadline,omitempty"` // Unix milliseconds
}
// ListTendersRequest represents a request to list tenders with pagination and filtering
type ListTendersRequest struct {
Criteria TenderSearchCriteria `json:"criteria"`
Limit int `json:"limit" valid:"range(1|100)~Limit must be between 1 and 100"`
Offset int `json:"offset" valid:"range(0|999999)~Offset must be non-negative"`
CompanyID *string `json:"company_id,omitempty"` // Optional company ID for match percentage calculation
From *int64 `json:"from,omitempty"`
To *int64 `json:"to,omitempty"`
// SearchForm represents a request to list tenders with pagination and filtering
type SearchForm struct {
Search *string `query:"q" valid:"optional"`
NoticeType *string `query:"notice_type" valid:"optional"`
ProcurementType *string `query:"procurement_type" valid:"optional"`
CountryCodes []string `query:"country_codes" valid:"optional"`
RegionCodes []string `query:"region_codes" valid:"optional"`
CompanyID *string `query:"company_id" valid:"optional"`
Status []string `query:"status" valid:"optional"`
Classifications []string `query:"classifications" valid:"optional"`
MinEstimatedValue *float64 `query:"min_estimated_value" valid:"optional"`
MaxEstimatedValue *float64 `query:"max_estimated_value" valid:"optional"`
Currency string `query:"currency" valid:"optional"`
DeadlineFrom *int64 `query:"deadline_from" valid:"optional"`
DeadlineTo *int64 `query:"deadline_to" valid:"optional"`
PublicationDateFrom *int64 `query:"publication_date_from" valid:"optional"`
PublicationDateTo *int64 `query:"publication_date_to" valid:"optional"`
Source []string `query:"source" valid:"optional"`
BuyerOrganizationID *string `query:"buyer_organization_id" valid:"optional"`
Languages []string `query:"languages" valid:"optional"`
}
// ListTendersResponse represents the response for listing tenders
type ListTendersResponse struct {
// SearchResponse represents the response for listing tenders
type SearchResponse struct {
Tenders []TenderResponse `json:"tenders"`
Metadata *response.Meta `json:"metadata"`
Metadata *response.Meta `json:"-"`
}
// TenderResponse represents a tender in API responses
@@ -57,7 +69,7 @@ type OrganizationResponse struct {
}
// ToTenderResponse converts a Tender entity to TenderResponse
func (t *Tender) ToTenderResponse() *TenderResponse {
func (t *Tender) ToResponse() *TenderResponse {
response := &TenderResponse{
ID: t.ID.Hex(),
NoticePublicationID: t.NoticePublicationID,