Commit 032e6d86 by lihuaikun

feat:接口联调完毕 done

parent 70683b4e
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
signingConfigs {
debug {
storeFile file('./release.jks')
storePassword 'dankal'
keyAlias 'dk'
keyPassword 'dankal'
}
release {
storeFile file('./release.jks')
storePassword 'dankal'
keyAlias 'dk'
keyPassword 'dankal'
}
}
compileSdkVersion build_versions.compile_sdk compileSdkVersion build_versions.compile_sdk
defaultConfig { defaultConfig {
...@@ -14,7 +29,9 @@ android { ...@@ -14,7 +29,9 @@ android {
buildTypes { buildTypes {
release { release {
debuggable false
minifyEnabled false minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
......
File added
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "cn.dankal.yunlaboratory",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 1,
"versionName": "1",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}
\ No newline at end of file
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:name="cn.dankal.basiclib.DankalApplication" android:name="cn.dankal.basiclib.DankalApplication"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_config">
<activity android:name=".ui.activity.LoginActivity"> <activity android:name=".ui.activity.LoginActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
...@@ -6,6 +6,8 @@ import android.widget.EditText; ...@@ -6,6 +6,8 @@ import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import java.util.HashMap;
import api.UserServiceFactory; import api.UserServiceFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
...@@ -17,10 +19,13 @@ import cn.dankal.basiclib.eventbus.AppBus; ...@@ -17,10 +19,13 @@ import cn.dankal.basiclib.eventbus.AppBus;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.UserInfoBody; import cn.dankal.basiclib.model.UserInfoBody;
import cn.dankal.basiclib.model.UserModel; import cn.dankal.basiclib.model.UserModel;
import cn.dankal.basiclib.rx.MapFunc;
import cn.dankal.basiclib.rx.NormalSubscriber; import cn.dankal.basiclib.rx.NormalSubscriber;
import cn.dankal.yunlaboratory.R; import cn.dankal.yunlaboratory.R;
import cn.dankal.yunlaboratory.ui.widget.MainButton; import cn.dankal.yunlaboratory.ui.widget.MainButton;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class ChangeNicknameActivity extends BaseActivity { public class ChangeNicknameActivity extends BaseActivity {
@BindView(R.id.iv_onback) @BindView(R.id.iv_onback)
...@@ -69,23 +74,29 @@ public class ChangeNicknameActivity extends BaseActivity { ...@@ -69,23 +74,29 @@ public class ChangeNicknameActivity extends BaseActivity {
UserInfoBody userInfoBody = new UserInfoBody(); UserInfoBody userInfoBody = new UserInfoBody();
userInfoBody.setUpdate_type("name"); userInfoBody.setUpdate_type("name");
userInfoBody.setName(name); userInfoBody.setName(name);
UserServiceFactory.updateInfo(userInfoBody, null).subscribe(new NormalSubscriber<BaseModel<UserModel>>() { HashMap<String,RequestBody> map=new HashMap<>();
RequestBody body=RequestBody.create(MediaType.parse("multipart/form-data"),name);
map.put("name",body);
RequestBody updateTypeBody=RequestBody.create(MediaType.parse("multipart/form-data"),"name");
map.put("update_type",updateTypeBody);
UserServiceFactory.updateName("name", name).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
showLoadingDialog(); showLoadingDialog();
} }
@Override @Override
public void onNext(BaseModel<UserModel> stringBaseModel) { public void onNext(BaseModel stringBaseModel) {
if (stringBaseModel.getData() != null) {
UserModel userModel = DKUserManager.getUserInfo(); UserModel userModel = DKUserManager.getUserInfo();
userModel.setName(stringBaseModel.getData().getName()); userModel.setName(name);
DKUserManager.updateUserInfo(userModel); DKUserManager.updateUserInfo(userModel);
AppBus.getInstance().post(new InfoChange()); AppBus.getInstance().post(new InfoChange());
}
finish();
} }
......
...@@ -13,6 +13,7 @@ import api.UserServiceFactory; ...@@ -13,6 +13,7 @@ import api.UserServiceFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import cn.dankal.basiclib.DKUserManager; import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.DankalApplication;
import cn.dankal.basiclib.base.activity.BaseActivity; import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter; import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
...@@ -76,6 +77,12 @@ public class LoginActivity extends BaseActivity { ...@@ -76,6 +77,12 @@ public class LoginActivity extends BaseActivity {
etAccount.addTextChangedListener(textWatcher); etAccount.addTextChangedListener(textWatcher);
etPwd.addTextChangedListener(textWatcher); etPwd.addTextChangedListener(textWatcher);
if (DankalApplication.isLogin()){
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
} }
......
...@@ -15,6 +15,7 @@ import cn.dankal.basiclib.model.BaseModel; ...@@ -15,6 +15,7 @@ import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.ProjectModel; import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SubmitRecordModel; import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody; import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.rx.MapFunc;
import cn.dankal.basiclib.rx.NormalSubscriber; import cn.dankal.basiclib.rx.NormalSubscriber;
import cn.dankal.yunlaboratory.R; import cn.dankal.yunlaboratory.R;
import cn.dankal.yunlaboratory.ui.dialog.ChooseItemDialog; import cn.dankal.yunlaboratory.ui.dialog.ChooseItemDialog;
...@@ -69,6 +70,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -69,6 +70,7 @@ public class StartTestActivity extends BaseActivity {
chooseProjectDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() { chooseProjectDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
chooseProjectDialog.dismiss();
int pos = chooseProjectDialog.getCurrentItem(); int pos = chooseProjectDialog.getCurrentItem();
if (projectModels!=null&&pos<projectModels.size()){ if (projectModels!=null&&pos<projectModels.size()){
...@@ -81,6 +83,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -81,6 +83,7 @@ public class StartTestActivity extends BaseActivity {
chooseDeviceDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() { chooseDeviceDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
chooseDeviceDialog.dismiss();
int pos = chooseDeviceDialog.getCurrentItem(); int pos = chooseDeviceDialog.getCurrentItem();
if (deviceModels!=null&&pos<deviceModels.size()){ if (deviceModels!=null&&pos<deviceModels.size()){
...@@ -124,7 +127,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -124,7 +127,7 @@ public class StartTestActivity extends BaseActivity {
} }
public void getProjectList() { public void getProjectList() {
UserServiceFactory.getProjectList().subscribe(new NormalSubscriber<BaseModel<List<ProjectModel>>>() { UserServiceFactory.getProjectList(recordModel.getId()).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<List<ProjectModel>>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
...@@ -150,7 +153,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -150,7 +153,7 @@ public class StartTestActivity extends BaseActivity {
} }
public void getDeviceList() { public void getDeviceList() {
UserServiceFactory.getProjectList().subscribe(new NormalSubscriber<BaseModel<List<ProjectModel>>>() { UserServiceFactory.getDeviceList(recordModel.getId()).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<List<ProjectModel>>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
......
...@@ -58,15 +58,21 @@ public class UploadResultActivity extends BaseActivity { ...@@ -58,15 +58,21 @@ public class UploadResultActivity extends BaseActivity {
if (!TextUtils.isEmpty(report)){ if (!TextUtils.isEmpty(report)){
body.setContent(report); body.setContent(report);
UserServiceFactory.submitReport(body).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<String>>() { UserServiceFactory.submitReport(body).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
} }
@Override @Override
public void onNext(BaseModel<String> stringBaseModel) { public void onNext(BaseModel stringBaseModel) {
showToast("上传成功");
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
},1000);
} }
}); });
}else { }else {
......
...@@ -23,6 +23,7 @@ import java.io.File; ...@@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import api.UserServiceFactory; import api.UserServiceFactory;
...@@ -36,6 +37,7 @@ import cn.dankal.basiclib.eventbus.Subscribe; ...@@ -36,6 +37,7 @@ import cn.dankal.basiclib.eventbus.Subscribe;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.UserInfoBody; import cn.dankal.basiclib.model.UserInfoBody;
import cn.dankal.basiclib.model.UserModel; import cn.dankal.basiclib.model.UserModel;
import cn.dankal.basiclib.rx.MapFunc;
import cn.dankal.basiclib.rx.NormalSubscriber; import cn.dankal.basiclib.rx.NormalSubscriber;
import cn.dankal.basiclib.util.FileUtil; import cn.dankal.basiclib.util.FileUtil;
import cn.dankal.basiclib.util.GlideUtils; import cn.dankal.basiclib.util.GlideUtils;
...@@ -100,6 +102,9 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener ...@@ -100,6 +102,9 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener
renderDialog = new RenderDialog(getContext()); renderDialog = new RenderDialog(getContext());
btnExit.setEnabled(true);
tvTitle.setText("个人中心");
if (DKUserManager.getUserInfo() != null) { if (DKUserManager.getUserInfo() != null) {
UserModel userModel = DKUserManager.getUserInfo(); UserModel userModel = DKUserManager.getUserInfo();
...@@ -274,26 +279,23 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener ...@@ -274,26 +279,23 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener
} }
public void updateSex(int sex) { public void updateSex(int sex) {
UserInfoBody userInfoBody = new UserInfoBody();
userInfoBody.setUpdate_type("sex");
userInfoBody.setSex(sex); UserServiceFactory.updateSex("sex", sex).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() {
UserServiceFactory.updateInfo(userInfoBody, null).subscribe(new NormalSubscriber<BaseModel<UserModel>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
showLoadingDialog(); showLoadingDialog();
} }
@Override @Override
public void onNext(BaseModel<UserModel> stringBaseModel) { public void onNext(BaseModel stringBaseModel) {
if (stringBaseModel.getData()!=null){
UserModel userModel = DKUserManager.getUserInfo(); UserModel userModel = DKUserManager.getUserInfo();
userModel.setSex(stringBaseModel.getData().getSex()); userModel.setSex(sex);
DKUserManager.updateUserInfo(userModel); DKUserManager.updateUserInfo(userModel);
tvSex.setText(userModel.getRealSex()); tvSex.setText(userModel.getRealSex());
}
} }
...@@ -313,16 +315,21 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener ...@@ -313,16 +315,21 @@ public class PersonFragment extends BaseFragment implements View.OnClickListener
*/ */
private void updateAvatar(Uri uri) { private void updateAvatar(Uri uri) {
if (!TextUtils.isEmpty(uri.toString())) { if (!TextUtils.isEmpty(uri.toString())) {
UserInfoBody userInfoBody = new UserInfoBody();
userInfoBody.setUpdate_type("avatar");
HashMap<String,RequestBody> map=new HashMap<>();
RequestBody updateTypeBody=RequestBody.create(MediaType.parse("application/json"),"avatar");
map.put("update_type",updateTypeBody);
File file = new File(FileUtil.getRealFilePath(getContext(), uri)); File file = new File(FileUtil.getRealFilePath(getContext(), uri));
RequestBody fileRQ = RequestBody.create(MediaType.parse("image/*"), file); RequestBody fileRQ = RequestBody.create(MediaType.parse("image/png"), file);
MultipartBody.Part part = MultipartBody.Part.createFormData("picture", file.getName(), fileRQ); MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), fileRQ);
// map.put("file",fileRQ);
UserServiceFactory.updateInfo(userInfoBody, part).subscribe(new NormalSubscriber<BaseModel<UserModel>>() { UserServiceFactory.updateInfo(map,part).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<UserModel>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
showLoadingDialog(); showLoadingDialog();
......
...@@ -58,32 +58,7 @@ public class ScanFragment extends BaseFragment { ...@@ -58,32 +58,7 @@ public class ScanFragment extends BaseFragment {
getBackSampleDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() { getBackSampleDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
getBackSampleDialog.dismiss(); inputPersonNoDialog.dismiss();
UserServiceFactory.sample(codeResult).map(new MapFunc<BaseModel<SampleModel>>()).subscribe(new NormalSubscriber<BaseModel<SampleModel>>() {
@Override
public void onSubscribe(Disposable d) {
showLoadingDialog();
}
@Override
public void onNext(BaseModel<SampleModel> sampleModelBaseModel) {
SampleModel sampleModel = sampleModelBaseModel.getData();
if (sampleModel.getType() == 1) {
inputPersonNoDialog.show();
} else {
Intent intent = new Intent(getContext(), GetSampleActivity.class);
intent.putExtra("data", sampleModel.getUpload_list());
getContext().startActivity(intent);
}
}
@Override
public void onComplete() {
super.onComplete();
dismissLoadingDialog();
}
}
);
} }
}); });
...@@ -94,7 +69,7 @@ public class ScanFragment extends BaseFragment { ...@@ -94,7 +69,7 @@ public class ScanFragment extends BaseFragment {
String nameStr = inputPersonNoDialog.getInputName(); String nameStr = inputPersonNoDialog.getInputName();
if (!TextUtils.isEmpty(nameStr)) { if (!TextUtils.isEmpty(nameStr)) {
inputPersonNoDialog.dismiss(); inputPersonNoDialog.dismiss();
UserServiceFactory.sampleNext(nameStr).subscribe(new NormalSubscriber<BaseModel<SubmitRecordModel>>() { UserServiceFactory.sampleNext(nameStr).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<SubmitRecordModel>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
showLoadingDialog(); showLoadingDialog();
...@@ -141,8 +116,38 @@ public class ScanFragment extends BaseFragment { ...@@ -141,8 +116,38 @@ public class ScanFragment extends BaseFragment {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == RC_SCAN) { if (resultCode == Activity.RESULT_OK && requestCode == RC_SCAN) {
codeResult = data.getStringExtra("data"); codeResult = data.getStringExtra("data");
requestData();
}
}
/**
* 判断是否是第一次取样
*/
public void requestData(){
UserServiceFactory.sample(codeResult).map(new MapFunc<BaseModel<SampleModel>>()).subscribe(new NormalSubscriber<BaseModel<SampleModel>>() {
@Override
public void onSubscribe(Disposable d) {
showLoadingDialog();
}
@Override
public void onNext(BaseModel<SampleModel> sampleModelBaseModel) {
SampleModel sampleModel = sampleModelBaseModel.getData();
if (sampleModel.getType() == 1) {
getBackSampleDialog.show(); getBackSampleDialog.show();
} else {
Intent intent = new Intent(getContext(), GetSampleActivity.class);
intent.putExtra("data", sampleModel.getUpload_list());
getContext().startActivity(intent);
}
}
@Override
public void onComplete() {
super.onComplete();
dismissLoadingDialog();
} }
});
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<resources> <resources>
<color name="colorPrimary">#fff</color> <color name="colorPrimary">#fff</color>
<color name="colorPrimaryDark">#fff</color> <color name="colorPrimaryDark">#fff</color>
<color name="colorAccent">#fff</color> <color name="colorAccent">#6fc3ff</color>
<color name="color14">#141414</color> <color name="color14">#141414</color>
<color name="color33">#333333</color> <color name="color33">#333333</color>
<color name="colorcf">#CFCFCF</color> <color name="colorcf">#CFCFCF</color>
......
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
\ No newline at end of file
...@@ -8,8 +8,6 @@ import cn.dankal.basiclib.common.qiniu.QiniuConfigResponse; ...@@ -8,8 +8,6 @@ import cn.dankal.basiclib.common.qiniu.QiniuConfigResponse;
import cn.dankal.basiclib.model.LoginModel; import cn.dankal.basiclib.model.LoginModel;
import cn.dankal.basiclib.model.TokenModel; import cn.dankal.basiclib.model.TokenModel;
import cn.dankal.basiclib.model.UserModel; import cn.dankal.basiclib.model.UserModel;
import cn.dankal.basiclib.pojo.UserInfoBean;
import cn.dankal.basiclib.pojo.UserResponseBody;
import cn.dankal.basiclib.util.PreferenceUtil; import cn.dankal.basiclib.util.PreferenceUtil;
...@@ -41,8 +39,8 @@ public class DKUserManager { ...@@ -41,8 +39,8 @@ public class DKUserManager {
* 如登录后可更新当前的UserInfo和本地的缓存 * 如登录后可更新当前的UserInfo和本地的缓存
*/ */
public static void saveUserInfo(LoginModel userResponseBody) { public static void saveUserInfo(LoginModel userResponseBody) {
UserModel userInfo = userResponseBody.getUser(); UserModel userInfo = userResponseBody.getInfo();
TokenModel token = userResponseBody.getToken(); TokenModel token = userResponseBody.getMeta();
if (userInfo != null) { if (userInfo != null) {
PreferenceUtil.updateBean(mSpUserInfo, getUserInfo(), userInfo); PreferenceUtil.updateBean(mSpUserInfo, getUserInfo(), userInfo);
} }
...@@ -69,7 +67,7 @@ public class DKUserManager { ...@@ -69,7 +67,7 @@ public class DKUserManager {
* mUserInfo是否等于null,防止UserManager.getUserInfo出现空指针 * mUserInfo是否等于null,防止UserManager.getUserInfo出现空指针
*/ */
private static void readUserInfo() { private static void readUserInfo() {
userInfo = (UserModel) PreferenceUtil.getBeanValue(mSpUserInfo, UserInfoBean.class); userInfo = (UserModel) PreferenceUtil.getBeanValue(mSpUserInfo, UserModel.class);
if (userInfo == null) { if (userInfo == null) {
userInfo = new UserModel(); userInfo = new UserModel();
} }
...@@ -77,7 +75,7 @@ public class DKUserManager { ...@@ -77,7 +75,7 @@ public class DKUserManager {
private static void readUserToken() { private static void readUserToken() {
userToken = (TokenModel) PreferenceUtil.getBeanValue(mSpToken, userToken = (TokenModel) PreferenceUtil.getBeanValue(mSpToken,
UserResponseBody.TokenBean.class); TokenModel.class);
if (userToken == null) { if (userToken == null) {
userToken = new TokenModel(); userToken = new TokenModel();
} }
......
...@@ -25,8 +25,8 @@ import static cn.dankal.basiclib.DankalApplication.isDev; ...@@ -25,8 +25,8 @@ import static cn.dankal.basiclib.DankalApplication.isDev;
*/ */
public class BaseApi { public class BaseApi {
public static final String BASE_URL = isDev ? "https://www.baidu.com" public static final String BASE_URL = isDev ? "http://tp.lzdu.com/api/"
: "https://www.google.com"; : "http://tp.lzdu.com/api/";
private static LinkedHashMap<String, Retrofit> linkedHashMap = new LinkedHashMap<>(3); private static LinkedHashMap<String, Retrofit> linkedHashMap = new LinkedHashMap<>(3);
...@@ -72,7 +72,7 @@ public class BaseApi { ...@@ -72,7 +72,7 @@ public class BaseApi {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override @Override
public void log(String message) { public void log(String message) {
Logger.d(message); Logger.e(message);
} }
}); });
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
......
package cn.dankal.basiclib.api; package cn.dankal.basiclib.api;
import java.util.List; import java.util.List;
import java.util.Map;
import cn.dankal.annotations.ApiFactory; import cn.dankal.annotations.ApiFactory;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
...@@ -13,6 +14,7 @@ import cn.dankal.basiclib.model.UserInfoBody; ...@@ -13,6 +14,7 @@ import cn.dankal.basiclib.model.UserInfoBody;
import cn.dankal.basiclib.model.UserModel; import cn.dankal.basiclib.model.UserModel;
import io.reactivex.Observable; import io.reactivex.Observable;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.Field; import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; import retrofit2.http.FormUrlEncoded;
...@@ -21,6 +23,7 @@ import retrofit2.http.Multipart; ...@@ -21,6 +23,7 @@ import retrofit2.http.Multipart;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.PUT; import retrofit2.http.PUT;
import retrofit2.http.Part; import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Query; import retrofit2.http.Query;
/** /**
...@@ -62,14 +65,14 @@ public interface UserService { ...@@ -62,14 +65,14 @@ public interface UserService {
* 获取项目 * 获取项目
*/ */
@GET("project") @GET("project")
Observable<BaseModel<List<ProjectModel>>> getProjectList(); Observable<BaseModel<List<ProjectModel>>> getProjectList(@Query("sample_id")int sample_id);
/** /**
* 获取设备 * 获取设备
*/ */
@GET("device") @GET("device")
Observable<BaseModel<List<ProjectModel>>> getDeviceList(); Observable<BaseModel<List<ProjectModel>>> getDeviceList(@Query("sample_id")int sample_id);
/** /**
...@@ -96,8 +99,36 @@ public interface UserService { ...@@ -96,8 +99,36 @@ public interface UserService {
* @return * @return
*/ */
@Multipart @Multipart
@POST("update/info")
Observable<BaseModel<UserModel>> updateInfo(@PartMap Map<String, RequestBody> body, @Part MultipartBody.Part file);
/**
* 更新昵称
* update_type avatar: 更新头像name:更新昵称sex:性别
* name 昵称
* sex 性别 1男2女
* file 头像图片
*
* @return
*/
@FormUrlEncoded
@PUT("update/info") @PUT("update/info")
Observable<BaseModel<UserModel>> updateInfo(@Part("body") UserInfoBody body, @Part MultipartBody.Part file); Observable<BaseModel> updateName(@Field("update_type")String type,@Field("name")String name);
/**
* 更新昵称
* update_type avatar: 更新头像name:更新昵称sex:性别
* name 昵称
* sex 性别 1男2女
* file 头像图片
*
* @return
*/
@PUT("update/info")
@FormUrlEncoded
Observable<BaseModel> updateSex(@Field("update_type")String type,@Field("sex")int sex);
/** /**
......
...@@ -23,7 +23,7 @@ public class TokenInterceptor implements Interceptor { ...@@ -23,7 +23,7 @@ public class TokenInterceptor implements Interceptor {
String accessToken = DKUserManager.getUserToken().getAccess_token(); String accessToken = DKUserManager.getUserToken().getAccess_token();
if (accessToken != null) { if (accessToken != null) {
Request requestAuthorised = originalRequest.newBuilder() Request requestAuthorised = originalRequest.newBuilder()
.header("X-Access-Token", accessToken) .header("authorization", accessToken)
.build(); .build();
return chain.proceed(requestAuthorised); return chain.proceed(requestAuthorised);
} }
......
package cn.dankal.basiclib.model; package cn.dankal.basiclib.model;
public class LoginModel { public class LoginModel {
private UserModel user; private UserModel info;
private TokenModel token; private TokenModel meta;
public UserModel getUser() { public UserModel getInfo() {
return user; return info;
} }
public void setUser(UserModel user) { public void setInfo(UserModel info) {
this.user = user; this.info = info;
} }
public TokenModel getToken() { public TokenModel getMeta() {
return token; return meta;
} }
public void setToken(TokenModel token) { public void setMeta(TokenModel meta) {
this.token = token; this.meta = meta;
} }
} }
...@@ -6,6 +6,7 @@ public class UserInfoBody { ...@@ -6,6 +6,7 @@ public class UserInfoBody {
private String name; private String name;
private int sex; private int sex;
public String getUpdate_type() { public String getUpdate_type() {
return update_type; return update_type;
} }
......
...@@ -24,6 +24,7 @@ public abstract class NormalSubscriber<T> implements Observer<T> { ...@@ -24,6 +24,7 @@ public abstract class NormalSubscriber<T> implements Observer<T> {
public void onError(Throwable e) { public void onError(Throwable e) {
ToastUtils.showLong(e.getLocalizedMessage()); ToastUtils.showLong(e.getLocalizedMessage());
onComplete();
} }
......
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