From b30e88cae0da9a5d44584735ef331ecf78e23dd6 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Wed, 29 Nov 2023 14:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E6=94=B6Wing=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Information.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/application/api/controller/Information.php b/application/api/controller/Information.php index 4e6f09d..3d30819 100644 --- a/application/api/controller/Information.php +++ b/application/api/controller/Information.php @@ -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();