8000 增加对微信硬件平台事件消息的支持 by fuqiangdong01 · Pull Request #83 · binarywang/WxJava · GitHub
[go: up one dir, main page]

Skip to content

增加对微信硬件平台事件消息的支持 #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public class WxConsts {
public static final String XML_MSG_LOCATION = "location";
public static final String XML_MSG_LINK = "link";
public static final String XML_MSG_EVENT = "event";
public static final String XML_MSG_DEVICE_TEXT = "device_text";
public static final String XML_MSG_DEVICE_EVENT = "device_event";
public static final String XML_MSG_DEVICE_STATUS = "device_status";
public static final String XML_MSG_HARDWARE = "hardware";
public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";


///////////////////////
// 主动发送消息(即客服消息)的消息类型
///////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,81 @@ public class WxMpXmlMessage implements Serializable {
@XStreamAlias("FailReason")
private String failReason;


///////////////////////////////////////
// 微信硬件平台相关事件推送
///////////////////////////////////////
/**
* 设备类型,目前为"公众账号原始ID"
*/
@XStreamAlias("DeviceType")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceType;

/**
* 设备ID,第三方提供
*/
@XStreamAlias("DeviceId")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceId;


@XStreamAlias("HardWare")
private HardWare hardWare = new HardWare();

/**
* 请求类型:0:退订设备状态;1:心跳;(心跳的处理方式跟订阅一样)2:订阅设备状态
*/
@XStreamAlias("OpType")
private Integer opType;

/**
* 设备状态:0:未连接;1:已连接
*/
@XStreamAlias("DeviceStatus")
private Integer deviceStatus;

public Integer getOpType() {
return opType;
}

public void setOpType(Integer opType) {
this.opType = opType;
}

public Integer getDeviceStatus() {

return deviceStatus;
}

public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}

public HardWare getHardWare() {
return hardWare;
}

public void setHardWare(HardWare hardWare) {
this.hardWare = hardWare;
}

public String getDeviceType() {
return deviceType;
}

public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}

public String getDeviceId() {
return deviceId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}

public Long getExpiredTime() {
return this.expiredTime;
}
Expand Down Expand Up @@ -346,7 +421,6 @@ public void setCreateTime(Long createTime) {
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
* </pre>
*
*/
public String getMsgType() {
return this.msgType;
Expand Down Expand Up @@ -555,17 +629,17 @@ public static WxMpXmlMessage fromXml(InputStream is) {
* @param msgSignature
*/
public static WxMpXmlMessage fromEncryptedXml(String encryptedXml,
WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce,
String msgSignature) {
WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce,
String msgSignature) {
WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage);
String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce,
encryptedXml);
return fromXml(plainText);
}

public static WxMpXmlMessage fromEncryptedXml(InputStream is,
WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce,
String msgSignature) {
WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce,
String msgSignature) {
try {
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxMpConfigStorage,
timestamp, nonce, msgSignature);
Expand Down Expand Up @@ -719,6 +793,44 @@ public void setFromKfAccount(String fromKfAccount) {
this.fromKfAccount = fromKfAccount;
}

@XStreamAlias("HardWare")
public static class HardWare {
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
}

/**
* 消息展示,目前支持myrank(排行榜)
*/
@XStreamAlias("MessageView")
@XStreamConverter(value = XStreamCDataConverter.class)
private String messageView;

/**
* 消息点击动作,目前支持ranklist(点击跳转排行榜)
*/
@XStreamAlias("MessageAction")
@XStreamConverter(value = XStreamCDataConverter.class)
private String messageAction;

public String getMessageView() {
return messageView;
}

public void setMessageView(String messageView) {
this.messageView = messageView;
}

public String getMessageAction() {
return messageAction;
}

public void setMessageAction(String messageAction) {
this.messageAction = messageAction;
}
}

@XStreamAlias("ScanCodeInfo")
public static class ScanCodeInfo {
@Override
Expand Down
0