diff --git a/application/api/controller/Product.php b/application/api/controller/Product.php new file mode 100644 index 0000000..27c873d --- /dev/null +++ b/application/api/controller/Product.php @@ -0,0 +1,106 @@ +where('productId',$productId)->find(); + + $data = [ + 'productId' => $productId, // 产品ID + 'productName' => $item['productName'], // 产品名称 + 'tenantId' => $item['tenantId'], // 租户ID + 'productDesc' => $item['productDesc'], // 产品描述 +// 'productType' => $item['productType'], // Integer,产品类别 +// 'secondaryType' => $item['secondaryType'], // Integer 二级分类名称 +// 'thirdType' => $item['thirdType'], // Integer,三级分类 + 'productProtocol' => $item['productProtocol'], // Integer,产品协议:1.T-LINK协议 2.MQTT协议 3.LWM2M协议 4.TUP协议 5.HTTP协议 6.JT/T808 7.TCP协议 8.私有TCP(网关子设备协议) 9.私有UDP(网关子设备协议) 10.网关产品MQTT(网关产品协议) 11.南向云 +// 'authType' => $item['authType'], // Integer,认证方式 1:特征串认证,2:sm9认证,3:dtls双向认证,4:IMEI认证,5:SIMID认证,6:sm2认证 +// 'payloadFormat' => $item['payloadFormat'], // Integer,消息类型 1:json,2:紧凑二进制 + 'createTime' => $item['createTime'], // 创建时间 + 'updateTime' => $item['updateTime'], // 更新时间 + 'networkType' => $item['networkType'], // Integer,网络类型:1.wifi2.移动蜂窝数据3.NB-IoT4.以太网 +// 'endpointFormat' => $item['endpointFormat'], // Integer,Endpoint格式:1.IMEI 2.URN:IMEI:############### 3.URN:IMEI-IMSI: ###############-############### +// 'powerModel' => $item['powerModel'], // Integer,省电模式:1.PSM 2.DRX 3.eDRX + 'apiKey' => $item['apiKey'], // MasterKey + 'deviceCount' => $item['deviceCount'], // Integer,设备总数 + 'productTypeValue' => $item['productTypeValue'], // 产品分类名称 + 'secondaryTypeValue' => $item['secondaryTypeValue'], // 二级分类名称 + 'thirdTypeValue' => $item['thirdTypeValue'], // 三级分类名称 + 'encryptionType' => $item['encryptionType'], // 加密认证方式 0:一机一密,1:一型一密 +// 'rootCert' => $item['rootCert'], // T-Link证书认证根证书 + 'createBy' => $item['createBy'], // 创建者 + 'updateBy' => $item['updateBy'], // 更新者 +// 'tupDeviceModel' => $item['tupDeviceModel'], // tup设备类型 +// 'tupDeviceType' => $item['tupDeviceType'], // tup设备型号 + 'accessType' => $item['accessType'], // 接入类型: 1.设备直连,2.网关接入,3.南向云接入,4.视图云接入 + 'nodeType' => $item['nodeType'], // 节点类型:1设备 ,2.网关 + 'tupIsThrough' => $item['tupIsThrough'], // 是否透传:0.透传,1不透传 + 'dataEncryption' => $item['dataEncryption'], // 数据加密方式 1:sm1,2:sm2,3:sm4,4:dtls,5:明文 +// 'lwm2mEdrxTime' => $item['lwm2mEdrxTime'], // eDRX模式时间窗 +// 'categoryId' => $item['categoryId'], // 社区协议设备分类 +// 'categoryName' => $item['categoryName'], // 社区协议设备分类名称 +// 'msgParserMode' => $item['msgParserMode'], // 脚本解析方式:1.js脚本解析 + ]; + + if ($query) { + + $update = []; + foreach ($query as $key => $row) { + if (isset($data[$key]) && $data[$key] != $row) { + $update[$key] = $row; + } + } + + if ($update) { + Db::table($tableName)->where('id',$query['id'])->update($update); + } + + } else { + + Db::table($tableName)->insert($data); + } + } + + return $this->jsonError($jsonDataDe['msg']); + } else { + return $this->jsonError($jsonDataDe['msg'] ?: '数据获取失败'); + } + } + +} \ No newline at end of file diff --git a/application/config.php b/application/config.php index 3f64a59..ea6c235 100644 --- a/application/config.php +++ b/application/config.php @@ -240,4 +240,12 @@ return [ 'var_page' => 'page', 'list_rows' => 15, ], + + // 物联网配置 + 'iot' => [ + 'app_id' => '290441', + 'app_key' => 'wY9JtbBHr23', + 'app_secret' => 'lx5Iu36wwu', + 'access_domain' => '2000423559.api.ctwing.cn' + ] ];