Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
69d6a838
Commit
69d6a838
authored
Sep 04, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
极光消息推送
parent
ad3b77d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
pom.xml
xx-universal/xx-universal-api/pom.xml
+11
-0
JPushBiz.java
...c/main/java/com/xxfc/platform/universal/biz/JPushBiz.java
+52
-0
JPushController.java
...m/xxfc/platform/universal/controller/JPushController.java
+31
-0
No files found.
xx-universal/xx-universal-api/pom.xml
View file @
69d6a838
...
@@ -72,6 +72,17 @@
...
@@ -72,6 +72,17 @@
<artifactId>
junrar
</artifactId>
<artifactId>
junrar
</artifactId>
<version>
0.7
</version>
<version>
0.7
</version>
</dependency>
</dependency>
<!-- jpush -->
<dependency>
<groupId>
cn.jpush.api
</groupId>
<artifactId>
jpush-client
</artifactId>
<version>
3.3.7
</version>
</dependency>
<dependency>
<groupId>
cn.jpush.api
</groupId>
<artifactId>
jiguang-common
</artifactId>
<version>
1.1.1
</version>
</dependency>
</dependencies>
</dependencies>
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/JPushBiz.java
0 → 100644
View file @
69d6a838
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
cn.jiguang.common.ClientConfig
;
import
cn.jiguang.common.resp.APIConnectionException
;
import
cn.jiguang.common.resp.APIRequestException
;
import
cn.jpush.api.JPushClient
;
import
cn.jpush.api.push.PushResult
;
import
cn.jpush.api.push.model.PushPayload
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.universal.service.SmsService
;
import
com.xxfc.platform.universal.utils.CCPRestSmsUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
@Service
@Slf4j
public
class
JPushBiz
{
@Value
(
"${universal.MASTER_SECRET}"
)
private
String
MASTER_SECRET
;
@Value
(
"${universal.APP_KEY}"
)
private
String
APP_KEY
;
//推送给所有平台设备
public
ObjectRestResponse
jpushToAllPlat
(
String
title
){
ClientConfig
clientConfig
=
ClientConfig
.
getInstance
();
final
JPushClient
jpushClient
=
new
JPushClient
(
MASTER_SECRET
,
APP_KEY
,
null
,
clientConfig
);
PushPayload
payload
=
PushPayload
.
alertAll
(
title
);
try
{
PushResult
result
=
jpushClient
.
sendPush
(
payload
);
log
.
debug
(
"\n推送结果:"
+
result
);
return
ObjectRestResponse
.
succ
();
}
catch
(
APIConnectionException
e
)
{
// Connection error, should retry later
log
.
debug
(
"\nConnection error, should retry later"
+
e
);
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
e
.
getMessage
());
}
catch
(
APIRequestException
e
)
{
// Should review the error, and fix the request
log
.
debug
(
"\nShould review the error, and fix the request"
+
e
);
log
.
debug
(
"\nHTTP Status: "
+
e
.
getStatus
());
log
.
debug
(
"\nError Code: "
+
e
.
getErrorCode
());
log
.
debug
(
"\nError Message: "
+
e
.
getErrorMessage
());
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
e
.
getMessage
());
}
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/JPushController.java
0 → 100644
View file @
69d6a838
package
com
.
xxfc
.
platform
.
universal
.
controller
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.universal.biz.JPushBiz
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
/**
* 极光推送
*/
@RestController
@RequestMapping
(
"jpush"
)
@IgnoreUserToken
public
class
JPushController
{
@Autowired
JPushBiz
jPushBiz
;
@RequestMapping
(
value
=
"/app/unauth/all"
,
method
=
RequestMethod
.
GET
)
//匹配的是href中的download请求
public
ObjectRestResponse
sendSms
(
@RequestParam
(
"title"
)
String
title
)
throws
Exception
{
return
jPushBiz
.
jpushToAllPlat
(
title
);
}
}
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