feat: Add CronJob functionality and integrate with existing services
- Implemented CronJobProcessor for managing scheduled jobs and processing job queues. - Created CronJobRepository for database interactions related to cron jobs. - Defined CronJobType for job types, statuses, and backoff calculations. - Added ApiloLogger for logging actions related to API interactions. - Enhanced UpdateController to check for updates and display update logs. - Updated FormAction to include a preview action for forms. - Modified ApiRouter to handle new dependencies for OrderAdminService and ProductsApiController. - Extended DictionariesApiController to manage attributes and producers. - Enhanced ProductsApiController with variant management and image upload functionality. - Updated ShopBasketController and ShopProductController to sort attributes and handle custom fields. - Added configuration for cron jobs in config.php. - Initialized apilo-sync-queue.json for managing sync tasks.
This commit is contained in:
@@ -357,4 +357,34 @@ class ProducerRepository
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Znajdź producenta po nazwie lub utwórz nowego (dla API).
|
||||
*
|
||||
* @return array{id: int, created: bool}
|
||||
*/
|
||||
public function ensureProducerForApi(string $name): array
|
||||
{
|
||||
$name = trim($name);
|
||||
if ($name === '') {
|
||||
return ['id' => 0, 'created' => false];
|
||||
}
|
||||
|
||||
$existing = $this->db->get('pp_shop_producer', 'id', ['name' => $name]);
|
||||
if (!empty($existing)) {
|
||||
return ['id' => (int)$existing, 'created' => false];
|
||||
}
|
||||
|
||||
$this->db->insert('pp_shop_producer', [
|
||||
'name' => $name,
|
||||
'status' => 1,
|
||||
'img' => null,
|
||||
]);
|
||||
$id = (int)$this->db->id();
|
||||
if ($id <= 0) {
|
||||
return ['id' => 0, 'created' => false];
|
||||
}
|
||||
|
||||
return ['id' => $id, 'created' => true];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user