mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
5283aed996
- Change logic: automatically create product_warehouse if it does not exist during stock adjustment - Remove unnecessary/unused API endpoints - Ensure adjustment process continues even if product_warehouse was not previously available
50 lines
1.7 KiB
Go
50 lines
1.7 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 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)
|
|
IdExists(ctx context.Context, id 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)
|
|
}
|
|
func (r *WarehouseRepositoryImpl) IdExists(ctx context.Context, id uint) (bool, error) {
|
|
return repository.Exists[entity.Warehouse](ctx, r.db, id)
|
|
}
|