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
2fcc10da
Commit
2fcc10da
authored
Mar 02, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增终端设备表
parent
dd7d397b
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
254 additions
and
415 deletions
+254
-415
bootstrap/src/test/java/io/geekidea/springbootplus/test/LoginTest.java
+2
-2
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+3
-1
core/src/main/java/com/wecloud/im/controller/ImClientController.java
+6
-6
core/src/main/java/com/wecloud/im/entity/ImClient.java
+1
-16
core/src/main/java/com/wecloud/im/entity/ImClientDevice.java
+5
-1
core/src/main/java/com/wecloud/im/enums/DeviceTypeEnum.java
+10
-5
core/src/main/java/com/wecloud/im/externalaccess/param/UserLoginParam.java
+2
-3
core/src/main/java/com/wecloud/im/externalaccess/service/UserService.java
+24
-14
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
+6
-2
core/src/main/java/com/wecloud/im/mapper/ImClientDeviceMapper.java
+9
-0
core/src/main/java/com/wecloud/im/mq/MqSender.java
+44
-17
core/src/main/java/com/wecloud/im/param/LogoutParam.java
+36
-0
core/src/main/java/com/wecloud/im/param/add/ClientDeviceUpdateParam.java
+9
-2
core/src/main/java/com/wecloud/im/service/ImClientDeviceService.java
+8
-0
core/src/main/java/com/wecloud/im/service/ImClientService.java
+9
-3
core/src/main/java/com/wecloud/im/service/impl/ImClientDeviceServiceImpl.java
+8
-0
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+29
-46
core/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
+2
-2
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+6
-6
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+10
-8
core/src/main/java/com/wecloud/im/thousandchat/action/ThousandChatAction.java
+10
-4
core/src/main/java/com/wecloud/im/ws/sender/AsyncPush.java
+0
-272
core/src/main/resources/mapper/ImClientDeviceMapper.xml
+8
-0
docs/db/feature-cluster增量.sql
+6
-4
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
+1
-1
No files found.
bootstrap/src/test/java/io/geekidea/springbootplus/test/LoginTest.java
View file @
2fcc10da
...
@@ -5,7 +5,7 @@ import cn.hutool.crypto.digest.MD5;
...
@@ -5,7 +5,7 @@ import cn.hutool.crypto.digest.MD5;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.enums.
Platform
Enum
;
import
com.wecloud.im.enums.
DeviceType
Enum
;
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.ws.utils.RedisUtils
;
import
com.wecloud.im.ws.utils.RedisUtils
;
...
@@ -85,7 +85,7 @@ public class LoginTest {
...
@@ -85,7 +85,7 @@ public class LoginTest {
}
}
// 生成token
// 生成token
String
generateToken
=
JwtUtil
.
generateToken
(
clientId
,
appKey
,
imApplication
.
getAppSecret
(),
Duration
.
ofDays
(
99999
),
Platform
Enum
.
WEB
.
getCode
());
String
generateToken
=
JwtUtil
.
generateToken
(
clientId
,
appKey
,
imApplication
.
getAppSecret
(),
Duration
.
ofDays
(
99999
),
DeviceType
Enum
.
WEB
.
getCode
());
// 保存redis
// 保存redis
redisTemplate
.
opsForValue
().
set
(
"client:"
+
imApplication
.
getAppKey
()
+
":"
+
clientId
,
generateToken
);
redisTemplate
.
opsForValue
().
set
(
"client:"
+
imApplication
.
getAppKey
()
+
":"
+
clientId
,
generateToken
);
...
...
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
2fcc10da
...
@@ -152,7 +152,9 @@ public class NormalChatAction {
...
@@ -152,7 +152,9 @@ public class NormalChatAction {
// 异步推送系统通知消息
// 异步推送系统通知消息
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
data
.
getPush
(),
imClientReceiver
,
imApplication
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
data
.
getPush
(),
imClientReceiver
,
imApplication
);
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
if
(
pushDTO
!=
null
)
{
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
}
}
}
// 响应发送方消息id等信息
// 响应发送方消息id等信息
...
...
core/src/main/java/com/wecloud/im/controller/ImClientController.java
View file @
2fcc10da
...
@@ -2,11 +2,11 @@ package com.wecloud.im.controller;
...
@@ -2,11 +2,11 @@ package com.wecloud.im.controller;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.friend.param.ImFriendApplyDto
;
import
com.wecloud.im.param.ClientInfoParam
;
import
com.wecloud.im.param.ClientInfoParam
;
import
com.wecloud.im.param.GetClientInfoParam
;
import
com.wecloud.im.param.GetClientInfoParam
;
import
com.wecloud.im.param.GetOnlineStatusParam
;
import
com.wecloud.im.param.GetOnlineStatusParam
;
import
com.wecloud.im.param.add.ImClientDeviceInfoAdd
;
import
com.wecloud.im.param.LogoutParam
;
import
com.wecloud.im.param.add.ClientDeviceUpdateParam
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
...
@@ -93,7 +93,7 @@ public class ImClientController extends BaseController {
...
@@ -93,7 +93,7 @@ public class ImClientController extends BaseController {
*/
*/
@PostMapping
(
"/addDeviceInfo"
)
@PostMapping
(
"/addDeviceInfo"
)
@ApiOperation
(
value
=
"添加或修改推送设备信息(每次请求都会覆盖之前的数据)"
)
@ApiOperation
(
value
=
"添加或修改推送设备信息(每次请求都会覆盖之前的数据)"
)
public
ApiResult
<
Boolean
>
addDeviceInfo
(
@Validated
(
Add
.
class
)
@RequestBody
ImClientDeviceInfoAdd
imClientDevice
)
throws
Exception
{
public
ApiResult
<
Boolean
>
addDeviceInfo
(
@Validated
(
Add
.
class
)
@RequestBody
ClientDeviceUpdateParam
imClientDevice
)
throws
Exception
{
boolean
flag
=
imClientService
.
updateDeviceInfo
(
imClientDevice
);
boolean
flag
=
imClientService
.
updateDeviceInfo
(
imClientDevice
);
return
ApiResult
.
result
(
flag
);
return
ApiResult
.
result
(
flag
);
}
}
...
@@ -130,8 +130,8 @@ public class ImClientController extends BaseController {
...
@@ -130,8 +130,8 @@ public class ImClientController extends BaseController {
*/
*/
@PostMapping
(
"/logout"
)
@PostMapping
(
"/logout"
)
@ApiOperation
(
value
=
"退出登陆 清除推送token等"
)
@ApiOperation
(
value
=
"退出登陆 清除推送token等"
)
public
ApiResult
<
Boolean
>
logout
()
throws
Exception
{
public
ApiResult
<
Boolean
>
logout
(
@RequestBody
@Validated
LogoutParam
param
)
throws
Exception
{
boolean
flag
=
imClientService
.
logout
();
boolean
flag
=
imClientService
.
logout
(
param
);
return
ApiResult
.
result
(
flag
);
return
ApiResult
.
result
(
flag
);
}
}
...
@@ -144,7 +144,7 @@ public class ImClientController extends BaseController {
...
@@ -144,7 +144,7 @@ public class ImClientController extends BaseController {
@ApiOperation
(
value
=
"获取用户在线状态(批量)"
)
@ApiOperation
(
value
=
"获取用户在线状态(批量)"
)
ApiResult
<
List
<
ImOnlineStatusVo
>>
getOnlineStatus
(
@RequestBody
GetOnlineStatusParam
getOnlineStatusParam
)
{
ApiResult
<
List
<
ImOnlineStatusVo
>>
getOnlineStatus
(
@RequestBody
GetOnlineStatusParam
getOnlineStatusParam
)
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询appid
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
...
core/src/main/java/com/wecloud/im/entity/ImClient.java
View file @
2fcc10da
...
@@ -48,25 +48,10 @@ public class ImClient extends BaseEntity {
...
@@ -48,25 +48,10 @@ public class ImClient extends BaseEntity {
@ApiModelProperty
(
"客户方提供的唯一id"
)
@ApiModelProperty
(
"客户方提供的唯一id"
)
private
String
clientId
;
private
String
clientId
;
@ApiModelProperty
(
"设备不想收到推送提醒, 1想, 0不想"
)
private
Integer
valid
;
@ApiModelProperty
(
"设备类型1:ios; 2:android"
)
private
Integer
deviceType
;
@ApiModelProperty
(
"设备推送token"
)
private
String
deviceToken
;
@ApiModelProperty
(
"头像"
)
@ApiModelProperty
(
"头像"
)
private
String
headPortrait
;
private
String
headPortrait
;
@ApiModelProperty
(
"主昵称"
)
@ApiModelProperty
(
"主昵称"
)
private
String
nickname
;
private
String
nickname
;
/**
* 客户端平台
* @see com.wecloud.im.enums.PlatformEnum
*/
@NotNull
(
message
=
"平台不可为空"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs"
)
private
Integer
platform
;
}
}
core/src/main/java/com/wecloud/im/entity/ImClientDevice.java
View file @
2fcc10da
...
@@ -2,6 +2,7 @@ package com.wecloud.im.entity;
...
@@ -2,6 +2,7 @@ package com.wecloud.im.entity;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.wecloud.im.enums.DeviceTypeEnum
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -30,6 +31,9 @@ public class ImClientDevice extends BaseEntity {
...
@@ -30,6 +31,9 @@ public class ImClientDevice extends BaseEntity {
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
private
Long
id
;
@ApiModelProperty
(
"应用appid"
)
private
Long
fkAppid
;
@ApiModelProperty
(
"client主键id"
)
@ApiModelProperty
(
"client主键id"
)
private
Long
fkClientId
;
private
Long
fkClientId
;
...
@@ -47,7 +51,7 @@ public class ImClientDevice extends BaseEntity {
...
@@ -47,7 +51,7 @@ public class ImClientDevice extends BaseEntity {
/**
/**
* 客户端平台
* 客户端平台
* @see
com.wecloud.im.enums.Platform
Enum
* @see
DeviceType
Enum
*/
*/
@NotNull
(
message
=
"平台不可为空"
)
@NotNull
(
message
=
"平台不可为空"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs"
)
...
...
core/src/main/java/com/wecloud/im/enums/
Platform
Enum.java
→
core/src/main/java/com/wecloud/im/enums/
DeviceType
Enum.java
View file @
2fcc10da
...
@@ -2,18 +2,23 @@ package com.wecloud.im.enums;
...
@@ -2,18 +2,23 @@ package com.wecloud.im.enums;
import
io.geekidea.springbootplus.framework.common.enums.BaseEnum
;
import
io.geekidea.springbootplus.framework.common.enums.BaseEnum
;
public
enum
PlatformEnum
implements
BaseEnum
{
/**
* @Author wenzhida
WEB
(
1
,
"web端"
),
* @Date 2022/3/2 17:15
* @Description 设备类型枚举
*/
public
enum
DeviceTypeEnum
implements
BaseEnum
{
IOS
(
1
,
"IOS端"
),
ANDROID
(
2
,
"安卓端"
),
ANDROID
(
2
,
"安卓端"
),
IOS
(
3
,
"IOS
端"
),
WEB
(
3
,
"web
端"
),
WIN
(
4
,
"PC-windows端"
),
WIN
(
4
,
"PC-windows端"
),
MAC
(
5
,
"PC-macOs端"
);
MAC
(
5
,
"PC-macOs端"
);
private
final
Integer
code
;
private
final
Integer
code
;
private
final
String
desc
;
private
final
String
desc
;
Platform
Enum
(
Integer
code
,
String
desc
)
{
DeviceType
Enum
(
Integer
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
code
=
code
;
this
.
desc
=
desc
;
this
.
desc
=
desc
;
}
}
...
...
core/src/main/java/com/wecloud/im/externalaccess/param/UserLoginParam.java
View file @
2fcc10da
package
com
.
wecloud
.
im
.
externalaccess
.
param
;
package
com
.
wecloud
.
im
.
externalaccess
.
param
;
import
com.wecloud.im.enums.DeviceTypeEnum
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -36,12 +37,10 @@ public class UserLoginParam implements Serializable {
...
@@ -36,12 +37,10 @@ public class UserLoginParam implements Serializable {
/**
/**
* 客户端平台
* 客户端平台
* @see
com.wecloud.im.enums.Platform
Enum
* @see
DeviceType
Enum
*/
*/
@NotNull
(
message
=
"平台不可为空"
)
@NotNull
(
message
=
"平台不可为空"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs"
)
private
Integer
platform
;
private
Integer
platform
;
@ApiModelProperty
(
"设备推送token"
)
private
String
deviceToken
;
}
}
core/src/main/java/com/wecloud/im/externalaccess/service/UserService.java
View file @
2fcc10da
...
@@ -3,19 +3,12 @@ package com.wecloud.im.externalaccess.service;
...
@@ -3,19 +3,12 @@ package com.wecloud.im.externalaccess.service;
import
cn.hutool.core.lang.Snowflake
;
import
cn.hutool.core.lang.Snowflake
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.wecloud.im.constant.NumberConstant
;
import
com.wecloud.im.constant.NumberConstant
;
import
com.wecloud.im.constant.RedisKeyPrefixConstant
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.enums.FriendStateEnum
;
import
com.wecloud.im.enums.FriendStateEnum
;
import
com.wecloud.im.enums.RelationEnum
;
import
com.wecloud.im.enums.RelationEnum
;
import
com.wecloud.im.enums.VerifySceneEnum
;
import
com.wecloud.im.enums.VerifySceneEnum
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.service.ImFriendService
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientNicknameUpdate
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.constant.RedisKeyPrefixConstant
;
import
com.wecloud.im.externalaccess.entity.User
;
import
com.wecloud.im.externalaccess.entity.User
;
import
com.wecloud.im.externalaccess.mapper.UserMapper
;
import
com.wecloud.im.externalaccess.mapper.UserMapper
;
import
com.wecloud.im.externalaccess.param.ChangePhoneParam
;
import
com.wecloud.im.externalaccess.param.ChangePhoneParam
;
...
@@ -31,6 +24,13 @@ import com.wecloud.im.externalaccess.param.ResetPasswordParam;
...
@@ -31,6 +24,13 @@ import com.wecloud.im.externalaccess.param.ResetPasswordParam;
import
com.wecloud.im.externalaccess.param.UserBaseDto
;
import
com.wecloud.im.externalaccess.param.UserBaseDto
;
import
com.wecloud.im.externalaccess.param.UserLoginParam
;
import
com.wecloud.im.externalaccess.param.UserLoginParam
;
import
com.wecloud.im.externalaccess.param.UserRegisterParam
;
import
com.wecloud.im.externalaccess.param.UserRegisterParam
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.service.ImFriendService
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientNicknameUpdate
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.ws.utils.RedisUtils
;
import
com.wecloud.im.ws.utils.RedisUtils
;
import
com.wecloud.utils.AesUtil
;
import
com.wecloud.utils.AesUtil
;
import
com.wecloud.utils.RandomUtil
;
import
com.wecloud.utils.RandomUtil
;
...
@@ -71,6 +71,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -71,6 +71,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 校验手机号码是否可使用
* 校验手机号码是否可使用
*
* @param param
* @param param
*/
*/
public
Boolean
checkPhone
(
CheckPhoneParam
param
)
{
public
Boolean
checkPhone
(
CheckPhoneParam
param
)
{
...
@@ -84,6 +85,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -84,6 +85,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 注册用户
* 注册用户
*
* @param param
* @param param
*/
*/
public
String
registerUser
(
UserRegisterParam
param
)
{
public
String
registerUser
(
UserRegisterParam
param
)
{
...
@@ -108,6 +110,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -108,6 +110,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 用户登录
* 用户登录
*
* @param param
* @param param
*/
*/
public
LoginSuccessDto
loginUser
(
UserLoginParam
param
)
{
public
LoginSuccessDto
loginUser
(
UserLoginParam
param
)
{
...
@@ -136,11 +139,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -136,11 +139,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
imClient
.
setClientId
(
user
.
getId
().
toString
());
imClient
.
setClientId
(
user
.
getId
().
toString
());
imClient
.
setHeadPortrait
(
user
.
getHeadPortrait
());
imClient
.
setHeadPortrait
(
user
.
getHeadPortrait
());
imClient
.
setNickname
(
user
.
getNickname
());
imClient
.
setNickname
(
user
.
getNickname
());
imClient
.
setPlatform
(
param
.
getPlatform
());
imClientService
.
save
(
imClient
);
imClientService
.
save
(
imClient
);
}
else
{
imClient
.
setPlatform
(
param
.
getPlatform
());
imClientService
.
updateById
(
imClient
);
}
}
LoginSuccessDto
loginSuccessDto
=
new
LoginSuccessDto
();
LoginSuccessDto
loginSuccessDto
=
new
LoginSuccessDto
();
...
@@ -151,6 +150,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -151,6 +150,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 重置密码
* 重置密码
*
* @param param
* @param param
*/
*/
public
void
resetPassword
(
ResetPasswordParam
param
)
{
public
void
resetPassword
(
ResetPasswordParam
param
)
{
...
@@ -167,6 +167,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -167,6 +167,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 更换手机号码
* 更换手机号码
*
* @param param
* @param param
*/
*/
public
void
changePhone
(
ChangePhoneParam
param
)
{
public
void
changePhone
(
ChangePhoneParam
param
)
{
...
@@ -208,6 +209,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -208,6 +209,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 查找用户
* 查找用户
*
* @param param
* @param param
*/
*/
public
UserBaseDto
findUser
(
FindUserParam
param
)
{
public
UserBaseDto
findUser
(
FindUserParam
param
)
{
...
@@ -239,6 +241,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -239,6 +241,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 查找用户
* 查找用户
*
* @param param
* @param param
*/
*/
public
UserBaseDto
getUserByUserId
(
GetUserParam
param
)
{
public
UserBaseDto
getUserByUserId
(
GetUserParam
param
)
{
...
@@ -266,6 +269,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -266,6 +269,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 修改头像
* 修改头像
*
* @param param
* @param param
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -283,6 +287,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -283,6 +287,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 修改昵称
* 修改昵称
*
* @param param
* @param param
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -303,6 +308,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -303,6 +308,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 修改昵称
* 修改昵称
*
* @param param
* @param param
*/
*/
public
void
modifyLandouNo
(
ModifyLandouParam
param
)
{
public
void
modifyLandouNo
(
ModifyLandouParam
param
)
{
...
@@ -323,6 +329,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -323,6 +329,7 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 修改性别
* 修改性别
*
* @param param
* @param param
*/
*/
public
void
modifySex
(
ModifySexParam
param
)
{
public
void
modifySex
(
ModifySexParam
param
)
{
...
@@ -336,16 +343,18 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -336,16 +343,18 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 根据蓝豆号获取用户
* 根据蓝豆号获取用户
*
* @param landouNo
* @param landouNo
* @return
* @return
*/
*/
public
User
getByLandouNo
(
String
landouNo
)
{
public
User
getByLandouNo
(
String
landouNo
)
{
return
this
.
getOne
(
new
QueryWrapper
<
User
>().
lambda
()
return
this
.
getOne
(
new
QueryWrapper
<
User
>().
lambda
()
.
eq
(
User:
:
getIdNumber
,
landouNo
));
.
eq
(
User:
:
getIdNumber
,
landouNo
));
}
}
/**
/**
* 校验短信验证码
* 校验短信验证码
*
* @param verifyCode
* @param verifyCode
* @param redisKey
* @param redisKey
*/
*/
...
@@ -359,9 +368,10 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
...
@@ -359,9 +368,10 @@ public class UserService extends BaseServiceImpl<UserMapper, User> {
/**
/**
* 获取可使用蓝豆号
* 获取可使用蓝豆号
*
* @return
* @return
*/
*/
private
String
getLandouNo
()
{
private
String
getLandouNo
()
{
String
landouNo
;
String
landouNo
;
do
{
do
{
landouNo
=
RandomUtil
.
generateRandomStr
(
8
);
landouNo
=
RandomUtil
.
generateRandomStr
(
8
);
...
...
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
View file @
2fcc10da
...
@@ -66,7 +66,9 @@ public class FriendEventSender {
...
@@ -66,7 +66,9 @@ public class FriendEventSender {
pushVO
.
setTitle
(
FRIEND_APPLY_TITLE
);
pushVO
.
setTitle
(
FRIEND_APPLY_TITLE
);
pushVO
.
setSubTitle
(
FRIEND_APPLY_TITLE_SUB
);
pushVO
.
setSubTitle
(
FRIEND_APPLY_TITLE_SUB
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
pushVO
,
receiveClient
,
app
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
pushVO
,
receiveClient
,
app
);
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
if
(
pushDTO
!=
null
)
{
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
}
}
}
public
void
sendFriendApproveEventMsg
(
ImClient
claimerClient
,
ImClient
receiveClient
,
boolean
isAgree
,
String
rejectRemark
)
{
public
void
sendFriendApproveEventMsg
(
ImClient
claimerClient
,
ImClient
receiveClient
,
boolean
isAgree
,
String
rejectRemark
)
{
...
@@ -94,6 +96,8 @@ public class FriendEventSender {
...
@@ -94,6 +96,8 @@ public class FriendEventSender {
pushVO
.
setTitle
(
FRIEND_APPROVE_TITLE
);
pushVO
.
setTitle
(
FRIEND_APPROVE_TITLE
);
pushVO
.
setSubTitle
(
isAgree
?
FRIEND_APPROVE_TITLE_AGREE
:
FRIEND_APPROVE_TITLE_REJECT
);
pushVO
.
setSubTitle
(
isAgree
?
FRIEND_APPROVE_TITLE_AGREE
:
FRIEND_APPROVE_TITLE_REJECT
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
pushVO
,
receiveClient
,
app
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
pushVO
,
receiveClient
,
app
);
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
if
(
pushDTO
!=
null
)
{
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
}
}
}
}
}
core/src/main/java/com/wecloud/im/mapper/ImClientDeviceMapper.java
View file @
2fcc10da
...
@@ -2,6 +2,7 @@ package com.wecloud.im.mapper;
...
@@ -2,6 +2,7 @@ package com.wecloud.im.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.wecloud.im.entity.ImClientDevice
;
import
com.wecloud.im.entity.ImClientDevice
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
/**
/**
...
@@ -12,4 +13,12 @@ import org.springframework.stereotype.Repository;
...
@@ -12,4 +13,12 @@ import org.springframework.stereotype.Repository;
@Repository
@Repository
public
interface
ImClientDeviceMapper
extends
BaseMapper
<
ImClientDevice
>
{
public
interface
ImClientDeviceMapper
extends
BaseMapper
<
ImClientDevice
>
{
/**
* 清除旧token
* @param appId
* @param deviceToken
* @return
*/
int
removeOldToken
(
@Param
(
"appId"
)
Long
appId
,
@Param
(
"deviceToken"
)
String
deviceToken
);
}
}
core/src/main/java/com/wecloud/im/mq/MqSender.java
View file @
2fcc10da
package
com
.
wecloud
.
im
.
mq
;
package
com
.
wecloud
.
im
.
mq
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClientDevice
;
import
com.wecloud.im.entity.ImConversationMembers
;
import
com.wecloud.im.service.ImClientDeviceService
;
import
com.wecloud.im.service.ImInboxService
;
import
com.wecloud.im.service.ImInboxService
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.pushserver.client.model.constant.MqConstant
;
import
com.wecloud.pushserver.client.model.constant.MqConstant
;
import
com.wecloud.pushserver.client.model.dto.ApplicationDTO
;
import
com.wecloud.pushserver.client.model.dto.ClientDTO
;
import
com.wecloud.pushserver.client.model.dto.ClientDeviceDTO
;
import
com.wecloud.pushserver.client.model.dto.ImApplicationDTO
;
import
com.wecloud.pushserver.client.model.dto.ImApplicationDTO
;
import
com.wecloud.pushserver.client.model.dto.ImClientDTO
;
import
com.wecloud.pushserver.client.model.dto.ImClientDTO
;
import
com.wecloud.pushserver.client.model.dto.MessageDTO
;
import
com.wecloud.pushserver.client.model.dto.MessageDTO
;
import
com.wecloud.pushserver.client.model.dto.PushDTO
;
import
com.wecloud.pushserver.client.model.dto.PushDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_BODY
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_BODY
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_TITLE
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_TITLE
;
...
@@ -34,8 +44,12 @@ public class MqSender {
...
@@ -34,8 +44,12 @@ public class MqSender {
@Autowired
@Autowired
private
RocketMqProducerService
rocketMqProducerService
;
private
RocketMqProducerService
rocketMqProducerService
;
@Autowired
private
ImClientDeviceService
imClientDeviceService
;
/**
/**
* mq同步推送方法
* mq同步推送方法
*
* @param topic
* @param topic
* @param tag
* @param tag
* @param pushDTO
* @param pushDTO
...
@@ -50,6 +64,7 @@ public class MqSender {
...
@@ -50,6 +64,7 @@ public class MqSender {
/**
/**
* mq异步推送方法
* mq异步推送方法
*
* @param topic
* @param topic
* @param tag
* @param tag
* @param pushDTO
* @param pushDTO
...
@@ -62,6 +77,7 @@ public class MqSender {
...
@@ -62,6 +77,7 @@ public class MqSender {
/**
/**
* mq按顺序发送
* mq按顺序发送
*
* @param topic
* @param topic
* @param tag
* @param tag
* @param pushDTO
* @param pushDTO
...
@@ -89,23 +105,34 @@ public class MqSender {
...
@@ -89,23 +105,34 @@ public class MqSender {
// 统计未读消息数量
// 统计未读消息数量
int
badge
=
imInboxService
.
countMyNotReadCount
(
imClientReceiver
.
getId
());
int
badge
=
imInboxService
.
countMyNotReadCount
(
imClientReceiver
.
getId
());
messageDTO
.
setBadge
(
badge
);
messageDTO
.
setBadge
(
badge
);
ImClientDTO
imClientDTO
=
new
ImClientDTO
();
ClientDTO
clientDTO
=
new
ClientDTO
();
imClientDTO
.
setClientId
(
imClientReceiver
.
getClientId
());
clientDTO
.
setClientId
(
imClientReceiver
.
getClientId
());
imClientDTO
.
setValid
(
imClientReceiver
.
getValid
());
List
<
ImClientDevice
>
clientDeviceList
=
imClientDeviceService
.
list
(
imClientDTO
.
setDeviceType
(
imClientReceiver
.
getDeviceType
());
new
QueryWrapper
<
ImClientDevice
>().
lambda
()
imClientDTO
.
setDeviceToken
(
imClientReceiver
.
getDeviceToken
());
.
eq
(
ImClientDevice:
:
getFkClientId
,
imClientReceiver
.
getId
()));
messageDTO
.
setImClientDTO
(
imClientDTO
);
if
(
CollectionUtils
.
isEmpty
(
clientDeviceList
))
{
ImApplicationDTO
imApplicationDTO
=
new
ImApplicationDTO
();
return
null
;
imApplicationDTO
.
setId
(
imApplication
.
getId
());
}
imApplicationDTO
.
setAppKey
(
imApplication
.
getAppKey
());
List
<
ClientDeviceDTO
>
deviceDTOList
=
Lists
.
newArrayList
();
imApplicationDTO
.
setAppSecret
(
imApplication
.
getAppSecret
());
for
(
ImClientDevice
imClientDevice
:
clientDeviceList
)
{
imApplicationDTO
.
setAppName
(
imApplication
.
getAppName
());
ClientDeviceDTO
clientDeviceDTO
=
new
ClientDeviceDTO
();
imApplicationDTO
.
setIosPushChannel
(
imApplication
.
getIosPushChannel
());
clientDeviceDTO
.
setValid
(
imClientDevice
.
getValid
());
imApplicationDTO
.
setAndroidPushChannel
(
imApplication
.
getAndroidPushChannel
());
clientDeviceDTO
.
setDeviceType
(
imClientDevice
.
getDeviceType
());
imApplicationDTO
.
setUmengKey
(
imApplication
.
getUmengKey
());
clientDeviceDTO
.
setDeviceToken
(
imClientDevice
.
getDeviceToken
());
imApplicationDTO
.
setUmengSecret
(
imApplication
.
getUmengSecret
());
}
imApplicationDTO
.
setFirebaseSecret
(
imApplication
.
getFirebaseSecret
());
clientDTO
.
setDeviceDTOList
(
deviceDTOList
);
messageDTO
.
setImApplicationDTO
(
imApplicationDTO
);
messageDTO
.
setClientDTO
(
clientDTO
);
ApplicationDTO
applicationDTO
=
new
ApplicationDTO
();
applicationDTO
.
setId
(
imApplication
.
getId
());
applicationDTO
.
setAppKey
(
imApplication
.
getAppKey
());
applicationDTO
.
setAppSecret
(
imApplication
.
getAppSecret
());
applicationDTO
.
setAppName
(
imApplication
.
getAppName
());
applicationDTO
.
setIosPushChannel
(
imApplication
.
getIosPushChannel
());
applicationDTO
.
setAndroidPushChannel
(
imApplication
.
getAndroidPushChannel
());
applicationDTO
.
setUmengKey
(
imApplication
.
getUmengKey
());
applicationDTO
.
setUmengSecret
(
imApplication
.
getUmengSecret
());
applicationDTO
.
setFirebaseSecret
(
imApplication
.
getFirebaseSecret
());
messageDTO
.
setApplicationDTO
(
applicationDTO
);
pushDTO
.
setMessageDTOList
(
Lists
.
newArrayList
(
messageDTO
));
pushDTO
.
setMessageDTOList
(
Lists
.
newArrayList
(
messageDTO
));
return
pushDTO
;
return
pushDTO
;
}
}
...
...
core/src/main/java/com/wecloud/im/param/LogoutParam.java
0 → 100644
View file @
2fcc10da
package
com
.
wecloud
.
im
.
param
;
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
;
/**
* 添加或修改推送设备信息
*
* @author wei
* @since 2021-04-27
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"添加或修改推送设备信息"
)
public
class
LogoutParam
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
2718673661281424767L
;
/**
* 设备类型
* @see com.wecloud.im.enums.DeviceTypeEnum
*/
@ApiModelProperty
(
"设备类型 1:ios; 2:android; 3:web; 4:win; 5:mac"
)
@NotNull
(
message
=
"设备类型不能为空"
)
private
Integer
deviceType
;
@ApiModelProperty
(
"唯一设备id"
)
private
String
uniqueDeviceId
;
}
core/src/main/java/com/wecloud/im/param/add/
ImClientDeviceInfoAdd
.java
→
core/src/main/java/com/wecloud/im/param/add/
ClientDeviceUpdateParam
.java
View file @
2fcc10da
...
@@ -17,15 +17,22 @@ import lombok.experimental.Accessors;
...
@@ -17,15 +17,22 @@ import lombok.experimental.Accessors;
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"添加或修改推送设备信息"
)
@ApiModel
(
value
=
"添加或修改推送设备信息"
)
public
class
ImClientDeviceInfoAdd
extends
BaseEntity
{
public
class
ClientDeviceUpdateParam
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"设备不想收到推送提醒, 1想, 0不想"
)
@ApiModelProperty
(
"设备不想收到推送提醒, 1想, 0不想"
)
private
Integer
valid
;
private
Integer
valid
;
@ApiModelProperty
(
"设备类型1:ios; 2:android; 3:web"
)
/**
* 设备类型
* @see com.wecloud.im.enums.DeviceTypeEnum
*/
@ApiModelProperty
(
"设备类型 1:ios; 2:android; 3:web; 4:win; 5:mac"
)
private
Integer
deviceType
;
private
Integer
deviceType
;
@ApiModelProperty
(
"设备推送token"
)
@ApiModelProperty
(
"设备推送token"
)
private
String
deviceToken
;
private
String
deviceToken
;
@ApiModelProperty
(
"唯一设备id"
)
private
String
uniqueDeviceId
;
}
}
core/src/main/java/com/wecloud/im/service/ImClientDeviceService.java
View file @
2fcc10da
...
@@ -10,4 +10,12 @@ import io.geekidea.springbootplus.framework.common.service.BaseService;
...
@@ -10,4 +10,12 @@ import io.geekidea.springbootplus.framework.common.service.BaseService;
*/
*/
public
interface
ImClientDeviceService
extends
BaseService
<
ImClientDevice
>
{
public
interface
ImClientDeviceService
extends
BaseService
<
ImClientDevice
>
{
/**
* 清除旧token
* @param appId
* @param deviceToken
* @return
*/
int
removeOldToken
(
Long
appId
,
String
deviceToken
);
}
}
core/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
2fcc10da
...
@@ -6,7 +6,8 @@ import com.wecloud.im.param.GetClientInfoParam;
...
@@ -6,7 +6,8 @@ import com.wecloud.im.param.GetClientInfoParam;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.add.ImClientDeviceInfoAdd
;
import
com.wecloud.im.param.LogoutParam
;
import
com.wecloud.im.param.add.ClientDeviceUpdateParam
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
...
@@ -85,9 +86,14 @@ public interface ImClientService extends BaseService<ImClient> {
...
@@ -85,9 +86,14 @@ public interface ImClientService extends BaseService<ImClient> {
* @param imClientDevice
* @param imClientDevice
* @return
* @return
*/
*/
boolean
updateDeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
);
boolean
updateDeviceInfo
(
ClientDeviceUpdateParam
imClientDevice
);
boolean
logout
();
/**
* 登出操作
* @param param
* @return
*/
boolean
logout
(
LogoutParam
param
);
/**
/**
...
...
core/src/main/java/com/wecloud/im/service/impl/ImClientDeviceServiceImpl.java
View file @
2fcc10da
...
@@ -5,6 +5,7 @@ import com.wecloud.im.mapper.ImClientDeviceMapper;
...
@@ -5,6 +5,7 @@ import com.wecloud.im.mapper.ImClientDeviceMapper;
import
com.wecloud.im.service.ImClientDeviceService
;
import
com.wecloud.im.service.ImClientDeviceService
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
/**
/**
...
@@ -16,5 +17,12 @@ import org.springframework.stereotype.Service;
...
@@ -16,5 +17,12 @@ import org.springframework.stereotype.Service;
@Service
@Service
public
class
ImClientDeviceServiceImpl
extends
BaseServiceImpl
<
ImClientDeviceMapper
,
ImClientDevice
>
implements
ImClientDeviceService
{
public
class
ImClientDeviceServiceImpl
extends
BaseServiceImpl
<
ImClientDeviceMapper
,
ImClientDevice
>
implements
ImClientDeviceService
{
@Autowired
private
ImClientDeviceMapper
imClientDeviceMapper
;
@Override
public
int
removeOldToken
(
Long
appId
,
String
deviceToken
)
{
return
imClientDeviceMapper
.
removeOldToken
(
appId
,
deviceToken
);
}
}
}
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
2fcc10da
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClientDevice
;
import
com.wecloud.im.enums.FriendStateEnum
;
import
com.wecloud.im.enums.FriendStateEnum
;
import
com.wecloud.im.enums.RelationEnum
;
import
com.wecloud.im.enums.RelationEnum
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.entity.ImFriend
;
...
@@ -18,13 +19,15 @@ import com.wecloud.im.param.GetClientInfoParam;
...
@@ -18,13 +19,15 @@ import com.wecloud.im.param.GetClientInfoParam;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.add.ImClientDeviceInfoAdd
;
import
com.wecloud.im.param.LogoutParam
;
import
com.wecloud.im.param.add.ClientDeviceUpdateParam
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
import
com.wecloud.im.param.add.ImClientNicknameAdd
;
import
com.wecloud.im.param.add.ImClientNicknameUpdate
;
import
com.wecloud.im.param.add.ImClientNicknameUpdate
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientDeviceService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.vo.ClientInfoVo
;
import
com.wecloud.im.vo.ClientInfoVo
;
import
com.wecloud.im.vo.GetInfoListVo
;
import
com.wecloud.im.vo.GetInfoListVo
;
...
@@ -71,6 +74,9 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
...
@@ -71,6 +74,9 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Autowired
@Autowired
private
ImClientBlacklistService
imClientBlacklistService
;
private
ImClientBlacklistService
imClientBlacklistService
;
@Autowired
private
ImClientDeviceService
imClientDeviceService
;
@Override
@Override
public
MyInfoVo
getMyInfo
()
{
public
MyInfoVo
getMyInfo
()
{
...
@@ -186,12 +192,6 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
...
@@ -186,12 +192,6 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
public
boolean
updateNickname
(
ImClientNicknameAdd
imClientNicknameAdd
)
throws
Exception
{
public
boolean
updateNickname
(
ImClientNicknameAdd
imClientNicknameAdd
)
throws
Exception
{
ImClient
curentClient
=
getCurrentClient
();
ImClient
curentClient
=
getCurrentClient
();
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
// ImApplication imApplication = imApplicationService.getOneByAppKey(curentJwtToken.getAppKey());
curentClient
.
setNickname
(
imClientNicknameAdd
.
getNickname
());
curentClient
.
setNickname
(
imClientNicknameAdd
.
getNickname
());
imClientMapper
.
updateById
(
curentClient
);
imClientMapper
.
updateById
(
curentClient
);
...
@@ -209,52 +209,35 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
...
@@ -209,52 +209,35 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
updateDeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
)
{
public
boolean
updateDeviceInfo
(
ClientDeviceUpdateParam
param
)
{
ImClient
currentClient
=
getCurrentClient
();
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
// 清除旧client的redis缓存
ImClientDevice
clientDevice
=
imClientDeviceService
.
getOne
(
new
QueryWrapper
<
ImClientDevice
>().
lambda
()
ImClient
imClient
=
this
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClientDevice:
:
getFkAppid
,
currentClient
.
getFkAppid
())
.
eq
(
ImClient:
:
getFkAppid
,
imApplication
.
getId
())
.
eq
(
ImClientDevice:
:
getDeviceToken
,
param
.
getDeviceToken
()));
.
eq
(
ImClient:
:
getDeviceToken
,
imClientDevice
.
getDeviceToken
()));
if
(
clientDevice
!=
null
)
{
if
(
imClient
!=
null
)
{
deleteCacheImClient
(
imClient
.
getFkAppid
(),
imClient
.
getClientId
());
// client登陆的时候 判断数据库内是否已经存在这个设备token,如果存在就清空旧的
// client登陆的时候 判断数据库内是否已经存在这个设备token,如果存在就清空旧的
this
.
removeOldToken
(
imApplication
.
getId
(),
curentJwtToken
.
getToken
());
JwtToken
currentJwtToken
=
JwtUtil
.
getCurrentJwtToken
();
imClientDeviceService
.
removeOldToken
(
currentClient
.
getId
(),
currentJwtToken
.
getToken
());
}
}
ImClient
client
=
getCurrentClient
();
ImClient
clientNew
=
new
ImClient
();
BeanUtils
.
copyProperties
(
imClientDevice
,
clientNew
);
clientNew
.
setId
(
client
.
getId
());
// 清除新client的redis缓存
deleteCacheImClient
(
client
.
getFkAppid
(),
client
.
getClientId
());
// 修改
// 修改
return
this
.
updateImClient
(
clientNew
);
return
imClientDeviceService
.
update
(
new
UpdateWrapper
<
ImClientDevice
>().
lambda
()
.
eq
(
ImClientDevice:
:
getFkAppid
,
currentClient
.
getFkAppid
())
.
eq
(
ImClientDevice:
:
getFkClientId
,
currentClient
.
getId
())
.
eq
(
ImClientDevice:
:
getDeviceType
,
param
.
getDeviceType
())
.
set
(
ImClientDevice:
:
getDeviceToken
,
param
.
getDeviceToken
())
);
}
}
@Override
@Override
public
boolean
logout
()
{
public
boolean
logout
(
LogoutParam
param
)
{
ImClient
currentClient
=
getCurrentClient
();
ImClient
curentClient
=
getCurrentClient
();
// 清除设备token
// 清除设备token
boolean
update
=
this
.
update
(
new
UpdateWrapper
<
ImClient
>().
lambda
()
return
imClientDeviceService
.
update
(
new
UpdateWrapper
<
ImClientDevice
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
curentClient
.
getFkAppid
())
.
eq
(
ImClientDevice:
:
getFkAppid
,
currentClient
.
getFkAppid
())
.
eq
(
ImClient:
:
getId
,
curentClient
.
getId
())
.
eq
(
ImClientDevice:
:
getFkClientId
,
currentClient
.
getId
())
.
set
(
ImClient:
:
getDeviceToken
,
null
)
.
eq
(
ImClientDevice:
:
getDeviceType
,
param
.
getDeviceType
())
);
.
set
(
ImClientDevice:
:
getDeviceToken
,
null
));
if
(
update
)
{
// 清除新client的redis缓存
deleteCacheImClient
(
curentClient
.
getFkAppid
(),
curentClient
.
getClientId
());
}
return
update
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -286,7 +269,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
...
@@ -286,7 +269,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
public
ImClient
getCurrentClient
()
{
public
ImClient
getCurrentClient
()
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询appid
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
return
getCacheImClient
(
imApplication
.
getId
(),
curentJwtToken
.
getClientId
());
return
getCacheImClient
(
imApplication
.
getId
(),
curentJwtToken
.
getClientId
());
...
...
core/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
View file @
2fcc10da
...
@@ -84,7 +84,7 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
...
@@ -84,7 +84,7 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
public
ApiResult
<
Boolean
>
saveOrUpdateClientRemarkName
(
ImConvMemeClientRemarkNameParam
imConvMemeClientRemarkNameParam
)
{
public
ApiResult
<
Boolean
>
saveOrUpdateClientRemarkName
(
ImConvMemeClientRemarkNameParam
imConvMemeClientRemarkNameParam
)
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
@@ -138,7 +138,7 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
...
@@ -138,7 +138,7 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
public
ApiResult
<
Boolean
>
saveOrUpdateAttr
(
ImConversationMemAttrUpdate
imConversationMemAttrUpdate
)
{
public
ApiResult
<
Boolean
>
saveOrUpdateAttr
(
ImConversationMemAttrUpdate
imConversationMemAttrUpdate
)
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
...
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
2fcc10da
...
@@ -131,7 +131,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -131,7 +131,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
@@ -261,7 +261,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -261,7 +261,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public
ApiResult
<
Boolean
>
addClientToConversation
(
ImClientToConversation
imClientToConversation
)
{
public
ApiResult
<
Boolean
>
addClientToConversation
(
ImClientToConversation
imClientToConversation
)
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
@@ -396,7 +396,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -396,7 +396,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public
ApiResult
<
Boolean
>
delClientToConversation
(
ImClientToConversation
imClientToConversation
)
throws
Exception
{
public
ApiResult
<
Boolean
>
delClientToConversation
(
ImClientToConversation
imClientToConversation
)
throws
Exception
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
@@ -626,7 +626,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -626,7 +626,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
transferOwner
(
TransferOwnerParam
param
)
{
public
Boolean
transferOwner
(
TransferOwnerParam
param
)
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImClient
imClientSender
=
imClientService
.
getCurrentClient
();
ImClient
imClientSender
=
imClientService
.
getCurrentClient
();
...
@@ -759,7 +759,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -759,7 +759,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public
ApiResult
<
Boolean
>
saveOrUpdateName
(
ImConversationNameUpdate
imConversationNameUpdate
)
throws
Exception
{
public
ApiResult
<
Boolean
>
saveOrUpdateName
(
ImConversationNameUpdate
imConversationNameUpdate
)
throws
Exception
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
@@ -842,7 +842,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -842,7 +842,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public
ApiResult
<
Boolean
>
saveOrUpdateAttr
(
ImConversationAttrUpdate
imConversationAttrUpdate
)
throws
Exception
{
public
ApiResult
<
Boolean
>
saveOrUpdateAttr
(
ImConversationAttrUpdate
imConversationAttrUpdate
)
throws
Exception
{
// shiro线程中获取当前token
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
JwtToken
curentJwtToken
=
JwtUtil
.
getCur
r
entJwtToken
();
// 根据appKey查询application
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
curentJwtToken
.
getAppKey
());
...
...
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
2fcc10da
...
@@ -16,6 +16,7 @@ import com.wecloud.im.entity.ImMessage;
...
@@ -16,6 +16,7 @@ import com.wecloud.im.entity.ImMessage;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.enums.ChatTypeEnum
;
import
com.wecloud.im.enums.ChatTypeEnum
;
import
com.wecloud.im.mapper.ImMessageMapper
;
import
com.wecloud.im.mapper.ImMessageMapper
;
import
com.wecloud.im.mq.MqSender
;
import
com.wecloud.im.param.ChatContentVo
;
import
com.wecloud.im.param.ChatContentVo
;
import
com.wecloud.im.param.GetReadersParam
;
import
com.wecloud.im.param.GetReadersParam
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.ImClientSimpleDto
;
...
@@ -40,8 +41,9 @@ import com.wecloud.im.ws.model.WsResponse;
...
@@ -40,8 +41,9 @@ import com.wecloud.im.ws.model.WsResponse;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.im.ws.model.request.ReceiveDataVO
;
import
com.wecloud.im.ws.model.request.ReceiveDataVO
;
import
com.wecloud.im.ws.model.request.ReceiveVO
;
import
com.wecloud.im.ws.model.request.ReceiveVO
;
import
com.wecloud.im.ws.sender.AsyncPush
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.pushserver.client.model.constant.MqConstant
;
import
com.wecloud.pushserver.client.model.dto.PushDTO
;
import
com.wecloud.utils.JsonUtils
;
import
com.wecloud.utils.JsonUtils
;
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
;
...
@@ -81,9 +83,6 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -81,9 +83,6 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
private
ImConversationService
imConversationService
;
private
ImConversationService
imConversationService
;
@Autowired
@Autowired
private
AsyncPush
asyncPush
;
@Autowired
private
ImApplicationService
imApplicationService
;
private
ImApplicationService
imApplicationService
;
...
@@ -96,6 +95,9 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -96,6 +95,9 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
@Autowired
@Autowired
private
ThousandChatService
thousandChatService
;
private
ThousandChatService
thousandChatService
;
@Autowired
private
MqSender
mqSender
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ApiResult
<
Boolean
>
restApiImMessageSend
(
ImMsgSendToOnlineClient
imMsgSendToOnlineClient
,
ImApplication
imApplication
)
{
public
ApiResult
<
Boolean
>
restApiImMessageSend
(
ImMsgSendToOnlineClient
imMsgSendToOnlineClient
,
ImApplication
imApplication
)
{
...
@@ -296,11 +298,11 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -296,11 +298,11 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
responseModel
.
setReqId
(
null
);
responseModel
.
setReqId
(
null
);
channelSender
.
sendMsg
(
responseModel
,
imClientReceiver
.
getId
());
channelSender
.
sendMsg
(
responseModel
,
imClientReceiver
.
getId
());
// 获取自定义推送字段
PushVO
pushVO
=
imMsgRecall
.
getPush
();
// 异步推送系统通知消息
// 异步推送系统通知消息
asyncPush
.
push
(
pushVO
,
imClientReceiver
,
imApplication
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
imMsgRecall
.
getPush
(),
imClientReceiver
,
imApplication
);
if
(
pushDTO
!=
null
)
{
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
}
}
}
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
...
...
core/src/main/java/com/wecloud/im/thousandchat/action/ThousandChatAction.java
View file @
2fcc10da
...
@@ -9,6 +9,7 @@ import com.wecloud.im.entity.ImClient;
...
@@ -9,6 +9,7 @@ import com.wecloud.im.entity.ImClient;
import
com.wecloud.im.entity.ImConversationMembers
;
import
com.wecloud.im.entity.ImConversationMembers
;
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.mq.MqSender
;
import
com.wecloud.im.param.ChatContentVo
;
import
com.wecloud.im.param.ChatContentVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.ImConversationQueryVo
;
import
com.wecloud.im.param.ImConversationQueryVo
;
...
@@ -21,8 +22,9 @@ import com.wecloud.im.service.ImMessageService;
...
@@ -21,8 +22,9 @@ import com.wecloud.im.service.ImMessageService;
import
com.wecloud.im.thousandchat.cache.ThousandChatCacheManager
;
import
com.wecloud.im.thousandchat.cache.ThousandChatCacheManager
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.sender.AsyncPush
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.pushserver.client.model.constant.MqConstant
;
import
com.wecloud.pushserver.client.model.dto.PushDTO
;
import
com.wecloud.utils.JsonUtils
;
import
com.wecloud.utils.JsonUtils
;
import
com.wecloud.utils.SnowflakeUtil
;
import
com.wecloud.utils.SnowflakeUtil
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
...
@@ -54,8 +56,6 @@ public class ThousandChatAction {
...
@@ -54,8 +56,6 @@ public class ThousandChatAction {
@Autowired
@Autowired
private
ImConversationService
imConversationService
;
private
ImConversationService
imConversationService
;
@Autowired
@Autowired
private
AsyncPush
systemPush
;
@Autowired
private
ImConversationMembersService
imConversationMembersService
;
private
ImConversationMembersService
imConversationMembersService
;
@Autowired
@Autowired
private
ImMessageService
imMessageService
;
private
ImMessageService
imMessageService
;
...
@@ -64,6 +64,9 @@ public class ThousandChatAction {
...
@@ -64,6 +64,9 @@ public class ThousandChatAction {
@Autowired
@Autowired
private
ThousandChatCacheManager
thousandChatCacheManager
;
private
ThousandChatCacheManager
thousandChatCacheManager
;
@Autowired
private
MqSender
mqSender
;
@ActionMapping
(
"/thousand/send"
)
@ActionMapping
(
"/thousand/send"
)
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
if
(
log
.
isDebugEnabled
())
{
if
(
log
.
isDebugEnabled
())
{
...
@@ -117,7 +120,10 @@ public class ThousandChatAction {
...
@@ -117,7 +120,10 @@ public class ThousandChatAction {
continue
;
continue
;
}
}
// 异步推送系统通知消息
// 异步推送系统通知消息
systemPush
.
push
(
data
.
getPush
(),
imClientReceiver
,
imApplication
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
data
.
getPush
(),
imClientReceiver
,
imApplication
);
if
(
pushDTO
!=
null
)
{
mqSender
.
orderSend
(
MqConstant
.
Topic
.
IM_ORDER_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_ORDER_MSG_TAG
,
pushDTO
);
}
}
}
// 响应发送方消息id等信息
// 响应发送方消息id等信息
...
...
core/src/main/java/com/wecloud/im/ws/sender/AsyncPush.java
deleted
100644 → 0
View file @
dd7d397b
package
com
.
wecloud
.
im
.
ws
.
sender
;
import
cn.hutool.core.codec.Base64
;
import
com.turo.pushy.apns.DeliveryPriority
;
import
com.turo.pushy.apns.PushType
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImIosApns
;
import
com.wecloud.im.push.PushUtils
;
import
com.wecloud.im.service.ImInboxService
;
import
com.wecloud.im.service.ImIosApnsService
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_BODY
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
PUSH_TITLE
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
SUB_TITLE
;
import
static
com
.
wecloud
.
im
.
ws
.
ImConstant
.
TITLE
;
/**
* 异步系统推送
*/
@Component
@Slf4j
public
class
AsyncPush
{
/**
* 谷歌推送地址
*/
private
static
final
String
API_URL_FCM
=
"https://fcm.googleapis.com/fcm/send"
;
// /**
// * 您收到一条新消息
// */
// private static final String PUSH_TITLE = "You have received a new message";
// /**
// * 点击查看
// */
// private static final String PUSH_BODY = "Click to view";
// private static final String TITLE = "title";
// private static final String SUB_TITLE = "subTitle";
@Autowired
private
ImIosApnsService
imIosApnsService
;
@Autowired
private
ImInboxService
imInboxService
;
/**
* 异步系统推送
*
* @param imClientReceiver
*/
@Async
public
void
push
(
PushVO
pushVO
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
log
.
info
(
"push: {}"
,
imClientReceiver
.
getClientId
());
if
(
pushVO
==
null
)
{
pushVO
=
new
PushVO
();
pushVO
.
setTitle
(
PUSH_TITLE
);
pushVO
.
setSubTitle
(
PUSH_BODY
);
}
// 校验参数
if
(
imClientReceiver
.
getValid
()
==
null
||
imClientReceiver
.
getDeviceToken
()
==
null
||
imClientReceiver
.
getDeviceType
()
==
null
)
{
log
.
info
(
"{} 应用未配置push,或client无DeviceToken {}"
,
imApplication
.
getId
(),
imClientReceiver
.
getClientId
());
return
;
}
// 设备不想收到推送提醒, 1想, 0不想
if
(
imClientReceiver
.
getValid
()
==
0
)
{
return
;
}
// 设备类型1:ios; 2:android
if
(
imClientReceiver
.
getDeviceType
()
==
1
)
{
ios
(
pushVO
,
imClientReceiver
,
imApplication
);
}
else
{
android
(
pushVO
,
imClientReceiver
,
imApplication
);
}
}
/**
* 异步系统推送
*
* @param imClientReceiver
*/
@Async
public
void
push
(
HashMap
<
String
,
String
>
pushMap
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
log
.
info
(
"push:"
+
imClientReceiver
.
getClientId
());
PushVO
pushVO
=
new
PushVO
();
if
(
pushMap
==
null
||
pushMap
.
isEmpty
())
{
pushVO
.
setTitle
(
PUSH_TITLE
);
pushVO
.
setSubTitle
(
PUSH_BODY
);
}
else
{
pushVO
.
setTitle
(
pushMap
.
get
(
TITLE
));
pushVO
.
setSubTitle
(
pushMap
.
get
(
SUB_TITLE
));
}
this
.
push
(
pushVO
,
imClientReceiver
,
imApplication
);
}
private
void
android
(
PushVO
pushVO
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
if
(
imApplication
.
getAndroidPushChannel
()
==
null
)
{
return
;
}
// 安卓推送通道,友盟:1;firebase:2; 信鸽3
if
(
imApplication
.
getAndroidPushChannel
()
==
1
)
{
log
.
info
(
"友盟"
);
// 友盟推送
PushUtils
pushUtils
=
new
PushUtils
(
imApplication
.
getUmengKey
(),
imApplication
.
getUmengSecret
());
// 安卓 单推
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
try
{
pushUtils
.
sendIOSUnicast
(
deviceToken
,
pushVO
.
getTitle
(),
pushVO
.
getSubTitle
(),
PUSH_BODY
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
imApplication
.
getAndroidPushChannel
()
==
2
)
{
//firebase:2
log
.
info
(
"android_firebase"
);
firebase
(
pushVO
,
imClientReceiver
,
imApplication
);
}
else
if
(
imApplication
.
getAndroidPushChannel
()
==
3
)
{
// 信鸽3
log
.
info
(
"信鸽3"
);
}
else
{
log
.
info
(
"没有找到推送类型"
);
}
}
private
void
ios
(
PushVO
pushVO
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
if
(
imApplication
.
getIosPushChannel
()
==
null
)
{
return
;
}
// ios推送通道,友盟:1;firebase:2; apns原生:3
if
(
imApplication
.
getIosPushChannel
()
==
1
)
{
log
.
info
(
"友盟"
);
// 友盟推送
PushUtils
pushUtils
=
new
PushUtils
(
imApplication
.
getUmengKey
(),
imApplication
.
getUmengSecret
());
// 安卓单推
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
unicastText
=
"Android unicast text"
;
String
unicastTicker
=
pushVO
.
getSubTitle
();
try
{
pushUtils
.
sendAndroidUnicast
(
deviceToken
,
unicastText
,
unicastTicker
,
pushVO
.
getTitle
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
imApplication
.
getIosPushChannel
()
==
2
)
{
//firebase:2
log
.
info
(
"firebase"
);
firebase
(
pushVO
,
imClientReceiver
,
imApplication
);
}
else
if
(
imApplication
.
getIosPushChannel
()
==
3
)
{
// apns原生:3
log
.
info
(
"apns原生"
);
apnsPush
(
pushVO
,
imClientReceiver
,
imApplication
);
}
else
{
log
.
info
(
"没有找到推送类型"
);
}
}
public
void
firebase
(
PushVO
pushVO
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
String
jsonStr
=
null
;
try
{
URL
url
=
new
URL
(
API_URL_FCM
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setUseCaches
(
false
);
conn
.
setDoInput
(
true
);
conn
.
setDoOutput
(
true
);
conn
.
setConnectTimeout
(
10000
);
conn
.
setRequestMethod
(
"POST"
);
//不设置默认发送文本格式。设置就是json
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Authorization"
,
"key="
+
imApplication
.
getFirebaseSecret
());
JSONObject
json
=
new
JSONObject
();
//推送到哪台客户端机器
json
.
put
(
"to"
,
imClientReceiver
.
getDeviceToken
());
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"title"
,
pushVO
.
getTitle
());
info
.
put
(
"body"
,
pushVO
.
getSubTitle
());
//数据消息data 通知消息 notification
json
.
put
(
"notification"
,
info
);
OutputStreamWriter
wr
=
new
OutputStreamWriter
(
conn
.
getOutputStream
());
jsonStr
=
json
.
toString
();
wr
.
write
(
jsonStr
);
wr
.
flush
();
InputStream
inputStream
=
conn
.
getInputStream
();
InputStreamReader
in
=
new
InputStreamReader
(
inputStream
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
String
line
=
reader
.
readLine
();
log
.
info
(
line
);
wr
.
close
();
reader
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
"FCM push failure: "
+
jsonStr
,
e
);
}
}
private
void
apnsPush
(
PushVO
pushVO
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
// 查询apns证书
ImIosApns
apns
=
imIosApnsService
.
getImIosApnsByAppId
(
imApplication
.
getId
());
Map
<
String
,
Object
>
customProperty
=
new
HashMap
<
String
,
Object
>(
1
);
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
alertTitle
=
pushVO
.
getTitle
();
String
alertBody
=
pushVO
.
getSubTitle
();
// 统计未读消息数量
int
badge
=
imInboxService
.
countMyNotReadCount
(
imClientReceiver
.
getId
());
String
topicBundleId
=
apns
.
getBundleId
();
String
certificatePassword
=
apns
.
getPwd
();
boolean
contentAvailable
=
false
;
String
sound
=
"default"
;
// 解码
byte
[]
decode
=
Base64
.
decode
(
apns
.
getApnsFileValue
());
InputStream
inputStream2
=
new
ByteArrayInputStream
(
decode
);
// productFlag 环境,测试=Boolean.FALSE,正式=Boolean.TRUE
Boolean
productFlag
=
Boolean
.
FALSE
;
// 正式1,测试0
if
(
apns
.
getEnv
()
==
1
)
{
productFlag
=
Boolean
.
TRUE
;
}
IosPush
.
push
(
certificatePassword
,
inputStream2
,
productFlag
,
deviceToken
,
alertTitle
,
alertBody
,
contentAvailable
,
customProperty
,
badge
,
DeliveryPriority
.
IMMEDIATE
,
PushType
.
ALERT
,
topicBundleId
,
sound
);
}
}
core/src/main/resources/mapper/ImClientDeviceMapper.xml
View file @
2fcc10da
...
@@ -2,4 +2,12 @@
...
@@ -2,4 +2,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.wecloud.im.mapper.ImClientDeviceMapper"
>
<mapper
namespace=
"com.wecloud.im.mapper.ImClientDeviceMapper"
>
<update
id=
"removeOldToken"
>
UPDATE im_client_device
SET device_token = NULL
WHERE device_token = #{deviceToken}
AND fk_appid = #{appId}
</update>
</mapper>
</mapper>
docs/db/feature-cluster增量.sql
View file @
2fcc10da
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...
@@ -103,15 +103,17 @@ CREATE TABLE `im_user`
...
@@ -103,15 +103,17 @@ CREATE TABLE `im_user`
CREATE
TABLE
`im_client_device`
CREATE
TABLE
`im_client_device`
(
(
`id`
bigint
NOT
NULL
COMMENT
'主键id'
,
`id`
bigint
NOT
NULL
COMMENT
'主键id'
,
`fk_appid`
bigint
DEFAULT
NULL
COMMENT
'应用appid'
,
`fk_client_id`
bigint
NOT
NULL
COMMENT
'客户端id'
,
`fk_client_id`
bigint
NOT
NULL
COMMENT
'客户端id'
,
`valid`
int
DEFAULT
NULL
COMMENT
'设备不想收到推送提醒'
,
`valid`
int
DEFAULT
NULL
COMMENT
'设备不想收到推送提醒'
,
`device_type`
int
DEFAULT
NULL
COMMENT
'设备类型1:ios; 2:android'
,
`device_type`
int
DEFAULT
NULL
COMMENT
'设备类型1:ios; 2:android'
,
`device_token`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'设备推送token'
,
`device_token`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'设备推送token'
,
`unique_id`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'设备唯一id(由设备端生成)'
,
`unique_device_id`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'设备唯一id(由设备端生成)'
,
`platform`
int
DEFAULT
NULL
COMMENT
'平台编码:1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs'
,
`create_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
`create_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_time`
timestamp
NULL
DEFAULT
NULL
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_time`
timestamp
NULL
DEFAULT
NULL
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
KEY
`idx_fk_client_id`
(
`fk_client_id`
)
USING
BTREE
,
KEY
`idx_device_token_appid`
(
`device_token`
,
`fk_appid`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'客户端设备表'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'客户端设备表'
;
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
View file @
2fcc10da
...
@@ -59,7 +59,7 @@ public class JwtUtil {
...
@@ -59,7 +59,7 @@ public class JwtUtil {
*
*
* @return
* @return
*/
*/
public
static
JwtToken
getCurentJwtToken
()
{
public
static
JwtToken
getCur
r
entJwtToken
()
{
JwtToken
jwtToken
=
(
JwtToken
)
SecurityUtils
.
getSubject
().
getPrincipal
();
JwtToken
jwtToken
=
(
JwtToken
)
SecurityUtils
.
getSubject
().
getPrincipal
();
return
jwtToken
;
return
jwtToken
;
}
}
...
...
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