mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
Feat(BE-36,37,38,39): master area, customer, kandang, location, warehouse
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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 WarehouseRepository interface {
|
||||
repository.BaseRepository[entity.Warehouse]
|
||||
AreaExists(ctx context.Context, areaId uint) (bool, error)
|
||||
LocationExists(ctx context.Context, locationId uint) (bool, error)
|
||||
KandangExists(ctx context.Context, kandangId uint) (bool, error)
|
||||
NameExists(ctx context.Context, name string, excludeID *uint) (bool, error)
|
||||
}
|
||||
|
||||
type WarehouseRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.Warehouse]
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewWarehouseRepository(db *gorm.DB) WarehouseRepository {
|
||||
return &WarehouseRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.Warehouse](db),
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *WarehouseRepositoryImpl) AreaExists(ctx context.Context, areaId uint) (bool, error) {
|
||||
return repository.Exists[entity.Area](ctx, r.db, areaId)
|
||||
}
|
||||
|
||||
func (r *WarehouseRepositoryImpl) LocationExists(ctx context.Context, locationId uint) (bool, error) {
|
||||
return repository.Exists[entity.Location](ctx, r.db, locationId)
|
||||
}
|
||||
|
||||
func (r *WarehouseRepositoryImpl) KandangExists(ctx context.Context, kandangId uint) (bool, error) {
|
||||
return repository.Exists[entity.Kandang](ctx, r.db, kandangId)
|
||||
}
|
||||
|
||||
func (r *WarehouseRepositoryImpl) NameExists(ctx context.Context, name string, excludeID *uint) (bool, error) {
|
||||
return repository.ExistsByName[entity.Warehouse](ctx, r.db, name, excludeID)
|
||||
}
|
||||
Reference in New Issue
Block a user