Commit 755ec6ea by Future

修改会话属性接口调整

parent 79aed1f7
...@@ -67,6 +67,7 @@ public class ConversationAction { ...@@ -67,6 +67,7 @@ public class ConversationAction {
@ActionMapping("/saveOrUpdateAttr") @ActionMapping("/saveOrUpdateAttr")
@ApiOperation(value = "添加或修改会话拓展字段", notes = "权限:所有client都权限操作") @ApiOperation(value = "添加或修改会话拓展字段", notes = "权限:所有client都权限操作")
public WsResponse<Map<String, Boolean>> saveOrUpdateAttr(ImConversationAttrUpdate data) { public WsResponse<Map<String, Boolean>> saveOrUpdateAttr(ImConversationAttrUpdate data) {
log.info("添加或修改会话拓展字段 {}", JSON.toJSONString(data));
imConversationService.saveOrUpdateAttr(data); imConversationService.saveOrUpdateAttr(data);
return WsResponse.ok(); return WsResponse.ok();
} }
...@@ -212,6 +213,7 @@ public class ConversationAction { ...@@ -212,6 +213,7 @@ public class ConversationAction {
@ActionMapping("/info") @ActionMapping("/info")
@ApiOperation(value = "根据会话id查询指定会话信息", notes = "根据会话id查询指定会话信息 与每个会话的未读条数") @ApiOperation(value = "根据会话id查询指定会话信息", notes = "根据会话id查询指定会话信息 与每个会话的未读条数")
public WsResponse<ConversationVo> info(@Validated ImConversationQueryParam data) throws Exception { public WsResponse<ConversationVo> info(@Validated ImConversationQueryParam data) throws Exception {
log.info("根据会话id查询指定会话信息 {}", JSON.toJSONString(data));
ConversationVo conversationVo = imConversationService.infoImConversationAndMsgCount(data); ConversationVo conversationVo = imConversationService.infoImConversationAndMsgCount(data);
return WsResponse.ok(conversationVo); return WsResponse.ok(conversationVo);
} }
...@@ -222,7 +224,7 @@ public class ConversationAction { ...@@ -222,7 +224,7 @@ public class ConversationAction {
@ActionMapping("/displayUpdate") @ActionMapping("/displayUpdate")
@ApiOperation(value = "批量修改单向隐藏或显示会话", notes = "拉取会话列表不展示已隐藏状态的会话,云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录") @ApiOperation(value = "批量修改单向隐藏或显示会话", notes = "拉取会话列表不展示已隐藏状态的会话,云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录")
public WsResponse<Map<String, Boolean>> updateDisplayConversation(ImConversationDisplayUpdate data) throws Exception { public WsResponse<Map<String, Boolean>> updateDisplayConversation(ImConversationDisplayUpdate data) throws Exception {
log.info("批量修改单向隐藏或显示会话 {}", JSON.toJSONString(data));
imConversationService.updateDisplayConversation(data); imConversationService.updateDisplayConversation(data);
return WsResponse.ok(); return WsResponse.ok();
} }
......
...@@ -973,13 +973,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -973,13 +973,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveOrUpdateAttr(ImConversationAttrUpdate imConversationAttrUpdate) { public void saveOrUpdateAttr(ImConversationAttrUpdate imConversationAttrUpdate) {
// 获取当前client
// shiro线程中获取当前token ImClient currentClient = contextService.getImClientIfNotNullOrThrow();
JwtToken curentJwtToken = JwtUtil.getCurrentJwtToken(); // 根据appId查询application
// 根据appKey查询application ImApplication imApplication = contextService.getImApplicationIfNotNullOrThrow(currentClient.getFkAppid());
ImApplication imApplication = imApplicationService.getCacheAppByAppKey(curentJwtToken.getAppKey());
ImClient imClientSender = imClientService.getCurrentClient();
ImConversation imConversationById = imConversationService.getById(imConversationAttrUpdate.getConversationId()); ImConversation imConversationById = imConversationService.getById(imConversationAttrUpdate.getConversationId());
// 判断是否为群主 // 判断是否为群主
...@@ -992,30 +989,22 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -992,30 +989,22 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
new QueryWrapper<ImConversationMembers>().lambda() new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkAppid, imApplication.getId()) .eq(ImConversationMembers::getFkAppid, imApplication.getId())
.eq(ImConversationMembers::getFkConversationId, imConversationAttrUpdate.getConversationId()) .eq(ImConversationMembers::getFkConversationId, imConversationAttrUpdate.getConversationId())
.ne(ImConversationMembers::getFkClientId, imClientSender.getId()) .ne(ImConversationMembers::getFkClientId, currentClient.getId())
); );
String attributes = JsonUtils.encodeJson(imConversationAttrUpdate.getAttributes()); String attributes = JsonUtils.encodeJson(imConversationAttrUpdate.getAttributes());
imConversationById.setAttributes(attributes); imConversationById.setAttributes(attributes);
boolean b = imConversationService.updateById(imConversationById); boolean b = imConversationService.updateById(imConversationById);
// 删除redis中该会话的缓存 // 删除redis中该会话的缓存
deleteCacheImConversationById(imConversationAttrUpdate.getConversationId()); deleteCacheImConversationById(imConversationAttrUpdate.getConversationId());
if (b) { if (b) {
// ws下发拓展字段变动事件 // ws下发拓展字段变动事件
HashMap<String, String> content = Maps.newHashMap();
// 内容
HashMap<String, String> content = new HashMap<>();
content.put("attributes", imConversationById.getAttributes()); content.put("attributes", imConversationById.getAttributes());
// 遍历发送 // 遍历发送
for (ImConversationMembers conversationMembers : membersList) { for (ImConversationMembers conversationMembers : membersList) {
// 查询接收方 // 查询接收方
ImClient imClientReceiver = imClientService.getOne(new QueryWrapper<ImClient>().lambda() ImClient imClientReceiver = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, imApplication.getId()) .eq(ImClient::getFkAppid, imApplication.getId())
...@@ -1023,7 +1012,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1023,7 +1012,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
if (imClientReceiver == null) { if (imClientReceiver == null) {
continue; continue;
} }
// 封装响应的实体 // 封装响应的实体
ImMessageOnlineSend imMessageOnlineSend = new ImMessageOnlineSend(); ImMessageOnlineSend imMessageOnlineSend = new ImMessageOnlineSend();
...@@ -1045,7 +1033,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1045,7 +1033,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
responseModel.setData(imMessageOnlineSend); responseModel.setData(imMessageOnlineSend);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, imClientReceiver.getId()); channelSender.sendMsg(responseModel, imClientReceiver.getId());
} }
} else { } else {
......
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