82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\controllers;
|
|
|
|
use Yii;
|
|
use yii\web\Controller;
|
|
use yii\filters\VerbFilter;
|
|
|
|
/**
|
|
* CardController implements the CRUD actions for Card model.
|
|
*/
|
|
class ApiController extends Controller {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function behaviors() {
|
|
return [
|
|
'verbs' => [
|
|
'class' => VerbFilter::className(),
|
|
'actions' => [
|
|
'delete' => ['POST'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function actionSaveLogs() {
|
|
if (Yii::$app->request->post()) {
|
|
$post = Yii::$app->request->bodyParams;
|
|
$model = new \app\models\FaceLogs();
|
|
$model->create($post);
|
|
Yii::$app->response->format = "json";
|
|
return ["stt" => true];
|
|
}
|
|
}
|
|
|
|
public function actionWaitingRecognize() {
|
|
if (Yii::$app->request->post()) {
|
|
$post = Yii::$app->request->bodyParams;
|
|
$model = new \app\models\WaitingReq();
|
|
$model->create($post);
|
|
\app\models\SyncUrl::find()->one();
|
|
Yii::$app->response->format = "json";
|
|
return ["stt" => true];
|
|
}
|
|
}
|
|
|
|
public function actionSyncUrl() {
|
|
if (Yii::$app->request->post()) {
|
|
$post = Yii::$app->request->bodyParams;
|
|
$sync = \app\models\SyncUrl::find()->one();
|
|
if ($sync) {
|
|
$sync->data = $post['url'];
|
|
$sync->save();
|
|
} else {
|
|
$model = new \app\models\SyncUrl();
|
|
$model->create($post);
|
|
}
|
|
Yii::$app->response->format = "json";
|
|
return ["stt" => true];
|
|
}
|
|
}
|
|
|
|
public function actionTest() {
|
|
Yii::info("Hello");
|
|
// echo base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/imgs/test.jpg"));
|
|
// \app\models\WaitingReq::deleteAll();
|
|
// $test1 = \app\models\WaitingReq::find()->all();
|
|
$test = \app\models\ResponseReq::find()->orderBy(['time' => SORT_DESC])->all();
|
|
// echo "<pre>";
|
|
// var_dump($test1, count($test));
|
|
// echo "</pre>";
|
|
foreach ($test as $key => $value) {
|
|
var_dump($value->content);
|
|
echo "<br>";
|
|
}
|
|
return;
|
|
}
|
|
|
|
}
|