Skip to content

Commit

Permalink
Merge pull request #246 from liukaitj/develop
Browse files Browse the repository at this point in the history
企业号的发送消息接口的数据格式中加入safe字段
  • Loading branch information
chanjarster committed Dec 18, 2015
2 parents 0388c8d + 15d6b79 commit 5309e13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class WxConsts {
public static final String CUSTOM_MSG_NEWS = "news";
public static final String CUSTOM_MSG_FILE = "file";
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
public static final String CUSTOM_MSG_SAFE_NO = "0";
public static final String CUSTOM_MSG_SAFE_YES = "1";

///////////////////////
// 群发消息的消息类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class WxCpMessage implements Serializable {
private String description;
private String musicUrl;
private String hqMusicUrl;
private String safe;
private List<WxArticle> articles = new ArrayList<WxArticle>();

public String getToUser() {
Expand Down Expand Up @@ -63,6 +64,14 @@ public String getMsgType() {
return msgType;
}

public String getSafe() {
return safe;
}

public void setSafe(String safe) {
this.safe = safe;
}

/**
* <pre>
* 请使用
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.chanjar.weixin.cp.bean.messagebuilder;

import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.cp.bean.WxCpMessage;

public class BaseBuilder<T> {
Expand All @@ -8,6 +9,7 @@ public class BaseBuilder<T> {
protected String toUser;
protected String toParty;
protected String toTag;
protected String safe;

public T agentId(String agentId) {
this.agentId = agentId;
Expand All @@ -29,13 +31,20 @@ public T toTag(String toTag) {
return (T) this;
}

public T safe(String safe) {
this.safe = safe;
return (T) this;
}

public WxCpMessage build() {
WxCpMessage m = new WxCpMessage();
m.setAgentId(this.agentId);
m.setMsgType(this.msgType);
m.setToUser(this.toUser);
m.setToParty(this.toParty);
m.setToTag(this.toTag);
m.setSafe(
(this.safe == null || "".equals(this.safe))? WxConsts.CUSTOM_MSG_SAFE_NO: this.safe);
return m;
}

Expand Down

0 comments on commit 5309e13

Please sign in to comment.