mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#760 小程序增加统一服务消息接口
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* Created by Binary Wang on 2018/9/23.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class WxMaTemplateData {
|
||||
private String name;
|
||||
private String value;
|
||||
private String color;
|
||||
|
||||
public WxMaTemplateData(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WxMaTemplateData(String name, String value, String color) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class WxMaTemplateMessage implements Serializable {
|
||||
* 描述: 模板内容,不填则下发空模板
|
||||
* </pre>
|
||||
*/
|
||||
private List<Data> data;
|
||||
private List<WxMaTemplateData> data;
|
||||
|
||||
/**
|
||||
* 模板内容字体的颜色,不填默认黑色.
|
||||
@@ -95,7 +95,7 @@ public class WxMaTemplateMessage implements Serializable {
|
||||
*/
|
||||
private String emphasisKeyword;
|
||||
|
||||
public WxMaTemplateMessage addData(Data datum) {
|
||||
public WxMaTemplateMessage addData(WxMaTemplateData datum) {
|
||||
if (this.data == null) {
|
||||
this.data = new ArrayList<>();
|
||||
}
|
||||
@@ -108,24 +108,4 @@ public class WxMaTemplateMessage implements Serializable {
|
||||
return WxMaGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
@NoArgsConstructor
|
||||
public static class Data {
|
||||
private String name;
|
||||
private String value;
|
||||
private String color;
|
||||
|
||||
public Data(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Data(String name, String value, String color) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 模板消息.
|
||||
* 参考 https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#接口说明 模板消息部分
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class WxMaUniformMessage implements Serializable {
|
||||
private static final long serialVersionUID = 5063374783759519418L;
|
||||
|
||||
/**
|
||||
* 是否发送公众号模版消息,否则发送小程序模版消息.
|
||||
*/
|
||||
private boolean isMpTemplateMsg;
|
||||
|
||||
/**
|
||||
* 用户openid.
|
||||
* 可以是小程序的openid,也可以是mp_template_msg.appid对应的公众号的openid
|
||||
*/
|
||||
private String toUser;
|
||||
|
||||
/**
|
||||
* 公众号appid,要求与小程序有绑定且同主体.
|
||||
*/
|
||||
private String appid;
|
||||
|
||||
/**
|
||||
* 公众号或小程序模板ID.
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 公众号模板消息所要跳转的url.
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 小程序页面路径.
|
||||
*/
|
||||
private String page;
|
||||
|
||||
/**
|
||||
* 小程序模板消息formid.
|
||||
*/
|
||||
private String formId;
|
||||
|
||||
/**
|
||||
* 公众号模板消息所要跳转的小程序,小程序的必须与公众号具有绑定关系.
|
||||
*/
|
||||
private MiniProgram miniProgram;
|
||||
|
||||
/**
|
||||
* 小程序模板数据.
|
||||
*/
|
||||
private List<WxMaTemplateData> data;
|
||||
|
||||
/**
|
||||
* 模板需要放大的关键词,不填则默认无放大.
|
||||
*/
|
||||
private String emphasisKeyword;
|
||||
|
||||
public WxMaUniformMessage addData(WxMaTemplateData datum) {
|
||||
if (this.data == null) {
|
||||
this.data = new ArrayList<>();
|
||||
}
|
||||
this.data.add(datum);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxMaGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MiniProgram implements Serializable {
|
||||
private static final long serialVersionUID = -7945254706501974849L;
|
||||
|
||||
private String appid;
|
||||
private String pagePath;
|
||||
|
||||
/**
|
||||
* 是否使用path,否则使用pagepath.
|
||||
* 加入此字段是基于微信官方接口变化多端的考虑
|
||||
*/
|
||||
private boolean usePath = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user