View Javadoc
1   package com.foxinmy.weixin4j.qy.message;
2   
3   import java.io.Serializable;
4   
5   import com.alibaba.fastjson.annotation.JSONField;
6   import com.foxinmy.weixin4j.qy.model.IdParameter;
7   import com.foxinmy.weixin4j.tuple.NotifyTuple;
8   
9   /**
10   * 消息提醒对象
11   *
12   * @className NotifyMessage
13   * @author jinyu(foxinmy@gmail.com)
14   * @date 2014年11月22日
15   * @since JDK 1.6
16   * @see com.foxinmy.weixin4j.tuple.Text
17   * @see com.foxinmy.weixin4j.tuple.Image
18   * @see com.foxinmy.weixin4j.tuple.Voice
19   * @see com.foxinmy.weixin4j.tuple.Video
20   * @see com.foxinmy.weixin4j.tuple.File
21   * @see com.foxinmy.weixin4j.tuple.News
22   * @see com.foxinmy.weixin4j.tuple.MpNews
23   */
24  public class NotifyMessage implements Serializable {
25  
26  	private static final long serialVersionUID = 1219589414293000383L;
27  
28  	/**
29  	 * 企业应用的id,整型。可在应用的设置页面查看
30  	 */
31  	@JSONField(name = "agentid")
32  	private int agentId;
33  	/**
34  	 * 表示是否是保密消息,0表示否,1表示是,默认0
35  	 */
36  	private int safe;
37  	/**
38  	 * 消息对象
39  	 */
40  	@JSONField(serialize = false)
41  	private NotifyTuple tuple;
42  	/**
43  	 * 发送对象
44  	 */
45  	@JSONField(serialize = false)
46  	private IdParameter target;
47  
48  	public NotifyMessage(int agentid, NotifyTuple tuple) {
49  		this(agentid, tuple, IdParameter.get(), false);
50  	}
51  
52  	public NotifyMessage(int agentId, NotifyTuple tuple, IdParameter target,
53  			boolean isSafe) {
54  		this.agentId = agentId;
55  		this.safe = isSafe ? 1 : 0;
56  		this.tuple = tuple;
57  		this.target = target;
58  	}
59  
60  	public int getAgentId() {
61  		return agentId;
62  	}
63  
64  	public NotifyTuple getTuple() {
65  		return tuple;
66  	}
67  
68  	public IdParameter getTarget() {
69  		return target;
70  	}
71  
72  	public void setTarget(IdParameter target) {
73  		this.target = target;
74  	}
75  
76  	public int getSafe() {
77  		return safe;
78  	}
79  
80  	public void setSafe(boolean isSafe) {
81  		this.safe = isSafe ? 1 : 0;
82  	}
83  
84  	@Override
85  	public String toString() {
86  		return "NotifyMessage [agentId=" + agentId + ", safe=" + safe
87  				+ ", tuple=" + tuple + ", target=" + target + "]";
88  	}
89  }