🐛 #2148 【企业微信】修复互联企业消息推送接口返回字段问题

This commit is contained in:
pg 2021-06-23 16:12:19 +08:00 committed by GitHub
parent 1e64a7f7b3
commit 71289e4dea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 11 deletions

View File

@ -1,10 +1,7 @@
package me.chanjar.weixin.cp.api; package me.chanjar.weixin.cp.api;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage; import me.chanjar.weixin.cp.bean.message.*;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
/** /**
* 消息推送接口. * 消息推送接口.
@ -52,5 +49,5 @@ public interface WxCpMessageService {
* @return the wx cp message send result * @return the wx cp message send result
* @throws WxErrorException the wx error exception * @throws WxErrorException the wx error exception
*/ */
WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException; WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException;
} }

View File

@ -5,10 +5,7 @@ import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpMessageService; import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage; import me.chanjar.weixin.cp.bean.message.*;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
@ -40,13 +37,13 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
} }
@Override @Override
public WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException { public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
Integer agentId = message.getAgentId(); Integer agentId = message.getAgentId();
if (null == agentId) { if (null == agentId) {
message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId()); message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
} }
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() return WxCpLinkedCorpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson())); .getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
} }
} }

View File

@ -0,0 +1,38 @@
package me.chanjar.weixin.cp.bean.message;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
/**
* 互联企业的消息推送接口返回实体
*
* @author pg
* @date 2021年6月22日
*/
@Setter
@Getter
public class WxCpLinkedCorpMessageSendResult extends WxCpBaseResp {
private static final long serialVersionUID = 3990693822996824333L;
@SerializedName("invaliduser")
private String[] invalidUser;
@SerializedName("invalidparty")
private String[] invalidParty;
@SerializedName("invalidtag")
private String[] invalidTag;
@Override
public String toString() {
return WxCpGsonBuilder.create().toJson(this);
}
public static WxCpLinkedCorpMessageSendResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpLinkedCorpMessageSendResult.class);
}
}