repository attachment api

This commit is contained in:
efrilm
2025-10-15 21:58:44 +07:00
parent da2246d45a
commit 58128495a6
15 changed files with 606 additions and 64 deletions
+47 -34
View File
@@ -53,6 +53,7 @@ func (a *App) Initialize(cfg *config.Config) error {
onlyOfficeHandler := handler.NewOnlyOfficeHandler(services.onlyOfficeService)
analyticsHandler := handler.NewAnalyticsHandler(services.analyticsService)
notificationHandler := handler.NewNotificationHandler(services.notificationService)
repositoryAttachmentHandler := handler.NewRepositoryAttachmentHandler(services.repositoryAttachmentService)
a.router = router.NewRouter(
cfg,
@@ -70,6 +71,7 @@ func (a *App) Initialize(cfg *config.Config) error {
onlyOfficeHandler,
analyticsHandler,
notificationHandler,
repositoryAttachmentHandler,
)
return nil
@@ -147,6 +149,7 @@ type repositories struct {
approvalFlowRepo *repository.ApprovalFlowRepository
letterOutgoingApprovalRepo *repository.LetterOutgoingApprovalRepository
analyticsRepo *repository.AnalyticsRepository
repositoryAttachmentRepo *repository.RepositoryAttachmentRepositoryImpl
}
func (a *App) initRepositories() *repositories {
@@ -181,6 +184,7 @@ func (a *App) initRepositories() *repositories {
approvalFlowRepo: repository.NewApprovalFlowRepository(a.db),
letterOutgoingApprovalRepo: repository.NewLetterOutgoingApprovalRepository(a.db),
analyticsRepo: repository.NewAnalyticsRepository(a.db),
repositoryAttachmentRepo: repository.NewRepositoryAttachmentRepositoryImpl(a.db),
}
}
@@ -198,13 +202,14 @@ type processors struct {
letterDispositionProcessor *processor.LetterDispositionProcessorImpl
letterDispositionDeptProcessor *processor.LetterDispositionDepartmentProcessorImpl
// Modular processors for letter outgoing
letterValidationProcessor processor.LetterValidationProcessor
letterCreationProcessor processor.LetterCreationProcessor
letterApprovalProcessor processor.LetterApprovalProcessor
letterAttachmentProcessor processor.LetterAttachmentProcessor
letterOutgoingRecipientProcessor processor.LetterOutgoingRecipientProcessor
letterActivityProcessor processor.LetterActivityProcessor
txManager *repository.TxManager
letterValidationProcessor processor.LetterValidationProcessor
letterCreationProcessor processor.LetterCreationProcessor
letterApprovalProcessor processor.LetterApprovalProcessor
letterAttachmentProcessor processor.LetterAttachmentProcessor
letterOutgoingRecipientProcessor processor.LetterOutgoingRecipientProcessor
letterActivityProcessor processor.LetterActivityProcessor
repositoryAttachmentProcessor *processor.RepositoryAttachmentProcessorImpl
txManager *repository.TxManager
}
func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processors {
@@ -249,7 +254,7 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
letterActivityProc := processor.NewLetterActivityProcessor(
repos.letterOutgoingActivityLogRepo,
)
// Create the main letter outgoing processor for backward compatibility
letterOutgoingProc := processor.NewLetterOutgoingProcessor(
a.db,
@@ -286,14 +291,14 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
// Create Novu processor for backward compatibility
novuConfig := internalConfig.LoadNovuConfig(cfg)
novuProc := processor.NewNovuProcessor(novuConfig)
// Create notification processor with Novu provider
novuProvider := processor.NewNovuProvider(novuConfig)
notificationProc := processor.NewNotificationProcessor(novuProvider, novuConfig.IncomingLetterWorkflowID)
// Create user role processor
userRoleProc := processor.NewUserRoleProcessor(a.db)
// Create user processor with Novu integration
userProc := processor.NewUserProcessor(repos.userRepo, repos.userProfileRepo, userRoleProc)
userProc.SetNovuProcessor(novuProc)
@@ -327,6 +332,9 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
repos.letterRepo,
)
repositoryAttachmentProc := processor.NewRepositoryAttachmentProcessor(
repos.repositoryAttachmentRepo)
return &processors{
userProcessor: userProc,
cachedUserProcessor: cachedUserProc,
@@ -347,23 +355,25 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
letterAttachmentProcessor: letterAttachmentProc,
letterOutgoingRecipientProcessor: letterOutgoingRecipientProc,
letterActivityProcessor: letterActivityProc,
repositoryAttachmentProcessor: repositoryAttachmentProc,
txManager: txMgr,
}
}
type services struct {
userService *service.UserServiceImpl
authService *service.AuthServiceImpl
fileService *service.FileServiceImpl
rbacService *service.RBACServiceImpl
masterService *service.MasterServiceImpl
letterService *service.LetterServiceImpl
letterOutgoingService *service.LetterOutgoingServiceImpl
approvalFlowService *service.ApprovalFlowServiceImpl
dispositionRouteService *service.DispositionRouteServiceImpl
onlyOfficeService *service.OnlyOfficeServiceImpl
analyticsService *service.AnalyticsServiceImpl
notificationService *service.NotificationServiceImpl
userService *service.UserServiceImpl
authService *service.AuthServiceImpl
fileService *service.FileServiceImpl
rbacService *service.RBACServiceImpl
masterService *service.MasterServiceImpl
letterService *service.LetterServiceImpl
letterOutgoingService *service.LetterOutgoingServiceImpl
approvalFlowService *service.ApprovalFlowServiceImpl
dispositionRouteService *service.DispositionRouteServiceImpl
onlyOfficeService *service.OnlyOfficeServiceImpl
analyticsService *service.AnalyticsServiceImpl
notificationService *service.NotificationServiceImpl
repositoryAttachmentService *service.RepositoryAttachmentServiceImpl
}
func (a *App) initServices(processors *processors, repos *repositories, cfg *config.Config) *services {
@@ -423,19 +433,22 @@ func (a *App) initServices(processors *processors, repos *repositories, cfg *con
novuConfig := internalConfig.LoadNovuConfig(cfg)
notificationSvc := service.NewNotificationService(novuConfig, processors.userProcessor)
repositoryAttachmentSvc := service.NewRepositoryAttachmentService(processors.repositoryAttachmentProcessor)
return &services{
userService: userSvc,
authService: authService,
fileService: fileSvc,
rbacService: rbacSvc,
masterService: masterSvc,
letterService: letterSvc,
letterOutgoingService: letterOutgoingSvc,
approvalFlowService: approvalFlowSvc,
dispositionRouteService: dispRouteSvc,
onlyOfficeService: onlyOfficeSvc,
analyticsService: analyticsSvc,
notificationService: notificationSvc,
userService: userSvc,
authService: authService,
fileService: fileSvc,
rbacService: rbacSvc,
masterService: masterSvc,
letterService: letterSvc,
letterOutgoingService: letterOutgoingSvc,
approvalFlowService: approvalFlowSvc,
dispositionRouteService: dispRouteSvc,
onlyOfficeService: onlyOfficeSvc,
analyticsService: analyticsSvc,
notificationService: notificationSvc,
repositoryAttachmentService: repositoryAttachmentSvc,
}
}