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
69c70dfb
Commit
69c70dfb
authored
Jan 27, 2022
by
zuoadmin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!12
parents
83787df1
17f7a014
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
280 additions
and
92 deletions
+280
-92
GeTuiUtils.java
src/main/java/com/weface/component/GeTuiUtils.java
+163
-70
MenuService.java
src/main/java/com/weface/component/MenuService.java
+4
-3
MessageTemplate.java
src/main/java/com/weface/component/MessageTemplate.java
+18
-2
PushController.java
src/main/java/com/weface/controller/PushController.java
+10
-0
InformForm.java
src/main/java/com/weface/dto/InformForm.java
+36
-0
application.yml
src/main/resources/application.yml
+1
-1
PushMessageApplicationTests.java
src/test/java/com/weface/PushMessageApplicationTests.java
+48
-16
No files found.
src/main/java/com/weface/component/GeTuiUtils.java
View file @
69c70dfb
This diff is collapsed.
Click to expand it.
src/main/java/com/weface/component/MenuService.java
View file @
69c70dfb
package
com
.
weface
.
component
;
package
com
.
weface
.
component
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.ConvertException
;
import
cn.hutool.core.convert.ConvertException
;
import
cn.hutool.core.lang.Snowflake
;
import
cn.hutool.core.lang.Snowflake
;
...
@@ -104,7 +105,7 @@ public class MenuService {
...
@@ -104,7 +105,7 @@ public class MenuService {
}
}
return
all
;
return
all
;
}
else
{
}
else
{
log
.
error
(
"
返回值内不包含需要解析的数据"
+
jsonObject
.
toJSONString
());
log
.
error
(
"
看看生活:返回值内不包含需要解析的数据{}"
,
jsonObject
.
toJSONString
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -133,7 +134,7 @@ public class MenuService {
...
@@ -133,7 +134,7 @@ public class MenuService {
JSONArray
userTag
=
jsonObject
.
getJSONArray
(
"userTag"
);
JSONArray
userTag
=
jsonObject
.
getJSONArray
(
"userTag"
);
return
getUserTagByTag
(
userTag
,
2
,
tags
);
return
getUserTagByTag
(
userTag
,
2
,
tags
);
}
else
{
}
else
{
log
.
error
(
"
返回值内不包含需要解析的数据"
+
jsonObject
.
toJSONString
());
log
.
error
(
"
看看社保:返回值内不包含需要解析的数据{}"
,
jsonObject
.
toJSONString
());
}
}
return
null
;
return
null
;
}
}
...
@@ -185,7 +186,7 @@ public class MenuService {
...
@@ -185,7 +186,7 @@ public class MenuService {
}
}
//如果调用的是看看生活的用户标签失败时,尝试调取看看社保用户标签
//如果调用的是看看生活的用户标签失败时,尝试调取看看社保用户标签
if
(
type
==
1
)
{
if
(
type
==
1
&&
CollUtil
.
isNotEmpty
(
gidList
)
)
{
List
<
Map
<
String
,
Object
>>
sbTags
=
getSBTags
(
gidList
,
tags
);
List
<
Map
<
String
,
Object
>>
sbTags
=
getSBTags
(
gidList
,
tags
);
if
(
sbTags
!=
null
&&
sbTags
.
size
()
>
0
)
{
if
(
sbTags
!=
null
&&
sbTags
.
size
()
>
0
)
{
userTags
.
addAll
(
sbTags
);
userTags
.
addAll
(
sbTags
);
...
...
src/main/java/com/weface/component/MessageTemplate.java
View file @
69c70dfb
...
@@ -75,11 +75,10 @@ public class MessageTemplate implements Serializable {
...
@@ -75,11 +75,10 @@ public class MessageTemplate implements Serializable {
@AllArgsConstructor
@AllArgsConstructor
public
static
class
PushMessage
implements
Serializable
{
public
static
class
PushMessage
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
//手机端通知展示时间段,格式为毫秒时间戳段,两个时间的时间差必须大于10分钟,例如:"1590547347000-1590633747000"
//手机端通知展示时间段,格式为毫秒时间戳段,两个时间的时间差必须大于10分钟,例如:"1590547347000-1590633747000"
private
String
duration
;
private
String
duration
;
//纯透传消息内容,安卓和iOS均支持,与notification、revoke 三选一,都填写时报错,长度 ≤ 3072
//纯透传消息内容,安卓和iOS均支持,与notification、revoke 三选一,都填写时报错,长度 ≤ 3072
private
String
transmission
;
private
Transmission
transmission
;
//消息模板
//消息模板
private
Notification
notification
;
private
Notification
notification
;
//撤回消息时使用(仅撤回个推通道消息),与notification、transmission三选一,都填写时报错(消息撤回请勿填写策略参数)
//撤回消息时使用(仅撤回个推通道消息),与notification、transmission三选一,都填写时报错(消息撤回请勿填写策略参数)
...
@@ -109,6 +108,23 @@ public class MessageTemplate implements Serializable {
...
@@ -109,6 +108,23 @@ public class MessageTemplate implements Serializable {
private
String
thread_id
;
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
@Data
public
static
class
Revoke
{
public
static
class
Revoke
{
private
String
old_task_id
;
private
String
old_task_id
;
...
...
src/main/java/com/weface/controller/PushController.java
View file @
69c70dfb
package
com
.
weface
.
controller
;
package
com
.
weface
.
controller
;
import
com.weface.code.CommonResult
;
import
com.weface.code.CommonResult
;
import
com.weface.component.GeTuiUtils
;
import
com.weface.dto.InformForm
;
import
com.weface.dto.MsgDTO
;
import
com.weface.dto.MsgDTO
;
import
com.weface.dto.PushDTO
;
import
com.weface.dto.PushDTO
;
import
com.weface.service.PushService
;
import
com.weface.service.PushService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.groups.Default
;
/**
/**
* @author Administrator
* @author Administrator
*/
*/
...
@@ -29,4 +34,9 @@ public class PushController {
...
@@ -29,4 +34,9 @@ public class PushController {
public
CommonResult
pushSingle
(
@RequestBody
MsgDTO
param
)
{
public
CommonResult
pushSingle
(
@RequestBody
MsgDTO
param
)
{
return
pushService
.
pushSingle
(
param
);
return
pushService
.
pushSingle
(
param
);
}
}
@PostMapping
(
"/all"
)
public
CommonResult
pushAll
(
@Validated
({
Default
.
class
})
InformForm
informForm
)
{
return
GeTuiUtils
.
listPush
(
informForm
);
}
}
}
src/main/java/com/weface/dto/InformForm.java
0 → 100644
View file @
69c70dfb
package
com
.
weface
.
dto
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* @author : Administrator
*/
@Data
public
class
InformForm
{
//标题
@NotBlank
private
String
title
;
//内容
@NotBlank
private
String
body
;
//跳转url
private
String
url
;
//推送类型 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/main/resources/application.yml
View file @
69c70dfb
...
@@ -64,4 +64,4 @@ gexiang:
...
@@ -64,4 +64,4 @@ gexiang:
maxIdle
:
50
maxIdle
:
50
minIdle
:
10
minIdle
:
10
user_tag_id
:
251696
user_tag_id
:
251696
push_max_size
:
1
0000
push_max_size
:
8
0000
src/test/java/com/weface/PushMessageApplicationTests.java
View file @
69c70dfb
package
com
.
weface
;
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.GeTuiUtils
;
import
com.weface.component.MenuService
;
import
com.weface.component.MenuService
;
import
com.weface.component.MessageTemplate
;
import
com.weface.component.MessageTemplate
;
import
com.weface.dto.InformForm
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.entity.UserMenusEntity
;
import
com.weface.entity.UserMenusEntity
;
...
@@ -15,7 +19,9 @@ import org.junit.jupiter.api.Test;
...
@@ -15,7 +19,9 @@ import org.junit.jupiter.api.Test;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
...
@@ -87,30 +93,56 @@ class PushMessageApplicationTests {
...
@@ -87,30 +93,56 @@ class PushMessageApplicationTests {
}
}
@Test
@Test
void
testConventTemplate
()
{
void
testConventTemplate
()
throws
UnsupportedEncodingException
{
//String[] alias = {"kksh_10255318"};
InformForm
informForm
=
new
InformForm
();
//String[] alias = {"kksh_10131492"};
String
[]
alias
=
{
"kksh_59354"
};
String
[]
alias
=
{
"kksh_10131492"
};
String
token
=
GeTuiUtils
.
getAuthToken
(
"kk_sh_token_ge_tui"
);
// 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
messageTemplate
=
new
MessageTemplate
();
messageTemplate
.
setAudience
(
new
MessageTemplate
.
Audience
(
alias
));
MessageTemplate
.
Settings
settings
=
new
MessageTemplate
.
Settings
();
messageTemplate
.
setSettings
(
new
MessageTemplate
.
Settings
(
3600000
,
0
));
settings
.
setTtl
(
3600000
);
messageTemplate
.
setSettings
(
settings
);
MessageTemplate
.
PushMessage
pushMessage
=
new
MessageTemplate
.
PushMessage
();
MessageTemplate
.
PushMessage
pushMessage
=
new
MessageTemplate
.
PushMessage
();
MessageTemplate
.
PushMessage
.
Notification
notification
=
new
MessageTemplate
.
PushMessage
.
Notification
();
notification
.
setTitle
(
"看看生活提醒"
);
MessageTemplate
.
PushMessage
.
Transmission
transmission
=
new
MessageTemplate
.
PushMessage
.
Transmission
();
notification
.
setBody
(
"看看生活->让领钱更简单"
);
transmission
.
setTitle
(
informForm
.
getTitle
());
notification
.
setClick_type
(
"url"
);
transmission
.
setContent
(
informForm
.
getBody
());
notification
.
setUrl
(
"https://www.baidu.com/"
);
transmission
.
setUrl
(
informForm
.
getUrl
());
notification
.
setChannel_level
(
4
);
pushMessage
.
setNotification
(
notification
);
pushMessage
.
setTransmission
(
transmission
);
messageTemplate
.
setPush_message
(
pushMessage
);
messageTemplate
.
setPush_message
(
pushMessage
);
String
s
=
GeTuiUtils
.
singlePushAlias
(
alias
,
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
);
System
.
out
.
println
(
s
);
}
@Test
void
testRevoke
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"request_id"
,
String
.
valueOf
(
IdUtil
.
getSnowflake
(
1
,
1
).
nextId
()));
map
.
put
(
"audience"
,
"all"
);
Map
<
String
,
Object
>
push_message
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
revoke
=
new
HashMap
<>();
revoke
.
put
(
"old_task_id"
,
"RASA_0127_011f801354c5236738787cdda86cf232"
);
revoke
.
put
(
"force"
,
false
);
push_message
.
put
(
"revoke"
,
revoke
);
map
.
put
(
"push_message"
,
push_message
);
String
url
=
GeTuiUtils
.
GE_TUI_BASE_URL
+
GeTuiUtils
.
KK_SH_APP_ID
+
"/push/all"
;
String
kk_sh_token_ge_tui
=
GeTuiUtils
.
getAuthToken
(
"kk_sh_token_ge_tui"
);
String
s
=
GeTuiUtils
.
generalPost
(
url
,
kk_sh_token_ge_tui
,
map
);
System
.
out
.
println
(
s
);
}
}
}
}
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