1.修改app推送逻辑,可关闭推送
This commit is contained in:
parent
89bacebe1f
commit
75b4051cbe
|
|
@ -4,6 +4,7 @@ import com.getui.push.v2.sdk.ApiHelper;
|
||||||
import com.getui.push.v2.sdk.GtApiConfiguration;
|
import com.getui.push.v2.sdk.GtApiConfiguration;
|
||||||
import com.getui.push.v2.sdk.api.PushApi;
|
import com.getui.push.v2.sdk.api.PushApi;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -23,11 +24,14 @@ public class MyApiHelper {
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个推接口实例化
|
* 个推接口实例化
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Bean(name = "onlyPushApi")
|
@Bean(name = "onlyPushApi")
|
||||||
|
@ConditionalOnProperty(prefix = "getui.app", name = "enabled", havingValue = "true")
|
||||||
public PushApi pushApi() {
|
public PushApi pushApi() {
|
||||||
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
||||||
//填写应用配置,参数在“Uni Push”下的“应用配置”页面中获取
|
//填写应用配置,参数在“Uni Push”下的“应用配置”页面中获取
|
||||||
|
|
@ -40,5 +44,4 @@ public class MyApiHelper {
|
||||||
PushApi pushApi = apiHelper.creatApi(PushApi.class);
|
PushApi pushApi = apiHelper.creatApi(PushApi.class);
|
||||||
return pushApi;
|
return pushApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.message.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.config.init.MyApiHelper;
|
||||||
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
||||||
import org.jeecg.modules.message.service.IAppMessageService;
|
import org.jeecg.modules.message.service.IAppMessageService;
|
||||||
import org.jeecg.modules.message.util.PushAppUtil;
|
import org.jeecg.modules.message.util.PushAppUtil;
|
||||||
|
|
@ -18,19 +19,23 @@ public class AppMessageServiceImpl implements IAppMessageService {
|
||||||
private PushAppUtil pushAppUtil;
|
private PushAppUtil pushAppUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppMessageMapper appMessageMapper;
|
private AppMessageMapper appMessageMapper;
|
||||||
|
@Autowired
|
||||||
|
private MyApiHelper myApiHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendToSingle(MessageDTO messageDTO, String groupId) {
|
public void sendToSingle(MessageDTO messageDTO, String groupId) {
|
||||||
//根据分组id查询出关联的用户id
|
//个推启用才推送消息到app
|
||||||
List<String> groupUserIds = appMessageMapper.findGroupUserIds(groupId);
|
if (myApiHelper.isEnabled()){
|
||||||
if (CollectionUtils.isNotEmpty(groupUserIds)) {
|
//根据分组id查询出关联的用户id
|
||||||
//根据用户id查询出用户关联的app客户端id
|
List<String> groupUserIds = appMessageMapper.findGroupUserIds(groupId);
|
||||||
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
|
if (CollectionUtils.isNotEmpty(groupUserIds)) {
|
||||||
if (CollectionUtils.isNotEmpty(userClientId)) {
|
//根据用户id查询出用户关联的app客户端id
|
||||||
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
|
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
|
||||||
//调用app推送方法
|
if (CollectionUtils.isNotEmpty(userClientId)) {
|
||||||
pushAppUtil.pushToList(messageDTO, userClientId);
|
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
|
||||||
|
//调用app推送方法
|
||||||
|
pushAppUtil.pushToList(messageDTO, userClientId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
|
||||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -29,7 +30,8 @@ public class PushAppUtil {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppMessageMapper appMessageMapper;
|
private AppMessageMapper appMessageMapper;
|
||||||
@Resource(name = "onlyPushApi")
|
@Autowired(required = false)
|
||||||
|
@Qualifier("onlyPushApi")
|
||||||
private PushApi pushApi;
|
private PushApi pushApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration debug="false">
|
<configuration debug="false">
|
||||||
<!--定义日志文件的存储地址 -->
|
<!--定义日志文件的存储地址 -->
|
||||||
<property name="LOG_HOME" value="../logs" />
|
<property name="LOG_HOME" value="./logs" />
|
||||||
<property name="ERROR_LOG_HOME" value="../errorLogs" />
|
<property name="ERROR_LOG_HOME" value="./errorLogs" />
|
||||||
|
|
||||||
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
|
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
|
||||||
<!-- 控制台输出 -->
|
<!-- 控制台输出 -->
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ db:
|
||||||
'0': ${POSTGRESQL-PWD:postgres}
|
'0': ${POSTGRESQL-PWD:postgres}
|
||||||
url:
|
url:
|
||||||
'0': jdbc:postgresql://${POSTGRESQL-HOST:127.0.0.1}:${POSTGRESQL-PORT:5432}/${POSTGRESQL-DB:nacos}?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java
|
'0': jdbc:postgresql://${POSTGRESQL-HOST:127.0.0.1}:${POSTGRESQL-PORT:5432}/${POSTGRESQL-DB:nacos}?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java
|
||||||
#'0': jdbc:postgresql://${MYSQL-HOST:172.21.50.118}:${MYSQL-PORT:5432}/${MYSQL-DB:nacos}?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java
|
|
||||||
user:
|
user:
|
||||||
'0': ${POSTGRESQL-USER:postgres}
|
'0': ${POSTGRESQL-USER:postgres}
|
||||||
pool:
|
pool:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user