|
|
@@ -2,6 +2,8 @@ package com.fs.im.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
@@ -50,8 +52,6 @@ import com.google.common.base.Joiner;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONObject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@@ -129,7 +129,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonResponse = new JSONObject(response);
|
|
|
if (jsonResponse.getInt("errCode") == 0) {
|
|
|
JSONObject data = jsonResponse.getJSONObject("data");
|
|
|
- adminToken = data.getString("token");
|
|
|
+ adminToken = data.getStr("token");
|
|
|
redisCache.setCacheObject("openImAdminToken:" + imConfig.getUserID(), adminToken,
|
|
|
data.getInt("expireTimeSeconds"), TimeUnit.SECONDS);
|
|
|
return adminToken;
|
|
|
@@ -313,16 +313,16 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
if (total > 0) {
|
|
|
JSONArray conversations = data.getJSONArray("conversations");
|
|
|
// 遍历当前页的所有会话
|
|
|
- for (int i = 0; i < conversations.length(); i++) {
|
|
|
+ for (int i = 0; i < conversations.size(); i++) {
|
|
|
JSONObject conversation = conversations.getJSONObject(i);
|
|
|
- String convId = conversation.getString("conversationID");
|
|
|
+ String convId = conversation.getStr("conversationID");
|
|
|
// 如果找到目标会话,返回其ex字段
|
|
|
if (conversationId.equals(convId)) {
|
|
|
- return conversation.getString("ex");
|
|
|
+ return conversation.getStr("ex");
|
|
|
}
|
|
|
}
|
|
|
// 如果当前页没有找到且已经是最后一页,则退出循环
|
|
|
- if (conversations.length() < pageSize) {
|
|
|
+ if (conversations.size() < pageSize) {
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
@@ -933,7 +933,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
.body();
|
|
|
JSONObject jsonObject = new JSONObject(body);
|
|
|
JSONArray results = jsonObject.getJSONObject("data").getJSONArray("results");
|
|
|
- if (results != null && results.length() > 0) {
|
|
|
+ if (results != null && !results.isEmpty()) {
|
|
|
JSONObject resultObj = results.getJSONObject(0);
|
|
|
int accountStatus = resultObj.getInt("accountStatus");
|
|
|
//未注册自动注册
|
|
|
@@ -1009,7 +1009,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
Integer errCode = (Integer)userJson.get("errCode");
|
|
|
if (errCode==0){
|
|
|
JSONObject userData = userJson.getJSONObject("data");
|
|
|
- String userToken = userData.getString("token");
|
|
|
+ String userToken = userData.getStr("token");
|
|
|
return R.ok().put("token", userToken);
|
|
|
}
|
|
|
// return R.error("注册失败");
|