Browse Source

接收Wing推送数据接口优化

master
wanghongjun 2 years ago
parent
commit
b30e88cae0
  1. 15
      application/api/controller/Information.php

15
application/api/controller/Information.php

@ -2,12 +2,13 @@
namespace app\api\controller; namespace app\api\controller;
use app\api\validate\InformationValidate;
use think\Db; use think\Db;
use think\Exception;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\Loader; use think\Loader;
use think\Request; use think\Request;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
class Information extends Base class Information extends Base
{ {
@ -16,6 +17,9 @@ class Information extends Base
* 接收Wing推送数据 * 接收Wing推送数据
* @param Request $request * @param Request $request
* @return false|string * @return false|string
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws DbException
*/ */
public function receivingInformation(Request $request) public function receivingInformation(Request $request)
{ {
@ -35,10 +39,13 @@ class Information extends Base
'protocol' => $param['protocol'], 'protocol' => $param['protocol'],
'product_id' => $param['productId'], 'product_id' => $param['productId'],
'device_id' => $param['deviceId'], 'device_id' => $param['deviceId'],
'timestamp' => $param['timestamp'], 'timestamp' => $param['timestamp']
'create_time' => date("Y-m-d H:i:s"),
]; ];
$query = Db::table('bs_device_receiving_information')->where($insertArr)->field('id')->find();
if ($query) throw new ValidateException('数据已存在,请勿重复发送');
$insertArr['create_time'] = date("Y-m-d H:i:s");
Db::table('bs_device_receiving_information')->insert($insertArr); Db::table('bs_device_receiving_information')->insert($insertArr);
return $this->jsonSuccess(); return $this->jsonSuccess();

Loading…
Cancel
Save