feat(BE-50): add getOne endpoint for adjustment history

This commit is contained in:
aguhh18
2025-10-13 09:36:38 +07:00
parent cd4c908334
commit ce28429efd
4 changed files with 43 additions and 7 deletions
@@ -50,7 +50,9 @@ func (s *adjustmentService) withRelations(db *gorm.DB) *gorm.DB {
}
func (s *adjustmentService) GetOne(c *fiber.Ctx, id uint) (*entity.StockLog, error) {
stockLog, err := s.StockLogsRepository.GetByID(c.Context(), id, s.withRelations)
stockLog, err := s.StockLogsRepository.GetByID(c.Context(), id, func(db *gorm.DB) *gorm.DB {
return s.withRelations(db).Preload("ProductWarehouse.Product.ProductCategory")
})
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, fiber.NewError(fiber.StatusNotFound, "Adjustment not found")