mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
使用lombok的@Data注解简化mp模块的所有bean类
This commit is contained in:
parent
4c79eec2a5
commit
5db9725685
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.bean.kefu.request;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@ -8,6 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class WxMpKfAccountRequest implements Serializable {
|
||||
private static final long serialVersionUID = -5451863610674856927L;
|
||||
|
||||
|
@ -3,11 +3,15 @@ package me.chanjar.weixin.mp.bean.message;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@XStreamAlias("xml")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
|
||||
private static final long serialVersionUID = -4159937804975448945L;
|
||||
|
||||
@ -20,7 +24,8 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
|
||||
|
||||
@XStreamAlias("Music")
|
||||
@Data
|
||||
public static class Music {
|
||||
public static class Music implements Serializable {
|
||||
private static final long serialVersionUID = -5492592401691895334L;
|
||||
|
||||
@XStreamAlias("Title")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
@ -41,7 +46,46 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
|
||||
@XStreamAlias("HQMusicUrl")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String hqMusicUrl;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.music.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.music.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.music.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.music.description = description;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return this.music.thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.music.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public String getMusicUrl() {
|
||||
return this.music.musicUrl;
|
||||
}
|
||||
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
this.music.musicUrl = musicUrl;
|
||||
}
|
||||
|
||||
public String getHqMusicUrl() {
|
||||
return this.music.hqMusicUrl;
|
||||
}
|
||||
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
this.music.hqMusicUrl = hqMusicUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.bean.message;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
@ -10,6 +11,7 @@ import java.io.Serializable;
|
||||
|
||||
@XStreamAlias("xml")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
|
||||
private static final long serialVersionUID = 1745902309380113978L;
|
||||
|
||||
@ -39,4 +41,27 @@ public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
|
||||
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return this.video.mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.video.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.video.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.video.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.video.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.video.description = description;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.bean.store;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.annotation.Required;
|
||||
import me.chanjar.weixin.common.util.ToStringUtils;
|
||||
@ -21,6 +22,7 @@ import java.util.List;
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class WxMpStoreBaseInfo implements Serializable {
|
||||
private static final long serialVersionUID = 829577606838118218L;
|
||||
|
||||
@ -98,7 +100,8 @@ public class WxMpStoreBaseInfo implements Serializable {
|
||||
*/
|
||||
@Required
|
||||
@SerializedName("offset_type")
|
||||
private Integer offsetType = 1;
|
||||
@Builder.Default
|
||||
private final Integer offsetType = 1;
|
||||
/**
|
||||
* longitude
|
||||
* 门店所在地理位置的经度
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.chanjar.weixin.mp.bean.template;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.util.List;
|
||||
* 参考 http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN 发送模板消息接口部分
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class WxMpTemplateMessage implements Serializable {
|
||||
private static final long serialVersionUID = 5063374783759519418L;
|
||||
|
||||
@ -42,9 +44,11 @@ public class WxMpTemplateMessage implements Serializable {
|
||||
/**
|
||||
* 模板数据
|
||||
*/
|
||||
private List<WxMpTemplateData> data = new ArrayList<>();
|
||||
@Builder.Default
|
||||
private final List<WxMpTemplateData> data = new ArrayList<>();
|
||||
|
||||
public WxMpTemplateMessage() {
|
||||
public void addWxMpTemplateData(WxMpTemplateData datum) {
|
||||
this.data.add(datum);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
|
@ -47,8 +47,8 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder thumbMediaId(String thumb_media_id) {
|
||||
this.thumbMediaId = thumb_media_id;
|
||||
public MusicBuilder thumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxMpXmlOutVide
|
||||
public WxMpXmlOutVideoMessage build() {
|
||||
WxMpXmlOutVideoMessage m = new WxMpXmlOutVideoMessage();
|
||||
setCommon(m);
|
||||
m.setTitle(this.title);
|
||||
m.setDescription(this.description);
|
||||
m.setMediaId(this.mediaId);
|
||||
m.getVideo().setTitle(this.title);
|
||||
m.getVideo().setDescription(this.description);
|
||||
m.getVideo().setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class WxMpXmlMessageTest {
|
||||
assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getScale(), "15");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi");
|
||||
}
|
||||
|
||||
public void testFromXml2() {
|
||||
@ -167,7 +167,7 @@ public class WxMpXmlMessageTest {
|
||||
assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getScale(), "15");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi");
|
||||
assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class WxMpXmlOutMusicMessageTest {
|
||||
m.setHqMusicUrl("hQMusicUrl");
|
||||
m.setMusicUrl("musicUrl");
|
||||
m.setThumbMediaId("thumbMediaId");
|
||||
m.setCreateTime(1122l);
|
||||
m.setCreateTime(1122L);
|
||||
m.setFromUserName("fromUser");
|
||||
m.setToUserName("toUser");
|
||||
|
||||
|
@ -145,8 +145,8 @@ public class WxMpCurrentAutoReplyInfoTest {
|
||||
WxMpCurrentAutoReplyInfo autoReplyInfo = WxMpCurrentAutoReplyInfo.fromJson(json);
|
||||
|
||||
assertNotNull(autoReplyInfo);
|
||||
assertTrue(autoReplyInfo.getAddFriendReplyOpen());
|
||||
assertTrue(autoReplyInfo.getAutoReplyOpen());
|
||||
assertTrue(autoReplyInfo.getIsAddFriendReplyOpen());
|
||||
assertTrue(autoReplyInfo.getIsAutoReplyOpen());
|
||||
assertNotNull(autoReplyInfo.getAddFriendAutoReplyInfo());
|
||||
assertNotNull(autoReplyInfo.getMessageDefaultAutoReplyInfo());
|
||||
assertTrue(autoReplyInfo.getKeywordAutoReplyInfo().getList().size() > 0);
|
||||
|
Loading…
Reference in New Issue
Block a user