mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat(BE-278): unrestrict feat warehouse purchase,adding purchase upload document
This commit is contained in:
+25
@@ -199,6 +199,31 @@ func (r *ProductWarehouseRepositoryImpl) CleanupEmpty(ctx context.Context, affec
|
||||
return nil
|
||||
}
|
||||
|
||||
var inUseIDs []uint
|
||||
if err := r.DB().WithContext(ctx).
|
||||
Model(&entity.PurchaseItem{}).
|
||||
Where("product_warehouse_id IN ?", emptyIDs).
|
||||
Distinct().
|
||||
Pluck("product_warehouse_id", &inUseIDs).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if len(inUseIDs) > 0 {
|
||||
inUse := make(map[uint]struct{}, len(inUseIDs))
|
||||
for _, id := range inUseIDs {
|
||||
inUse[id] = struct{}{}
|
||||
}
|
||||
filtered := make([]uint, 0, len(emptyIDs))
|
||||
for _, id := range emptyIDs {
|
||||
if _, exists := inUse[id]; !exists {
|
||||
filtered = append(filtered, id)
|
||||
}
|
||||
}
|
||||
emptyIDs = filtered
|
||||
}
|
||||
if len(emptyIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := r.DB().WithContext(ctx).
|
||||
Model(&entity.PurchaseItem{}).
|
||||
Where("product_warehouse_id IN ?", emptyIDs).
|
||||
|
||||
Reference in New Issue
Block a user