Enhance Tender Management with Company-Based Matching and API Updates
- Updated the tender service to include company-based matching for tenders, allowing for more relevant results based on company CPV codes. - Modified the ListTenders endpoint to accept a company ID parameter for calculating match percentages and sorting tenders accordingly. - Refactored the tender response structure to include match percentage and days until deadline for better client-side handling. - Updated API documentation to reflect changes in the tender listing functionality and added new endpoints for public tender access. - Removed deprecated customer-related methods and streamlined customer listing functionality for improved clarity and performance.
This commit is contained in:
+23
-8
@@ -53,17 +53,18 @@ type UpdateTenderRequest struct {
|
||||
|
||||
// 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"`
|
||||
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
|
||||
}
|
||||
|
||||
// ListTendersResponse represents the response for listing tenders
|
||||
type ListTendersResponse struct {
|
||||
Tenders []Tender `json:"tenders"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Tenders []TenderResponse `json:"tenders"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
|
||||
// SearchTendersRequest represents a request to search tenders
|
||||
@@ -160,6 +161,7 @@ type TenderResponse struct {
|
||||
IsActive bool `json:"is_active"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
HasErrors bool `json:"has_errors"`
|
||||
MatchPercentage *int `json:"match_percentage,omitempty"` // Match percentage for company (0-100)
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
@@ -210,7 +212,12 @@ type ErrorResponse struct {
|
||||
|
||||
// ToTenderResponse converts a Tender entity to TenderResponse
|
||||
func (t *Tender) ToTenderResponse() *TenderResponse {
|
||||
return &TenderResponse{
|
||||
return t.ToTenderResponseWithMatch(nil)
|
||||
}
|
||||
|
||||
// ToTenderResponseWithMatch converts a Tender entity to TenderResponse with optional match percentage
|
||||
func (t *Tender) ToTenderResponseWithMatch(companyCPVCodes []string) *TenderResponse {
|
||||
response := &TenderResponse{
|
||||
ID: t.ID.Hex(),
|
||||
ContractNoticeID: t.ContractNoticeID,
|
||||
NoticePublicationID: t.NoticePublicationID,
|
||||
@@ -257,6 +264,14 @@ func (t *Tender) ToTenderResponse() *TenderResponse {
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
}
|
||||
|
||||
// Calculate match percentage if company CPV codes are provided
|
||||
if companyCPVCodes != nil {
|
||||
matchPercentage := t.CalculateMatchPercentage(companyCPVCodes)
|
||||
response.MatchPercentage = &matchPercentage
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// ToScrapingJobResponse converts a ScrapingJob entity to ScrapingJobResponse
|
||||
|
||||
Reference in New Issue
Block a user