|
|
|
@ -2,12 +2,13 @@ |
|
|
|
|
|
|
|
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; |
|
|
|
use think\db\exception\DataNotFoundException; |
|
|
|
use think\db\exception\ModelNotFoundException; |
|
|
|
use think\exception\DbException; |
|
|
|
|
|
|
|
class Information extends Base |
|
|
|
{ |
|
|
|
@ -16,6 +17,9 @@ class Information extends Base |
|
|
|
* 接收Wing推送数据 |
|
|
|
* @param Request $request |
|
|
|
* @return false|string |
|
|
|
* @throws DataNotFoundException |
|
|
|
* @throws ModelNotFoundException |
|
|
|
* @throws DbException |
|
|
|
*/ |
|
|
|
public function receivingInformation(Request $request) |
|
|
|
{ |
|
|
|
@ -35,10 +39,13 @@ class Information extends Base |
|
|
|
'protocol' => $param['protocol'], |
|
|
|
'product_id' => $param['productId'], |
|
|
|
'device_id' => $param['deviceId'], |
|
|
|
'timestamp' => $param['timestamp'], |
|
|
|
'create_time' => date("Y-m-d H:i:s"), |
|
|
|
'timestamp' => $param['timestamp'] |
|
|
|
]; |
|
|
|
|
|
|
|
$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); |
|
|
|
|
|
|
|
return $this->jsonSuccess(); |
|
|
|
|