Files
yusheng-android/moduleUtil/src/main/java/com/qxcm/moduleutil/http/BaseModel.java

69 lines
1.4 KiB
Java
Raw Normal View History

2025-05-15 11:08:23 +08:00
package com.qxcm.moduleutil.http;
import android.os.Parcel;
import android.os.Parcelable;
public class BaseModel<T> implements Parcelable {
private int code;
2025-05-15 11:08:23 +08:00
private T data;
private String msg;
2025-05-15 11:08:23 +08:00
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public int getCode() {
return code;
2025-05-15 11:08:23 +08:00
}
public void setCode(int code) {
this.code = code;
2025-05-15 11:08:23 +08:00
}
public String getMsg() {
return msg;
2025-05-15 11:08:23 +08:00
}
public void setMsg(String msg) {
this.msg = msg;
2025-05-15 11:08:23 +08:00
}
public BaseModel() {
}
public boolean isSuccess() {
return code == 1; // 根据实际业务码判断是否成功
}
2025-05-15 11:08:23 +08:00
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.code);
dest.writeString(this.msg);
2025-05-15 11:08:23 +08:00
}
protected BaseModel(Parcel in) {
this.code = in.readInt();
this.msg = in.readString();
2025-05-15 11:08:23 +08:00
}
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];
}
};
}