mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
Feat(BE-36,37,38,39): master area, customer, kandang, location, warehouse
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user