77 lines
2.1 KiB
PHP
77 lines
2.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\controllers;
|
|
|
|
use app\models\RegisterObjectFiles;
|
|
use app\services\api\NomenclatureService;
|
|
use app\services\api\Sync;
|
|
use app\services\api\SyncCategory;
|
|
use app\services\JWT;
|
|
use yii\web\Controller;
|
|
|
|
class ApiController extends Controller
|
|
{
|
|
public function actionEndpoints()
|
|
{
|
|
return $this->renderPartial('endpoints');
|
|
}
|
|
|
|
public function actionCategories()
|
|
{
|
|
header('Access-Control-Allow-Origin: *');
|
|
return $this->asJson(NomenclatureService::categorySelect());
|
|
}
|
|
|
|
public function actionCategoriesTree()
|
|
{
|
|
return $this->asJson(NomenclatureService::categoryTree());
|
|
}
|
|
|
|
public function actionObjectTemplates()
|
|
{
|
|
return $this->asJson(NomenclatureService::objectTemplates($_GET['sc_id'] ?? null));
|
|
}
|
|
|
|
public function actionFilePreviewDelivery($id)
|
|
{
|
|
if ($id) {
|
|
$decode = JWT::decode($id, JWT::SECRET_KEY);
|
|
/** @var RegisterObjectFiles $objectFile */
|
|
$objectFile = RegisterObjectFiles::findOne($decode->id);
|
|
if ($objectFile) {
|
|
if ($objectFile->file_content_type == 1 && $objectFile->extension == 'pdf') {
|
|
|
|
|
|
return $this->renderPartial('pdf-preview', ['objectFile' => $objectFile]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function actionStreamFile($id)
|
|
{
|
|
$decode = JWT::decode($id, JWT::SECRET_KEY);
|
|
/** @var RegisterObjectFiles $objectFile */
|
|
$objectFile = RegisterObjectFiles::findOne($decode->id);
|
|
return $this->renderPartial('stream-file-content', ['objectFile' => $objectFile]);
|
|
}
|
|
|
|
public function actionRenderModel($id)
|
|
{
|
|
|
|
$decode = JWT::decode($id, JWT::SECRET_KEY);
|
|
|
|
/** @var RegisterObjectFiles $objectFile */
|
|
$objectFile = RegisterObjectFiles::findOne($decode->id);
|
|
|
|
//echo '<h1 style="color: #FFFFFF">'.$objectFile->id.'</h1>';
|
|
//exit;
|
|
if ($objectFile) {
|
|
if ($objectFile->file_content_type == 4 && $objectFile->extension == 'glb') {
|
|
return $this->renderPartial('render-3d-model', ['id' => $id]);
|
|
}
|
|
}
|
|
}
|
|
}
|