Skip to content

Commit 2226149

Browse files
committed
使用lombok的@DaTa注解简化cp模块的所有bean类
1 parent e00e7bb commit 2226149

16 files changed

+104
-1062
lines changed
Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package me.chanjar.weixin.cp.bean;
22

3+
import lombok.Data;
34
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
45

56
import java.io.Serializable;
67

78
/**
8-
* 微信部门
9+
* 微信部门.
910
*
1011
* @author Daniel Qian
1112
*/
13+
@Data
1214
public class WxCpDepart implements Serializable {
1315

1416
private static final long serialVersionUID = -5028321625140879571L;
@@ -21,49 +23,8 @@ public static WxCpDepart fromJson(String json) {
2123
return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class);
2224
}
2325

24-
public Integer getId() {
25-
return this.id;
26-
}
27-
28-
public void setId(Integer id) {
29-
this.id = id;
30-
}
31-
32-
public String getName() {
33-
return this.name;
34-
}
35-
36-
public void setName(String name) {
37-
this.name = name;
38-
}
39-
40-
public Integer getParentId() {
41-
return this.parentId;
42-
}
43-
44-
public void setParentId(Integer parentId) {
45-
this.parentId = parentId;
46-
}
47-
48-
public Long getOrder() {
49-
return this.order;
50-
}
51-
52-
public void setOrder(Long order) {
53-
this.order = order;
54-
}
55-
5626
public String toJson() {
5727
return WxCpGsonBuilder.create().toJson(this);
5828
}
5929

60-
@Override
61-
public String toString() {
62-
return "WxCpDepart{" +
63-
"id=" + this.id +
64-
", name='" + this.name + '\'' +
65-
", parentId=" + this.parentId +
66-
", order=" + this.order +
67-
'}';
68-
}
6930
}
Lines changed: 12 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.chanjar.weixin.cp.bean;
22

3+
import lombok.Data;
34
import me.chanjar.weixin.common.api.WxConsts;
45
import me.chanjar.weixin.cp.bean.article.MpnewsArticle;
56
import me.chanjar.weixin.cp.bean.article.NewArticle;
@@ -11,13 +12,14 @@
1112
import java.util.List;
1213

1314
/**
14-
* 消息
15+
* 消息.
1516
*
1617
* @author Daniel Qian
1718
*/
19+
@Data
1820
public class WxCpMessage implements Serializable {
19-
2021
private static final long serialVersionUID = -2082278303476631708L;
22+
2123
private String toUser;
2224
private String toParty;
2325
private String toTag;
@@ -36,104 +38,61 @@ public class WxCpMessage implements Serializable {
3638
private List<MpnewsArticle> mpnewsArticles = new ArrayList<>();
3739

3840
/**
39-
* 获得文本消息builder
41+
* 获得文本消息builder.
4042
*/
4143
public static TextBuilder TEXT() {
4244
return new TextBuilder();
4345
}
4446

4547
/**
46-
* 获得文本卡片消息builder
48+
* 获得文本卡片消息builder.
4749
*/
4850
public static TextCardBuilder TEXTCARD() {
4951
return new TextCardBuilder();
5052
}
5153

5254
/**
53-
* 获得图片消息builder
55+
* 获得图片消息builder.
5456
*/
5557
public static ImageBuilder IMAGE() {
5658
return new ImageBuilder();
5759
}
5860

5961
/**
60-
* 获得语音消息builder
62+
* 获得语音消息builder.
6163
*/
6264
public static VoiceBuilder VOICE() {
6365
return new VoiceBuilder();
6466
}
6567

6668
/**
67-
* 获得视频消息builder
69+
* 获得视频消息builder.
6870
*/
6971
public static VideoBuilder VIDEO() {
7072
return new VideoBuilder();
7173
}
7274

7375
/**
74-
* 获得图文消息builder
76+
* 获得图文消息builder.
7577
*/
7678
public static NewsBuilder NEWS() {
7779
return new NewsBuilder();
7880
}
7981

8082
/**
81-
* 获得mpnews图文消息builder
83+
* 获得mpnews图文消息builder.
8284
*/
8385
public static MpnewsBuilder MPNEWS() {
8486
return new MpnewsBuilder();
8587
}
8688

8789
/**
88-
* 获得文件消息builder
90+
* 获得文件消息builder.
8991
*/
9092
public static FileBuilder FILE() {
9193
return new FileBuilder();
9294
}
9395

94-
public List<MpnewsArticle> getMpnewsArticles() {
95-
return mpnewsArticles;
96-
}
97-
98-
public void setMpnewsArticles(List<MpnewsArticle> mpnewsArticles) {
99-
this.mpnewsArticles = mpnewsArticles;
100-
}
101-
102-
public String getToUser() {
103-
return this.toUser;
104-
}
105-
106-
public void setToUser(String toUser) {
107-
this.toUser = toUser;
108-
}
109-
110-
public String getToParty() {
111-
return this.toParty;
112-
}
113-
114-
public void setToParty(String toParty) {
115-
this.toParty = toParty;
116-
}
117-
118-
public String getToTag() {
119-
return this.toTag;
120-
}
121-
122-
public void setToTag(String toTag) {
123-
this.toTag = toTag;
124-
}
125-
126-
public Integer getAgentId() {
127-
return this.agentId;
128-
}
129-
130-
public void setAgentId(Integer agentId) {
131-
this.agentId = agentId;
132-
}
133-
134-
public String getMsgType() {
135-
return this.msgType;
136-
}
13796

13897
/**
13998
* <pre>
@@ -153,87 +112,8 @@ public void setMsgType(String msgType) {
153112
this.msgType = msgType;
154113
}
155114

156-
public String getSafe() {
157-
return this.safe;
158-
}
159-
160-
public void setSafe(String safe) {
161-
this.safe = safe;
162-
}
163-
164-
public String getContent() {
165-
return this.content;
166-
}
167-
168-
public void setContent(String content) {
169-
this.content = content;
170-
}
171-
172-
public String getMediaId() {
173-
return this.mediaId;
174-
}
175-
176-
public void setMediaId(String mediaId) {
177-
this.mediaId = mediaId;
178-
}
179-
180-
public String getThumbMediaId() {
181-
return this.thumbMediaId;
182-
}
183-
184-
public void setThumbMediaId(String thumbMediaId) {
185-
this.thumbMediaId = thumbMediaId;
186-
}
187-
188-
public String getTitle() {
189-
return this.title;
190-
}
191-
192-
public void setTitle(String title) {
193-
this.title = title;
194-
}
195-
196-
public String getDescription() {
197-
return this.description;
198-
}
199-
200-
public void setDescription(String description) {
201-
this.description = description;
202-
}
203-
204-
public String getMusicUrl() {
205-
return this.musicUrl;
206-
}
207-
208-
public void setMusicUrl(String musicUrl) {
209-
this.musicUrl = musicUrl;
210-
}
211-
212-
public String getHqMusicUrl() {
213-
return this.hqMusicUrl;
214-
}
215-
216-
public void setHqMusicUrl(String hqMusicUrl) {
217-
this.hqMusicUrl = hqMusicUrl;
218-
}
219-
220-
public List<NewArticle> getArticles() {
221-
return this.articles;
222-
}
223-
224-
public void setArticles(List<NewArticle> articles) {
225-
this.articles = articles;
226-
}
227-
228115
public String toJson() {
229116
return WxCpGsonBuilder.INSTANCE.create().toJson(this);
230117
}
231118

232-
public String getUrl() {
233-
return this.url;
234-
}
235-
236-
public void setUrl(String url) {
237-
this.url = url;
238-
}
239119
}

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

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22

33
import com.google.common.base.Splitter;
44
import com.google.gson.annotations.SerializedName;
5+
import lombok.Data;
56
import me.chanjar.weixin.common.util.ToStringUtils;
67
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
78
import org.apache.commons.lang3.StringUtils;
89

10+
import java.io.Serializable;
911
import java.util.Collections;
1012
import java.util.List;
1113

1214
/**
13-
* <pre>
14-
* 消息发送结果对象类
15+
* 消息发送结果对象类.
1516
* Created by Binary Wang on 2017-6-22.
17+
*
1618
* @author <a href="https://github.com/binarywang">Binary Wang</a>
17-
* </pre>
1819
*/
19-
public class WxCpMessageSendResult {
20+
@Data
21+
public class WxCpMessageSendResult implements Serializable {
22+
private static final long serialVersionUID = 916455987193190004L;
23+
2024
@Override
2125
public String toString() {
2226
return ToStringUtils.toSimpleString(this);
@@ -41,52 +45,13 @@ public static WxCpMessageSendResult fromJson(String json) {
4145
@SerializedName("invalidtag")
4246
private String invalidTag;
4347

44-
public Integer getErrCode() {
45-
return this.errCode;
46-
}
47-
48-
public void setErrCode(Integer errCode) {
49-
this.errCode = errCode;
50-
}
51-
52-
public String getErrMsg() {
53-
return this.errMsg;
54-
}
55-
56-
public void setErrMsg(String errMsg) {
57-
this.errMsg = errMsg;
58-
}
59-
60-
public String getInvalidUser() {
61-
return this.invalidUser;
62-
}
63-
64-
public void setInvalidUser(String invalidUser) {
65-
this.invalidUser = invalidUser;
66-
}
67-
68-
public String getInvalidParty() {
69-
return this.invalidParty;
70-
}
71-
72-
public void setInvalidParty(String invalidParty) {
73-
this.invalidParty = invalidParty;
74-
}
75-
76-
public String getInvalidTag() {
77-
return this.invalidTag;
78-
}
79-
80-
public void setInvalidTag(String invalidTag) {
81-
this.invalidTag = invalidTag;
82-
}
8348

8449
public List<String> getInvalidUserList() {
8550
return this.content2List(this.invalidUser);
8651
}
8752

8853
private List<String> content2List(String content) {
89-
if(StringUtils.isBlank(content)){
54+
if (StringUtils.isBlank(content)) {
9055
return Collections.emptyList();
9156
}
9257

0 commit comments

Comments
 (0)