Commit 785b6363 by Future

聊天室完善

parent 6ab229e5
...@@ -27,16 +27,16 @@ spring: ...@@ -27,16 +27,16 @@ spring:
# Redis配置 # Redis配置
redis: redis:
# database: 0
# host: 127.0.0.1
# password:
# port: 6379
database: 0 database: 0
host: 121.37.22.224 host: 127.0.0.1
password: temple123456 password:
port: 6379 port: 6379
# database: 0
# host: 121.37.22.224
# password: temple123456
# port: 6379
dubbo: dubbo:
protocol: protocol:
port: 20882 port: 20882
......
...@@ -280,7 +280,7 @@ public class ConversationAction { ...@@ -280,7 +280,7 @@ public class ConversationAction {
/** /**
* 全量获取聊天室成员 * 全量获取聊天室成员
*/ */
@PostMapping("/listChatRoomMember") @ActionMapping("/listChatRoomMember")
@ApiOperation(value = "全量获取聊天室成员", notes = "全量获取聊天室成员") @ApiOperation(value = "全量获取聊天室成员", notes = "全量获取聊天室成员")
public WsResponse<List<ChatRoomMemberVo>> listChatRoomMember(ChatRoomMemberPageParam data) { public WsResponse<List<ChatRoomMemberVo>> listChatRoomMember(ChatRoomMemberPageParam data) {
log.info("全量获取聊天室成员入参 {}", JSON.toJSONString(data)); log.info("全量获取聊天室成员入参 {}", JSON.toJSONString(data));
......
...@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -25,9 +26,9 @@ public class ChatRoomCacheManager { ...@@ -25,9 +26,9 @@ public class ChatRoomCacheManager {
/** /**
* redis的群聊天室房间键 key * redis的群聊天室房间键 key
*/ */
public static final String CHAT_ROOM_KEY = "chat_room_"; public static final String CHAT_MEMBER_KEY = "chat_member_";
@Autowired @Resource
private RedisUtils redisUtils; private RedisUtils redisUtils;
/** /**
...@@ -38,7 +39,7 @@ public class ChatRoomCacheManager { ...@@ -38,7 +39,7 @@ public class ChatRoomCacheManager {
* @param platform * @param platform
*/ */
public void intoRoom(Long clientId, Long chatRoomId, Integer platform) { public void intoRoom(Long clientId, Long chatRoomId, Integer platform) {
redisUtils.hashset(CHAT_ROOM_KEY + chatRoomId, clientId + RedisUtils.SPLIT + platform, GetIpUtils.getlanIp(), redisUtils.hashset(CHAT_MEMBER_KEY + chatRoomId, clientId + RedisUtils.SPLIT + platform, GetIpUtils.getlanIp(),
2, TimeUnit.DAYS); 2, TimeUnit.DAYS);
} }
...@@ -51,7 +52,7 @@ public class ChatRoomCacheManager { ...@@ -51,7 +52,7 @@ public class ChatRoomCacheManager {
* @param platform * @param platform
*/ */
public void exitRoom(Long clientId, Long chatRoomId, Integer platform) { public void exitRoom(Long clientId, Long chatRoomId, Integer platform) {
redisUtils.hashdel(CHAT_ROOM_KEY + chatRoomId, clientId + RedisUtils.SPLIT + platform); redisUtils.hashdel(CHAT_MEMBER_KEY + chatRoomId, clientId + RedisUtils.SPLIT + platform);
} }
/** /**
...@@ -61,7 +62,7 @@ public class ChatRoomCacheManager { ...@@ -61,7 +62,7 @@ public class ChatRoomCacheManager {
* @return 在线成员的key-val,其中key是 client的主键id:platform, val是 ip * @return 在线成员的key-val,其中key是 client的主键id:platform, val是 ip
*/ */
public Map<String, String> findOnlineClientsByChatRoomId(Long chatRoomId) { public Map<String, String> findOnlineClientsByChatRoomId(Long chatRoomId) {
return redisUtils.hashgetll(CHAT_ROOM_KEY + chatRoomId); return redisUtils.hashgetll(CHAT_MEMBER_KEY + chatRoomId);
} }
/** /**
......
...@@ -45,7 +45,7 @@ public class ImConversation extends BaseEntity { ...@@ -45,7 +45,7 @@ public class ImConversation extends BaseEntity {
@ApiModelProperty("群成员数量") @ApiModelProperty("群成员数量")
private Integer memberCount; private Integer memberCount;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群") @ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群,4:聊天室")
private Integer chatType; private Integer chatType;
@NotNull(message = "应用appid不能为空") @NotNull(message = "应用appid不能为空")
......
...@@ -24,4 +24,7 @@ public class ImConversationQueryParam implements Serializable { ...@@ -24,4 +24,7 @@ public class ImConversationQueryParam implements Serializable {
@ApiModelProperty("会话id") @ApiModelProperty("会话id")
private Long id; private Long id;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群 4:聊天室")
private Integer chatType;
} }
...@@ -52,7 +52,7 @@ public class ImConversationQueryVo implements Serializable { ...@@ -52,7 +52,7 @@ public class ImConversationQueryVo implements Serializable {
@ApiModelProperty("群成员数量") @ApiModelProperty("群成员数量")
private Integer memberCount; private Integer memberCount;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群") @ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群,4:聊天室")
private Integer chatType; private Integer chatType;
/** /**
......
...@@ -1135,6 +1135,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1135,6 +1135,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
try { try {
// 获取当前client // 获取当前client
ImClient client = contextService.getImClientIfNotNullOrThrow(); ImClient client = contextService.getImClientIfNotNullOrThrow();
if (param.getChatType() != null && param.getChatType() == 4) {
// 聊天室
ImConversation imConversation = imConversationMapper.selectById(param.getId());
if (imConversation != null) {
ConversationVo conversationVo = new ConversationVo();
BeanUtils.copyProperties(imConversation, conversationVo);
return conversationVo;
}
}
// 查询用户加入的所有会话 与每个会话的未读条数 成员 // 查询用户加入的所有会话 与每个会话的未读条数 成员
List<ConversationVo> conversationList = imConversationMapper.getMyImConversationListAndMsgCount(client.getId(), client.getClientId(), param.getId()); List<ConversationVo> conversationList = imConversationMapper.getMyImConversationListAndMsgCount(client.getId(), client.getClientId(), param.getId());
if (CollectionUtils.isEmpty(conversationList)) { if (CollectionUtils.isEmpty(conversationList)) {
......
...@@ -67,7 +67,7 @@ public class Conversation implements Serializable { ...@@ -67,7 +67,7 @@ public class Conversation implements Serializable {
private String members; private String members;
/** /**
* "会话属性,1:单聊,2:普通群,3:万人群" * "会话属性,1:单聊,2:普通群,3:万人群,4:聊天室"
*/ */
private Integer chatType; private Integer chatType;
......
...@@ -19,7 +19,7 @@ public class ListConversationRequest extends WebServiceRequest { ...@@ -19,7 +19,7 @@ public class ListConversationRequest extends WebServiceRequest {
private static final long serialVersionUID = -3602523207000275557L; private static final long serialVersionUID = -3602523207000275557L;
/** /**
* 会话属性,1:单聊,2:普通群,3:万人群 * 会话属性,1:单聊,2:普通群,3:万人群,4:聊天室
*/ */
private Integer chatType; private Integer chatType;
......
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