feat:askbot

This commit is contained in:
苏竹红
2025-07-03 11:18:20 +08:00
parent 8d3f7dca85
commit 8228731004
5 changed files with 38 additions and 4 deletions

View File

@@ -85,7 +85,7 @@ public interface PushService {
*/
XgjAccessTokenDTO getXgjAccessToken();
Integer getUnReadMessageNum(String partnerId);

View File

@@ -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);
}

View File

@@ -288,6 +288,13 @@ public class PCTestController {
return ResponseResult.success(pushService.getXgjAccessToken());
}
@GetMapping("/getUnReadMessageNum")
@ApiOperation("getUnReadMessageNum")
public ResponseResult<Object> getUnReadMessageNum(@RequestParam(value = "partnerId", required = true,defaultValue = "0") String partnerId) {
return ResponseResult.success(pushService.getUnReadMessageNum(partnerId));
}
@Resource
ShopAccountService accountService;

View File

@@ -124,4 +124,6 @@ zx.food.url=https://datacenter.zhengxinshipin.com
cool.api.appKey=k8J7fG2qR5tY9vX3
cool.api.secret=wP4sN6dL8zK2xM9c
special.user.id=wpayJeDAAAklx_q1jGhyGUd4yEh8vV_g_woayJeDAAAtwLSAPVMWbpGi9q4caSujg
special.user.id=wpayJeDAAAklx_q1jGhyGUd4yEh8vV_g_woayJeDAAAtwLSAPVMWbpGi9q4caSujg
ask.bot.url=https://auth.wx.askbot.cn

View File

@@ -130,3 +130,5 @@ cool.api.secret=wP4sN6dL8zK2xM9c
#maozhejun userID
special.user.id=wpayJeDAAAhGIFgUJpJN-zg39JuNbYhg_woayJeDAAA0TC8mkCJeXouw94hYA-D3Q
ask.bot.url=https://test.auth.wx.askbot.cn