81914e2eeb
- Introduced a new API endpoint to retrieve company-specific tender approval statistics, enhancing the analytics capabilities of the tender management system. - Implemented the `GetCompanyTenderApprovalStats` method in the service layer to fetch detailed statistics, including total approvals, approved and rejected tenders, and submission counts. - Updated Swagger documentation to accurately reflect the new endpoint, including detailed descriptions, parameters, and response formats for the `CompanyTenderApprovalStatsResponse`. - Enhanced the router to include the new statistics route, ensuring adherence to Clean Architecture principles and maintaining a clear separation of concerns in the handler layer. - Added necessary request and response forms to support the new functionality, improving the overall API structure and usability.
111 lines
5.7 KiB
Go
111 lines
5.7 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"`
|
|
}
|
|
|
|
// CompanyTenderApprovalStatsResponse represents company-specific tender approval statistics
|
|
type CompanyTenderApprovalStatsResponse struct {
|
|
CompanyID string `json:"company_id"`
|
|
TotalApprovals int64 `json:"total_approvals"`
|
|
ApprovedTenders int64 `json:"approved_tenders"`
|
|
RejectedTenders int64 `json:"rejected_tenders"`
|
|
SelfApplyCount int64 `json:"self_apply_count"`
|
|
PartnershipCount int64 `json:"partnership_count"`
|
|
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)"`
|
|
}
|
|
|
|
// CompanyTenderApprovalStatsRequest represents a request for company tender approval statistics
|
|
type CompanyTenderApprovalStatsRequest struct {
|
|
CompanyIDs []string `query:"company_ids" valid:"optional"`
|
|
CompanyID *string `query:"company_id" valid:"optional"`
|
|
}
|
|
|
|
// AggregatedCompanyStatsResponse represents aggregated statistics across all companies
|
|
type AggregatedCompanyStatsResponse struct {
|
|
TotalCompanies int64 `json:"total_companies"`
|
|
TotalApprovals int64 `json:"total_approvals"`
|
|
TotalApprovedTenders int64 `json:"total_approved_tenders"`
|
|
TotalRejectedTenders int64 `json:"total_rejected_tenders"`
|
|
TotalSelfApplyCount int64 `json:"total_self_apply_count"`
|
|
TotalPartnershipCount int64 `json:"total_partnership_count"`
|
|
ApprovalsByStatus map[string]int64 `json:"approvals_by_status"`
|
|
ApprovalsBySubmission map[string]int64 `json:"approvals_by_submission"`
|
|
CompanyStats []*CompanyTenderApprovalStatsResponse `json:"company_stats"`
|
|
LastUpdated int64 `json:"last_updated"`
|
|
}
|