mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
Feat[BE-261,265]: createing BOP and BOP realization(Unfinished)
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
type ExpenseRepository interface {
|
||||
repository.BaseRepository[entity.Expense]
|
||||
IdExists(ctx context.Context, id uint64) (bool, error)
|
||||
GetNextSequence(ctx context.Context) (int, error)
|
||||
GetWithSupplier(ctx context.Context, id uint64) (*entity.Expense, error)
|
||||
}
|
||||
|
||||
type ExpenseRepositoryImpl struct {
|
||||
@@ -26,3 +28,24 @@ func NewExpenseRepository(db *gorm.DB) ExpenseRepository {
|
||||
func (r *ExpenseRepositoryImpl) IdExists(ctx context.Context, id uint64) (bool, error) {
|
||||
return repository.Exists[entity.Expense](ctx, r.DB(), uint(id))
|
||||
}
|
||||
|
||||
func (r *ExpenseRepositoryImpl) GetNextSequence(ctx context.Context) (int, error) {
|
||||
var sequence int
|
||||
err := r.DB().Raw("SELECT nextval('expenses_ref_seq')").Scan(&sequence).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return sequence, nil
|
||||
}
|
||||
|
||||
func (r *ExpenseRepositoryImpl) GetWithSupplier(ctx context.Context, id uint64) (*entity.Expense, error) {
|
||||
var expense entity.Expense
|
||||
err := r.DB().WithContext(ctx).
|
||||
Where("id = ?", id).
|
||||
Preload("Supplier").
|
||||
First(&expense).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &expense, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user