Merge branch 'cc_20250703_askbot_api' into 'master'

Cc 20250703 askbot api

See merge request hangzhou/java/custom_zxjp!125
This commit is contained in:
苏竹红
2025-07-07 09:43:28 +00:00
6 changed files with 69 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

@@ -0,0 +1,31 @@
package com.cool.store.controller.webc;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.PushService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author: WangShuo
* @Date: 2025/07/04/10:16
* @Version 1.0
* @注释:
*/
@RestController
@RequestMapping("/mini/askBot")
public class AskBotController {
@Resource
private PushService pushService;
@GetMapping("/getUnReadMessageNum")
@ApiOperation("获取未读数量")
public ResponseResult<Object> getUnReadMessageNum(@RequestParam(value = "partnerId", required = true,defaultValue = "0") String partnerId) {
return ResponseResult.success(pushService.getUnReadMessageNum(partnerId));
}
}

View File

@@ -125,3 +125,5 @@ cool.api.appKey=k8J7fG2qR5tY9vX3
cool.api.secret=wP4sN6dL8zK2xM9c
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