81 lines
2.8 KiB
PHP
81 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class WrenchJobManager extends BaseController
|
|
{
|
|
use ResponseTrait;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->request = $request = \Config\Services::request();
|
|
}
|
|
|
|
public function jobManagerList()
|
|
{
|
|
$raw_json = file_get_contents('php://input');
|
|
$in = json_decode($raw_json, true);
|
|
$in["action"] = WRENCHBOARD_JOB_LISTJOBS;
|
|
$out = [];
|
|
$endpoint = "WRENCHBOARD_JOB_LISTJOBS-" . $in["client_uid"];
|
|
|
|
$out = $this->getCache($endpoint);
|
|
// if (count($out) == 0) { //suspend cache for now
|
|
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
|
$this->saveCache($endpoint, $out, 1500);
|
|
$out['internal_return'] = $ret;
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerList Cache Done:::Ret " . $ret);
|
|
//}
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerList Ret ");
|
|
return $this->respond($this->summaryReturnData($in, $out), 200);
|
|
}
|
|
|
|
public function jobManagerActive()
|
|
{
|
|
$raw_json = file_get_contents('php://input');
|
|
$in = json_decode($raw_json, true);
|
|
|
|
$in["job_mode"] = $in["job_mode"] ?? "ACTIVE";
|
|
$in["action"] = WRENCHBOARD_JOB_ACTIVE;
|
|
|
|
$out = [];
|
|
$endpoint = "WRENCHBOARD_JOB_ACTIVE-" . $in["job_mode"]."-".$in["uuid"];
|
|
|
|
$out = $this->getCache($endpoint);
|
|
if (count($out) == 0) {
|
|
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
|
$this->saveCache($endpoint, $out, 1500);
|
|
$out['internal_return'] = $ret;
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerActive Cache Done:::Ret " . $ret);
|
|
}
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerActive Ret ");
|
|
return $this->respond($this->summaryReturnData($in, $out), 200);
|
|
}
|
|
|
|
public function jobManagerManageOffers()
|
|
{
|
|
$raw_json = file_get_contents('php://input');
|
|
$in = json_decode($raw_json, true);
|
|
|
|
$in["job_mode"] = $in["job_mode"] ?? "OFFERS";
|
|
$in["action"] = WRENCHBOARD_JOB_OFFERS;
|
|
|
|
$out = [];
|
|
$endpoint = "WRENCHBOARD_JOB_OFFERS-OFFERS-".$in["uuid"];
|
|
|
|
$out = $this->getCache($endpoint);
|
|
if (count($out) == 0) {
|
|
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
|
$this->saveCache($endpoint, $out, 1500);
|
|
$out['internal_return'] = $ret;
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerManageOffers Cache Done:::Ret " . $ret);
|
|
}
|
|
log_message('critical', "***** ***** WrenchJobManager::jobManagerManageOffers Ret ");
|
|
return $this->respond($this->summaryReturnData($in, $out), 200);
|
|
}
|
|
|
|
|
|
|
|
} |