Skip to content

Commit 5309e13

Browse files
committed
Merge pull request #246 from liukaitj/develop
企业号的发送消息接口的数据格式中加入safe字段
2 parents 0388c8d + 15d6b79 commit 5309e13

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class WxConsts {
3030
public static final String CUSTOM_MSG_NEWS = "news";
3131
public static final String CUSTOM_MSG_FILE = "file";
3232
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
33+
public static final String CUSTOM_MSG_SAFE_NO = "0";
34+
public static final String CUSTOM_MSG_SAFE_YES = "1";
3335

3436
///////////////////////
3537
// 群发消息的消息类型

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class WxCpMessage implements Serializable {
2626
private String description;
2727
private String musicUrl;
2828
private String hqMusicUrl;
29+
private String safe;
2930
private List<WxArticle> articles = new ArrayList<WxArticle>();
3031

3132
public String getToUser() {
@@ -63,6 +64,14 @@ public String getMsgType() {
6364
return msgType;
6465
}
6566

67+
public String getSafe() {
68+
return safe;
69+
}
70+
71+
public void setSafe(String safe) {
72+
this.safe = safe;
73+
}
74+
6675
/**
6776
* <pre>
6877
* 请使用

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.chanjar.weixin.cp.bean.messagebuilder;
22

3+
import me.chanjar.weixin.common.api.WxConsts;
34
import me.chanjar.weixin.cp.bean.WxCpMessage;
45

56
public class BaseBuilder<T> {
@@ -8,6 +9,7 @@ public class BaseBuilder<T> {
89
protected String toUser;
910
protected String toParty;
1011
protected String toTag;
12+
protected String safe;
1113

1214
public T agentId(String agentId) {
1315
this.agentId = agentId;
@@ -29,13 +31,20 @@ public T toTag(String toTag) {
2931
return (T) this;
3032
}
3133

34+
public T safe(String safe) {
35+
this.safe = safe;
36+
return (T) this;
37+
}
38+
3239
public WxCpMessage build() {
3340
WxCpMessage m = new WxCpMessage();
3441
m.setAgentId(this.agentId);
3542
m.setMsgType(this.msgType);
3643
m.setToUser(this.toUser);
3744
m.setToParty(this.toParty);
3845
m.setToTag(this.toTag);
46+
m.setSafe(
47+
(this.safe == null || "".equals(this.safe))? WxConsts.CUSTOM_MSG_SAFE_NO: this.safe);
3948
return m;
4049
}
4150

0 commit comments

Comments
 (0)