104 lines
4.9 KiB
Go
104 lines
4.9 KiB
Go
package tender
|
|
|
|
import "tm/pkg/response"
|
|
|
|
// UpdateTenderRequest represents a request to update an existing tender
|
|
type UpdateTenderRequest struct {
|
|
ID string `json:"id" valid:"required~Tender ID is required"`
|
|
Title *string `json:"title,omitempty" valid:"stringlength(1|500)~Title must be between 1 and 500 characters"`
|
|
Description *string `json:"description,omitempty" valid:"stringlength(0|5000)~Description must not exceed 5000 characters"`
|
|
Status *TenderStatus `json:"status,omitempty"`
|
|
EstimatedValue *float64 `json:"estimated_value,omitempty" valid:"range(0|999999999999)~Estimated value must be between 0 and 999999999999"`
|
|
Currency *string `json:"currency,omitempty" valid:"stringlength(3|3)~Currency must be 3 characters"`
|
|
TenderDeadline *int64 `json:"tender_deadline,omitempty"` // Unix milliseconds
|
|
}
|
|
|
|
// 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"`
|
|
CustomerID *string `query:"customer_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"`
|
|
OnlyActiveDeadlines bool `query:"-" valid:"optional"`
|
|
}
|
|
|
|
// SearchResponse represents the response for listing tenders
|
|
type SearchResponse struct {
|
|
Tenders []TenderResponse `json:"tenders"`
|
|
Metadata *response.Meta `json:"-"`
|
|
}
|
|
|
|
// TenderResponse represents a tender in API responses
|
|
type TenderResponse struct {
|
|
ID string `json:"id"`
|
|
NoticePublicationID string `json:"notice_publication_id"`
|
|
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"`
|
|
PublicationDate int64 `json:"publication_date"`
|
|
TenderDeadline int64 `json:"tender_deadline"`
|
|
SubmissionDeadline int64 `json:"submission_deadline"`
|
|
ApplicationDeadline int64 `json:"application_deadline"`
|
|
SubmissionURL string `json:"submission_url"`
|
|
CountryCode string `json:"country_code"`
|
|
BuyerOrganization *OrganizationResponse `json:"buyer_organization"`
|
|
Status TenderStatus `json:"status"`
|
|
TenderID string `json:"tender_id"`
|
|
}
|
|
|
|
type OrganizationResponse struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// ToTenderResponse converts a Tender entity to TenderResponse
|
|
func (t *Tender) ToResponse() *TenderResponse {
|
|
|
|
org := &OrganizationResponse{}
|
|
if t.BuyerOrganization != nil {
|
|
org.Name = t.BuyerOrganization.Name
|
|
}
|
|
response := &TenderResponse{
|
|
ID: t.ID.Hex(),
|
|
NoticePublicationID: t.NoticePublicationID,
|
|
Title: t.Title,
|
|
Description: t.Description,
|
|
ProcurementTypeCode: t.ProcurementTypeCode,
|
|
ProcedureCode: t.ProcedureCode,
|
|
EstimatedValue: t.EstimatedValue,
|
|
Currency: t.Currency,
|
|
Duration: t.Duration,
|
|
DurationUnit: t.DurationUnit,
|
|
PublicationDate: t.PublicationDate,
|
|
TenderDeadline: t.TenderDeadline,
|
|
SubmissionDeadline: t.SubmissionDeadline,
|
|
ApplicationDeadline: t.ApplicationDeadline,
|
|
CountryCode: t.CountryCode,
|
|
SubmissionURL: t.SubmissionURL,
|
|
BuyerOrganization: org,
|
|
Status: t.Status,
|
|
TenderID: t.TenderID,
|
|
}
|
|
|
|
return response
|
|
}
|