mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
整理及重构
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.common.bean;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
public class WxAccessToken {
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private int expiresIn = -1;
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public int getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpiresIn(int expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
public static WxAccessToken fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxAccessToken.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package me.chanjar.weixin.common.bean;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 企业号菜单
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMenu {
|
||||
|
||||
private List<WxMenuButton> buttons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public List<WxMenuButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButtons(List<WxMenuButton> buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxMenu fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMenu.class);
|
||||
}
|
||||
|
||||
public static WxMenu fromJson(InputStream is) {
|
||||
return WxGsonBuilder.create().fromJson(new InputStreamReader(is), WxMenu.class);
|
||||
}
|
||||
|
||||
public static class WxMenuButton {
|
||||
|
||||
private String type;
|
||||
private String name;
|
||||
private String key;
|
||||
private String url;
|
||||
|
||||
private List<WxMenuButton> subButtons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public List<WxMenuButton> getSubButtons() {
|
||||
return subButtons;
|
||||
}
|
||||
|
||||
public void setSubButtons(List<WxMenuButton> subButtons) {
|
||||
this.subButtons = subButtons;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package me.chanjar.weixin.common.bean.result;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 微信错误码说明
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxError {
|
||||
|
||||
private int errorCode;
|
||||
|
||||
private String errorMsg;
|
||||
|
||||
private String json;
|
||||
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(int errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public void setJson(String json) {
|
||||
this.json = json;
|
||||
}
|
||||
|
||||
public static WxError fromJson(String json) {
|
||||
WxError error = WxGsonBuilder.create().fromJson(json, WxError.class);
|
||||
return error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "微信错误 errcode=" + errorCode + ", errmsg=" + errorMsg + "\njson:" + json;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.chanjar.weixin.common.bean.result;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
public class WxMediaUploadResult {
|
||||
|
||||
private String type;
|
||||
private String mediaId;
|
||||
private String thumbMediaId;
|
||||
private long createdAt;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public static WxMediaUploadResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", thumb_media_id=" + thumbMediaId
|
||||
+ ", created_at=" + createdAt + "]";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user