mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 20:57:47 +08:00
#1058 公众号模块加入设备绑定解绑消息支持
https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-2
This commit is contained in:
parent
e1b623906b
commit
3465d53880
@ -528,6 +528,14 @@ public class WxMpXmlMessage implements Serializable {
|
|||||||
@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;
|
||||||
|
}
|
||||||
|
}
|
@ -80,6 +80,13 @@ public abstract class WxMpXmlOutMessage implements Serializable {
|
|||||||
return new TransferCustomerServiceBuilder();
|
return new TransferCustomerServiceBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得设备消息builder
|
||||||
|
*/
|
||||||
|
public static DeviceBuilder DEVICE() {
|
||||||
|
return new DeviceBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public String toXml() {
|
public String toXml() {
|
||||||
return XStreamTransformer.toXml((Class<WxMpXmlOutMessage>) this.getClass(), this);
|
return XStreamTransformer.toXml((Class<WxMpXmlOutMessage>) this.getClass(), this);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user