Skip to content
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

加入设备消息 #1058

Merged
merged 1 commit into from
May 28, 2019
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 @@ -527,6 +527,14 @@ public class WxMpXmlMessage implements Serializable {
@XStreamAlias("DeviceID")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceId;

/**
* 微信客户端生成的session id,用于request和response对应,
* 因此响应中该字段第三方需要原封不变的带回
*/
@XStreamAlias("SessionID")
@XStreamConverter(value = XStreamCDataConverter.class)
private String sessionId;

/**
* 微信用户账号的OpenID.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package me.chanjar.weixin.mp.bean.message;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;

import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;

@XStreamAlias("xml")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMpXmlOutDeviceMessage extends WxMpXmlOutMessage {
private static final long serialVersionUID = -3093843149649157587L;

@XStreamAlias("DeviceType")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceType;

@XStreamAlias("DeviceID")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceId;

@XStreamAlias("Content")
@XStreamConverter(value = XStreamCDataConverter.class)
private String content;

@XStreamAlias("SessionID")
@XStreamConverter(value = XStreamCDataConverter.class)
private String sessionId;

public WxMpXmlOutDeviceMessage() {
this.msgType = WxConsts.XmlMsgType.DEVICE_TEXT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public static NewsBuilder NEWS() {
public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
return new TransferCustomerServiceBuilder();
}

/**
* 获得设备消息builder
*/
public static DeviceBuilder DEVICE() {
return new DeviceBuilder();
}

@SuppressWarnings("unchecked")
public String toXml() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package me.chanjar.weixin.mp.builder.outxml;

import me.chanjar.weixin.mp.bean.message.WxMpXmlOutDeviceMessage;

/**
* 设备消息 Builder
* @author biggates
* @see https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-2
*/
public final class DeviceBuilder extends BaseBuilder<DeviceBuilder, WxMpXmlOutDeviceMessage> {

private String deviceId;
private String deviceType;
private String content;
private String sessionId;

public DeviceBuilder deviceType(String deviceType) {
this.deviceType = deviceType;
return this;
}

public DeviceBuilder deviceId(String deviceId) {
this.deviceId = deviceId;
return this;
}

public DeviceBuilder content(String content) {
this.content = content;
return this;
}

public DeviceBuilder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}

@Override
public WxMpXmlOutDeviceMessage build() {
WxMpXmlOutDeviceMessage m = new WxMpXmlOutDeviceMessage();
setCommon(m);
m.setDeviceId(this.deviceId);
m.setDeviceType(this.deviceType);
m.setContent(this.content);
m.setSessionId(this.sessionId);
return m;
}

}