https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-2master
@@ -527,6 +527,14 @@ public class WxMpXmlMessage implements Serializable { | |||||
@XStreamAlias("DeviceID") | @XStreamAlias("DeviceID") | ||||
@XStreamConverter(value = XStreamCDataConverter.class) | @XStreamConverter(value = XStreamCDataConverter.class) | ||||
private String deviceId; | private String deviceId; | ||||
/** | |||||
* 微信客户端生成的session id,用于request和response对应, | |||||
* 因此响应中该字段第三方需要原封不变的带回 | |||||
*/ | |||||
@XStreamAlias("SessionID") | |||||
@XStreamConverter(value = XStreamCDataConverter.class) | |||||
private String sessionId; | |||||
/** | /** | ||||
* 微信用户账号的OpenID. | * 微信用户账号的OpenID. | ||||
@@ -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; | |||||
} | |||||
} |
@@ -79,6 +79,13 @@ public abstract class WxMpXmlOutMessage implements Serializable { | |||||
public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() { | public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() { | ||||
return new TransferCustomerServiceBuilder(); | return new TransferCustomerServiceBuilder(); | ||||
} | } | ||||
/** | |||||
* 获得设备消息builder | |||||
*/ | |||||
public static DeviceBuilder DEVICE() { | |||||
return new DeviceBuilder(); | |||||
} | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public String toXml() { | public String toXml() { | ||||
@@ -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; | |||||
} | |||||
} |