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
5b9cb41e
Commit
5b9cb41e
authored
Feb 09, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
好友申请与通过返回添加申请人id
parent
4022001d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
11 deletions
+15
-11
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
+1
-1
core/src/main/java/com/wecloud/im/friend/param/FriendBaseEventDto.java
+3
-0
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
+4
-3
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
+7
-7
No files found.
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
View file @
5b9cb41e
...
...
@@ -126,7 +126,7 @@ public class ImFriendController extends BaseController {
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
boolean
ok
=
imFriendService
.
approveFriend
(
currentClient
.
getId
()
,
friendClient
,
param
.
getAgree
(),
param
.
getRejectRemark
());
boolean
ok
=
imFriendService
.
approveFriend
(
currentClient
,
friendClient
,
param
.
getAgree
(),
param
.
getRejectRemark
());
return
ApiResult
.
ok
(
ok
);
}
...
...
core/src/main/java/com/wecloud/im/friend/param/FriendBaseEventDto.java
View file @
5b9cb41e
...
...
@@ -19,6 +19,9 @@ public class FriendBaseEventDto implements Serializable {
@ApiModelProperty
(
"响应命令"
)
private
Integer
subCmd
;
@ApiModelProperty
(
"申请人的client-id"
)
private
String
claimerClientId
;
@ApiModelProperty
(
"好友的client-id"
)
private
String
friendClientId
;
...
...
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
View file @
5b9cb41e
...
...
@@ -46,11 +46,12 @@ public class FriendEventSender {
private
final
static
String
FRIEND_APPROVE_TITLE_REJECT
=
"您的好友同意了您的好友申请"
;
public
void
sendFriendApplyEventMsg
(
ImClient
receiveClient
,
String
requestRemark
)
{
public
void
sendFriendApplyEventMsg
(
ImClient
claimerClient
,
ImClient
receiveClient
,
String
requestRemark
)
{
FriendApplyEventDto
applyDto
=
new
FriendApplyEventDto
();
applyDto
.
setSubCmd
(
EventResponseSubCmdEnum
.
FRIEND_APPLY
.
getCode
());
applyDto
.
setRequestRemark
(
requestRemark
);
applyDto
.
setClaimerClientId
(
claimerClient
.
getClientId
());
applyDto
.
setFriendClientId
(
receiveClient
.
getClientId
());
// 向接收方推送
...
...
@@ -68,17 +69,17 @@ public class FriendEventSender {
PushVO
pushVO
=
new
PushVO
();
pushVO
.
setTitle
(
FRIEND_APPLY_TITLE
);
pushVO
.
setSubTitle
(
FRIEND_APPLY_TITLE_SUB
);
// systemPush.push(pushVO, receiveClient, app);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
pushVO
,
receiveClient
,
app
);
mqSender
.
synSend
(
MqConstant
.
Topic
.
IM_MSG_TOPIC
,
MqConstant
.
Tag
.
IM_MSG_TAG
,
pushDTO
);
}
public
void
sendFriendApproveEventMsg
(
ImClient
receiveClient
,
boolean
isAgree
,
String
rejectRemark
)
{
public
void
sendFriendApproveEventMsg
(
ImClient
claimerClient
,
ImClient
receiveClient
,
boolean
isAgree
,
String
rejectRemark
)
{
FriendApproveEventDto
approveDto
=
new
FriendApproveEventDto
();
approveDto
.
setSubCmd
(
EventResponseSubCmdEnum
.
FRIEND_APPROVE
.
getCode
());
approveDto
.
setAgree
(
isAgree
);
approveDto
.
setRejectRemark
(
rejectRemark
);
approveDto
.
setClaimerClientId
(
claimerClient
.
getClientId
());
approveDto
.
setFriendClientId
(
receiveClient
.
getClientId
());
// 向接收方推送
...
...
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
View file @
5b9cb41e
...
...
@@ -85,7 +85,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
* @return
*/
@Transactional
public
Boolean
applyFriend
(
ImClient
currentClient
,
ImClient
friendClient
,
String
friendName
,
String
requestRemark
)
{
public
Boolean
applyFriend
(
ImClient
currentClient
,
ImClient
friendClient
,
String
friendName
,
String
requestRemark
)
{
//好友关系有维护两条,我和他,他和我
ImFriend
my
=
new
ImFriend
();
my
.
setFkClientId
(
currentClient
.
getId
());
...
...
@@ -131,7 +131,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
//既然申请好友了,就删除好友推荐
this
.
batchDeleteRecommend
(
currentClient
,
Collections
.
singletonList
(
friendClient
.
getClientId
()));
this
.
batchDeleteRecommend
(
friendClient
,
Collections
.
singletonList
(
currentClient
.
getClientId
()));
friendEventSender
.
sendFriendApplyEventMsg
(
friendClient
,
requestRemark
);
friendEventSender
.
sendFriendApplyEventMsg
(
currentClient
,
friendClient
,
requestRemark
);
return
true
;
}
...
...
@@ -164,13 +164,13 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
/**
* 好友通过/拒绝
* @param currentClient
Id
* @param currentClient
* @param friendClient
* @param agree
* @param rejectRemark
*/
@Transactional
public
boolean
approveFriend
(
Long
currentClientId
,
ImClient
friendClient
,
boolean
agree
,
String
rejectRemark
)
{
public
boolean
approveFriend
(
ImClient
currentClient
,
ImClient
friendClient
,
boolean
agree
,
String
rejectRemark
)
{
if
(
agree
)
{
rejectRemark
=
null
;
}
...
...
@@ -178,7 +178,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
//好友的先更新
ImFriend
friend
=
new
ImFriend
();
friend
.
setFkClientId
(
friendClient
.
getId
());
friend
.
setFkClientIdFriend
(
currentClient
Id
);
friend
.
setFkClientIdFriend
(
currentClient
.
getId
()
);
friend
.
setFkClientIdClaimer
(
friendClient
.
getId
());
friend
.
setState
(
agree
?
FriendStateEnum
.
CONFORM
.
getCode
()
:
FriendStateEnum
.
REJECT
.
getCode
());
if
(
StringUtils
.
isNotEmpty
(
rejectRemark
))
{
...
...
@@ -187,7 +187,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
boolean
ok1
=
this
.
updateByKeyAndClaimer
(
friend
);
// 同时更新我的
ImFriend
my
=
new
ImFriend
();
my
.
setFkClientId
(
currentClient
Id
);
my
.
setFkClientId
(
currentClient
.
getId
()
);
my
.
setFkClientIdFriend
(
friendClient
.
getId
());
my
.
setFkClientIdClaimer
(
friendClient
.
getId
());
my
.
setState
(
agree
?
FriendStateEnum
.
CONFORM
.
getCode
()
:
FriendStateEnum
.
REJECT
.
getCode
());
...
...
@@ -196,7 +196,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
}
boolean
ok2
=
this
.
updateByKeyAndClaimer
(
my
);
friendEventSender
.
sendFriendApproveEventMsg
(
friendClient
,
agree
,
rejectRemark
);
friendEventSender
.
sendFriendApproveEventMsg
(
currentClient
,
friendClient
,
agree
,
rejectRemark
);
return
ok1
||
ok2
;
}
...
...
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