fix(im): 修复addGroupMember时memberName因@JsonIgnore在Feign传输中丢失
移除MemberListDTO.memberName上的@JsonIgnore注解,确保名称能通过Feign跨服务传输。 改为在发送腾讯IM API前手动移除memberName字段,避免发送IM不接受的字段。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package com.renkang.im.dto;
|
package com.renkang.im.dto;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -55,7 +54,6 @@ public class AddGroupMemberDTO {
|
|||||||
/**
|
/**
|
||||||
* 群成员名称(可选,仅用于IM账号导入,不发送到腾讯IM)
|
* 群成员名称(可选,仅用于IM账号导入,不发送到腾讯IM)
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
|
||||||
private String memberName;
|
private String memberName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,9 +548,13 @@ public class TencentCloudImUtil {
|
|||||||
String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.GroupManage.ADD_GROUP_MEMBER, random);
|
String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.GroupManage.ADD_GROUP_MEMBER, random);
|
||||||
String jsonString = objectMapper.writeValueAsString(dto);
|
String jsonString = objectMapper.writeValueAsString(dto);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||||
// JSONObject jsonObject = new JSONObject();
|
// 移除 memberName 字段,腾讯IM API 不接受此字段
|
||||||
// jsonObject.put("GroupId", dto.getGroupId());
|
JSONArray memberList = jsonObject.getJSONArray("MemberList");
|
||||||
// jsonObject.put("MemberList", dto.getMemberList());
|
if (memberList != null) {
|
||||||
|
for (int i = 0; i < memberList.size(); i++) {
|
||||||
|
memberList.getJSONObject(i).remove("memberName");
|
||||||
|
}
|
||||||
|
}
|
||||||
log.info("腾讯云im添加群成员,请求参数:{}", jsonObject);
|
log.info("腾讯云im添加群成员,请求参数:{}", jsonObject);
|
||||||
String result = HttpUtil.doPost(httpsUrl, jsonObject);
|
String result = HttpUtil.doPost(httpsUrl, jsonObject);
|
||||||
log.info("腾讯云im添加群成员,返回结果:{}", result);
|
log.info("腾讯云im添加群成员,返回结果:{}", result);
|
||||||
|
|||||||
Reference in New Issue
Block a user