GetuiLaboratory / getui-pushapi-java-client-v2

个推官方提供的推送服务端SDK(Java语言),基于全新的RestAPI V2接口(https://docs.getui.com/getui/server/rest_v2/introduction/)
Apache License 2.0
95 stars 35 forks source link

读取CidStatusDTO内容报错 #35

Open xxxidos opened 1 year ago

xxxidos commented 1 year ago

springboot:3.0.6 jdk:zulu17 sdk:1.0.0.11

问题: 使用userApi进行client状态查询时,读取CidStatusDTO状态时报错, 提示对象为StatisticDTO类型

    SpringApplication.run(DemoApplication.class, args);
    GtApiConfiguration apiConfiguration = new GtApiConfiguration();
    //填写应用配置
    apiConfiguration.setAppId("xxx");
    apiConfiguration.setAppKey("xxx");
    apiConfiguration.setMasterSecret("xxx");
    // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
    apiConfiguration.setDomain("https://restapi.getui.com/v2/");
    // 实例化ApiHelper对象,用于创建接口对象
    ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
    // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
    UserApi userApi = apiHelper.creatApi(UserApi.class);

    String clientId = "xxx";
    HashSet<String> set = new HashSet<>();
    set.add(clientId);
    ApiResult<Map<String, CidStatusDTO>> mapApiResult = userApi.queryUserStatus(set);
    System.out.println(mapApiResult);
    Map<String, CidStatusDTO> data = mapApiResult.getData();
    System.out.println(data.get(clientId).getStatus());

报错: ApiResult{code=0, msg='success', data=StatisticDTO{xxx=StatisticDTO{last_login_time=1682225850979, status=offline}}} Exception in thread "main" java.lang.ClassCastException: class com.getui.push.v2.sdk.dto.res.statistic.StatisticDTO cannot be cast to class com.getui.push.v2.sdk.dto.res.CidStatusDTO (com.getui.push.v2.sdk.dto.res.statistic.StatisticDTO and com.getui.push.v2.sdk.dto.res.CidStatusDTO are in unnamed module of loader 'app') at com.example.demo.DemoApplication.main(DemoApplication.java:39)

GetuiLab commented 1 year ago

您好,麻烦个推官网扫技术支持企业微信二维码添加企业微信解决。

support @.***

---- 回复的原邮件 ---- 发件人 @.> 发送日期 2023年04月24日 08:58 收件人 @.> 抄送人 @.***> 主题 [GetuiLaboratory/getui-pushapi-java-client-v2] 读取CidStatusDTO内容报错 (Issue #35)

springboot:3.0.6 jdk:zulu17 sdk:1.0.0.11 问题: 使用userApi进行client状态查询时,读取CidStatusDTO状态时报错, 提示对象为StatisticDTO类型 SpringApplication.run(DemoApplication.class, args); GtApiConfiguration apiConfiguration = new GtApiConfiguration(); //填写应用配置 apiConfiguration.setAppId("xxx"); apiConfiguration.setAppKey("xxx"); apiConfiguration.setMasterSecret("xxx"); // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId apiConfiguration.setDomain("https://restapi.getui.com/v2/"); // 实例化ApiHelper对象,用于创建接口对象 ApiHelper apiHelper = ApiHelper.build(apiConfiguration); // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi UserApi userApi = apiHelper.creatApi(UserApi.class);

String clientId = "xxx";
HashSet<String> set = new HashSet<>();
set.add(clientId);
ApiResult<Map<String, CidStatusDTO>> mapApiResult = userApi.queryUserStatus(set);
System.out.println(mapApiResult);
Map<String, CidStatusDTO> data = mapApiResult.getData();
System.out.println(data.get(clientId).getStatus());

报错: ApiResult{code=0, msg='success', data=StatisticDTO{xxx=StatisticDTO{last_login_time=1682225850979, status=offline}}} Exception in thread "main" java.lang.ClassCastException: class com.getui.push.v2.sdk.dto.res.statistic.StatisticDTO cannot be cast to class com.getui.push.v2.sdk.dto.res.CidStatusDTO (com.getui.push.v2.sdk.dto.res.statistic.StatisticDTO and com.getui.push.v2.sdk.dto.res.CidStatusDTO are in unnamed module of loader 'app') at com.example.demo.DemoApplication.main(DemoApplication.java:39) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>