mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
FIX[BE] : use repository instead of raw query on service on productflock service
This commit is contained in:
@@ -121,14 +121,8 @@ func (s *chickinService) CreateOne(c *fiber.Ctx, req *validation.Create) (*entit
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var productWarehouses []entity.ProductWarehouse
|
||||
err = s.ProductWarehouseRepo.DB().
|
||||
WithContext(c.Context()).
|
||||
Joins("JOIN products ON products.id = product_warehouses.product_id").
|
||||
Joins("JOIN product_categories ON product_categories.id = products.product_category_id").
|
||||
Where("product_categories.code = ? AND product_warehouses.warehouse_id = ?", "DOC", warehouse.Id).
|
||||
Order("created_at DESC").
|
||||
Find(&productWarehouses).Error
|
||||
// move complex DB query into repository for cleaner service
|
||||
productWarehouses, err := s.ProductWarehouseRepo.GetByCategoryCodeAndWarehouseID(c.Context(), "DOC", warehouse.Id)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to get product warehouses: %+v", err)
|
||||
return nil, err
|
||||
@@ -289,7 +283,6 @@ func (s chickinService) DeleteOne(c *fiber.Ctx, id uint) error {
|
||||
return rollback(err)
|
||||
}
|
||||
|
||||
// helper: restore quantities from details; returns (restored bool, error)
|
||||
restoreFromDetails := func() (bool, error) {
|
||||
var details []entity.ProjectChickinDetail
|
||||
if err := tx.WithContext(c.Context()).Where("project_chickin_id = ?", chickin.Id).Find(&details).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user