Merge branch 'leiyong_adjust_feishu' into 'master'

* Fix bug#24192.

See merge request easycorp/zentaopms!4136
This commit is contained in:
孙广明
2022-06-27 02:49:22 +00:00
3 changed files with 35 additions and 14 deletions
+20 -10
View File
@@ -11,9 +11,8 @@ class feishuapi
/**
* Construct
*
* @param string $appKey
* @param string $appId
* @param string $appSecret
* @param string $agentId
* @param string $apiUrl
* @access public
* @return void
@@ -147,6 +146,7 @@ class feishuapi
/**
* Get department tree structure.
*
* @param string $departmentID
* @access public
* @return array
*/
@@ -191,7 +191,7 @@ class feishuapi
/* Gets the enterprise name. */
$response = $this->queryAPI($this->apiUrl . "tenant/v2/tenant/query", '', array(CURLOPT_CUSTOMREQUEST => "GET"));
$company = array('id' => '1', 'pId' => '0', 'name' => $response->data->tenant->name, 'open' => 1);
$depts = array($company);
$depts = array($company);
$departmentIdList = $this->getScopes();
@@ -229,7 +229,7 @@ class feishuapi
while(true)
{
$response = $this->queryAPI($this->apiUrl . "contact/v3/scopes" . "?user_id_type=open_id&department_id_type=open_department_id&page_token={$pageToken}&page_size=100", '', array(CURLOPT_CUSTOMREQUEST => "GET"));
$response = $this->queryAPI($this->apiUrl . "contact/v3/scopes" . "?user_id_type=open_id&department_id_type=open_department_id&page_token={$pageToken}&page_size=100", '', array(CURLOPT_CUSTOMREQUEST => "GET"));
$departmentIds = isset($response->data->department_ids) ? $response->data->department_ids : array();
foreach($departmentIds as $id) $departmentIdList[] = $id;
@@ -243,12 +243,13 @@ class feishuapi
/**
* Handle the concurrency of requests.
*
* @param array $urls
* @access public
* @return array
*/
public function multiRequest($urls)
{
$curl = curl_multi_init();
$curl = curl_multi_init();
$urlHandlers = array();
$urlData = array();
@@ -276,7 +277,7 @@ class feishuapi
}
while($mrc == CURLM_CALL_MULTI_PERFORM);
while($active && $mrc == CURLM_OK)
while($active and $mrc == CURLM_OK)
{
usleep(50000);
if(curl_multi_select($curl) != -1)
@@ -325,13 +326,13 @@ class feishuapi
* @access public
* @return string
*/
public function queryAPI($url, $data = '', $opt = array())
public function queryAPI($url, $data = '', $options = array())
{
$headers = array();
$headers[] = "Content-Type: application/json";
if($this->token) $headers[] = "Authorization:Bearer {$this->token}";
$response = common::http($url, $data, $opt, $headers);
$response = common::http($url, $data, $options, $headers);
$errors = commonModel::$requestErrors;
$response = json_decode($response);
@@ -342,8 +343,17 @@ class feishuapi
if(isset($response->code)) $this->errors[$response->code] = "Errcode:{$response->code}, Errmsg:{$response->msg}";
if(!empty($this->errors))
{
echo js::error(array_shift($this->errors));
die(js::locate(helper::createLink('webhook', 'browse')));
if(helper::isAjaxRequest())
{
http_response_code(500);
echo array_shift($this->errors);
die();
}
else
{
echo js::error(array_shift($this->errors));
die(js::locate(helper::createLink('webhook', 'browse')));
}
}
return false;
}
+1 -1
View File
@@ -14,7 +14,7 @@
#showAverage {margin: 0;}
.chosen-container-single .chosen-single div b {top: 8px !important;}
.chosen-container .chosen-drop {bottom: auto !important;}
.pull-left {margin: 24px 0px;}
.pull-left {margin: 12px 0px;}
</style>
<?php include '../../common/view/header.html.php';?>
<?php js::set('executionID', $executionID);?>
+14 -3
View File
@@ -69,8 +69,9 @@ $(function()
{
beforeClick: ztreeBeforeClick,
beforeAsync: ztreeBeforeAsync,
onClick: ztreeOnAsyncSuccess,
onAsyncSuccess: zTreeOnAsyncSuccess
onClick: ztreeOnClick,
onAsyncSuccess: zTreeOnAsyncSuccess,
onAsyncError: zTreeOnAsyncError
}
};
@@ -101,8 +102,12 @@ $(function()
return true;
}
function ztreeOnAsyncSuccess(event, treeId, treeNode)
function ztreeOnClick(event, treeId, treeNode)
{
var treeID = treeNode.tId;
if($('#' + treeID).hasClass('loading')) return false;
$('#' + treeID).addClass('loading');
if(treeNode == undefined)
{
departmentID = "0";
@@ -151,6 +156,12 @@ $(function()
$("#loadPrompt").remove();
}
function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown)
{
var errorMsg = XMLHttpRequest.responseText;
alert(errorMsg);
}
var ztreeObj = $.fn.zTree.init($("#deptList"), setting);
}
else