You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\api\validate\InformationValidate;
|
|
use think\Db;
|
|
use think\Exception;
|
|
use think\exception\ValidateException;
|
|
use think\Loader;
|
|
use think\Request;
|
|
|
|
class Information extends Base
|
|
{
|
|
|
|
/**
|
|
* 接收Wing推送数据
|
|
* @param Request $request
|
|
* @return false|string
|
|
*/
|
|
public function receivingInformation(Request $request)
|
|
{
|
|
|
|
$param = $request->param();
|
|
|
|
try {
|
|
|
|
$InformationValidate = Loader::validate('InformationValidate');
|
|
if(!$InformationValidate->check($param)){
|
|
throw new ValidateException($InformationValidate->getError());
|
|
}
|
|
|
|
$insertArr = [
|
|
'tenant_id' => $param['tenantId'],
|
|
'task_id' => $param['taskId'],
|
|
'protocol' => $param['protocol'],
|
|
'product_id' => $param['productId'],
|
|
'device_id' => $param['deviceId'],
|
|
'timestamp' => $param['timestamp'],
|
|
'create_time' => date("Y-m-d H:i:s"),
|
|
];
|
|
|
|
Db::table('bs_device_receiving_information')->insert($insertArr);
|
|
|
|
return $this->jsonSuccess();
|
|
} catch (ValidateException $exception) {
|
|
return $this->jsonError($exception->getMessage());
|
|
}
|
|
}
|
|
|
|
}
|