mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
90 lines
2.4 KiB
PHP
90 lines
2.4 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\General\Helper;
|
|
use App\Classes\Jobs\ListPackingListsJob;
|
|
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
|
|
|
class ListPackingListsJobLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Job Retrieving PackingLists',
|
|
'message' => 'You have successfully submit a job to retrieve a list of PackingLists'
|
|
];
|
|
}
|
|
|
|
/** @var CreatesJobResult */
|
|
private $createsJobResult;
|
|
|
|
/**
|
|
* ListPackingListsJobLogic constructor.
|
|
* @param CreatesJobResult $createsJobResult
|
|
*/
|
|
public function __construct(CreatesJobResult $createsJobResult)
|
|
{
|
|
$this->createsJobResult = $createsJobResult;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$jobId = uniqid();
|
|
|
|
$user = Auth::user();
|
|
$userInfo = (object) [
|
|
// 'email' => $user->email,
|
|
'type' => $user->type,
|
|
];
|
|
|
|
|
|
$userInfoJson = json_encode($userInfo);
|
|
$requestSignature = md5($userInfoJson . $request->fullUrl());
|
|
|
|
|
|
$listGenericJobObject = new ListGenericJobObject(
|
|
$request->fullUrl(),
|
|
$request->all(),
|
|
$requestSignature,
|
|
null,
|
|
$jobId,
|
|
$userInfo
|
|
);
|
|
|
|
|
|
// $filters = Helper::deserializeFilters($request->input('filters'));
|
|
// if(isset($filters['priority'])){
|
|
// if($filters['priority'] == '1'){
|
|
// ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('hellokitty1'); //cief todo: testing sqs
|
|
// }
|
|
// else{
|
|
// ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('hellokitty2'); //cief todo: testing sqs
|
|
// }
|
|
// }
|
|
ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('high_priority');
|
|
|
|
$result = [];
|
|
$result['job_id'] = $jobId;
|
|
|
|
|
|
$this->createsJobResult->execute($listGenericJobObject);
|
|
|
|
return $this->response(['data' => $result]);
|
|
}
|
|
|
|
}
|