Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
9a31da94
Commit
9a31da94
authored
Jun 03, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步系统推送
parent
e1de3059
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
349 additions
and
138 deletions
+349
-138
common/pom.xml
+7
-0
common/src/main/java/com/wecloud/im/controller/ImApplicationController.java
+127
-97
common/src/main/java/com/wecloud/im/entity/ImApplication.java
+7
-4
common/src/main/java/com/wecloud/im/param/ImApplicationPageParam.java
+2
-0
common/src/main/java/com/wecloud/im/param/add/ImApplicationAdd.java
+66
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/sender/PushTask.java
+123
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/service/impl/WriteDataServiceImpl.java
+2
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
+10
-35
common/src/main/resources/mapper/ImApplicationMapper.xml
+2
-1
config/src/main/java/io/geekidea/springbootplus/config/constant/CommonConstant.java
+1
-1
config/src/main/resources/config/application.yml
+2
-0
No files found.
common/pom.xml
View file @
9a31da94
...
@@ -22,6 +22,13 @@
...
@@ -22,6 +22,13 @@
</dependency>
</dependency>
<dependency>
<groupId>
com.google.firebase
</groupId>
<artifactId>
firebase-admin
</artifactId>
<version>
6.4.0
</version>
</dependency>
<!-- netty-->
<!-- netty-->
<dependency>
<dependency>
<groupId>
io.netty
</groupId>
<groupId>
io.netty
</groupId>
...
...
common/src/main/java/com/wecloud/im/controller/ImApplicationController.java
View file @
9a31da94
//package com.wecloud.im.controller;
package
com
.
wecloud
.
im
.
controller
;
//
//import com.wecloud.im.entity.ImApplication;
import
com.wecloud.im.entity.ImApplication
;
//import com.wecloud.im.param.ImApplicationPageParam;
import
com.wecloud.im.param.ImApplicationPageParam
;
//import com.wecloud.im.param.ImApplicationQueryVo;
import
com.wecloud.im.param.ImApplicationQueryVo
;
//import com.wecloud.im.service.ImApplicationService;
import
com.wecloud.im.param.add.ImApplicationAdd
;
//import io.geekidea.springbootplus.framework.common.api.ApiResult;
import
com.wecloud.im.service.ImApplicationService
;
//import io.geekidea.springbootplus.framework.common.controller.BaseController;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
//import io.geekidea.springbootplus.framework.core.pagination.Paging;
import
io.geekidea.springbootplus.framework.common.controller.BaseController
;
//import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
//import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import
io.geekidea.springbootplus.framework.core.validator.groups.Add
;
//import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import
io.geekidea.springbootplus.framework.core.validator.groups.Update
;
//import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import
io.geekidea.springbootplus.framework.log.annotation.OperationLog
;
//import io.swagger.annotations.Api;
import
io.geekidea.springbootplus.framework.log.enums.OperationLogType
;
//import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.Api
;
//import lombok.extern.slf4j.Slf4j;
import
io.swagger.annotations.ApiOperation
;
//import org.springframework.beans.factory.annotation.Autowired;
import
lombok.extern.slf4j.Slf4j
;
//import org.springframework.validation.annotation.Validated;
import
org.springframework.beans.BeanUtils
;
//import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.validation.annotation.Validated
;
//import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.GetMapping
;
//import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.PostMapping
;
//import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
//import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.bind.annotation.RequestMapping
;
//
import
org.springframework.web.bind.annotation.RequestParam
;
///**
import
org.springframework.web.bind.annotation.RestController
;
// * 第三方应用表 控制器
// *
/**
// * @author wei
* 第三方应用表 控制器
// * @since 2021-04-27
*
// */
* @author wei
//@Slf4j
* @since 2021-04-27
//@RestController
*/
//@RequestMapping("/imApplication")
@Slf4j
//@Api(value = "第三方应用表API", tags = {"第三方应用表"})
@RestController
//public class ImApplicationController extends BaseController {
@RequestMapping
(
"/imApplication"
)
//
@Api
(
value
=
"第三方应用表API"
,
tags
=
{
"第三方应用表"
})
// @Autowired
public
class
ImApplicationController
extends
BaseController
{
// private ImApplicationService imApplicationService;
//
public
static
final
String
ADMIN_PWD
=
"si0132g9ad4gd6xv8x888wd6g86aga731h6pzc1pzc68b7eln96s2360j0sjkh028sj131h0gjb"
;
// /**
// * 添加第三方应用表
@Autowired
// */
private
ImApplicationService
imApplicationService
;
// @PostMapping("/add")
// @OperationLog(name = "添加第三方应用表", type = OperationLogType.ADD)
/**
// @ApiOperation(value = "添加第三方应用表")
* 添加第三方应用表
// public ApiResult<Boolean> addImApplication(@Validated(Add.class) @RequestBody ImApplication imApplication) throws Exception {
*/
// boolean flag = imApplicationService.saveImApplication(imApplication);
@PostMapping
(
"/add"
)
// return ApiResult.result(flag);
@OperationLog
(
name
=
"添加第三方应用表"
,
type
=
OperationLogType
.
ADD
)
// }
@ApiOperation
(
value
=
"添加第三方应用表"
)
//
public
ApiResult
<
Boolean
>
addImApplication
(
@Validated
(
Add
.
class
)
@RequestBody
ImApplicationAdd
imApplicationAdd
)
throws
Exception
{
// /**
// * 修改第三方应用表
if
(!
imApplicationAdd
.
getAdminPwd
().
equals
(
ADMIN_PWD
))
{
// */
return
ApiResult
.
fail
();
// @PostMapping("/update")
}
// @OperationLog(name = "修改第三方应用表", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改第三方应用表")
ImApplication
imApplication
=
new
ImApplication
();
// public ApiResult<Boolean> updateImApplication(@Validated(Update.class) @RequestBody ImApplication imApplication) throws Exception {
BeanUtils
.
copyProperties
(
imApplicationAdd
,
imApplication
);
// boolean flag = imApplicationService.updateImApplication(imApplication);
boolean
flag
=
imApplicationService
.
saveImApplication
(
imApplication
);
// return ApiResult.result(flag);
return
ApiResult
.
result
(
flag
);
// }
}
//
// /**
/**
// * 删除第三方应用表
* 修改第三方应用表
// */
*/
// @PostMapping("/delete/{id}")
@PostMapping
(
"/update"
)
// @OperationLog(name = "删除第三方应用表", type = OperationLogType.DELETE)
@OperationLog
(
name
=
"修改第三方应用表"
,
type
=
OperationLogType
.
UPDATE
)
// @ApiOperation(value = "删除第三方应用表")
@ApiOperation
(
value
=
"修改第三方应用表"
)
// public ApiResult<Boolean> deleteImApplication(@PathVariable("id") Long id) throws Exception {
public
ApiResult
<
Boolean
>
updateImApplication
(
@Validated
(
Update
.
class
)
@RequestBody
ImApplicationAdd
imApplicationAdd
)
throws
Exception
{
// boolean flag = imApplicationService.deleteImApplication(id);
// return ApiResult.result(flag);
if
(!
imApplicationAdd
.
getAdminPwd
().
equals
(
ADMIN_PWD
))
{
// }
return
ApiResult
.
fail
();
//
}
// /**
// * 获取第三方应用表详情
ImApplication
imApplication
=
new
ImApplication
();
// */
boolean
flag
=
imApplicationService
.
updateImApplication
(
imApplication
);
// @GetMapping("/info/{id}")
return
ApiResult
.
result
(
flag
);
// @OperationLog(name = "第三方应用表详情", type = OperationLogType.INFO)
}
// @ApiOperation(value = "第三方应用表详情")
// public ApiResult<ImApplicationQueryVo> getImApplication(@PathVariable("id") Long id) throws Exception {
/**
// ImApplicationQueryVo imApplicationQueryVo = imApplicationService.getImApplicationById(id);
* 删除第三方应用表
// return ApiResult.ok(imApplicationQueryVo);
*/
// }
@PostMapping
(
"/delete"
)
//
@OperationLog
(
name
=
"删除第三方应用表"
,
type
=
OperationLogType
.
DELETE
)
// /**
@ApiOperation
(
value
=
"删除第三方应用表"
)
// * 第三方应用表分页列表
public
ApiResult
<
Boolean
>
deleteImApplication
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"pwd"
)
String
pwd
)
throws
Exception
{
// */
// @PostMapping("/getPageList")
if
(!
pwd
.
equals
(
ADMIN_PWD
))
{
// @OperationLog(name = "第三方应用表分页列表", type = OperationLogType.PAGE)
return
ApiResult
.
fail
();
// @ApiOperation(value = "第三方应用表分页列表")
}
// public ApiResult<Paging<ImApplicationQueryVo>> getImApplicationPageList(@Validated @RequestBody ImApplicationPageParam imApplicationPageParam) throws Exception {
boolean
flag
=
imApplicationService
.
deleteImApplication
(
id
);
// Paging<ImApplicationQueryVo> paging = imApplicationService.getImApplicationPageList(imApplicationPageParam);
return
ApiResult
.
result
(
flag
);
// return ApiResult.ok(paging);
}
// }
//
/**
//}
* 获取第三方应用表详情
//
*/
@GetMapping
(
"/info/"
)
@OperationLog
(
name
=
"第三方应用表详情"
,
type
=
OperationLogType
.
INFO
)
@ApiOperation
(
value
=
"第三方应用表详情"
)
public
ApiResult
<
ImApplicationQueryVo
>
getImApplication
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"pwd"
)
String
pwd
)
throws
Exception
{
if
(!
pwd
.
equals
(
ADMIN_PWD
))
{
return
null
;
}
ImApplicationQueryVo
imApplicationQueryVo
=
imApplicationService
.
getImApplicationById
(
id
);
return
ApiResult
.
ok
(
imApplicationQueryVo
);
}
/**
* 第三方应用表分页列表
*/
@PostMapping
(
"/getPageList"
)
@OperationLog
(
name
=
"第三方应用表分页列表"
,
type
=
OperationLogType
.
PAGE
)
@ApiOperation
(
value
=
"第三方应用表分页列表"
)
public
ApiResult
<
Paging
<
ImApplicationQueryVo
>>
getImApplicationPageList
(
@Validated
@RequestBody
ImApplicationPageParam
imApplicationPageParam
)
throws
Exception
{
if
(!
imApplicationPageParam
.
getPwd
().
equals
(
ADMIN_PWD
))
{
return
null
;
}
Paging
<
ImApplicationQueryVo
>
paging
=
imApplicationService
.
getImApplicationPageList
(
imApplicationPageParam
);
return
ApiResult
.
ok
(
paging
);
}
}
common/src/main/java/com/wecloud/im/entity/ImApplication.java
View file @
9a31da94
...
@@ -45,15 +45,18 @@ public class ImApplication extends BaseEntity {
...
@@ -45,15 +45,18 @@ public class ImApplication extends BaseEntity {
@ApiModelProperty
(
"app名称"
)
@ApiModelProperty
(
"app名称"
)
private
String
appName
;
private
String
appName
;
@ApiModelProperty
(
"ios推送
证书
"
)
@ApiModelProperty
(
"ios推送
通道,友盟:1;firebase:2; apns原生:3
"
)
private
String
iosPush
;
private
Integer
iosPushChannel
;
@ApiModelProperty
(
"安卓推送
证书
"
)
@ApiModelProperty
(
"安卓推送
通道,友盟:1;firebase:2; 信鸽3
"
)
private
String
androidPush
;
private
Integer
androidPushChannel
;
@ApiModelProperty
(
"友盟推送key"
)
@ApiModelProperty
(
"友盟推送key"
)
private
String
umengKey
;
private
String
umengKey
;
@ApiModelProperty
(
"友盟推送密钥"
)
@ApiModelProperty
(
"友盟推送密钥"
)
private
String
umengSecret
;
private
String
umengSecret
;
@ApiModelProperty
(
"firebase推送密钥"
)
private
String
firebaseSecret
;
}
}
common/src/main/java/com/wecloud/im/param/ImApplicationPageParam.java
View file @
9a31da94
...
@@ -19,5 +19,7 @@ import lombok.experimental.Accessors;
...
@@ -19,5 +19,7 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"第三方应用表分页参数"
)
@ApiModel
(
value
=
"第三方应用表分页参数"
)
public
class
ImApplicationPageParam
extends
BasePageOrderParam
{
public
class
ImApplicationPageParam
extends
BasePageOrderParam
{
private
String
pwd
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
}
}
common/src/main/java/com/wecloud/im/param/add/ImApplicationAdd.java
0 → 100644
View file @
9a31da94
package
com
.
wecloud
.
im
.
param
.
add
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* 第三方应用表
*
* @author wei
* @since 2021-04-27
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImApplicationAdd"
)
public
class
ImApplicationAdd
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"应用appid不能为空"
)
@ApiModelProperty
(
"应用appid"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"key"
)
private
String
appKey
;
@ApiModelProperty
(
"密钥"
)
private
String
appSecret
;
@ApiModelProperty
(
"app名称"
)
private
String
appName
;
@ApiModelProperty
(
"ios推送通道,友盟:1;firebase:2; apns原生:3"
)
private
Integer
iosPushChannel
;
@ApiModelProperty
(
"安卓推送通道,友盟:1;firebase:2; 信鸽3"
)
private
Integer
androidPushChannel
;
@ApiModelProperty
(
"友盟推送key"
)
private
String
umengKey
;
@ApiModelProperty
(
"友盟推送密钥"
)
private
String
umengSecret
;
@ApiModelProperty
(
"firebase推送密钥"
)
private
String
firebaseSecret
;
private
String
adminPwd
;
}
common/src/main/java/com/wecloud/im/tillo/app_ws/sender/PushTask.java
0 → 100644
View file @
9a31da94
package
com
.
wecloud
.
im
.
tillo
.
app_ws
.
sender
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.push.PushUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
/**
* 异步系统推送
*/
@Component
@Slf4j
public
class
PushTask
{
/**
* 异步系统推送
*
* @param imClientReceiver
* @param imClientSender
* @param imMessage
*/
@Async
public
void
push
(
ImClient
imClientReceiver
,
ImClient
imClientSender
,
ImMessage
imMessage
,
ImApplication
imApplication
)
{
log
.
debug
(
"push "
+
imClientReceiver
.
getClientId
());
// 校验参数
if
(
imClientReceiver
.
getValid
()
==
null
||
imClientReceiver
.
getDeviceToken
()
==
null
||
imClientReceiver
.
getDeviceType
()
==
null
)
{
log
.
debug
(
"push参数错误"
);
return
;
}
// 设备不想收到推送提醒, 1想, 0不想
if
(
imClientReceiver
.
getValid
()
==
0
)
{
return
;
}
// 设备类型1:ios; 2:android
if
(
imClientReceiver
.
getDeviceType
()
==
1
)
{
ios
(
imClientReceiver
,
imApplication
);
}
else
{
android
(
imClientReceiver
,
imApplication
);
}
}
private
void
android
(
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
// 安卓推送通道,友盟:1;firebase:2; 信鸽3
if
(
imApplication
.
getAndroidPushChannel
()
==
1
)
{
log
.
debug
(
"友盟"
);
// 友盟推送
PushUtils
pushUtils
=
new
PushUtils
(
imApplication
.
getUmengKey
(),
imApplication
.
getUmengSecret
());
// 安卓 单推
String
deviceTokenIOS
=
imClientReceiver
.
getDeviceToken
();
String
titleIOS
=
"收到新消息"
;
String
subtitle
=
""
;
String
body
=
"点击查看"
;
try
{
pushUtils
.
sendIOSUnicast
(
deviceTokenIOS
,
titleIOS
,
subtitle
,
body
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
imApplication
.
getAndroidPushChannel
()
==
2
)
{
//firebase:2
log
.
debug
(
"firebase"
);
}
else
if
(
imApplication
.
getAndroidPushChannel
()
==
3
)
{
// 信鸽3
log
.
debug
(
"信鸽3"
);
}
else
{
log
.
debug
(
"没有找到推送类型"
);
return
;
}
}
private
void
ios
(
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
// ios推送通道,友盟:1;firebase:2; apns原生:3
if
(
imApplication
.
getIosPushChannel
()
==
1
)
{
log
.
debug
(
"友盟"
);
// 友盟推送
PushUtils
pushUtils
=
new
PushUtils
(
imApplication
.
getUmengKey
(),
imApplication
.
getUmengSecret
());
// 安卓单推
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
unicastText
=
"Android unicast text"
;
String
unicastTicker
=
"点击查看"
;
String
title
=
"收到新消息"
;
try
{
pushUtils
.
sendAndroidUnicast
(
deviceToken
,
unicastText
,
unicastTicker
,
title
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
imApplication
.
getIosPushChannel
()
==
2
)
{
//firebase:2
log
.
debug
(
"firebase"
);
}
else
if
(
imApplication
.
getIosPushChannel
()
==
3
)
{
// apns原生:3
log
.
debug
(
"apns原生"
);
}
else
{
log
.
debug
(
"没有找到推送类型"
);
return
;
}
}
}
common/src/main/java/com/wecloud/im/tillo/app_ws/service/impl/WriteDataServiceImpl.java
View file @
9a31da94
...
@@ -9,6 +9,7 @@ import com.wecloud.im.tillo.app_ws.service.WriteDataService;
...
@@ -9,6 +9,7 @@ import com.wecloud.im.tillo.app_ws.service.WriteDataService;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -53,6 +54,7 @@ public class WriteDataServiceImpl implements WriteDataService {
...
@@ -53,6 +54,7 @@ public class WriteDataServiceImpl implements WriteDataService {
}
}
@Override
@Override
@Async
public
void
write
(
ResponseModel
responseModel
,
String
toAppKey
,
String
toClientId
)
{
public
void
write
(
ResponseModel
responseModel
,
String
toAppKey
,
String
toClientId
)
{
JsonMapper
jsonMapper
=
new
JsonMapper
();
JsonMapper
jsonMapper
=
new
JsonMapper
();
...
...
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
View file @
9a31da94
...
@@ -9,7 +9,6 @@ import com.wecloud.im.entity.ImConversationMembers;
...
@@ -9,7 +9,6 @@ import com.wecloud.im.entity.ImConversationMembers;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.push.PushUtils
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImConversationMembersService
;
import
com.wecloud.im.service.ImConversationMembersService
;
...
@@ -19,6 +18,7 @@ import com.wecloud.im.tillo.app_ws.annotation.ReceiveTypeAnnotation;
...
@@ -19,6 +18,7 @@ import com.wecloud.im.tillo.app_ws.annotation.ReceiveTypeAnnotation;
import
com.wecloud.im.tillo.app_ws.enums.WsRequestCmdEnum
;
import
com.wecloud.im.tillo.app_ws.enums.WsRequestCmdEnum
;
import
com.wecloud.im.tillo.app_ws.model.ResponseModel
;
import
com.wecloud.im.tillo.app_ws.model.ResponseModel
;
import
com.wecloud.im.tillo.app_ws.model.request.ReceiveModel
;
import
com.wecloud.im.tillo.app_ws.model.request.ReceiveModel
;
import
com.wecloud.im.tillo.app_ws.sender.PushTask
;
import
com.wecloud.im.tillo.app_ws.service.MangerChannelService
;
import
com.wecloud.im.tillo.app_ws.service.MangerChannelService
;
import
com.wecloud.im.tillo.app_ws.service.WriteDataService
;
import
com.wecloud.im.tillo.app_ws.service.WriteDataService
;
import
com.wecloud.im.tillo.app_ws.strategy.AbstractReceiveStrategy
;
import
com.wecloud.im.tillo.app_ws.strategy.AbstractReceiveStrategy
;
...
@@ -61,6 +61,9 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
...
@@ -61,6 +61,9 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
@Autowired
@Autowired
private
ImClientService
imClientService
;
private
ImClientService
imClientService
;
@Autowired
private
PushTask
pushTask
;
@Override
@Override
public
void
process
(
ReceiveModel
receiveModel
,
String
language
,
ChannelHandlerContext
ctx
,
String
data
)
{
public
void
process
(
ReceiveModel
receiveModel
,
String
language
,
ChannelHandlerContext
ctx
,
String
data
)
{
...
@@ -130,8 +133,7 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
...
@@ -130,8 +133,7 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
imMessageOnlineSend
.
setContent
(
receiveModel
.
getData
());
imMessageOnlineSend
.
setContent
(
receiveModel
.
getData
());
imMessageOnlineSend
.
setConversationId
(
toConversationId
);
imMessageOnlineSend
.
setConversationId
(
toConversationId
);
// 友盟推送
PushUtils
pushUtils
=
new
PushUtils
(
imApplication
.
getUmengKey
(),
imApplication
.
getUmengSecret
());
// 遍历发送
// 遍历发送
for
(
ImConversationMembers
conversationMembers
:
membersList
)
{
for
(
ImConversationMembers
conversationMembers
:
membersList
)
{
...
@@ -169,37 +171,8 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
...
@@ -169,37 +171,8 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
responseModel
.
setReqId
(
null
);
responseModel
.
setReqId
(
null
);
writeDataService
.
write
(
responseModel
,
appKey
,
imClientReceiver
.
getClientId
());
writeDataService
.
write
(
responseModel
,
appKey
,
imClientReceiver
.
getClientId
());
// 系统推送
// 异步推送
// 设备不想收到推送提醒, 1想, 0不想
pushTask
.
push
(
imClientReceiver
,
imClientSender
,
imMessage
,
imApplication
);
if
(
imClientReceiver
.
getValid
()
!=
null
&&
imClientReceiver
.
getValid
()
!=
0
&&
imClientReceiver
.
getDeviceToken
()
!=
null
)
{
// 设备类型1:ios; 2:android
if
(
imClientReceiver
.
getDeviceType
()
==
1
)
{
// ios 单推
String
deviceTokenIOS
=
imClientReceiver
.
getDeviceToken
();
String
titleIOS
=
"收到新消息"
;
String
subtitle
=
""
;
String
body
=
"点击查看"
;
try
{
pushUtils
.
sendIOSUnicast
(
deviceTokenIOS
,
titleIOS
,
subtitle
,
body
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
// 安卓单推
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
unicastText
=
"Android unicast text"
;
String
unicastTicker
=
"点击查看"
;
String
title
=
"收到新消息"
;
try
{
pushUtils
.
sendAndroidUnicast
(
deviceToken
,
unicastText
,
unicastTicker
,
title
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
// 响应发送方消息id等信息
// 响应发送方消息id等信息
...
@@ -209,7 +182,7 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
...
@@ -209,7 +182,7 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
responseModel
.
setCode
(
result
.
getCode
());
responseModel
.
setCode
(
result
.
getCode
());
responseModel
.
setMsg
(
result
.
getMessage
());
responseModel
.
setMsg
(
result
.
getMessage
());
HashMap
<
String
,
Long
>
stringHashMap
=
new
HashMap
<
String
,
Long
>();
HashMap
<
String
,
Long
>
stringHashMap
=
new
HashMap
<>();
stringHashMap
.
put
(
"msgId"
,
messageId
);
stringHashMap
.
put
(
"msgId"
,
messageId
);
responseModel
.
setData
(
stringHashMap
);
responseModel
.
setData
(
stringHashMap
);
...
@@ -217,4 +190,6 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
...
@@ -217,4 +190,6 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
writeDataService
.
write
(
responseModel
,
appKey
,
clientUniId
);
writeDataService
.
write
(
responseModel
,
appKey
,
clientUniId
);
}
}
}
}
common/src/main/resources/mapper/ImApplicationMapper.xml
View file @
9a31da94
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
<!-- 通用查询结果列 -->
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id
id
, create_time, update_time, app_key, app_secret, app_name, ios_push, android_push,umeng_key,umeng_secret
, create_time, update_time, app_key, app_secret, app_name, ios_push_channel, android_push_channel,umeng_key,umeng_secret,firebase_secret
</sql>
</sql>
<select
id=
"getImApplicationById"
resultType=
"com.wecloud.im.param.ImApplicationQueryVo"
>
<select
id=
"getImApplicationById"
resultType=
"com.wecloud.im.param.ImApplicationQueryVo"
>
...
...
config/src/main/java/io/geekidea/springbootplus/config/constant/CommonConstant.java
View file @
9a31da94
...
@@ -37,7 +37,7 @@ public interface CommonConstant {
...
@@ -37,7 +37,7 @@ public interface CommonConstant {
/**
/**
* 数量最大为100
* 数量最大为100
*/
*/
Long
MAX_PAGE_SIZE
=
100L
;
Long
MAX_PAGE_SIZE
=
100
0
L
;
/**
/**
...
...
config/src/main/resources/config/application.yml
View file @
9a31da94
...
@@ -195,6 +195,8 @@ spring-boot-plus:
...
@@ -195,6 +195,8 @@ spring-boot-plus:
# - /actuator/**
# - /actuator/**
-
# 排除首页
-
# 排除首页
-
/,/index.html
-
/,/index.html
# 应用相关
-
/imApplication/**
# 多行字符串权限配置
# 多行字符串权限配置
filter-chain-definitions
:
|
filter-chain-definitions
:
|
...
...
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