mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
[FIX/BE-US] adjustment sso-location
This commit is contained in:
@@ -48,16 +48,13 @@ func (s warehouseService) GetAll(c *fiber.Ctx, params *validation.Query) ([]enti
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
scope, err := m.ResolveAreaScope(c, s.Repository.DB())
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
var scopeErr error
|
||||
|
||||
offset := (params.Page - 1) * params.Limit
|
||||
|
||||
warehouses, total, err := s.Repository.GetAll(c.Context(), offset, params.Limit, func(db *gorm.DB) *gorm.DB {
|
||||
db = s.withRelations(db)
|
||||
db = m.ApplyScopeFilter(db, scope, "area_id")
|
||||
db, scopeErr = m.ApplyAreaScope(c, db, "warehouses.area_id")
|
||||
if params.Search != "" {
|
||||
db = db.Where("warehouses.name ILIKE ?", "%"+params.Search+"%")
|
||||
}
|
||||
@@ -84,6 +81,9 @@ func (s warehouseService) GetAll(c *fiber.Ctx, params *validation.Query) ([]enti
|
||||
return db.Order("created_at DESC").Order("updated_at DESC")
|
||||
})
|
||||
|
||||
if scopeErr != nil {
|
||||
return nil, 0, scopeErr
|
||||
}
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to get warehouses: %+v", err)
|
||||
return nil, 0, err
|
||||
@@ -92,16 +92,16 @@ func (s warehouseService) GetAll(c *fiber.Ctx, params *validation.Query) ([]enti
|
||||
}
|
||||
|
||||
func (s warehouseService) GetOne(c *fiber.Ctx, id uint) (*entity.Warehouse, error) {
|
||||
scope, err := m.ResolveAreaScope(c, s.Repository.DB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var scopeErr error
|
||||
|
||||
warehouse, err := s.Repository.GetByID(c.Context(), id, func(db *gorm.DB) *gorm.DB {
|
||||
db = s.withRelations(db)
|
||||
db = m.ApplyScopeFilter(db, scope, "area_id")
|
||||
db, scopeErr = m.ApplyAreaScope(c, db, "warehouses.area_id")
|
||||
return db
|
||||
})
|
||||
if scopeErr != nil {
|
||||
return nil, scopeErr
|
||||
}
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, fiber.NewError(fiber.StatusNotFound, "Warehouse not found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user