AndroidApp/ApiResponse.java

61 lines
1.4 KiB
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.example.myapplication.model;
import com.google.gson.annotations.SerializedName;
public class ApiResponse<T> {
@SerializedName("code")
private int code;
@SerializedName("msg")
private String msg; // 严格匹配服务器字段名 "msg"
@SerializedName("data")
private T data;
@SerializedName("status")
private int status;
@SerializedName("success")
private boolean success;
// Getters
public int getCode() {
return code;
}
public String getMsg() { // 方法名改为 getMsg() 与字段名一致
return msg;
}
public T getData() {
return data;
}
public int getStatus() {
return status;
}
public boolean isSuccess() {
return success;
}
// Setters按需添加
public void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return "ApiResponse{" +
"code=" + code +
", msg='" + msg + '\'' +
", data=" + data +
", status=" + status +
", success=" + success +
'}';
}
}