mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
|
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type BankRepository interface {
|
|
repository.BaseRepository[entity.Bank]
|
|
NameExists(ctx context.Context, name string, excludeID *uint) (bool, error)
|
|
AccountNumberExists(ctx context.Context, accountNumber string, excludeID *uint) (bool, error)
|
|
}
|
|
|
|
type BankRepositoryImpl struct {
|
|
*repository.BaseRepositoryImpl[entity.Bank]
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewBankRepository(db *gorm.DB) BankRepository {
|
|
return &BankRepositoryImpl{
|
|
BaseRepositoryImpl: repository.NewBaseRepository[entity.Bank](db),
|
|
db: db,
|
|
}
|
|
}
|
|
|
|
func (r *BankRepositoryImpl) NameExists(ctx context.Context, name string, excludeID *uint) (bool, error) {
|
|
return repository.ExistsByName[entity.Bank](ctx, r.db, name, excludeID)
|
|
}
|
|
|
|
func (r *BankRepositoryImpl) AccountNumberExists(ctx context.Context, accountNumber string, excludeID *uint) (bool, error) {
|
|
return repository.ExistsByField[entity.Bank](ctx, r.db, "account_number", accountNumber, excludeID)
|
|
}
|