You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
package com.community.pocket.data.main.visitor;
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
import com.community.pocket.data.model.LocalToken;
|
|
import com.community.pocket.ui.main.ui.visitor.my.VisitorMyResponse;
|
|
import com.community.pocket.util.HttpRequest;
|
|
import com.community.pocket.util.HttpUtil;
|
|
import com.community.pocket.util.SimpleHttpParse;
|
|
|
|
import okhttp3.FormBody;
|
|
|
|
/**
|
|
* 我的访客请求接口
|
|
*/
|
|
public class VisitorMyRequest {
|
|
private static volatile VisitorMyRequest instance;
|
|
|
|
private VisitorMyRequest() {
|
|
}
|
|
|
|
public static VisitorMyRequest getInstance() {
|
|
if (instance == null) {
|
|
instance = new VisitorMyRequest();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
/**
|
|
* 加载我的访客
|
|
*/
|
|
@HttpRequest("/visitor/my")
|
|
public void loadMy(MutableLiveData<VisitorMyResponse> liveData, String startDate, String endDate, Long page) {
|
|
FormBody.Builder builder = new FormBody.Builder()
|
|
.add("username", LocalToken.getUsername())
|
|
.add("token", LocalToken.getToken());
|
|
if (startDate != null && !startDate.isEmpty()) {
|
|
builder.add("startDate", startDate);
|
|
}
|
|
if (endDate != null && !endDate.isEmpty()) {
|
|
builder.add("endDate", endDate);
|
|
}
|
|
builder.add("currentPage", String.valueOf(page));
|
|
HttpUtil.getRequest(HttpUtil.Method.GET,
|
|
new SimpleHttpParse<VisitorMyResponse>(liveData).getInterface(VisitorMyResponse.class), builder.build());
|
|
}
|
|
}
|
|
|