Skip to content

Commit

Permalink
🐛 #2148 【企业微信】修复互联企业消息推送接口返回字段问题
Browse files Browse the repository at this point in the history
  • Loading branch information
chutian0124 authored Jun 23, 2021
1 parent 1e64a7f commit 71289e4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package me.chanjar.weixin.cp.api;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
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.bean.message.*;

/**
* 消息推送接口.
Expand Down Expand Up @@ -52,5 +49,5 @@ public interface WxCpMessageService {
* @return the wx cp message send result
* @throws WxErrorException the wx error exception
*/
WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException;
WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
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.bean.message.*;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

Expand Down Expand Up @@ -40,13 +37,13 @@ public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorExcep
}

@Override
public WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
Integer agentId = message.getAgentId();
if (null == agentId) {
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()));
}
}
Original file line number Diff line number Diff line change
@@ -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);
}

}

0 comments on commit 71289e4

Please sign in to comment.