修改名称。
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.xscm.moduleutil.http;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class BaseModel<T> implements Parcelable {
|
||||
@SerializedName("code")
|
||||
private int code;
|
||||
@SerializedName("data")
|
||||
private T data;
|
||||
@SerializedName("msg")
|
||||
private String msg;
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public BaseModel() {
|
||||
|
||||
}
|
||||
public boolean isSuccess() {
|
||||
return code == 1; // 根据实际业务码判断是否成功
|
||||
}
|
||||
|
||||
public boolean isTokenExpired() {
|
||||
return code == 301; // token过期码
|
||||
}
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.code);
|
||||
dest.writeString(this.msg);
|
||||
}
|
||||
|
||||
protected BaseModel(Parcel in) {
|
||||
this.code = in.readInt();
|
||||
this.msg = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<BaseModel> CREATOR = new Creator<BaseModel>() {
|
||||
@Override
|
||||
public BaseModel createFromParcel(Parcel source) {
|
||||
return new BaseModel(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseModel[] newArray(int size) {
|
||||
return new BaseModel[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user