diff --git a/src/main/java/com/ifish7/mq/push/AliyunPushApi.java b/src/main/java/com/ifish7/mq/push/AliyunPushApi.java index 261fa5e..5ff58c2 100644 --- a/src/main/java/com/ifish7/mq/push/AliyunPushApi.java +++ b/src/main/java/com/ifish7/mq/push/AliyunPushApi.java @@ -6,6 +6,7 @@ import com.aliyuncs.http.FormatType; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.push.model.v20160801.PushRequest; import com.aliyuncs.push.model.v20160801.PushResponse; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ifish7.mq.business.user.entity.TblAliyunDeviceInfo; import com.ifish7.mq.business.user.entity.TblPushList; @@ -59,7 +60,14 @@ public class AliyunPushApi { //根据Target来设定,多个值使用逗号分隔 //此处应该查询出用户所对应的deviceId ★★★★★ // String deviceIds = getUserDevices(String.valueOf(pushList.getUserId())); - List pushUserDevices = aliyunDeviceInfoService.list(new QueryWrapper().lambda().eq(TblAliyunDeviceInfo::getUserId, pushList.getUserId())); + //查询所有 + LambdaQueryWrapper allQuary = new QueryWrapper().lambda().eq(TblAliyunDeviceInfo::getUserId, pushList.getUserId()); + if ("IOS".equals(pushList.getPhoneType().toUpperCase())) { + allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"iOS"); + } else if("ANDROID".equals(pushList.getPhoneType().toUpperCase())) { + allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"ANDROID"); + } + List pushUserDevices = aliyunDeviceInfoService.list(allQuary); pushUserDevices.forEach(aliyunDeviceInfo -> { if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) { pushRequest.setAppKey(Long.parseLong(iosAppKey)); @@ -97,11 +105,11 @@ public class AliyunPushApi { pushList.setReportId(Integer.parseInt(response.getMessageId())); //未读 pushList.setIsRead(1); - pushList.setDeviceId(pushList.getDeviceId() == 0 ? null : pushList.getDeviceId()); - pushListService.save(pushList); + pushList.setDeviceId((pushList.getDeviceId() == null || pushList.getDeviceId() == 0)? null : pushList.getDeviceId()); } catch (ClientException e) { log.error(e.getMessage(),e); } }); + pushListService.save(pushList); } } diff --git a/src/main/resources/jdbc.properties b/src/main/resources/jdbc.properties index 40ec20d..a5700c3 100644 --- a/src/main/resources/jdbc.properties +++ b/src/main/resources/jdbc.properties @@ -1,8 +1,6 @@ jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8 #jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8 -#jdbc.username=root -#jdbc.password=123456 jdbc.username=ifish jdbc.password=ifish7pwd #jdbc.username=root diff --git a/src/main/resources/mq.properties b/src/main/resources/mq.properties index 77df9ed..5eb164d 100644 --- a/src/main/resources/mq.properties +++ b/src/main/resources/mq.properties @@ -1,4 +1,5 @@ broker_url=tcp://localhost:61616 +#broker_url=tcp://test.ifish7.com:61616 username=admin #password=admin password=adminifish7 diff --git a/src/main/resources/push.properties b/src/main/resources/push.properties index d48a135..0c971fd 100644 --- a/src/main/resources/push.properties +++ b/src/main/resources/push.properties @@ -1,7 +1,7 @@ accessKeyId= LTAIfZaosFH5IWlD accessKeySecret = dvlE8eFii31BcGb8HzkGz3eSaJ6Y94 android_app_key = 26023230 -ios_app_key = 26023230 +ios_app_key = 26007228 #\u76EE\u524D\u8BE5\u503C\u56FA\u5B9A\uFF0C\u4E0D\u7528\u52A8 regionId = cn-hangzhou