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.
53 lines
1.7 KiB
53 lines
1.7 KiB
package com.community.pocket.data.main.info;
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
import com.community.pocket.data.model.LocalToken;
|
|
import com.community.pocket.ui.main.ui.info.InfoResponse;
|
|
import com.community.pocket.util.HttpRequest;
|
|
import com.community.pocket.util.HttpUtil;
|
|
import com.community.pocket.util.SimpleHttpParse;
|
|
|
|
import okhttp3.FormBody;
|
|
|
|
/**
|
|
* 个人信息请求接口
|
|
*/
|
|
public class InfoRequest {
|
|
private static volatile InfoRequest instance;
|
|
|
|
private InfoRequest() {
|
|
}
|
|
|
|
public static InfoRequest getInstance() {
|
|
if (instance == null) {
|
|
instance = new InfoRequest();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
//修改密码
|
|
@HttpRequest("/my/info/modifyPwd")
|
|
public void modifyPwd(MutableLiveData<InfoResponse> liveData, String oldPassword, String newPassword) {
|
|
HttpUtil.getRequest(HttpUtil.Method.POST,
|
|
new SimpleHttpParse<InfoResponse>(liveData).getInterface(InfoResponse.class),
|
|
new FormBody.Builder()
|
|
.add("oldPassword", oldPassword)
|
|
.add("newPassword", newPassword)
|
|
.add("token", LocalToken.getToken())
|
|
.add("username", LocalToken.getUsername())
|
|
.build());
|
|
}
|
|
|
|
//获取个人信息
|
|
@HttpRequest("/my/info")
|
|
public void loadInfo(MutableLiveData<InfoResponse> liveData) {
|
|
HttpUtil.getRequest(HttpUtil.Method.GET,
|
|
new SimpleHttpParse<InfoResponse>(liveData).getInterface(InfoResponse.class),
|
|
new FormBody.Builder()
|
|
.add("token", LocalToken.getToken())
|
|
.add("username", LocalToken.getUsername())
|
|
.build());
|
|
}
|
|
}
|
|
|