Enhance Tender Approval Service with Tender Details Integration
- Updated the tender approval service to include methods for retrieving tender approvals with associated tender details, improving the response structure for API consumers. - Modified the tender approval handler to utilize the new service methods, ensuring that tender details are included in the responses for created, updated, and retrieved tender approvals. - Enhanced the API documentation to reflect the changes in response formats, including the new `TenderApprovalWithTenderResponse` structure. - Ensured adherence to Clean Architecture principles by maintaining a clear separation of concerns in the service and handler layers.
This commit is contained in:
@@ -52,6 +52,42 @@ type TenderApprovalResponse struct {
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
|
||||
// TenderApprovalWithTenderResponse represents the response data for tender approval with tender details
|
||||
type TenderApprovalWithTenderResponse struct {
|
||||
ID string `json:"id"`
|
||||
TenderID string `json:"tender_id"`
|
||||
CompanyID string `json:"company_id"`
|
||||
SubmissionMode string `json:"submission_mode"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
Tender *TenderDetails `json:"tender,omitempty"`
|
||||
}
|
||||
|
||||
// TenderDetails represents essential tender information for the response
|
||||
type (
|
||||
TenderDetails struct {
|
||||
ID string `json:"id"`
|
||||
NoticePublicationID string `json:"notice_publication_id"`
|
||||
PublicationDate int64 `json:"publication_date"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ProcurementTypeCode string `json:"procurement_type_code"`
|
||||
ProcedureCode string `json:"procedure_code"`
|
||||
EstimatedValue float64 `json:"estimated_value"`
|
||||
Currency string `json:"currency"`
|
||||
Duration string `json:"duration"`
|
||||
DurationUnit string `json:"duration_unit"`
|
||||
TenderDeadline int64 `json:"tender_deadline"`
|
||||
SubmissionDeadline int64 `json:"submission_deadline"`
|
||||
CountryCode string `json:"country_code"`
|
||||
BuyerOrganization *OrganizationResponse `json:"buyer_organization"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
OrganizationResponse struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// TenderApprovalSearchCriteria represents search criteria for tender approvals
|
||||
type TenderApprovalSearchCriteria struct {
|
||||
TenderID *string `json:"tender_id,omitempty"`
|
||||
@@ -64,6 +100,16 @@ type TenderApprovalSearchCriteria struct {
|
||||
Offset int `json:"offset,omitempty"`
|
||||
}
|
||||
|
||||
// TenderApprovalListResponseWithTender represents a paginated list of tender approvals with tender details
|
||||
type TenderApprovalListResponseWithTender struct {
|
||||
TenderApprovals []*TenderApprovalWithTenderResponse `json:"tender_approvals"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Page int `json:"page"`
|
||||
Pages int `json:"pages"`
|
||||
}
|
||||
|
||||
// TenderApprovalStatistics represents statistics for tender approvals
|
||||
type TenderApprovalStatistics struct {
|
||||
TotalApprovals int64 `json:"total_approvals"`
|
||||
@@ -123,3 +169,16 @@ func (ta *TenderApproval) ToResponse() *TenderApprovalResponse {
|
||||
CreatedAt: ta.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// ToResponseWithTender converts TenderApproval to TenderApprovalWithTenderResponse
|
||||
func (ta *TenderApproval) ToResponseWithTender(tenderDetails *TenderDetails) *TenderApprovalWithTenderResponse {
|
||||
return &TenderApprovalWithTenderResponse{
|
||||
ID: ta.ID.Hex(),
|
||||
TenderID: ta.TenderID,
|
||||
CompanyID: ta.CompanyID,
|
||||
SubmissionMode: string(ta.SubmissionMode),
|
||||
Status: string(ta.Status),
|
||||
CreatedAt: ta.CreatedAt,
|
||||
Tender: tenderDetails,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user