Commit 5b9cb41e by Future

好友申请与通过返回添加申请人id

parent 4022001d
......@@ -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);
}
......
......@@ -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;
......
......@@ -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());
// 向接收方推送
......
......@@ -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 currentClientId
* @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(currentClientId);
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(currentClientId);
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment