|
|
@@ -48,7 +48,7 @@ public class ImRoomOperator {
|
|
|
this.supplierMaxSort=supplierMaxSort;
|
|
|
|
|
|
Arrays.asList(assitId,doctorId)
|
|
|
- .forEach(userId-> unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId)));
|
|
|
+ .forEach(this::getSet);
|
|
|
}
|
|
|
|
|
|
private synchronized void initMaxSort(){
|
|
|
@@ -72,7 +72,7 @@ public class ImRoomOperator {
|
|
|
* @return void
|
|
|
*/
|
|
|
public void addUnreadMsg(String userId, List<String> key){
|
|
|
- unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId)).addAll(key);
|
|
|
+ getSet(userId).addAll(key);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -84,7 +84,7 @@ public class ImRoomOperator {
|
|
|
* @return void
|
|
|
*/
|
|
|
public void readUnreadMsg(String userId, List<String> key){
|
|
|
- unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId)).removeAll(key);
|
|
|
+ getSet(userId).removeAll(key);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -95,7 +95,7 @@ public class ImRoomOperator {
|
|
|
* @return void
|
|
|
*/
|
|
|
public void readUnreadMsgAll(String userId){
|
|
|
- unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId)).delete();
|
|
|
+ getSet(userId).delete();
|
|
|
}
|
|
|
/**
|
|
|
* 描述: 获取用户未读消息数量
|
|
|
@@ -105,7 +105,7 @@ public class ImRoomOperator {
|
|
|
* @return long
|
|
|
*/
|
|
|
public Integer unReadCount(String userId){
|
|
|
- return unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId))
|
|
|
+ return getSet(userId)
|
|
|
.size();
|
|
|
}
|
|
|
|
|
|
@@ -118,7 +118,7 @@ public class ImRoomOperator {
|
|
|
* @return Set<String>
|
|
|
*/
|
|
|
public Set<String> allUnreadMsgKey(String userId){
|
|
|
- return unReadMap.computeIfAbsent(userId,k->redissonClient.getSet("im:unread:"+id+":"+userId)).readAll();
|
|
|
+ return getSet(userId).readAll();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -173,4 +173,12 @@ public class ImRoomOperator {
|
|
|
public void setDoctorOnline(boolean online){
|
|
|
this.doctorOnline=online;
|
|
|
}
|
|
|
+
|
|
|
+ private RSet<String> getSet(String userId){
|
|
|
+ return unReadMap.computeIfAbsent(userId, k -> {
|
|
|
+ RSet<String> result = redissonClient.getSet("im:unread:" + id + ":" + userId);
|
|
|
+ result.expire(Duration.of(40,ChronoUnit.DAYS));
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|