1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\controllers;
- use Yii;
- use app\models\entity\Tmc;
- /** Created by Anton on 17.02.2020. */
- class TmcController extends MainController
- {
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- // $key = Yii::$app->request->headers->get('uuid-key');
- // $this->checkAuth($key);
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- return true;
- }
- public function actionGive()
- {
- $userId = Yii::$app->request->post('userId');
- $tmc = Tmc::findOne(['employee' => $userId]);
- if (!$tmc) {
- $result = ['error' => 'Устройство не найдено'];
- } else {
- $result = ['success' => $tmc->characteristic];
- }
- $buf = pack("Cl", null, $result);
- echo base64_encode($buf);
- }
- }
|