阿里云推送优化

This commit is contained in:
易焱 2019-06-03 19:10:52 +08:00
parent f1f0080537
commit 8861bbb246
4 changed files with 13 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import com.aliyuncs.http.FormatType;
import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.push.model.v20160801.PushRequest; import com.aliyuncs.push.model.v20160801.PushRequest;
import com.aliyuncs.push.model.v20160801.PushResponse; 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ifish7.mq.business.user.entity.TblAliyunDeviceInfo; import com.ifish7.mq.business.user.entity.TblAliyunDeviceInfo;
import com.ifish7.mq.business.user.entity.TblPushList; import com.ifish7.mq.business.user.entity.TblPushList;
@ -59,7 +60,14 @@ public class AliyunPushApi {
//根据Target来设定多个值使用逗号分隔 //根据Target来设定多个值使用逗号分隔
//此处应该查询出用户所对应的deviceId //此处应该查询出用户所对应的deviceId
// String deviceIds = getUserDevices(String.valueOf(pushList.getUserId())); // String deviceIds = getUserDevices(String.valueOf(pushList.getUserId()));
List<TblAliyunDeviceInfo> pushUserDevices = aliyunDeviceInfoService.list(new QueryWrapper<TblAliyunDeviceInfo>().lambda().eq(TblAliyunDeviceInfo::getUserId, pushList.getUserId())); //查询所有
LambdaQueryWrapper<TblAliyunDeviceInfo> allQuary = new QueryWrapper<TblAliyunDeviceInfo>().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<TblAliyunDeviceInfo> pushUserDevices = aliyunDeviceInfoService.list(allQuary);
pushUserDevices.forEach(aliyunDeviceInfo -> { pushUserDevices.forEach(aliyunDeviceInfo -> {
if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) { if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) {
pushRequest.setAppKey(Long.parseLong(iosAppKey)); pushRequest.setAppKey(Long.parseLong(iosAppKey));
@ -97,11 +105,11 @@ public class AliyunPushApi {
pushList.setReportId(Integer.parseInt(response.getMessageId())); pushList.setReportId(Integer.parseInt(response.getMessageId()));
//未读 //未读
pushList.setIsRead(1); pushList.setIsRead(1);
pushList.setDeviceId(pushList.getDeviceId() == 0 ? null : pushList.getDeviceId()); pushList.setDeviceId((pushList.getDeviceId() == null || pushList.getDeviceId() == 0)? null : pushList.getDeviceId());
pushListService.save(pushList);
} catch (ClientException e) { } catch (ClientException e) {
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
} }
}); });
pushListService.save(pushList);
} }
} }

View File

@ -1,8 +1,6 @@
jdbc.driver=com.mysql.jdbc.Driver jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8 jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
#jdbc.url=jdbc\:mysql\://139.196.24.156\: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.username=ifish
jdbc.password=ifish7pwd jdbc.password=ifish7pwd
#jdbc.username=root #jdbc.username=root

View File

@ -1,4 +1,5 @@
broker_url=tcp://localhost:61616 broker_url=tcp://localhost:61616
#broker_url=tcp://test.ifish7.com:61616
username=admin username=admin
#password=admin #password=admin
password=adminifish7 password=adminifish7

View File

@ -1,7 +1,7 @@
accessKeyId= LTAIfZaosFH5IWlD accessKeyId= LTAIfZaosFH5IWlD
accessKeySecret = dvlE8eFii31BcGb8HzkGz3eSaJ6Y94 accessKeySecret = dvlE8eFii31BcGb8HzkGz3eSaJ6Y94
android_app_key = 26023230 android_app_key = 26023230
ios_app_key = 26023230 ios_app_key = 26007228
#\u76EE\u524D\u8BE5\u503C\u56FA\u5B9A\uFF0C\u4E0D\u7528\u52A8 #\u76EE\u524D\u8BE5\u503C\u56FA\u5B9A\uFF0C\u4E0D\u7528\u52A8
regionId = cn-hangzhou regionId = cn-hangzhou