Commit 4c876043 by Shadow

修复更新client attributes 后把旧的覆盖了的问题

parent 54533414
......@@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.wecloud.dispatch.extend.ActionRequest;
import com.wecloud.dispatch.util.ActionRequestHolder;
import com.wecloud.im.entity.ImApplication;
......@@ -405,7 +406,21 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
if (targetClient == null) {
throw new BusinessException("用户不存在");
}
targetClient.setAttributes(JSONObject.toJSONString(attributes));
TypeReference<Map<String, Object>> typeReference = new TypeReference<Map<String, Object>>() {
};
Map<String, Object> clientAttribute = JSONObject.parseObject(targetClient.getAttributes(), typeReference);
if (clientAttribute == null) {
clientAttribute = Maps.newHashMap();
}
if (attributes == null || attributes.isEmpty()) {
clientAttribute = Maps.newHashMap();
} else {
clientAttribute.putAll(attributes);
}
targetClient.setAttributes(JSONObject.toJSONString(clientAttribute));
// 清除client的redis缓存
redisUtils.delKey("cache" + targetClient.getId());
redisUtils.delKey("cache" + targetClient.getFkAppid() + targetClient.getClientId());
......
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