From 8cc01b311b942272873fa286de7f64e4e1636392 Mon Sep 17 00:00:00 2001 From: czp Date: Mon, 2 Apr 2018 10:14:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=8E=B7=E5=A5=96=E8=AE=B0=E5=BD=95=20=E7=9A=84=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hiczp/bilibili/api/live/LiveService.java | 3 +- .../api/live/entity/AwardsEntity.java | 229 +++++++++++++++++- .../bilibili/api/test/GetAwardsTest.java | 2 +- 3 files changed, 218 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/hiczp/bilibili/api/live/LiveService.java b/src/main/java/com/hiczp/bilibili/api/live/LiveService.java index 1c9741d..cdebec8 100644 --- a/src/main/java/com/hiczp/bilibili/api/live/LiveService.java +++ b/src/main/java/com/hiczp/bilibili/api/live/LiveService.java @@ -552,10 +552,9 @@ public interface LiveService { //TODO 头衔工坊(没有可升级头衔, 暂不明确此 API) - //TODO 获奖记录(没有获奖记录, 暂不明确返回值) //侧拉抽屉 -> 直播中心 -> 获奖记录 @GET("AppUser/awards") - Call getAwards(); + Call getAwardRecords(); /** * 瓜子商店 diff --git a/src/main/java/com/hiczp/bilibili/api/live/entity/AwardsEntity.java b/src/main/java/com/hiczp/bilibili/api/live/entity/AwardsEntity.java index 7e81926..34b051b 100644 --- a/src/main/java/com/hiczp/bilibili/api/live/entity/AwardsEntity.java +++ b/src/main/java/com/hiczp/bilibili/api/live/entity/AwardsEntity.java @@ -1,6 +1,5 @@ package com.hiczp.bilibili.api.live.entity; -import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; import java.util.List; @@ -9,7 +8,7 @@ public class AwardsEntity { /** * code : 0 * message : OK - * data : {"list":[],"use_count":0,"count":0} + * data : {"list":[{"id":100000,"uid":1000000,"gift_name":"小电视","gift_type":"2","gift_num":1,"user_name":"打码","user_phone":"打码","user_address":"打码","user_extra_field":"{\"user_area\":\"打码\",\"user_post_code\":\"打码\",\"user_city\":\"打码\",\"user_province\":\"打码\"}","source":"小电视抽奖","source_id":10000,"create_time":"2018-02-01 00:00:00","update_time":null,"expire_time":"2018-02-16 00:00:00","comment":null,"status":0,"expire":true,"finished":true},{"id":10000,"uid":1000000,"gift_name":"小米Max2手机","gift_type":"2","gift_num":1,"user_name":"打码","user_phone":"打码","user_address":"打码","user_extra_field":"{\"user_province\":\"\\u6253\\u7801\",\"user_city\":\"\\u6253\\u7801\",\"user_area\":\"\\u6253\\u7801\",\"user_post_code\":\"打码\"}","source":"小米Max2超耐久直播第二季","source_id":1,"create_time":"2017-06-01 00:00:00","update_time":"2017-06-01 00:00:00","expire_time":"2017-06-30 00:00:00","comment":null,"status":0,"expire":true,"finished":true}],"use_count":0,"count":2} */ @SerializedName("code") @@ -17,7 +16,7 @@ public class AwardsEntity { @SerializedName("message") private String message; @SerializedName("data") - private Data data; + private DataEntity data; public int getCode() { return code; @@ -35,19 +34,19 @@ public class AwardsEntity { this.message = message; } - public Data getData() { + public DataEntity getData() { return data; } - public void setData(Data data) { + public void setData(DataEntity data) { this.data = data; } - public static class Data { + public static class DataEntity { /** - * list : [] + * list : [{"id":100000,"uid":1000000,"gift_name":"小电视","gift_type":"2","gift_num":1,"user_name":"打码","user_phone":"打码","user_address":"打码","user_extra_field":"{\"user_area\":\"打码\",\"user_post_code\":\"打码\",\"user_city\":\"打码\",\"user_province\":\"打码\"}","source":"小电视抽奖","source_id":10000,"create_time":"2018-02-01 00:00:00","update_time":null,"expire_time":"2018-02-16 00:00:00","comment":null,"status":0,"expire":true,"finished":true},{"id":10000,"uid":1000000,"gift_name":"小米Max2手机","gift_type":"2","gift_num":1,"user_name":"打码","user_phone":"打码","user_address":"打码","user_extra_field":"{\"user_province\":\"\\u6253\\u7801\",\"user_city\":\"\\u6253\\u7801\",\"user_area\":\"\\u6253\\u7801\",\"user_post_code\":\"打码\"}","source":"小米Max2超耐久直播第二季","source_id":1,"create_time":"2017-06-01 00:00:00","update_time":"2017-06-01 00:00:00","expire_time":"2017-06-30 00:00:00","comment":null,"status":0,"expire":true,"finished":true}] * use_count : 0 - * count : 0 + * count : 2 */ @SerializedName("use_count") @@ -55,7 +54,7 @@ public class AwardsEntity { @SerializedName("count") private int count; @SerializedName("list") - private List list; + private List awardList; public int getUseCount() { return useCount; @@ -73,12 +72,216 @@ public class AwardsEntity { this.count = count; } - public List getList() { - return list; + public List getAwardList() { + return awardList; } - public void setList(List list) { - this.list = list; + public void setAwardList(List awardList) { + this.awardList = awardList; + } + + public static class AwardEntity { + /** + * id : 100000 + * uid : 1000000 + * gift_name : 小电视 + * gift_type : 2 + * gift_num : 1 + * user_name : 打码 + * user_phone : 打码 + * user_address : 打码 + * user_extra_field : {"user_area":"打码","user_post_code":"打码","user_city":"打码","user_province":"打码"} + * source : 小电视抽奖 + * source_id : 10000 + * create_time : 2018-02-01 00:00:00 + * update_time : null + * expire_time : 2018-02-16 00:00:00 + * comment : null + * status : 0 + * expire : true + * finished : true + */ + + @SerializedName("id") + private int id; + @SerializedName("uid") + private int uid; + @SerializedName("gift_name") + private String giftName; + @SerializedName("gift_type") + private String giftType; + @SerializedName("gift_num") + private int giftNum; + @SerializedName("user_name") + private String userName; + @SerializedName("user_phone") + private String userPhone; + @SerializedName("user_address") + private String userAddress; + @SerializedName("user_extra_field") + private String userExtraField; + @SerializedName("source") + private String source; + @SerializedName("source_id") + private int sourceId; + @SerializedName("create_time") + private String createTime; + @SerializedName("update_time") + private Object updateTime; + @SerializedName("expire_time") + private String expireTime; + @SerializedName("comment") + private Object comment; + @SerializedName("status") + private int status; + @SerializedName("expire") + private boolean expire; + @SerializedName("finished") + private boolean finished; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public String getGiftName() { + return giftName; + } + + public void setGiftName(String giftName) { + this.giftName = giftName; + } + + public String getGiftType() { + return giftType; + } + + public void setGiftType(String giftType) { + this.giftType = giftType; + } + + public int getGiftNum() { + return giftNum; + } + + public void setGiftNum(int giftNum) { + this.giftNum = giftNum; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserAddress() { + return userAddress; + } + + public void setUserAddress(String userAddress) { + this.userAddress = userAddress; + } + + public String getUserExtraField() { + return userExtraField; + } + + public void setUserExtraField(String userExtraField) { + this.userExtraField = userExtraField; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public int getSourceId() { + return sourceId; + } + + public void setSourceId(int sourceId) { + this.sourceId = sourceId; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public Object getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Object updateTime) { + this.updateTime = updateTime; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public Object getComment() { + return comment; + } + + public void setComment(Object comment) { + this.comment = comment; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public boolean isExpire() { + return expire; + } + + public void setExpire(boolean expire) { + this.expire = expire; + } + + public boolean isFinished() { + return finished; + } + + public void setFinished(boolean finished) { + this.finished = finished; + } } } } diff --git a/src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java b/src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java index e481975..f3af578 100644 --- a/src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java +++ b/src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java @@ -13,7 +13,7 @@ public class GetAwardsTest { public void getAwards() throws Exception { BILIBILI_API .getLiveService(Collections.emptyList(), HttpLoggingInterceptor.Level.BODY) - .getAwards() + .getAwardRecords() .execute() .body(); }