代码优化

This commit is contained in:
wong
2026-01-19 10:30:09 +08:00
parent 16aec83f02
commit 6b31889261
2 changed files with 176 additions and 14 deletions

View File

@@ -80,14 +80,24 @@ class MessageChatroomListJob
// 调用添加好友任务获取方法
$result = $messageController->getChatroomList($pageIndex,$pageSize,true);
$response = json_decode($result,true);
// 确保 response 是数组格式
if (!is_array($response)) {
$response = [];
}
// 判断是否成功
if ($response['code'] == 200) {
$data = $response['data'];
if (isset($response['code']) && $response['code'] == 200) {
$data = isset($response['data']) ? $response['data'] : [];
// 确保 data 是数组格式
if (!is_array($data)) {
$data = [];
}
// 判断是否有下一页,且未超过最大同步页数
if (!empty($data) && count($data) > 0) {
if (!empty($data) && is_array($data) && count($data) > 0) {
$nextPageIndex = $pageIndex + 1;
// 检查是否超过最大同步页数
if ($nextPageIndex < self::MAX_SYNC_PAGES) {