bulk delete incoming letter

This commit is contained in:
efrilm
2025-10-30 11:36:49 +07:00
parent 7f67f6db4f
commit 9e4481a0bd
6 changed files with 67 additions and 0 deletions
+26
View File
@@ -352,6 +352,32 @@ func (p *LetterProcessorImpl) SoftDeleteIncomingLetter(ctx context.Context, id u
})
}
func (p *LetterProcessorImpl) BulkSoftDeleteIncomingLetters(ctx context.Context, ids []uuid.UUID) error {
if len(ids) == 0 {
return nil
}
return p.txManager.WithTransaction(ctx, func(txCtx context.Context) error {
if err := p.letterRepo.BulkSoftDelete(txCtx, ids); err != nil {
return err
}
if p.activity != nil {
userID := appcontext.FromGinContext(txCtx).UserID
action := "letter.bulk_deleted"
// Log activity untuk setiap letter yang dihapus
for _, id := range ids {
if err := p.activity.Log(txCtx, id, action, &userID, nil, nil, nil, nil, nil, map[string]interface{}{}); err != nil {
return err
}
}
}
return nil
})
}
// CreateDispositions creates a new disposition with modular helper functions
func (p *LetterProcessorImpl) CreateDispositions(ctx context.Context, req *contract.CreateLetterDispositionRequest) (*contract.ListDispositionsResponse, error) {
// Transaction should be handled at service layer