Commit a9d2e510 authored by fallenstardust's avatar fallenstardust

添加同步用户全部卡组接口方法

parent 51100030
package cn.garymb.ygomobile.deck_square;
import java.util.List;
public class DeckResponseJson {
int code;
String message;
String name;
List<DeckInfo> hobbies;
}
\ No newline at end of file
......@@ -27,6 +27,8 @@ import cn.garymb.ygomobile.deck_square.api_response.PushCardJson;
import cn.garymb.ygomobile.deck_square.api_response.PushDeckPublicState;
import cn.garymb.ygomobile.deck_square.api_response.PushDeckResponse;
import cn.garymb.ygomobile.deck_square.api_response.SquareDeckResponse;
import cn.garymb.ygomobile.deck_square.api_response.SyncDeckReq;
import cn.garymb.ygomobile.deck_square.api_response.SyncDecksResponse;
import cn.garymb.ygomobile.ui.plus.VUiKit;
import cn.garymb.ygomobile.utils.LogUtil;
import cn.garymb.ygomobile.utils.OkhttpUtil;
......@@ -242,6 +244,27 @@ public class DeckSquareApiUtil {
result = gson.fromJson(responseBodyString, PushDeckResponse.class);
LogUtil.i(TAG, "push deck response:" + responseBodyString);
return result;
}
public static SyncDecksResponse syncDecks(List<PushCardJson.DeckData> deckDataList, LoginToken loginToken) throws IOException {
SyncDecksResponse result = null;
String url = "http://rarnu.xyz:38383/api/mdpro3/sync/multi";
Map<String, String> headers = new HashMap<>();
headers.put("ReqSource", "MDPro3");
headers.put("token", loginToken.getServerToken());
Gson gson = new Gson();
SyncDeckReq syncDeckReq = new SyncDeckReq();
syncDeckReq.setDeckContributor(loginToken.getUserId().toString());
syncDeckReq.setUserId(loginToken.getUserId());
syncDeckReq.setDeckDataList(deckDataList);
String json = gson.toJson(syncDeckReq);
Response response = OkhttpUtil.postJson(url, json, headers, 1000);
String responseBodyString = response.body().string();
result = gson.fromJson(responseBodyString, SyncDecksResponse.class);
LogUtil.i(TAG, "push deck response:" + responseBodyString);
return result;
}
......
......@@ -121,6 +121,9 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
notifyDataSetChanged();
}
public List<MyDeckItem> getOriginalData(){
return this.originalData;
}
private void deleteMyDeckOnLine(MyDeckItem item) {
if (item != null) {
LoginToken loginToken = DeckSquareApiUtil.getLoginData();
......
package cn.garymb.ygomobile.deck_square.api_response;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.deck_square.api_response.PushCardJson.DeckData;
/*卡组同步请求类*/
public class SyncDeckReq {
private String deckContributor;
private Integer userId;
private List<DeckData> deckDataList;
public String getDeckContributor() {
return deckContributor;
}
public void setDeckContributor(String deckContributor) {
this.deckContributor = deckContributor;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public List<DeckData> getDeckDataList() {
return deckDataList;
}
public void setDeckDataList(List<DeckData> _deckDataList) {
this.deckDataList = _deckDataList;
}
}
package cn.garymb.ygomobile.deck_square.api_response;
/* 同步卡组响应体类*/
public class SyncDecksResponse {
private Integer code;
private String message;
private Integer data;
public SyncDecksResponse(Integer code, String message, Integer data) {
this.code = code;
this.message = message;
this.data = data;
}
// getters and setters
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getData() {
return data;
}
public void setData(Integer data) {
this.data = data;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment