bulk delete outgoing letter
This commit is contained in:
@@ -24,6 +24,7 @@ type LetterOutgoingService interface {
|
||||
SearchOutgoingLetters(ctx context.Context, req *contract.SearchOutgoingLettersRequest) (*contract.SearchOutgoingLettersResponse, error)
|
||||
UpdateOutgoingLetter(ctx context.Context, id uuid.UUID, req *contract.UpdateOutgoingLetterRequest) (*contract.OutgoingLetterResponse, error)
|
||||
DeleteOutgoingLetter(ctx context.Context, id uuid.UUID) error
|
||||
BulkDeleteOutgoingLetters(ctx context.Context, ids []uuid.UUID) error
|
||||
|
||||
SubmitForApproval(ctx context.Context, letterID uuid.UUID) error
|
||||
ApproveOutgoingLetter(ctx context.Context, letterID uuid.UUID, req *contract.ApproveLetterRequest) error
|
||||
@@ -591,18 +592,40 @@ func (s *LetterOutgoingServiceImpl) UpdateOutgoingLetter(ctx context.Context, id
|
||||
func (s *LetterOutgoingServiceImpl) DeleteOutgoingLetter(ctx context.Context, id uuid.UUID) error {
|
||||
userID := getUserIDFromContext(ctx)
|
||||
|
||||
letter, err := s.processor.GetOutgoingLetterByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//letter, err := s.processor.GetOutgoingLetterByID(ctx, id)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
if letter.Status != entities.LetterOutgoingStatusDraft {
|
||||
return gorm.ErrInvalidData
|
||||
}
|
||||
//if letter.Status != entities.LetterOutgoingStatusDraft {
|
||||
// return gorm.ErrInvalidData
|
||||
//}
|
||||
|
||||
return s.processor.DeleteOutgoingLetter(ctx, id, userID)
|
||||
}
|
||||
|
||||
func (s *LetterOutgoingServiceImpl) BulkDeleteOutgoingLetters(ctx context.Context, ids []uuid.UUID) error {
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
userID := getUserIDFromContext(ctx)
|
||||
|
||||
// Validasi semua letters sebelum delete
|
||||
//for _, id := range ids {
|
||||
// letter, err := s.processor.GetOutgoingLetterByID(ctx, id)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// if letter.Status != entities.LetterOutgoingStatusDraft {
|
||||
// return gorm.ErrInvalidData
|
||||
// }
|
||||
//}
|
||||
|
||||
return s.processor.BulkDeleteOutgoingLetters(ctx, ids, userID)
|
||||
}
|
||||
|
||||
func (s *LetterOutgoingServiceImpl) SubmitForApproval(ctx context.Context, letterID uuid.UUID) error {
|
||||
userID := getUserIDFromContext(ctx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user