Files
tm_back/internal/tender/form.go
T
n.nakhostin e986ee4135 Refactor Tender Management System by Removing Scraping Functionality and Enhancing Tender API
- Removed all scraping-related functionality, including routes, handlers, services, and repository methods, to streamline the tender management system.
- Updated the tender API to focus solely on tender management, enhancing endpoints for listing, retrieving, and updating tenders.
- Improved Swagger documentation to reflect the removal of scraping endpoints and the addition of new tender-related features.
- Ensured adherence to Clean Architecture principles throughout the refactoring process, maintaining a clear separation of concerns.
2025-08-16 16:52:17 +03:30

82 lines
3.6 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
}
// 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
}
// ListTendersResponse represents the response for listing tenders
type ListTendersResponse struct {
Tenders []TenderResponse `json:"tenders"`
Metadata *response.Meta `json:"metadata"`
}
// SearchTendersResponse represents the response for searching tenders
type SearchTendersResponse struct {
Tenders []Tender `json:"tenders"`
Query string `json:"query"`
Total int `json:"total"`
}
// TenderResponse represents a tender in API responses
type TenderResponse 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"`
CountryCode string `json:"country_code"`
BuyerOrganization *OrganizationResponse `json:"buyer_organization"`
Status TenderStatus `json:"status"`
}
type OrganizationResponse struct {
Name string `json:"name"`
}
// ToTenderResponse converts a Tender entity to TenderResponse
func (t *Tender) ToTenderResponse() *TenderResponse {
response := &TenderResponse{
ID: t.ID.Hex(),
NoticePublicationID: t.NoticePublicationID,
PublicationDate: t.PublicationDate,
Title: t.Title,
Description: t.Description,
ProcurementTypeCode: t.ProcurementTypeCode,
ProcedureCode: t.ProcedureCode,
EstimatedValue: t.EstimatedValue,
Currency: t.Currency,
Duration: t.Duration,
DurationUnit: t.DurationUnit,
TenderDeadline: t.TenderDeadline,
CountryCode: t.CountryCode,
BuyerOrganization: &OrganizationResponse{Name: t.BuyerOrganization.Name},
Status: t.Status,
}
return response
}