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
ded133fc
Commit
ded133fc
authored
Jan 27, 2022
by
renandong
🇨🇳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,处理冲突
parent
30d0f9bb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
244 additions
and
148 deletions
+244
-148
GeTuiUtils.java
src/main/java/com/weface/component/GeTuiUtils.java
+153
-116
MenuService.java
src/main/java/com/weface/component/MenuService.java
+8
-5
MessageTemplate.java
src/main/java/com/weface/component/MessageTemplate.java
+18
-2
PushController.java
src/main/java/com/weface/controller/PushController.java
+1
-1
InformForm.java
src/main/java/com/weface/dto/InformForm.java
+17
-3
PushMessageApplicationTests.java
src/test/java/com/weface/PushMessageApplicationTests.java
+47
-21
No files found.
src/main/java/com/weface/component/GeTuiUtils.java
View file @
ded133fc
This diff is collapsed.
Click to expand it.
src/main/java/com/weface/component/MenuService.java
View file @
ded133fc
package
com
.
weface
.
component
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.ConvertException
;
import
cn.hutool.core.lang.Snowflake
;
...
...
@@ -104,7 +105,7 @@ public class MenuService {
}
return
all
;
}
else
{
log
.
error
(
"
返回值内不包含需要解析的数据"
+
jsonObject
.
toJSONString
());
log
.
error
(
"
看看生活:返回值内不包含需要解析的数据{}"
,
jsonObject
.
toJSONString
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -133,7 +134,7 @@ public class MenuService {
JSONArray
userTag
=
jsonObject
.
getJSONArray
(
"userTag"
);
return
getUserTagByTag
(
userTag
,
2
,
tags
);
}
else
{
log
.
error
(
"
返回值内不包含需要解析的数据"
+
jsonObject
.
toJSONString
());
log
.
error
(
"
看看社保:返回值内不包含需要解析的数据{}"
,
jsonObject
.
toJSONString
());
}
return
null
;
}
...
...
@@ -186,9 +187,11 @@ public class MenuService {
//如果调用的是看看生活的用户标签失败时,尝试调取看看社保用户标签
if
(
type
==
1
)
{
List
<
Map
<
String
,
Object
>>
sbTags
=
getSBTags
(
gidList
,
tags
);
if
(
sbTags
!=
null
&&
sbTags
.
size
()
>
0
)
{
userTags
.
addAll
(
sbTags
);
if
(
CollUtil
.
isNotEmpty
(
gidList
))
{
List
<
Map
<
String
,
Object
>>
sbTags
=
getSBTags
(
gidList
,
tags
);
if
(
sbTags
!=
null
&&
sbTags
.
size
()
>
0
)
{
userTags
.
addAll
(
sbTags
);
}
}
}
}
...
...
src/main/java/com/weface/component/MessageTemplate.java
View file @
ded133fc
...
...
@@ -75,11 +75,10 @@ public class MessageTemplate implements Serializable {
@AllArgsConstructor
public
static
class
PushMessage
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//手机端通知展示时间段,格式为毫秒时间戳段,两个时间的时间差必须大于10分钟,例如:"1590547347000-1590633747000"
private
String
duration
;
//纯透传消息内容,安卓和iOS均支持,与notification、revoke 三选一,都填写时报错,长度 ≤ 3072
private
String
transmission
;
private
Transmission
transmission
;
//消息模板
private
Notification
notification
;
//撤回消息时使用(仅撤回个推通道消息),与notification、transmission三选一,都填写时报错(消息撤回请勿填写策略参数)
...
...
@@ -109,6 +108,23 @@ public class MessageTemplate implements Serializable {
private
String
thread_id
;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
Transmission
{
private
String
title
;
private
String
content
;
private
String
url
;
//0:h5 1:app原生
private
String
push_type
;
//跳转功能名称
private
String
className
;
//功能标题
private
String
classTitle
;
//是否需要登录
private
String
needLogin
;
}
@Data
public
static
class
Revoke
{
private
String
old_task_id
;
...
...
src/main/java/com/weface/controller/PushController.java
View file @
ded133fc
...
...
@@ -36,7 +36,7 @@ public class PushController {
}
@PostMapping
(
"/all"
)
public
CommonResult
pushAll
(
@
RequestBody
@
Validated
({
Default
.
class
})
InformForm
informForm
)
{
public
CommonResult
pushAll
(
@Validated
({
Default
.
class
})
InformForm
informForm
)
{
return
GeTuiUtils
.
listPush
(
informForm
);
}
}
src/main/java/com/weface/dto/InformForm.java
View file @
ded133fc
...
...
@@ -9,14 +9,28 @@ import javax.validation.constraints.NotBlank;
*/
@Data
public
class
InformForm
{
//标题
@NotBlank
private
String
title
;
//内容
@NotBlank
private
String
body
;
@NotBlank
private
String
click_type
;
//跳转url
private
String
url
;
private
String
[]
alias
;
//推送类型 0:h5 1:原生
private
String
push_type
;
//跳转功能名称
private
String
className
;
//功能标题
private
String
classTitle
;
//是否需要登录
private
String
needLogin
;
//请求应用名称首字母小写 例:看看生活->kksh
@NotBlank
private
String
equipmentType
;
//推送设备 4 android 1: ios
private
Integer
device
;
//定速推送,例如100,个推控制下发速度在100条/秒左右,0表示不限速
private
Integer
speed
;
}
src/test/java/com/weface/PushMessageApplicationTests.java
View file @
ded133fc
...
...
@@ -2,9 +2,12 @@ package com.weface;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.http.HtmlUtil
;
import
com.weface.code.CommonResult
;
import
com.weface.component.GeTuiUtils
;
import
com.weface.component.MenuService
;
import
com.weface.component.MessageTemplate
;
import
com.weface.dto.InformForm
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.entity.UserMenusEntity
;
...
...
@@ -90,33 +93,49 @@ class PushMessageApplicationTests {
}
}
@Test
void
testListPush
()
{
InformForm
informForm
=
new
InformForm
();
informForm
.
setTitle
(
"河南一名小学生确诊阳性!"
);
informForm
.
setBody
(
"1月23日新增一例本土确诊病例!为11岁小学生"
);
informForm
.
setUrl
(
"https://kk.weface.com.cn/news/page/?id=c0933d0e2fc85f7333b6202dff0e611c&type=hot&from=101"
);
informForm
.
setPush_type
(
"0"
);
informForm
.
setEquipmentType
(
"kksh"
);
CommonResult
commonResult
=
GeTuiUtils
.
listPush
(
informForm
);
System
.
out
.
println
(
commonResult
);
}
@Test
void
testConventTemplate
()
throws
UnsupportedEncodingException
{
//String[] alias = {"kksh_10255318"};
//String[] alias = {"kksh_10131492"};
String
[]
alias
=
{
"kksh_59354"
};
String
token
=
GeTuiUtils
.
getAuthToken
(
"kk_sh_token_ge_tui"
);
InformForm
informForm
=
new
InformForm
();
String
[]
alias
=
{
"kksh_10131492"
};
// String[] alias = {"kksh_59354"};
// String token = GeTuiUtils.getAuthToken("kk_sh_token_ge_tui");
String
token
=
GeTuiUtils
.
getAuthToken
(
"kk_sb_token_ge_tui"
);
informForm
.
setTitle
(
"河南一名小学生确诊阳性!"
);
informForm
.
setBody
(
"1月23日新增一例本土确诊病例!为11岁小学生"
);
informForm
.
setUrl
(
"https://kk.weface.com.cn/news/page/?id=c0933d0e2fc85f7333b6202dff0e611c&type=hot&from=101"
);
MessageTemplate
messageTemplate
=
new
MessageTemplate
();
messageTemplate
.
setAudience
(
new
MessageTemplate
.
Audience
(
alias
));
MessageTemplate
.
Settings
settings
=
new
MessageTemplate
.
Settings
();
settings
.
setTtl
(
3600000
);
messageTemplate
.
setSettings
(
settings
);
messageTemplate
.
setSettings
(
new
MessageTemplate
.
Settings
(
3600000
,
0
));
MessageTemplate
.
PushMessage
pushMessage
=
new
MessageTemplate
.
PushMessage
();
MessageTemplate
.
PushMessage
.
Notification
notification
=
new
MessageTemplate
.
PushMessage
.
Notification
();
notification
.
setTitle
(
"河南一名小学生确诊阳性!"
);
notification
.
setBody
(
"1月23日新增一例本土确诊病例!为11岁小学生"
);
notification
.
setClick_type
(
"intent"
);
String
pack
=
"com.weface.kksocialsecurity/com.weface.kksocialsecurity.activity.WellcomeActivity"
;
String
str
=
"intent:#Intent;component=%s;S.kkparam={\"content\": \"%s\", \"ispush\": \"1\", \"preload\": \"2\", \"push_type\": \"0\", \"pushlabel\": \"\", \"pushts\": \"1561619033\", \"title\": \"%s\", \"url\": \"%s\"};end"
;
String
url
=
"https://kk.weface.com.cn/news/page/?id=c0933d0e2fc85f7333b6202dff0e611c&type=hot&from=101"
;
String
intent
=
String
.
format
(
str
,
pack
,
notification
.
getBody
(),
notification
.
getTitle
(),
URLEncoder
.
encode
(
url
,
"UTF-8"
));
// String intent = "intent:#Intent;component=com.weface.kksocialsecurity/com.weface.kksocialsecurity.activity.WellcomeActivity;S.kkparam={\"content\": \"1月23日新增一例本土确诊病例!为11岁小学生\", \"ispush\": \"1\", \"preload\": \"2\", \"push_type\": \"0\", \"pushlabel\": \"\", \"pushts\": \"1561619033\", \"title\": \"河南一名小学生确诊阳性!\", \"url\": \"https://kk.weface.com.cn/news/page/?id=c0933d0e2fc85f7333b6202dff0e611c&type=hot&from=101\"};end";
notification
.
setIntent
(
intent
);
notification
.
setChannel_level
(
4
);
pushMessage
.
setNotification
(
notification
);
MessageTemplate
.
PushMessage
.
Transmission
transmission
=
new
MessageTemplate
.
PushMessage
.
Transmission
();
transmission
.
setTitle
(
informForm
.
getTitle
());
transmission
.
setContent
(
informForm
.
getBody
());
transmission
.
setUrl
(
informForm
.
getUrl
());
pushMessage
.
setTransmission
(
transmission
);
messageTemplate
.
setPush_message
(
pushMessage
);
String
s
=
GeTuiUtils
.
singlePushAlias
(
alias
,
GeTuiUtils
.
KK_SH_APP_ID
,
messageTemplate
,
token
);
// String s = GeTuiUtils.singlePushAlias(4, messageTemplate, GeTuiUtils.KK_SH_APP_ID, token);
String
s
=
GeTuiUtils
.
singlePushAlias
(
1
,
messageTemplate
,
GeTuiUtils
.
KK_SB_APP_ID
,
token
);
System
.
out
.
println
(
s
);
}
...
...
@@ -129,7 +148,7 @@ class PushMessageApplicationTests {
Map
<
String
,
Object
>
push_message
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
revoke
=
new
HashMap
<>();
revoke
.
put
(
"old_task_id"
,
"RASA_012
4_1679436c706dc2ea869c7c43eed0fb7d
"
);
revoke
.
put
(
"old_task_id"
,
"RASA_012
7_011f801354c5236738787cdda86cf232
"
);
revoke
.
put
(
"force"
,
false
);
push_message
.
put
(
"revoke"
,
revoke
);
map
.
put
(
"push_message"
,
push_message
);
...
...
@@ -140,4 +159,11 @@ class PushMessageApplicationTests {
}
@Test
void
testBase
()
{
String
url
=
"https://kk.weface.com.cn/news/page/?id=8def012d3485ca0e87455b6c5aeeea18&type=hot&from=101"
;
String
unescape
=
HtmlUtil
.
unescape
(
url
);
System
.
out
.
println
(
unescape
);
}
}
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