mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-22 06:15:44 +00:00
36 lines
1.0 KiB
Go
36 lines
1.0 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 LocationRepository interface {
|
|
repository.BaseRepository[entity.Location]
|
|
AreaExists(ctx context.Context, areaId uint) (bool, error)
|
|
NameExists(ctx context.Context, name string, excludeID *uint) (bool, error)
|
|
}
|
|
|
|
type LocationRepositoryImpl struct {
|
|
*repository.BaseRepositoryImpl[entity.Location]
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewLocationRepository(db *gorm.DB) LocationRepository {
|
|
return &LocationRepositoryImpl{
|
|
BaseRepositoryImpl: repository.NewBaseRepository[entity.Location](db),
|
|
db: db,
|
|
}
|
|
}
|
|
|
|
func (r *LocationRepositoryImpl) AreaExists(ctx context.Context, areaId uint) (bool, error) {
|
|
return repository.Exists[entity.Area](ctx, r.db, areaId)
|
|
}
|
|
|
|
func (r *LocationRepositoryImpl) NameExists(ctx context.Context, name string, excludeID *uint) (bool, error) {
|
|
return repository.ExistsByName[entity.Location](ctx, r.db, name, excludeID)
|
|
}
|