update unique letter number
This commit is contained in:
@@ -41,6 +41,25 @@ func (r *LetterOutgoingRepository) Get(ctx context.Context, id uuid.UUID) (*enti
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func (r *LetterOutgoingRepository) GetByReferenceNumber(ctx context.Context, refNumber *string) (*entities.LetterOutgoing, error) {
|
||||
db := DBFromContext(ctx, r.db)
|
||||
var e entities.LetterOutgoing
|
||||
if err := db.WithContext(ctx).
|
||||
Preload("Priority").
|
||||
Preload("ReceiverInstitution").
|
||||
Preload("Creator").
|
||||
Preload("ApprovalFlow").
|
||||
Preload("Recipients").
|
||||
Preload("Attachments").
|
||||
Preload("Approvals.Step").
|
||||
Preload("Approvals.Approver").
|
||||
Where("reference_number = ? AND deleted_at IS NULL", refNumber).
|
||||
First(&e).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func (r *LetterOutgoingRepository) Update(ctx context.Context, e *entities.LetterOutgoing) error {
|
||||
db := DBFromContext(ctx, r.db)
|
||||
return db.WithContext(ctx).Model(&entities.LetterOutgoing{}).Where("id = ? AND deleted_at IS NULL", e.ID).Updates(e).Error
|
||||
|
||||
@@ -29,6 +29,17 @@ func (r *LetterIncomingRepository) Get(ctx context.Context, id uuid.UUID) (*enti
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func (r *LetterIncomingRepository) GetByReferenceNumber(ctx context.Context, refNumber *string) (*entities.LetterIncoming, error) {
|
||||
db := DBFromContext(ctx, r.db)
|
||||
var e entities.LetterIncoming
|
||||
if err := db.WithContext(ctx).
|
||||
Where("reference_number = ? AND deleted_at IS NULL", refNumber).
|
||||
First(&e).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func (r *LetterIncomingRepository) GetByID(ctx context.Context, id uuid.UUID) (*entities.LetterIncoming, error) {
|
||||
return r.Get(ctx, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user