Skip to content

Commit

Permalink
Support php81
Browse files Browse the repository at this point in the history
  • Loading branch information
iMactool authored and iMactool committed Nov 27, 2023
1 parent 8c88548 commit 394e828
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
12 changes: 7 additions & 5 deletions src/Core/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,17 @@ public function imouSystemParams()
public function getCloudAccessToken()
{
$cacheKey = $this->getCacheKey(self::$config);
$accessToken = CacheAdapter::getInstance()->getItem($cacheKey);
$accessToken = self::getInstance()->getItem($cacheKey);
if (!$accessToken->isHit()) {
$result = $this->refreshCloudAccessToken();
if (!empty($result)) {
if (!$result['success']){
throw new \Exception($result['code'].' '.$result['errMsg']);
}
$this->cloud_access_token = $result['access_token'];
$accessToken->set($result);
$accessToken->expiresAfter((int) $result['expires_in'] - 3);
CacheAdapter::getInstance()->save($accessToken);
self::getInstance()->save($accessToken);
return $result;
}
} else {
Expand Down Expand Up @@ -356,18 +359,17 @@ public function refreshCloudAccessToken()
public function requestImouAccessToken()
{
$cacheKey = $this->getLcCacheKey(self::$config);
$accessToken = CacheAdapter::getInstance()->getItem($cacheKey);
$accessToken = self::getInstance()->getItem($cacheKey);
if (!$accessToken->isHit()) {
echo "没有命中缓存~";
$result = $this->refreshImouAccessToken();
$result = \json_decode($result,true);
var_dump($result);
if (!empty($result) && (int)$result['result']['code'] === 0) {
$data = $result['result']['data'];
$this->cloud_imou_token = $data['accessToken'];
$accessToken->set($data);
$accessToken->expiresAfter((int) $data['expireTime'] - 3);
CacheAdapter::getInstance()->save($accessToken);
self::getInstance()->save($accessToken);
return $data;
}
return $result;
Expand Down
4 changes: 4 additions & 0 deletions src/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Container implements \ArrayAccess
*/
public $register;

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
// TODO: Implement offsetExists() method.
Expand All @@ -44,6 +45,7 @@ public function offsetExists($offset)
*
* @return $this|mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (isset($this->instances[$offset])) {
Expand All @@ -61,11 +63,13 @@ public function offsetGet($offset)
* @param mixed $offset
* @param mixed $value
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->values[$offset] = $value;
}

#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
// TODO: Implement offsetUnset() method.
Expand Down
42 changes: 21 additions & 21 deletions src/Mixed/Mixed.php → src/Mixed/MixedApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use GuzzleHttp\Exception\BadResponseException;
use Imactool\DahuaCloud\Core\BaseService;

class Mixed extends BaseService
class MixedApi extends BaseService
{
/**
* AI -> 根据任务id获取相关信息
* @param $taskId
*
* @return mixed
* @return mixed
* @author cc
*/
public function getAinfoByTaskId($taskId)
Expand All @@ -32,7 +32,7 @@ public function getAinfoByTaskId($taskId)
* 微信管理 -> 根据微信授权码code获取openid
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function getWxOpenidByCode($code)
Expand All @@ -45,7 +45,7 @@ public function getWxOpenidByCode($code)
* 微信管理 -> 获取微信签名
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function getWxSignature($url)
Expand All @@ -58,7 +58,7 @@ public function getWxSignature($url)
* 流媒体相关 -> 获取乐橙userToken
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function getLeChengUserToken()
Expand All @@ -70,7 +70,7 @@ public function getLeChengUserToken()
* 单点登录 -> 免密登陆接口
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function userToken($telephone)
Expand All @@ -84,7 +84,7 @@ public function userToken($telephone)
* AI热度分析 -> 区域客流热度数据
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function aiAreaFlow(array $params)
Expand All @@ -96,7 +96,7 @@ public function aiAreaFlow(array $params)
* AI热度分析 -> AI热度图绘制数据接口
* @param $code
*
* @return mixed
* @return mixed
* @author cc
*/
public function aiHeatMap(array $params)
Expand All @@ -108,7 +108,7 @@ public function aiHeatMap(array $params)
* 视频追溯 -> 上传视频追溯单据
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function videoUploadTicket(array $params)
Expand All @@ -120,7 +120,7 @@ public function videoUploadTicket(array $params)
* 物流追溯 -> 上传物流单据
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function wlOrderUpload(array $params)
Expand All @@ -132,7 +132,7 @@ public function wlOrderUpload(array $params)
* 收银监督子系统 -> 上传小票数据
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function postTicketUpload(array $params)
Expand All @@ -144,7 +144,7 @@ public function postTicketUpload(array $params)
* 收银监督子系统 -> 删除pos机和通道关联关系
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function deletePosDevChannelRel(array $params)
Expand All @@ -156,7 +156,7 @@ public function deletePosDevChannelRel(array $params)
* 收银监督子系统 -> 添加pos机和通道绑定关系
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function addPosDevChannelRel(array $params)
Expand All @@ -168,7 +168,7 @@ public function addPosDevChannelRel(array $params)
* 巡检考评子系统 -> 上传事件考评图片
* @param string $pictureBase64 图片base64编码
*
* @return mixed
* @return mixed
* @author cc
*/
public function captureEvaluation(string $pictureBase64)
Expand All @@ -181,7 +181,7 @@ public function captureEvaluation(string $pictureBase64)
* 巡检考评子系统 -> 处理事件考评
* @param string $messageId
*
* @return mixed
* @return mixed
* @author cc
*/
public function evaluationMessage(string $messageId)
Expand All @@ -193,7 +193,7 @@ public function evaluationMessage(string $messageId)
* 巡检考评子系统 -> 店铺员工复议
* @param array $params
*
* @return mixed
* @return mixed
* @author cc
*/
public function onlineQuestion(array $params)
Expand All @@ -205,7 +205,7 @@ public function onlineQuestion(array $params)
* 巡检考评子系统 -> 查询事件考评详情
* @param string $messageId
*
* @return mixed
* @return mixed
* @author cc
*/
public function evaluationMessageInfo(string $messageId)
Expand All @@ -216,7 +216,7 @@ public function evaluationMessageInfo(string $messageId)

/**
* 基础功能 -> 文件上传
* @return mixed
* @return mixed
* @author cc
*/
public function getStoreMap()
Expand All @@ -230,7 +230,7 @@ public function getStoreMap()
* 刷新OSS图片有效期
* @param string $photoUrl
*
* @return mixed|string
* @return mixed|string
* @author cc
*/
public function refreshOssImg(string $photoUrl)
Expand All @@ -247,7 +247,7 @@ public function refreshOssImg(string $photoUrl)
* 查询通道是否开通云存储
* @param $devChnIds
*
* @return mixed
* @return mixed
* @author cc
*/
public function getStorageStrategy($devChnIds)
Expand All @@ -259,7 +259,7 @@ public function getStorageStrategy($devChnIds)
* 可视对讲 - 纯云app注册sip
* @param $phone
*
* @return mixed
* @return mixed
* @author cc
*/
public function registerChunYunSip($phone)
Expand Down
2 changes: 1 addition & 1 deletion src/Mixed/MixedProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MixedProvider implements Provider
public function serviceProvider (Container $container)
{
$container['Mixed'] = function ($container) {
return new Mixed($container);
return new MixedApi($container);
};
}
}
4 changes: 4 additions & 0 deletions src/Support/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,27 @@ public function get($key, $default = null)
return $config;
}

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return array_key_exists($offset, $this->config);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($offset);
}

#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (isset($this->config[$offset])) {
$this->config[$offset] = $value;
}
}

#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
if (isset($this->config[$offset])) {
Expand Down

0 comments on commit 394e828

Please sign in to comment.