Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
push-message
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liucheng
push-message
Commits
26258731
Commit
26258731
authored
Nov 12, 2020
by
lc@weface.com.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'多配置'
parent
61360f89
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
82 additions
and
39 deletions
+82
-39
pom.xml
pom.xml
+7
-0
GeTuiSDK.java
src/main/java/com/weface/component/GeTuiSDK.java
+23
-23
APPConfig.java
src/main/java/com/weface/config/APPConfig.java
+0
-5
GeTuiApp.java
src/main/java/com/weface/config/GeTuiApp.java
+21
-0
GeTuiConfig.java
src/main/java/com/weface/config/GeTuiConfig.java
+12
-0
PushDTO.java
src/main/java/com/weface/dto/PushDTO.java
+1
-0
AsyncService.java
src/main/java/com/weface/service/AsyncService.java
+1
-1
AsyncServiceImpl.java
src/main/java/com/weface/serviceimpl/AsyncServiceImpl.java
+2
-2
PushServiceImpl.java
src/main/java/com/weface/serviceimpl/PushServiceImpl.java
+1
-2
application.yml
src/main/resources/application.yml
+8
-6
PushMessageApplicationTests.java
src/test/java/com/weface/PushMessageApplicationTests.java
+6
-0
No files found.
pom.xml
View file @
26258731
...
...
@@ -41,6 +41,13 @@
</exclusions>
</dependency>
<dependency>
<groupId>
org.junit.platform
</groupId>
<artifactId>
junit-platform-launcher
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
...
...
src/main/java/com/weface/component/GeTuiSDK.java
View file @
26258731
package
com
.
weface
.
component
;
import
cn.hutool.core.util.StrUtil
;
import
com.gexin.rp.sdk.base.IBatch
;
import
com.gexin.rp.sdk.base.IIGtPush
;
import
com.gexin.rp.sdk.base.IPushResult
;
...
...
@@ -15,34 +14,35 @@ import com.gexin.rp.sdk.http.IGtPush;
import
com.gexin.rp.sdk.template.NotificationTemplate
;
import
com.gexin.rp.sdk.template.style.Style0
;
import
com.gexin.rp.sdk.template.style.Style6
;
import
com.weface.config.GeTuiApp
;
import
com.weface.config.GeTuiConfig
;
import
com.weface.dto.MsgDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Component
@Slf4j
public
class
GeTuiSDK
{
@
Value
(
"${config.getui.appkey}"
)
private
String
appKey
;
@
Resource
private
GeTuiApp
geTuiApp
;
@Value
(
"${config.getui.mastersecret}"
)
private
String
masterSecret
;
@Value
(
"${config.getui.appId}"
)
private
String
appId
;
@Value
(
"${config.getui.baseUrl}"
)
private
String
host
;
private
GeTuiConfig
getConfig
(
String
fromApp
){
return
geTuiApp
.
getApps
().
get
(
fromApp
);
}
public
IPushResult
pushSingle
(
String
alias
,
String
title
,
String
body
)
{
// 设置后,根据别名推送,会返回每个cid的推送结果
System
.
setProperty
(
Constants
.
GEXIN_PUSH_SINGLE_ALIAS_DETAIL
,
"true"
);
IGtPush
push
=
new
IGtPush
(
host
,
appKey
,
masterSecret
);
NotificationTemplate
template
=
getNotificationTemplate
(
title
,
body
);
String
fromApp
=
alias
.
split
(
"_"
)[
0
];
GeTuiConfig
config
=
getConfig
(
fromApp
);
String
appId
=
config
.
getAppId
();
String
appKey
=
config
.
getAppkey
();
IGtPush
push
=
new
IGtPush
(
config
.
getBaseUrl
(),
appKey
,
config
.
getMastersecret
());
NotificationTemplate
template
=
getNotificationTemplate
(
title
,
body
,
appId
,
appKey
);
SingleMessage
message
=
new
SingleMessage
();
message
.
setOffline
(
true
);
// 离线有效时间,单位为毫秒
...
...
@@ -68,7 +68,7 @@ public class GeTuiSDK {
return
ret
;
}
public
NotificationTemplate
getNotificationTemplate
(
String
title
,
String
body
)
{
public
NotificationTemplate
getNotificationTemplate
(
String
title
,
String
body
,
String
appId
,
String
appKey
)
{
NotificationTemplate
template
=
new
NotificationTemplate
();
// 设置APPID与APPKEY
template
.
setAppId
(
appId
);
...
...
@@ -84,8 +84,7 @@ public class GeTuiSDK {
style6
.
setRing
(
true
);
style6
.
setVibrate
(
true
);
style6
.
setClearable
(
true
);
/* // 设置通知栏标题与内容
/* // 设置通知栏标题与内容
style.setTitle(title);
style.setText(body);
// 配置通知栏图标
...
...
@@ -138,18 +137,19 @@ public class GeTuiSDK {
}
public
void
batchPush
(
List
<
MsgDTO
>
objs
)
throws
Exception
{
IIGtPush
push
=
new
IGtPush
(
host
,
appKey
,
masterSecret
);
public
void
batchPush
(
List
<
MsgDTO
>
objs
,
String
fromApp
)
throws
Exception
{
GeTuiConfig
config
=
getConfig
(
fromApp
);
IIGtPush
push
=
new
IGtPush
(
config
.
getBaseUrl
(),
config
.
getAppkey
(),
config
.
getMastersecret
());
IBatch
batch
=
push
.
getBatch
();
for
(
MsgDTO
msg
:
objs
)
{
constructClientNotifyMsg
(
msg
.
getFromApp
()
+
"_"
+
msg
.
getUserId
(),
msg
.
getTitle
(),
msg
.
getBody
(),
batch
);
constructClientNotifyMsg
(
msg
.
getFromApp
()
+
"_"
+
msg
.
getUserId
(),
msg
.
getTitle
(),
msg
.
getBody
(),
batch
,
config
.
getAppId
(),
config
.
getAppkey
()
);
}
batch
.
submit
();
}
public
void
constructClientNotifyMsg
(
String
alia
,
String
title
,
String
body
,
IBatch
batch
)
throws
Exception
{
public
void
constructClientNotifyMsg
(
String
alia
,
String
title
,
String
body
,
IBatch
batch
,
String
appId
,
String
appKey
)
throws
Exception
{
SingleMessage
message
=
new
SingleMessage
();
ITemplate
template
=
notificationTemplateDemo
(
title
,
body
);
ITemplate
template
=
notificationTemplateDemo
(
title
,
body
,
appId
,
appKey
);
//template.setAPNInfo(getAPNPayload()); //详见【推送模板说明】iOS通知样式设置
...
...
@@ -167,7 +167,7 @@ public class GeTuiSDK {
}
public
NotificationTemplate
notificationTemplateDemo
(
String
title
,
String
body
)
{
public
NotificationTemplate
notificationTemplateDemo
(
String
title
,
String
body
,
String
appId
,
String
appKey
)
{
NotificationTemplate
template
=
new
NotificationTemplate
();
// 设置APPID与APPKEY
template
.
setAppId
(
appId
);
...
...
src/main/java/com/weface/config/APPConfig.java
deleted
100644 → 0
View file @
61360f89
package
com
.
weface
.
config
;
public
class
APPConfig
{
public
static
final
String
[]
apps
=
{
"kkwj"
,
"kkmz"
,
"kksb"
};
}
src/main/java/com/weface/config/GeTuiApp.java
0 → 100644
View file @
26258731
package
com
.
weface
.
config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.Map
;
@Configuration
@ConfigurationProperties
(
prefix
=
"getui"
)
public
class
GeTuiApp
{
private
Map
<
String
,
GeTuiConfig
>
apps
;
public
Map
<
String
,
GeTuiConfig
>
getApps
()
{
return
apps
;
}
public
void
setApps
(
Map
<
String
,
GeTuiConfig
>
apps
)
{
this
.
apps
=
apps
;
}
}
src/main/java/com/weface/config/GeTuiConfig.java
0 → 100644
View file @
26258731
package
com
.
weface
.
config
;
import
lombok.Data
;
@Data
public
class
GeTuiConfig
{
private
String
appkey
;
private
String
mastersecret
;
private
String
appId
;
private
String
baseUrl
;
}
src/main/java/com/weface/dto/PushDTO.java
View file @
26258731
...
...
@@ -6,4 +6,5 @@ import java.util.List;
@Data
public
class
PushDTO
{
private
List
<
MsgDTO
>
userList
;
private
String
fromApp
;
}
src/main/java/com/weface/service/AsyncService.java
View file @
26258731
...
...
@@ -6,7 +6,7 @@ import java.util.List;
public
interface
AsyncService
{
void
batchPush
(
List
<
MsgDTO
>
objs
)
throws
Exception
;
void
batchPush
(
List
<
MsgDTO
>
objs
,
String
fromApp
)
throws
Exception
;
void
pushSingle
(
MsgDTO
param
);
}
src/main/java/com/weface/serviceimpl/AsyncServiceImpl.java
View file @
26258731
...
...
@@ -19,8 +19,8 @@ public class AsyncServiceImpl implements AsyncService {
@Override
@Async
public
void
batchPush
(
List
<
MsgDTO
>
objs
)
throws
Exception
{
geTuiSDK
.
batchPush
(
objs
);
public
void
batchPush
(
List
<
MsgDTO
>
objs
,
String
fromApp
)
throws
Exception
{
geTuiSDK
.
batchPush
(
objs
,
fromApp
);
}
@Override
...
...
src/main/java/com/weface/serviceimpl/PushServiceImpl.java
View file @
26258731
package
com
.
weface
.
serviceimpl
;
import
com.weface.code.CommonResult
;
import
com.weface.component.GeTuiSDK
;
import
com.weface.dto.MsgDTO
;
import
com.weface.dto.PushDTO
;
import
com.weface.service.AsyncService
;
...
...
@@ -17,7 +16,7 @@ public class PushServiceImpl implements PushService {
@Override
public
CommonResult
pushList
(
PushDTO
param
)
throws
Exception
{
asyncService
.
batchPush
(
param
.
getUserList
());
asyncService
.
batchPush
(
param
.
getUserList
()
,
param
.
getFromApp
()
);
return
CommonResult
.
success
(
null
);
}
...
...
src/main/resources/application.yml
View file @
26258731
...
...
@@ -3,9 +3,11 @@ spring:
name
:
service-web
server
:
port
:
8080
config
:
getui
:
appkey
:
"
vIBAFNAEk88qekbfS3miE8"
mastersecret
:
"
JojRk0duJd6oXiHIyFPqj"
appId
:
"
LhnWI1t7hc7ABsYbWokXD6"
baseUrl
:
"
http://api.getui.com/apiex.htm"
getui
:
apps
:
{
kkwj
:
{
appkey
:
"
vIBAFNAEk88qekbfS3miE8"
,
mastersecret
:
"
JojRk0duJd6oXiHIyFPqj"
,
appId
:
"
LhnWI1t7hc7ABsYbWokXD6"
,
baseUrl
:
"
http://api.getui.com/apiex.htm"
},
kkmz
:
{
appkey
:
"
ywXeatlN0k5vDkHDQCqb87"
,
mastersecret
:
"
Jt4Rj3b3YA6qJkOmkN8HG3"
,
appId
:
"
739bQ9FSze62zjgXsZtAF4"
,
baseUrl
:
"
http://api.getui.com/apiex.htm"
},
kksh
:
{
appkey
:
"
rdLx5zumRK7oEme8MheAh8"
,
mastersecret
:
"
mekLZ4frLu7RHtKsN9mQn"
,
appId
:
"
CYol79N33N71BV6dcjrqj3"
,
baseUrl
:
"
http://api.getui.com/apiex.htm"
}
}
src/test/java/com/weface/PushMessageApplicationTests.java
View file @
26258731
package
com
.
weface
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
...
...
@@ -10,4 +11,9 @@ class PushMessageApplicationTests {
void
contextLoads
()
{
}
@Test
public
void
test
(){
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment