Commit a26c1a50 by giaogiao

批量修改单向隐藏或显示会话

parent c09b444f
......@@ -58,10 +58,9 @@ public class ImConversationController extends BaseController {
*/
@PostMapping("/displayUpdate")
@ApiOperation(value = "批量修改单向隐藏或显示会话", notes = "拉取会话列表不展示已隐藏状态的会话,云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录")
public ApiResult<Boolean> updateDisplayConversation(@RequestBody List<ImConversationDisplayUpdate> imConversationDisplayUpdates) throws Exception {
for (ImConversationDisplayUpdate imConversationDisplayUpdate : imConversationDisplayUpdates) {
boolean flag = imConversationService.updateDisplayConversation(imConversationDisplayUpdate);
}
public ApiResult<Boolean> updateDisplayConversation(@RequestBody ImConversationDisplayUpdate imConversationDisplayUpdate) throws Exception {
imConversationService.updateDisplayConversation(imConversationDisplayUpdate);
return ApiResult.result(true);
}
......
......@@ -110,9 +110,8 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) {
log.info("客户端不活跃channelInactive");
String userIdByChannel = mangerChannelService.getInfoByChannel(ctx);
log.info("uid:" + userIdByChannel + "," + "不活跃" + ",channelId:" + ctx.channel().id().asLongText());
log.info("uid:" + userIdByChannel + "," + "channelInactive" + ",channelId:" + ctx.channel().id().asLongText());
}
/**
......
......@@ -7,6 +7,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 修改是否单向隐藏会话
*
......@@ -21,7 +23,7 @@ public class ImConversationDisplayUpdate extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "会话id", required = true)
private Long conversationId;
private List<Long> conversationIds;
@ApiModelProperty(value = "显示状态 1显示 0不显示", required = true)
private Integer displayStatus;
......
......@@ -230,15 +230,16 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Override
public boolean updateDisplayConversation(ImConversationDisplayUpdate imConversationDisplayUpdate) throws Exception {
ImClient curentClient = imClientService.getCurentClient();
// 修改为删除隐藏状态
boolean update = imConversationMembersService.update(new UpdateWrapper<ImConversationMembers>()
.set("display_status", imConversationDisplayUpdate.getDisplayStatus())
.eq("fk_client_id", curentClient.getId())
.eq("fk_conversation_id", imConversationDisplayUpdate.getConversationId())
.eq("fk_appid", curentClient.getFkAppid())
);
return update;
for (Long id : imConversationDisplayUpdate.getConversationIds()) {
// 修改为删除隐藏状态
boolean update = imConversationMembersService.update(new UpdateWrapper<ImConversationMembers>()
.set("display_status", imConversationDisplayUpdate.getDisplayStatus())
.eq("fk_client_id", curentClient.getId())
.eq("fk_conversation_id", id)
.eq("fk_appid", curentClient.getFkAppid())
);
}
return true;
}
@Override
......
......@@ -167,13 +167,16 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
// 获取加入的所有会话
List<ImConversation> myImConversationList = imConversationService.getMyImConversationList();
// 遍历会话列表, 查询每个会话列表的离线消息
for (ImConversation imConversation : myImConversationList) {
//根据客户端id与会话id 查询离线消息
List<OfflineMsgDto> offlineListByClientAndConversation = this.getOfflineListByClientAndConversation(client.getId(), imConversation.getId());
// 房间消息为空则不添加
if (offlineListByClientAndConversation.isEmpty()) {
continue;
}
ImMessageOfflineListVo imMessageOfflineListVo = new ImMessageOfflineListVo();
imMessageOfflineListVo.setMsgList(offlineListByClientAndConversation);
imMessageOfflineListVo.setConversationId(imConversation.getId());
......
......@@ -62,7 +62,7 @@ public class MangerChannelServiceImpl implements MangerChannelService {
// 断掉旧链接
NioSocketChannel nioSocketChannel = get(appKey, clientId);
if (null != nioSocketChannel) {
log.info("put新连接关掉旧链接:" + appKey + "," + clientId + "," + ",\nchannelId:" + nioSocketChannel.id().asLongText());
log.info("put新连接关掉旧链接:" + appKey + "," + clientId + ",\nchannelId:" + nioSocketChannel.id().asLongText());
nioSocketChannel.close();
}
......
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