铭牌
This commit is contained in:
@@ -5,6 +5,7 @@ import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.throwable.HeadwearPulledOffShelvesException;
|
||||
import com.yizhuan.xchat_android_core.decoration.nameplate.bean.NamePlateInfo;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.utils.net.BalanceNotEnoughExeption;
|
||||
@@ -278,11 +279,6 @@ public class HeadwearModel extends BaseModel implements IHeadwearModel {
|
||||
@Query("page") String page,
|
||||
@Query("pageSize") String pageSize);
|
||||
|
||||
@GET("nameplate/userNameplateList")
|
||||
Single<ServiceResult<List<HeadWearInfo>>> getNamePlateListV2(@Query("uid") String uid,
|
||||
@Query("page") String page,
|
||||
@Query("pageSize") String pageSize);
|
||||
|
||||
/**
|
||||
* 获取头饰详情
|
||||
* @param headwearId
|
||||
|
@@ -3,6 +3,7 @@ package com.yizhuan.xchat_android_core.decoration.headwear;
|
||||
import com.yizhuan.xchat_android_core.base.IModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.yizhuan.xchat_android_core.decoration.nameplate.bean.NamePlateInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package com.yizhuan.xchat_android_core.decoration.nameplate;
|
||||
|
||||
import com.yizhuan.xchat_android_core.base.IModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.yizhuan.xchat_android_core.decoration.nameplate.bean.NamePlateInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
public interface INamePlateModel extends IModel {
|
||||
|
||||
/**
|
||||
* 获取我的铭牌列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Single<ServiceResult<NamePlateInfo>> getNamePlateList(long uid);
|
||||
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package com.yizhuan.xchat_android_core.decoration.nameplate;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.HeadwearModel;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.IHeadwearModel;
|
||||
import com.yizhuan.xchat_android_core.decoration.nameplate.bean.NamePlateInfo;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Function;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public class NamePlateModel extends BaseModel {
|
||||
|
||||
private volatile static NamePlateModel model;
|
||||
private Api api;
|
||||
|
||||
public static NamePlateModel get() {
|
||||
if (model == null) {
|
||||
synchronized (NamePlateModel.class) {
|
||||
if (model == null) {
|
||||
model = new NamePlateModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private NamePlateModel() {
|
||||
api = RxNet.create(Api.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取铭牌列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Single<NamePlateInfo> getNamePlateList(long uid) {
|
||||
return api.getNamePlateList(String.valueOf(uid), "1", "1000")
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用铭牌
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Single<String> useMyNamePlate(String nameplateId,String word){
|
||||
long uid = AuthModel.get().getCurrentUid();
|
||||
String ticket = AuthModel.get().getTicket();
|
||||
return api.useMyNamePlate(String.valueOf(uid),nameplateId,word,ticket)
|
||||
.flatMap(new Function<ServiceResult<String>, SingleSource<String>>() {
|
||||
@Override
|
||||
public SingleSource<String> apply(ServiceResult<String> stringServiceResult) throws Exception {
|
||||
if (stringServiceResult.isSuccess()) {
|
||||
return Single.just("使用成功");
|
||||
}else {
|
||||
return Single.error(new Throwable(stringServiceResult.getMessage()));
|
||||
}
|
||||
}
|
||||
})
|
||||
.doOnSuccess(s -> {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
// 更新房间信息
|
||||
IMNetEaseManager.get().updateMyRoomRole();
|
||||
}
|
||||
})
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private interface Api {
|
||||
/**
|
||||
* 获取铭牌列表
|
||||
* @param uid
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@POST("nameplate/userNameplateList")
|
||||
Single<ServiceResult<NamePlateInfo>> getNamePlateList(@Query("uid") String uid,
|
||||
@Query("page") String page,
|
||||
@Query("pageSize") String pageSize);
|
||||
|
||||
@POST("nameplate/useNameplate")
|
||||
Single<ServiceResult<String>> useMyNamePlate(@Query("uid") String uid,
|
||||
@Query("userNameplateId") String userNameplateId,
|
||||
@Query("word") String word,
|
||||
@Query("ticket") String ticket);
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,192 @@
|
||||
package com.yizhuan.xchat_android_core.decoration.nameplate.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NamePlateInfo {
|
||||
|
||||
|
||||
/**
|
||||
* total : 4
|
||||
* nameplateList : [{"id":6,"uid":934999,"nameplateId":9,"isCustomWord":true,"remark":"5","expireTime":1587275848000,"createTime":1586930248000,"updateTime":1586930248000,"nameplateName":"天龙八部","nameplateImage":"http://4567.jpg","isExpired":false,"expireDays":71}]
|
||||
*/
|
||||
|
||||
private int total;
|
||||
private List<NameplateListBean> nameplateList;
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<NameplateListBean> getNameplateList() {
|
||||
return nameplateList;
|
||||
}
|
||||
|
||||
public void setNameplateList(List<NameplateListBean> nameplateList) {
|
||||
this.nameplateList = nameplateList;
|
||||
}
|
||||
|
||||
public static class NameplateListBean {
|
||||
/**
|
||||
* id : 6
|
||||
* uid : 934999
|
||||
* nameplateId : 9
|
||||
* isCustomWord : true
|
||||
* remark : 5
|
||||
* expireTime : 1587275848000
|
||||
* createTime : 1586930248000
|
||||
* updateTime : 1586930248000
|
||||
* nameplateName : 天龙八部
|
||||
* nameplateImage : http://4567.jpg
|
||||
* isExpired : false
|
||||
* expireDays : 71
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private int uid;
|
||||
private int nameplateId;
|
||||
private boolean isCustomWord;
|
||||
private String remark;
|
||||
private long expireTime;
|
||||
private long createTime;
|
||||
private long updateTime;
|
||||
private String nameplateName;
|
||||
private String nameplateImage;
|
||||
private boolean isExpired;
|
||||
private int expireDays;
|
||||
private boolean isUsing;
|
||||
private String word;
|
||||
|
||||
public String getWord() {
|
||||
return word;
|
||||
}
|
||||
|
||||
public void setWord(String word) {
|
||||
this.word = word;
|
||||
}
|
||||
|
||||
public boolean isCustomWord() {
|
||||
return isCustomWord;
|
||||
}
|
||||
|
||||
public void setCustomWord(boolean customWord) {
|
||||
isCustomWord = customWord;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return isExpired;
|
||||
}
|
||||
|
||||
public void setExpired(boolean expired) {
|
||||
isExpired = expired;
|
||||
}
|
||||
|
||||
public boolean isUsing() {
|
||||
return isUsing;
|
||||
}
|
||||
|
||||
public void setUsing(boolean using) {
|
||||
isUsing = using;
|
||||
}
|
||||
|
||||
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 int getNameplateId() {
|
||||
return nameplateId;
|
||||
}
|
||||
|
||||
public void setNameplateId(int nameplateId) {
|
||||
this.nameplateId = nameplateId;
|
||||
}
|
||||
|
||||
public boolean isIsCustomWord() {
|
||||
return isCustomWord;
|
||||
}
|
||||
|
||||
public void setIsCustomWord(boolean isCustomWord) {
|
||||
this.isCustomWord = isCustomWord;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getNameplateName() {
|
||||
return nameplateName;
|
||||
}
|
||||
|
||||
public void setNameplateName(String nameplateName) {
|
||||
this.nameplateName = nameplateName;
|
||||
}
|
||||
|
||||
public String getNameplateImage() {
|
||||
return nameplateImage;
|
||||
}
|
||||
|
||||
public void setNameplateImage(String nameplateImage) {
|
||||
this.nameplateImage = nameplateImage;
|
||||
}
|
||||
|
||||
public boolean isIsExpired() {
|
||||
return isExpired;
|
||||
}
|
||||
|
||||
public void setIsExpired(boolean isExpired) {
|
||||
this.isExpired = isExpired;
|
||||
}
|
||||
|
||||
public int getExpireDays() {
|
||||
return expireDays;
|
||||
}
|
||||
|
||||
public void setExpireDays(int expireDays) {
|
||||
this.expireDays = expireDays;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user