mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'feat/BE/US-281-uniformity' into 'development'
feat(BE-281): adjustment bug erorr 500 if 404 record projectflock See merge request mbugroup/lti-api!124
This commit is contained in:
+26
@@ -29,6 +29,8 @@ type ProductWarehouseRepository interface {
|
||||
IdExists(ctx context.Context, id uint) (bool, error)
|
||||
CleanupEmpty(ctx context.Context, affected map[uint]struct{}) error
|
||||
EnsureProductWarehouse(ctx context.Context, productID, warehouseID uint, projectFlockKandangID *uint, createdBy uint) (uint, error)
|
||||
GetByProductWarehouseAndProjectFlockKandang(ctx context.Context, productId, warehouseId, projectFlockKandangId uint) (*entity.ProductWarehouse, error)
|
||||
DeleteByProjectFlockKandangIDs(ctx context.Context, projectFlockKandangIDs []uint) error
|
||||
}
|
||||
|
||||
type ProductWarehouseRepositoryImpl struct {
|
||||
@@ -272,6 +274,30 @@ func (r *ProductWarehouseRepositoryImpl) EnsureProductWarehouse(
|
||||
return entity.Id, nil
|
||||
}
|
||||
|
||||
func (r *ProductWarehouseRepositoryImpl) GetByProductWarehouseAndProjectFlockKandang(
|
||||
ctx context.Context,
|
||||
productId uint,
|
||||
warehouseId uint,
|
||||
projectFlockKandangId uint,
|
||||
) (*entity.ProductWarehouse, error) {
|
||||
var productWarehouse entity.ProductWarehouse
|
||||
if err := r.DB().WithContext(ctx).
|
||||
Where("product_id = ? AND warehouse_id = ? AND project_flock_kandang_id = ?", productId, warehouseId, projectFlockKandangId).
|
||||
First(&productWarehouse).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &productWarehouse, nil
|
||||
}
|
||||
|
||||
func (r *ProductWarehouseRepositoryImpl) DeleteByProjectFlockKandangIDs(ctx context.Context, projectFlockKandangIDs []uint) error {
|
||||
if len(projectFlockKandangIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DB().WithContext(ctx).
|
||||
Where("project_flock_kandang_id IN ?", projectFlockKandangIDs).
|
||||
Delete(&entity.ProductWarehouse{}).Error
|
||||
}
|
||||
|
||||
func (r *ProductWarehouseRepositoryImpl) GetDetailByID(ctx context.Context, id uint) (*entity.ProductWarehouse, error) {
|
||||
var productWarehouse entity.ProductWarehouse
|
||||
err := r.DB().WithContext(ctx).
|
||||
|
||||
Reference in New Issue
Block a user