d
This commit is contained in:
75
app/src/main/java/com/fenghoo/seven/network/ApiCallBack.java
Normal file
75
app/src/main/java/com/fenghoo/seven/network/ApiCallBack.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.fenghoo.seven.network;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.fenghoo.seven.network.http.ResponseBean;
|
||||
import com.fenghoo.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import retrofit2.HttpException;
|
||||
|
||||
|
||||
/**
|
||||
* ApiCallBack
|
||||
* 类描述: 网络请求结果的二次封装
|
||||
* 作者: xiaoyu on 2016/12/29 13:40
|
||||
*/
|
||||
|
||||
public abstract class ApiCallBack<T> {
|
||||
|
||||
protected abstract void onSuccess(T responseData, String message);
|
||||
|
||||
protected abstract void onFailure(String error);
|
||||
|
||||
public void onResponse(final ResponseBean<T> responseBean) {
|
||||
if (responseBean == null) {
|
||||
//接口崩溃
|
||||
onFailure("系统错误");
|
||||
return;
|
||||
}
|
||||
//数据结果分类
|
||||
if (responseBean.getStatus() == ResponseBean.SUCCESS) {
|
||||
onSuccess(responseBean.getResult(), "");
|
||||
} else if (responseBean.getStatus() == ResponseBean.ERROR) {
|
||||
if ("用户不存在".equals("") || "\\u7528\\u6237\\u4e0d\\u5b58\\u5728".equals("")) {
|
||||
// TODO: 2017/4/28 用户被挤下线,让用户重新登录
|
||||
ProfileSpUtils.getInstance().saveLoginSatus(false);
|
||||
onFailure("您没有登录或您的登录信息过期,请重新登录");
|
||||
} else {
|
||||
//其他错误信息提示
|
||||
onFailure("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求失败
|
||||
*
|
||||
* @param throwable
|
||||
*/
|
||||
public void onFailure(final Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (throwable instanceof HttpException) {
|
||||
HttpException httpException = (HttpException) throwable;
|
||||
int code = httpException.code();
|
||||
if (code == 500 || code == 404) {
|
||||
onFailure("服务器出错");
|
||||
}
|
||||
} else if (throwable instanceof ConnectException) {
|
||||
onFailure("网络断开,请打开网络!");
|
||||
} else if (throwable instanceof SocketTimeoutException) {
|
||||
onFailure("网络连接超时!!");
|
||||
} else if (throwable instanceof LifeTreeAPIException) {
|
||||
onFailure(throwable.getMessage());
|
||||
} else if (throwable instanceof UnknownHostException) {
|
||||
onFailure("网络断开,请打开网络!");
|
||||
} else {
|
||||
onFailure("发生未知错误" + throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
84
app/src/main/java/com/fenghoo/seven/network/ApiUtils.java
Normal file
84
app/src/main/java/com/fenghoo/seven/network/ApiUtils.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.fenghoo.seven.network;
|
||||
|
||||
|
||||
import com.fenghoo.seven.network.http.MyApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* retrofit2网络请求框架
|
||||
*/
|
||||
public class ApiUtils {
|
||||
private static MyApi.Api api;
|
||||
private static WeChatApi.Api weChatApi;
|
||||
|
||||
static {
|
||||
//日志拦截器
|
||||
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
|
||||
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient mOkHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)//链接15秒超时
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.addInterceptor(httpLoggingInterceptor)
|
||||
.addInterceptor(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request().newBuilder()
|
||||
//在这里添加请求头或一些公共参数
|
||||
.build();
|
||||
return chain.proceed(request);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
api = new Retrofit.Builder()
|
||||
.baseUrl(MyApi.PREFIX)
|
||||
.client(mOkHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create())//添加Gson解析
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())//添加RxJava2支持
|
||||
.build()
|
||||
.create(MyApi.Api.class);
|
||||
|
||||
weChatApi = new Retrofit.Builder()
|
||||
.baseUrl(WeChatApi.BASE_URL)
|
||||
.client(mOkHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create())//添加Gson解析
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())//添加RxJava2支持
|
||||
.build()
|
||||
.create(WeChatApi.Api.class);
|
||||
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(MyApi.PREFIX)
|
||||
.client(mOkHttpClient)
|
||||
.addConverterFactory(LifeTreeConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MyApi.Api getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
|
||||
public static WeChatApi.Api getWeChatApi() {
|
||||
return weChatApi;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.fenghoo.seven.network;
|
||||
|
||||
/**
|
||||
* Created by: xudiwei
|
||||
* <p>
|
||||
* on: 2017/4/24.
|
||||
* <p>
|
||||
* 描述:http数据异常类
|
||||
*/
|
||||
|
||||
public class LifeTreeAPIException extends RuntimeException {
|
||||
public int errorCode;
|
||||
|
||||
public LifeTreeAPIException(int errorCode, String message) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.fenghoo.seven.network;
|
||||
|
||||
|
||||
import com.fenghoo.seven.BaseApplication;
|
||||
import com.fenghoo.seven.R;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
/**
|
||||
* Created by: xudiwei
|
||||
* <p>
|
||||
* on: 2017/4/24.
|
||||
* <p>
|
||||
* 描述:生命树http请求数据转换类
|
||||
*/
|
||||
|
||||
public class LifeTreeConverterFactory extends Converter.Factory {
|
||||
private static final String TAG = "LifeTreeConverterFactor";
|
||||
private static final int STATE_SUCCESS = 1;
|
||||
private static final int STATE_FAILED = 0;
|
||||
private Gson mGson = new Gson();
|
||||
|
||||
public static LifeTreeConverterFactory create() {
|
||||
return new LifeTreeConverterFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
|
||||
return new LifeTreeResponseConverter<>(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应解析
|
||||
*/
|
||||
private class LifeTreeResponseConverter<T> implements Converter<ResponseBody, T> {
|
||||
private Type mType;
|
||||
|
||||
LifeTreeResponseConverter(Type type) {
|
||||
mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T convert(ResponseBody value) throws IOException {
|
||||
return parser2(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一种解析
|
||||
*test测试用的,用于打印响应数据json
|
||||
* @param value
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private T parser(ResponseBody value) throws IOException {
|
||||
String response;
|
||||
try {
|
||||
response = value.string();
|
||||
if (mType == String.class) {
|
||||
return (T) response;
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
int state = jsonObject.getInt("status");
|
||||
if (state == STATE_FAILED) {
|
||||
String msg = jsonObject.getString("msg");
|
||||
throw new LifeTreeAPIException(state, msg);
|
||||
} else {
|
||||
String data = jsonObject.getString("data");
|
||||
return mGson.fromJson(data, mType);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new LifeTreeAPIException(0, BaseApplication.getContext().getString(R.string.text_http_data_parser_error));
|
||||
} finally {
|
||||
value.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二种解析
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private T parser2(ResponseBody value) throws IOException {
|
||||
String response;
|
||||
try {
|
||||
response = value.string();
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
int state = jsonObject.getInt("status");
|
||||
if (state == STATE_FAILED) {
|
||||
String msg = jsonObject.getString("msg");
|
||||
throw new LifeTreeAPIException(state, msg);
|
||||
} else {
|
||||
String data = jsonObject.getString("data");
|
||||
if (mType == String.class) {
|
||||
return (T) data;
|
||||
} else {
|
||||
return mGson.fromJson(data, mType);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new LifeTreeAPIException(0, BaseApplication.getContext().getString(R.string.text_http_data_parser_error));
|
||||
} finally {
|
||||
value.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
app/src/main/java/com/fenghoo/seven/network/WeChatApi.java
Normal file
32
app/src/main/java/com/fenghoo/seven/network/WeChatApi.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.fenghoo.seven.network;
|
||||
|
||||
import com.fenghoo.seven.main.entity.mine.WeChatLoginEntity;
|
||||
import com.fenghoo.seven.main.entity.mine.WeChatLoginResultEntity;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
/**
|
||||
* WeChatApi
|
||||
* (๑• . •๑)
|
||||
* 类描述: 微信登陆API
|
||||
* Created by LeiXiaoXing on 2017/5/24 15:06
|
||||
*/
|
||||
|
||||
public class WeChatApi {
|
||||
public static final String BASE_URL = "https://api.weixin.qq.com/sns/";
|
||||
|
||||
public interface Api {
|
||||
|
||||
@GET("oauth2/access_token")
|
||||
Observable<WeChatLoginResultEntity> access_token(@Query("appid") String appid
|
||||
, @Query("secret") String secret
|
||||
, @Query("code") String code
|
||||
, @Query("grant_type") String grant_type);
|
||||
|
||||
@GET("userinfo")
|
||||
Observable<WeChatLoginEntity> userInfo(@Query("access_token") String access_token
|
||||
, @Query("openid") String openid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.fenghoo.seven.network.http;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* retrofit2网络请求框架
|
||||
*/
|
||||
public class ApiUtils {
|
||||
private static MyApi.Api api;
|
||||
|
||||
|
||||
|
||||
|
||||
static {
|
||||
//日志拦截器
|
||||
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
|
||||
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient mOkHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)//链接15秒超时
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.addInterceptor(httpLoggingInterceptor)
|
||||
.addInterceptor(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request().newBuilder()
|
||||
//在这里添加请求头或一些公共参数
|
||||
.build();
|
||||
return chain.proceed(request);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
api = new Retrofit.Builder()
|
||||
.baseUrl(MyApi.PREFIX)
|
||||
.client(mOkHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create())//添加Gson解析
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())//添加RxJava2支持
|
||||
.build()
|
||||
.create(MyApi.Api.class);
|
||||
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(MyApi.PREFIX)
|
||||
.client(mOkHttpClient)
|
||||
.addConverterFactory(LifeTreeConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取API
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MyApi.Api getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.fenghoo.seven.network.http;
|
||||
|
||||
/**
|
||||
* Created by: xudiwei
|
||||
* <p>
|
||||
* on: 2017/4/24.
|
||||
* <p>
|
||||
* 描述:http数据异常类
|
||||
*/
|
||||
|
||||
public class LifeTreeAPIException extends RuntimeException {
|
||||
public int errorCode;
|
||||
|
||||
public LifeTreeAPIException(int errorCode, String message) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.fenghoo.seven.network.http;
|
||||
|
||||
|
||||
import com.fenghoo.seven.BaseApplication;
|
||||
import com.fenghoo.seven.R;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
/**
|
||||
* Created by: xudiwei
|
||||
* <p>
|
||||
* on: 2017/4/24.
|
||||
* <p>
|
||||
* 描述:生命树http请求数据转换类
|
||||
*/
|
||||
|
||||
public class LifeTreeConverterFactory extends Converter.Factory {
|
||||
private static final String TAG = "LifeTreeConverterFactor";
|
||||
private static final int STATE_SUCCESS = 1;
|
||||
private static final int STATE_FAILED = 0;
|
||||
private Gson mGson = new Gson();
|
||||
|
||||
public static LifeTreeConverterFactory create() {
|
||||
return new LifeTreeConverterFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
|
||||
return new LifeTreeResponseConverter<>(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应解析
|
||||
*/
|
||||
private class LifeTreeResponseConverter<T> implements Converter<ResponseBody, T> {
|
||||
private Type mType;
|
||||
|
||||
LifeTreeResponseConverter(Type type) {
|
||||
mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T convert(ResponseBody value) throws IOException {
|
||||
return parser2(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一种解析
|
||||
*test测试用的,用于打印响应数据json
|
||||
* @param value
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private T parser(ResponseBody value) throws IOException {
|
||||
String response;
|
||||
try {
|
||||
response = value.string();
|
||||
if (mType == String.class) {
|
||||
return (T) response;
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
int state = jsonObject.getInt("status");
|
||||
if (state == STATE_FAILED) {
|
||||
String msg = jsonObject.getString("msg");
|
||||
throw new LifeTreeAPIException(state, msg);
|
||||
} else {
|
||||
String data = jsonObject.getString("data");
|
||||
return mGson.fromJson(data, mType);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new LifeTreeAPIException(0, BaseApplication.getContext().getString(R.string.text_http_data_parser_error));
|
||||
} finally {
|
||||
value.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二种解析
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private T parser2(ResponseBody value) throws IOException {
|
||||
String response;
|
||||
try {
|
||||
response = value.string();
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
int state = jsonObject.getInt("status");
|
||||
if (state == STATE_FAILED) {
|
||||
String msg = jsonObject.getString("msg");
|
||||
throw new LifeTreeAPIException(state, msg);
|
||||
} else {
|
||||
String data = jsonObject.getString("data");
|
||||
if (mType == String.class) {
|
||||
return (T) data;
|
||||
} else {
|
||||
return mGson.fromJson(data, mType);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new LifeTreeAPIException(0, BaseApplication.getContext().getString(R.string.text_http_data_parser_error));
|
||||
} finally {
|
||||
value.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
163
app/src/main/java/com/fenghoo/seven/network/http/MyApi.java
Normal file
163
app/src/main/java/com/fenghoo/seven/network/http/MyApi.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package com.fenghoo.seven.network.http;
|
||||
|
||||
|
||||
import com.fenghoo.seven.main.entity.LoginBean;
|
||||
import com.fenghoo.seven.main.entity.mine.TreeUserEntity;
|
||||
import com.fenghoo.seven.main.find.entity.QuestionsEntity;
|
||||
import com.fenghoo.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.fenghoo.seven.main.my.entity.funSetBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
* MyApi
|
||||
* (๑• . •๑)
|
||||
* 类描述:
|
||||
* Created by LeiXiaoXing on 2017/4/21 13:53
|
||||
*/
|
||||
|
||||
public class MyApi {
|
||||
|
||||
|
||||
public static String URiBase = "http://192.168.1.3/device/";// 7月7
|
||||
|
||||
/**
|
||||
* 网络接口前缀
|
||||
*/
|
||||
public static final String PREFIX = URiBase;
|
||||
|
||||
public interface Api {
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @return
|
||||
*/
|
||||
@POST("SendSMS/send")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean> pin(@Field("phone") String phone);
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
*
|
||||
* @param phone 登录手机号码
|
||||
* @param password 登录密码
|
||||
* @return
|
||||
*/
|
||||
@POST("AppLogin/accountPwd")
|
||||
// @POST("/device/DevLogin/accountPwd")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<LoginBean>> loginpwd(@Field("phonenum") String phone
|
||||
, @Field("pwd") String password);
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param phone 登录手机号码
|
||||
* @param password 登录密码
|
||||
* @return
|
||||
*/
|
||||
@POST("SendSMS/checkCode")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<LoginBean>> login(@Field("phone") String phone
|
||||
, @Field("code") String password);
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息 - identity
|
||||
*
|
||||
* @param identity 用户在腾讯im的标识id
|
||||
* @return
|
||||
*/
|
||||
@POST("user/identity")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<TreeUserEntity>> userIdentity(@Field("identity") String identity);
|
||||
|
||||
|
||||
/**
|
||||
* 用户绑定微信账号
|
||||
*
|
||||
* @param user_id 用户token
|
||||
* @param open_id 微信的openid
|
||||
* @param nickname 微信账号的名称
|
||||
* @param headimg 微信账号的头像
|
||||
* @param sex 微信账号的性别
|
||||
* @param union_id 微信用户的unionid
|
||||
* @return
|
||||
*/
|
||||
@POST("user/bindWx")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<TreeUserEntity>> bindWx(@Field("user_id") String user_id
|
||||
, @Field("open_id") String open_id
|
||||
, @Field("nickname") String nickname
|
||||
, @Field("headimg") String headimg
|
||||
, @Field("sex") String sex
|
||||
, @Field("union_id") String union_id);
|
||||
|
||||
|
||||
/**
|
||||
* 微信登陆
|
||||
*
|
||||
* @param open_id 微信的openid
|
||||
* @param nickname 微信账号的名称
|
||||
* @param headimg 微信账号的头像
|
||||
* @param sex 微信账号的性别
|
||||
* @param union_id 微信用户的unionid
|
||||
* @return
|
||||
*/
|
||||
@POST("user/wxLogin")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<TreeUserEntity>> wxLogin(@Field("open_id") String open_id
|
||||
, @Field("nickname") String nickname
|
||||
, @Field("headimg") String headimg
|
||||
, @Field("sex") String sex
|
||||
, @Field("union_id") String union_id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 确认分配
|
||||
*
|
||||
* @param uid 登录员工的uid
|
||||
* @param content 分配内容[{"customer_id":"客户1","industry_id":"家具id","province":"610000","city":"610100"},{"customer_id":"客户1","industry_id":"建材id","province":"610000","city":"610100"},{"customer_id":"客户2","industry_id":"家具id","province":"610000","city":"610100"},{"customer_id":"客户2","industry_id":"建材id","province":"610000","city":"610100"}]
|
||||
* @return
|
||||
*/
|
||||
@POST("AppCustomer/sureFP")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<CommitDesignModel>> sureFP(@Field("uid") String uid
|
||||
, @Field("content") String content);
|
||||
|
||||
|
||||
/**
|
||||
* 答疑解惑
|
||||
* 提交问题
|
||||
*
|
||||
* @param user_id 用户token
|
||||
* @param qu_key 问题关键字
|
||||
* @return
|
||||
*/
|
||||
@POST("robotQA/ask")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<List<QuestionsEntity>>> ask(@Field("user_id") String user_id
|
||||
, @Field("qu_key") String qu_key);
|
||||
|
||||
|
||||
/**
|
||||
* 功能设置
|
||||
*
|
||||
*/
|
||||
@POST("AppLogin/funSet")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<funSetBean>> funSet(@Field("uid") String uid
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.fenghoo.seven.network.http;
|
||||
|
||||
/**
|
||||
* ResponseBean
|
||||
* 类描述: 公共响应体
|
||||
* 作者: LeiXiaoXing on 2017/1/9 20:08
|
||||
*/
|
||||
public class ResponseBean<T> {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = 0;
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int ERROR = 1;
|
||||
public int status;
|
||||
public T result;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user