implement archived
This commit is contained in:
parent
ca2acfd850
commit
90da195a2e
@ -54,15 +54,15 @@ type LetterOutgoingService interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LetterOutgoingServiceImpl struct {
|
type LetterOutgoingServiceImpl struct {
|
||||||
processor processor.LetterOutgoingProcessor
|
processor processor.LetterOutgoingProcessor
|
||||||
txManager *repository.TxManager
|
txManager *repository.TxManager
|
||||||
validationProcessor processor.LetterValidationProcessor
|
validationProcessor processor.LetterValidationProcessor
|
||||||
creationProcessor processor.LetterCreationProcessor
|
creationProcessor processor.LetterCreationProcessor
|
||||||
approvalProcessor processor.LetterApprovalProcessor
|
approvalProcessor processor.LetterApprovalProcessor
|
||||||
attachmentProcessor processor.LetterAttachmentProcessor
|
attachmentProcessor processor.LetterAttachmentProcessor
|
||||||
recipientProcessor processor.LetterOutgoingRecipientProcessor
|
recipientProcessor processor.LetterOutgoingRecipientProcessor
|
||||||
notificationProcessor processor.NotificationProcessor
|
notificationProcessor processor.NotificationProcessor
|
||||||
activityProcessor processor.LetterActivityProcessor
|
activityProcessor processor.LetterActivityProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLetterOutgoingService(
|
func NewLetterOutgoingService(
|
||||||
@ -77,15 +77,15 @@ func NewLetterOutgoingService(
|
|||||||
activityProcessor processor.LetterActivityProcessor,
|
activityProcessor processor.LetterActivityProcessor,
|
||||||
) *LetterOutgoingServiceImpl {
|
) *LetterOutgoingServiceImpl {
|
||||||
return &LetterOutgoingServiceImpl{
|
return &LetterOutgoingServiceImpl{
|
||||||
processor: processor,
|
processor: processor,
|
||||||
txManager: txManager,
|
txManager: txManager,
|
||||||
validationProcessor: validationProcessor,
|
validationProcessor: validationProcessor,
|
||||||
creationProcessor: creationProcessor,
|
creationProcessor: creationProcessor,
|
||||||
approvalProcessor: approvalProcessor,
|
approvalProcessor: approvalProcessor,
|
||||||
attachmentProcessor: attachmentProcessor,
|
attachmentProcessor: attachmentProcessor,
|
||||||
recipientProcessor: recipientProcessor,
|
recipientProcessor: recipientProcessor,
|
||||||
notificationProcessor: notificationProcessor,
|
notificationProcessor: notificationProcessor,
|
||||||
activityProcessor: activityProcessor,
|
activityProcessor: activityProcessor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ func (s *LetterOutgoingServiceImpl) CreateOutgoingLetter(ctx context.Context, re
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send notifications if letter needs approval
|
// Send notifications if letter needs approval
|
||||||
log.Printf("[DEBUG] createOutgoingLetter Finsig")
|
log.Printf("[DEBUG] createOutgoingLetter Finsig")
|
||||||
log.Printf("[DEBUG] NotificationProcessor is nil: %v", s.notificationProcessor == nil)
|
log.Printf("[DEBUG] NotificationProcessor is nil: %v", s.notificationProcessor == nil)
|
||||||
if s.notificationProcessor != nil && len(result.Approvals) > 0 {
|
if s.notificationProcessor != nil && len(result.Approvals) > 0 {
|
||||||
@ -180,7 +180,6 @@ func (s *LetterOutgoingServiceImpl) CreateOutgoingLetter(ctx context.Context, re
|
|||||||
go s.sendStepApprovalNotifications(context.Background(), result.ID, result.Subject, 1)
|
go s.sendStepApprovalNotifications(context.Background(), result.ID, result.Subject, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return transformLetterToResponse(result), nil
|
return transformLetterToResponse(result), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +241,11 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.IsArchived = req.IsArchived
|
archived := true
|
||||||
|
filter.IsArchived = &archived
|
||||||
|
if filter.IsArchived != nil {
|
||||||
|
filter.IsArchived = req.IsArchived
|
||||||
|
}
|
||||||
|
|
||||||
// Get raw letters data
|
// Get raw letters data
|
||||||
letters, total, err := s.processor.ListOutgoingLetters(ctx, filter, req.Limit, offset)
|
letters, total, err := s.processor.ListOutgoingLetters(ctx, filter, req.Limit, offset)
|
||||||
@ -479,7 +482,7 @@ func (s *LetterOutgoingServiceImpl) ApproveOutgoingLetter(ctx context.Context, l
|
|||||||
if s.notificationProcessor != nil {
|
if s.notificationProcessor != nil {
|
||||||
// Step approved but not final - notify creator about step completion AND next approvers
|
// Step approved but not final - notify creator about step completion AND next approvers
|
||||||
creatorMessage := fmt.Sprintf("Surat keluar '%s' telah disetujui pada tahap %d, menunggu persetujuan tahap berikutnya", letter.Subject, currentApproval.StepOrder)
|
creatorMessage := fmt.Sprintf("Surat keluar '%s' telah disetujui pada tahap %d, menunggu persetujuan tahap berikutnya", letter.Subject, currentApproval.StepOrder)
|
||||||
go s.sendApprovalNotificationToCreator(context.Background(), letterID, letter.CreatedBy, "Surat Keluar Disetujui Tahap " + fmt.Sprintf("%d", currentApproval.StepOrder), creatorMessage)
|
go s.sendApprovalNotificationToCreator(context.Background(), letterID, letter.CreatedBy, "Surat Keluar Disetujui Tahap "+fmt.Sprintf("%d", currentApproval.StepOrder), creatorMessage)
|
||||||
|
|
||||||
// Notify next step approvers
|
// Notify next step approvers
|
||||||
nextStepOrder := currentApproval.StepOrder + 1
|
nextStepOrder := currentApproval.StepOrder + 1
|
||||||
@ -734,7 +737,6 @@ func (s *LetterOutgoingServiceImpl) CreateDiscussion(ctx context.Context, letter
|
|||||||
go s.sendOutgoingDiscussionMentionNotifications(context.Background(), letterID, userID, req.Mentions, req.Message)
|
go s.sendOutgoingDiscussionMentionNotifications(context.Background(), letterID, userID, req.Mentions, req.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return transformDiscussionToResponse(result), nil
|
return transformDiscussionToResponse(result), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1602,7 +1604,7 @@ func (s *LetterOutgoingServiceImpl) sendStepApprovalNotifications(ctx context.Co
|
|||||||
log.Printf("[DEBUG] Checking approval: Step=%d, Status=%s, ApproverID=%v",
|
log.Printf("[DEBUG] Checking approval: Step=%d, Status=%s, ApproverID=%v",
|
||||||
approval.StepOrder, approval.Status, approval.ApproverID)
|
approval.StepOrder, approval.Status, approval.ApproverID)
|
||||||
|
|
||||||
if approval.StepOrder == stepOrder {
|
if approval.StepOrder == stepOrder {
|
||||||
log.Printf("[DEBUG] Sending notification to approver %s for step %d", approval.ApproverID.String(), stepOrder)
|
log.Printf("[DEBUG] Sending notification to approver %s for step %d", approval.ApproverID.String(), stepOrder)
|
||||||
|
|
||||||
err := s.notificationProcessor.SendOutgoingLetterNotification(
|
err := s.notificationProcessor.SendOutgoingLetterNotification(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user