feat:askbot
This commit is contained in:
@@ -85,7 +85,7 @@ public interface PushService {
|
||||
*/
|
||||
XgjAccessTokenDTO getXgjAccessToken();
|
||||
|
||||
|
||||
Integer getUnReadMessageNum(String partnerId);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class PushServiceImpl implements PushService {
|
||||
|
||||
// TODO: 2025/4/9 suzhuhong_
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String active;
|
||||
|
||||
@@ -85,6 +83,9 @@ public class PushServiceImpl implements PushService {
|
||||
@Value("${xzg.api.auth.url}")
|
||||
private String xzgUrl;
|
||||
|
||||
@Value("${ask.bot.url}")
|
||||
private String askBotUrl;
|
||||
|
||||
@Resource
|
||||
OkHttpClient okHttpClient;
|
||||
@Resource
|
||||
@@ -225,6 +226,28 @@ public class PushServiceImpl implements PushService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getUnReadMessageNum(String partnerId) {
|
||||
String apiUrl =askBotUrl + "/api-pluto/session/getUnReadMessageNum?userId="+partnerId;
|
||||
log.info("获取小正AI消息数据开始 url:{}", apiUrl);
|
||||
Request request = new Request.Builder()
|
||||
.url(apiUrl)
|
||||
.get()
|
||||
.build();
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,
|
||||
"HTTP请求失败,状态码: " + response.code());
|
||||
}
|
||||
String responseBody = response.body().string();
|
||||
log.info("getUnReadMessageNum response num:{}", responseBody);
|
||||
return Integer.valueOf(responseBody);
|
||||
} catch (Exception e) {
|
||||
log.error("API调用异常 - URL: {}, 错误: {}", url, e.getMessage(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "接口调用异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T executeApiCall(String url, Object requestBody, Class<T> responseType, String username, String secret){
|
||||
return executePostApiCall(url,requestBody,responseType,username,secret,null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user