добавил архив фото, откуда можно удалить и посмотреть

This commit is contained in:
2026-01-19 05:17:15 +03:00
parent bc036197cf
commit 323fc67cd5
12 changed files with 648 additions and 26 deletions

View File

@@ -16,6 +16,7 @@ import (
"rmser/internal/domain/drafts"
"rmser/internal/domain/invoices"
"rmser/internal/domain/ocr"
"rmser/internal/domain/photos"
"rmser/internal/domain/suppliers"
"rmser/internal/infrastructure/rms"
"rmser/internal/services/billing"
@@ -29,6 +30,7 @@ type Service struct {
accountRepo account.Repository
supplierRepo suppliers.Repository
invoiceRepo invoices.Repository
photoRepo photos.Repository
rmsFactory *rms.Factory
billingService *billing.Service
}
@@ -39,6 +41,7 @@ func NewService(
catalogRepo catalog.Repository,
accountRepo account.Repository,
supplierRepo suppliers.Repository,
photoRepo photos.Repository,
invoiceRepo invoices.Repository,
rmsFactory *rms.Factory,
billingService *billing.Service,
@@ -49,6 +52,7 @@ func NewService(
catalogRepo: catalogRepo,
accountRepo: accountRepo,
supplierRepo: supplierRepo,
photoRepo: photoRepo,
invoiceRepo: invoiceRepo,
rmsFactory: rmsFactory,
billingService: billingService,
@@ -126,16 +130,25 @@ func (s *Service) DeleteDraft(id uuid.UUID) (string, error) {
return "", err
}
// Логика статусов
if draft.Status == drafts.StatusCanceled {
draft.Status = drafts.StatusDeleted
s.draftRepo.Update(draft)
// Окончательное удаление
if err := s.draftRepo.Delete(id); err != nil {
return "", err
}
// ВАЖНО: Разрываем связь с фото (оно становится ORPHAN)
if err := s.photoRepo.ClearDraftLinkByDraftID(id); err != nil {
logger.Log.Error("failed to clear photo draft link", zap.Error(err))
}
return drafts.StatusDeleted, nil
}
if draft.Status != drafts.StatusCompleted {
draft.Status = drafts.StatusCanceled
s.draftRepo.Update(draft)
return drafts.StatusCanceled, nil
}
return draft.Status, nil
}