Files
tm_back/internal/tender_approval/form.go
T
n.nakhostin 392b31626d Refactor Tender Approval Management and Update API Documentation
- Replaced the existing tender approval update and delete endpoints with a new toggle functionality, allowing for more streamlined management of tender approvals.
- Introduced the `ToggleTenderApproval` method in the service layer to handle both approval and rejection actions based on the current state of the tender approval.
- Updated the API documentation to reflect the new endpoint structure and response formats, including the `TenderApprovalWithTenderResponse`.
- Enhanced Swagger documentation to ensure accurate representation of the updated tender approval operations.
- Removed obsolete methods and routes to maintain a clean and efficient codebase, adhering to Clean Architecture principles.
2025-08-19 11:01:49 +03:30

78 lines
3.8 KiB
Go

package tender_approval
// CreateTenderApprovalForm represents the form for creating a new tender approval
type CreateTenderApprovalForm struct {
TenderID string `json:"tender_id" valid:"required"`
SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"`
Status ApprovalStatus `json:"status,omitempty" valid:"optional,in(approved|rejected)"`
}
// UpdateTenderApprovalForm represents the form for updating a tender approval
type UpdateTenderApprovalForm struct {
SubmissionMode *string `json:"submission_mode,omitempty" valid:"optional,in(self-apply|partnership)"`
Status *string `json:"status,omitempty" valid:"optional,in(approved|rejected)"`
}
// ListTenderApprovalsForm represents the form for listing tender approvals with filters
type ListTenderApprovalsForm struct {
TenderID *string `query:"tender_id" valid:"optional"`
CompanyID *string `query:"company_id" valid:"optional"`
Status []string `query:"status" valid:"optional"`
SubmissionMode []string `query:"submission_mode" valid:"optional"`
CreatedAtFrom *int64 `query:"created_at_from" valid:"optional"`
CreatedAtTo *int64 `query:"created_at_to" valid:"optional"`
Limit *int `query:"limit" valid:"optional,range(1|100)"`
Offset *int `query:"offset" valid:"optional,min(0)"`
SortBy *string `query:"sort_by" valid:"optional,in(created_at|updated_at|status|submission_mode)"`
SortOrder *string `query:"sort_order" valid:"optional,in(asc|desc)"`
}
// ApproveTenderForm represents the form for approving a tender
type ApproveTenderForm struct {
Notes *string `json:"notes,omitempty" valid:"optional,length(0|1000)"`
}
// RejectTenderForm represents the form for rejecting a tender
type RejectTenderForm struct {
Reason string `json:"reason" valid:"required,length(10|500)"`
}
// TenderApprovalListResponse represents the response for listing tender approvals
type TenderApprovalListResponse struct {
TenderApprovals []*TenderApprovalResponse `json:"tender_approvals"`
Total int64 `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
TotalPages int `json:"total_pages"`
}
// TenderApproval search and matching DTOs
type TenderApprovalSearchForm struct {
Query *string `query:"q" valid:"optional"`
TenderID *string `query:"tender_id" valid:"optional"`
CompanyID *string `query:"company_id" valid:"optional"`
Status []string `query:"status" valid:"optional"`
SubmissionMode []string `query:"submission_mode" valid:"optional"`
CreatedAtFrom *int64 `query:"created_at_from" valid:"optional"`
CreatedAtTo *int64 `query:"created_at_to" valid:"optional"`
Limit *int `query:"limit" valid:"optional,range(1|100)"`
Offset *int `query:"offset" valid:"optional,min(0)"`
}
// TenderApproval statistics DTOs
type TenderApprovalStatsResponse struct {
TotalApprovals int64 `json:"total_approvals"`
ApprovedTenders int64 `json:"approved_tenders"`
RejectedTenders int64 `json:"rejected_tenders"`
ApprovalsByStatus map[string]int64 `json:"approvals_by_status"`
ApprovalsBySubmission map[string]int64 `json:"approvals_by_submission"`
LastUpdated int64 `json:"last_updated"`
}
// ToggleTenderApprovalForm represents the form for toggling a tender approval
type ToggleTenderApprovalForm struct {
TenderID string `json:"tender_id" valid:"required"`
Status ApprovalStatus `json:"status" valid:"required,in(approved|rejected)"`
SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"`
}