Enhance tender repository and service with AI procedure reference handling
continuous-integration/drone/push Build is passing

- Introduced `ProcedureReference` struct to encapsulate AI procedure coordinates for better data management.
- Added `GetByProcedureReferences` method in the `TenderRepository` to retrieve multiple tenders based on AI procedure references in a single query.
- Updated the `resolveRecommendedTenders` method in the service layer to utilize the new repository method, improving efficiency in fetching recommended tenders.
- Enhanced error handling and logging for the new repository method to ensure robust operation.

This update improves the handling of AI procedure references, streamlining tender retrieval processes and enhancing overall system performance.
This commit is contained in:
Mazyar
2026-06-21 15:43:58 +03:30
parent fa258020f1
commit db14bfe270
3 changed files with 93 additions and 13 deletions
+22
View File
@@ -19,6 +19,13 @@ func FormatAIProcedureRef(contractFolderID, noticePublicationID string) string {
return aiProcedurePrefix + contractFolderID + "/" + noticePublicationID
}
// ProcedureReference identifies a tender using AI procedure coordinates.
type ProcedureReference struct {
Ref string
ContractFolderID string
NoticePublicationID string
}
// ParseAIProcedureRef parses PROC_{contract_folder_id}/{notice_publication_id}.
func ParseAIProcedureRef(ref string) (contractFolderID, noticePublicationID string, ok bool) {
ref = strings.TrimSpace(ref)
@@ -45,6 +52,21 @@ func ParseAIProcedureRef(ref string) (contractFolderID, noticePublicationID stri
return contractFolderID, noticePublicationID, true
}
func tenderMatchesProcedureRef(t Tender, contractFolderID, noticePublicationID string) bool {
if strings.TrimSpace(t.ContractFolderID) != strings.TrimSpace(contractFolderID) {
return false
}
if t.NoticePublicationID == noticePublicationID {
return true
}
for _, related := range t.RelatedNoticePublicationIDs {
if related == noticePublicationID {
return true
}
}
return false
}
// IsMongoObjectIDRef reports whether ref is a 24-char hex MongoDB ObjectId.
func IsMongoObjectIDRef(ref string) bool {
ref = strings.TrimSpace(ref)