Commit e73fb8ff901430d098a3a5d59643731948bb8b4e
1 parent
949fe97fc9
Exists in
master
新版本发布
Showing
3 changed files
with
3 additions
and
4 deletions
Show diff stats
.idea/gradle.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project version="4"> | 2 | <project version="4"> |
| 3 | <component name="GradleMigrationSettings" migrationVersion="1" /> | 3 | <component name="GradleMigrationSettings" migrationVersion="1" /> |
| 4 | <component name="GradleSettings"> | 4 | <component name="GradleSettings"> |
| 5 | <option name="linkedExternalProjectsSettings"> | 5 | <option name="linkedExternalProjectsSettings"> |
| 6 | <GradleProjectSettings> | 6 | <GradleProjectSettings> |
| 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
| 8 | <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" /> | 8 | <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" /> |
| 9 | <option name="modules"> | 9 | <option name="modules"> |
| 10 | <set> | 10 | <set> |
| 11 | <option value="$PROJECT_DIR$" /> | 11 | <option value="$PROJECT_DIR$" /> |
| 12 | <option value="$PROJECT_DIR$/app" /> | 12 | <option value="$PROJECT_DIR$/app" /> |
| 13 | <option value="$PROJECT_DIR$/libs" /> | 13 | <option value="$PROJECT_DIR$/libs" /> |
| 14 | <option value="$PROJECT_DIR$/libs/common" /> | 14 | <option value="$PROJECT_DIR$/libs/common" /> |
| 15 | </set> | 15 | </set> |
| 16 | </option> | 16 | </option> |
| 17 | <option name="resolveExternalAnnotations" value="false" /> | 17 | <option name="resolveExternalAnnotations" value="false" /> |
| 18 | </GradleProjectSettings> | 18 | </GradleProjectSettings> |
| 19 | </option> | 19 | </option> |
| 20 | <option name="offlineMode" value="true" /> | ||
| 21 | </component> | 20 | </component> |
| 22 | </project> | 21 | </project> |
app/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | def androidId = rootProject.ext.androidId | 4 | def androidId = rootProject.ext.androidId |
| 5 | def support = rootProject.ext.dependencies | 5 | def support = rootProject.ext.dependencies |
| 6 | def url = rootProject.ext.url | 6 | def url = rootProject.ext.url |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | android { | 9 | android { |
| 10 | signingConfigs { | 10 | signingConfigs { |
| 11 | 11 | ||
| 12 | config { | 12 | config { |
| 13 | keyAlias 'alias' | 13 | keyAlias 'alias' |
| 14 | keyPassword '123456' | 14 | keyPassword '123456' |
| 15 | storeFile file('key.jks') | 15 | storeFile file('key.jks') |
| 16 | storePassword '123456' | 16 | storePassword '123456' |
| 17 | } | 17 | } |
| 18 | debug { | 18 | debug { |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| 21 | compileSdk 32 | 21 | compileSdk 32 |
| 22 | 22 | ||
| 23 | defaultConfig { | 23 | defaultConfig { |
| 24 | applicationId "com.hjx.parent" | 24 | applicationId "com.hjx.parent" |
| 25 | minSdk 26 | 25 | minSdk 26 |
| 26 | targetSdk 32 | 26 | targetSdk 32 |
| 27 | versionCode 1006 | 27 | versionCode 1007 |
| 28 | versionName "1.0.0.6" | 28 | versionName "1.0.0.7" |
| 29 | 29 | ||
| 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | android.applicationVariants.all { | 33 | android.applicationVariants.all { |
| 34 | variant -> | 34 | variant -> |
| 35 | variant.outputs.all { | 35 | variant.outputs.all { |
| 36 | //在这里修改apk文件名 | 36 | //在这里修改apk文件名 |
| 37 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 37 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | buildTypes { | 40 | buildTypes { |
| 41 | debug { | 41 | debug { |
| 42 | debuggable true | 42 | debuggable true |
| 43 | minifyEnabled false | 43 | minifyEnabled false |
| 44 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 44 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 45 | signingConfig signingConfigs.config | 45 | signingConfig signingConfigs.config |
| 46 | } | 46 | } |
| 47 | release { | 47 | release { |
| 48 | debuggable true | 48 | debuggable true |
| 49 | minifyEnabled false | 49 | minifyEnabled false |
| 50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 51 | signingConfig signingConfigs.config | 51 | signingConfig signingConfigs.config |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | lintOptions { | 54 | lintOptions { |
| 55 | checkReleaseBuilds false | 55 | checkReleaseBuilds false |
| 56 | abortOnError false | 56 | abortOnError false |
| 57 | } | 57 | } |
| 58 | buildFeatures { | 58 | buildFeatures { |
| 59 | viewBinding true | 59 | viewBinding true |
| 60 | dataBinding true | 60 | dataBinding true |
| 61 | } | 61 | } |
| 62 | compileOptions { | 62 | compileOptions { |
| 63 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 64 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | dependencies { | 68 | dependencies { |
| 69 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
| 70 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
| 71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
| 72 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
| 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
| 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
| 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
| 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
| 77 | //使用的三方 | 77 | //使用的三方 |
| 78 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
| 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
| 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
| 81 | 81 | ||
| 82 | // rx | 82 | // rx |
| 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
| 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
| 85 | 85 | ||
| 86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | 86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") |
| 87 | implementation("com.contrarywind:Android-PickerView:4.1.9") | 87 | implementation("com.contrarywind:Android-PickerView:4.1.9") |
| 88 | 88 | ||
| 89 | implementation 'com.google.android:flexbox:1.0.0' | 89 | implementation 'com.google.android:flexbox:1.0.0' |
| 90 | 90 | ||
| 91 | // 沉浸式状态栏和他的Kotlin拓展 | 91 | // 沉浸式状态栏和他的Kotlin拓展 |
| 92 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' | 92 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' |
| 93 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' | 93 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' |
| 94 | 94 | ||
| 95 | // 图片查看 | 95 | // 图片查看 |
| 96 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' | 96 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' |
| 97 | 97 | ||
| 98 | implementation 'com.jakewharton:butterknife:10.2.3' | 98 | implementation 'com.jakewharton:butterknife:10.2.3' |
| 99 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' | 99 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' |
| 100 | } | 100 | } |
libs/common/src/main/java/com/prws/common/net/NetWorks.java
| 1 | package com.prws.common.net; | 1 | package com.prws.common.net; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import com.google.gson.Gson; | 4 | import com.google.gson.Gson; |
| 5 | import com.google.gson.JsonObject; | 5 | import com.google.gson.JsonObject; |
| 6 | import com.prws.common.BuildConfig; | 6 | import com.prws.common.BuildConfig; |
| 7 | import com.prws.common.bean.CutPicBean; | 7 | import com.prws.common.bean.CutPicBean; |
| 8 | import com.prws.common.bean.GradeAndSubject; | 8 | import com.prws.common.bean.GradeAndSubject; |
| 9 | import com.prws.common.bean.PageInfo; | 9 | import com.prws.common.bean.PageInfo; |
| 10 | import com.prws.common.bean.ResponseResult; | 10 | import com.prws.common.bean.ResponseResult; |
| 11 | import com.prws.common.bean.ScheduleBean; | 11 | import com.prws.common.bean.ScheduleBean; |
| 12 | import com.prws.common.bean.Student; | 12 | import com.prws.common.bean.Student; |
| 13 | import com.prws.common.bean.Teacher; | 13 | import com.prws.common.bean.Teacher; |
| 14 | import com.prws.common.bean.TopicBean; | 14 | import com.prws.common.bean.TopicBean; |
| 15 | import com.prws.common.bean.UpdateBean; | 15 | import com.prws.common.bean.UpdateBean; |
| 16 | import com.prws.common.bean.User; | 16 | import com.prws.common.bean.User; |
| 17 | import com.prws.common.bean.baidu.BaiduInput; | 17 | import com.prws.common.bean.baidu.BaiduInput; |
| 18 | import com.prws.common.bean.homework.HomeWork; | 18 | import com.prws.common.bean.homework.HomeWork; |
| 19 | import com.prws.common.bean.homework.HomeworkDetail; | 19 | import com.prws.common.bean.homework.HomeworkDetail; |
| 20 | import com.prws.common.bean.homework.HomeworkList; | 20 | import com.prws.common.bean.homework.HomeworkList; |
| 21 | import com.prws.common.bean.homework.StDetail; | 21 | import com.prws.common.bean.homework.StDetail; |
| 22 | import com.prws.common.utils.BitmapUtils; | 22 | import com.prws.common.utils.BitmapUtils; |
| 23 | import com.prws.common.utils.SharedPreferencesUtil; | 23 | import com.prws.common.utils.SharedPreferencesUtil; |
| 24 | 24 | ||
| 25 | import java.io.File; | 25 | import java.io.File; |
| 26 | import java.util.HashMap; | 26 | import java.util.HashMap; |
| 27 | import java.util.List; | 27 | import java.util.List; |
| 28 | import java.util.Map; | 28 | import java.util.Map; |
| 29 | 29 | ||
| 30 | import io.reactivex.Observable; | 30 | import io.reactivex.Observable; |
| 31 | import io.reactivex.Observer; | 31 | import io.reactivex.Observer; |
| 32 | import io.reactivex.Single; | 32 | import io.reactivex.Single; |
| 33 | import io.reactivex.android.schedulers.AndroidSchedulers; | 33 | import io.reactivex.android.schedulers.AndroidSchedulers; |
| 34 | import io.reactivex.schedulers.Schedulers; | 34 | import io.reactivex.schedulers.Schedulers; |
| 35 | import okhttp3.MediaType; | 35 | import okhttp3.MediaType; |
| 36 | import okhttp3.MultipartBody; | 36 | import okhttp3.MultipartBody; |
| 37 | import okhttp3.RequestBody; | 37 | import okhttp3.RequestBody; |
| 38 | import okhttp3.ResponseBody; | 38 | import okhttp3.ResponseBody; |
| 39 | import retrofit2.Call; | 39 | import retrofit2.Call; |
| 40 | import retrofit2.Callback; | 40 | import retrofit2.Callback; |
| 41 | import retrofit2.http.Body; | 41 | import retrofit2.http.Body; |
| 42 | import retrofit2.http.GET; | 42 | import retrofit2.http.GET; |
| 43 | import retrofit2.http.Header; | 43 | import retrofit2.http.Header; |
| 44 | import retrofit2.http.Headers; | 44 | import retrofit2.http.Headers; |
| 45 | import retrofit2.http.Multipart; | 45 | import retrofit2.http.Multipart; |
| 46 | import retrofit2.http.POST; | 46 | import retrofit2.http.POST; |
| 47 | import retrofit2.http.PUT; | 47 | import retrofit2.http.PUT; |
| 48 | import retrofit2.http.Part; | 48 | import retrofit2.http.Part; |
| 49 | import retrofit2.http.PartMap; | 49 | import retrofit2.http.PartMap; |
| 50 | import retrofit2.http.Query; | 50 | import retrofit2.http.Query; |
| 51 | import retrofit2.http.Url; | 51 | import retrofit2.http.Url; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * 类名称:NetWorks | 54 | * 类名称:NetWorks |
| 55 | * 创建人: | 55 | * 创建人: |
| 56 | * <p> | 56 | * <p> |
| 57 | * 类描述:网络请求的操作类 | 57 | * 类描述:网络请求的操作类 |
| 58 | */ | 58 | */ |
| 59 | public class NetWorks extends RetrofitUtils { | 59 | public class NetWorks extends RetrofitUtils { |
| 60 | //服务器路径 | 60 | //服务器路径 |
| 61 | public static final NetService service_url = getMachineRetrofit("http://192.168.3.144:8088").create(NetService.class); | 61 | public static final NetService service_url = getMachineRetrofit("https://mgr.hjx.com").create(NetService.class); |
| 62 | 62 | ||
| 63 | //设缓存有效期为1天 | 63 | //设缓存有效期为1天 |
| 64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
| 65 | //查询缓存的Cache-Control设置,使用缓存 | 65 | //查询缓存的Cache-Control设置,使用缓存 |
| 66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
| 67 | //查询网络的Cache-Control设置。不使用缓存 | 67 | //查询网络的Cache-Control设置。不使用缓存 |
| 68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | public interface NetService { | 71 | public interface NetService { |
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | @GET("/api/v1/user/logout") | 74 | @GET("/api/v1/user/logout") |
| 75 | Observable<ResponseBody> logout(); | 75 | Observable<ResponseBody> logout(); |
| 76 | 76 | ||
| 77 | @Multipart | 77 | @Multipart |
| 78 | @POST("/api/v1/user/upLoadAvatar") | 78 | @POST("/api/v1/user/upLoadAvatar") |
| 79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | @Headers("Content-Type: application/json") | 82 | @Headers("Content-Type: application/json") |
| 83 | @POST("/api/v1/user/editUser") | 83 | @POST("/api/v1/user/editUser") |
| 84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
| 85 | 85 | ||
| 86 | @Headers("Content-Type: application/json") | 86 | @Headers("Content-Type: application/json") |
| 87 | @POST("/api/v1/user/changePassword") | 87 | @POST("/api/v1/user/changePassword") |
| 88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | @GET("/api/v1/user/searchById") | 91 | @GET("/api/v1/user/searchById") |
| 92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | @Headers("Content-Type: application/json") | 95 | @Headers("Content-Type: application/json") |
| 96 | @POST("/api/v1/login/userLogin") | 96 | @POST("/api/v1/login/userLogin") |
| 97 | Observable<ResponseBody> login(@Body RequestBody body); | 97 | Observable<ResponseBody> login(@Body RequestBody body); |
| 98 | 98 | ||
| 99 | @GET("/api/v1/resource/listGradeAndSubject") | 99 | @GET("/api/v1/resource/listGradeAndSubject") |
| 100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | @GET("/api/v1/manager/generalQrCode") | 103 | @GET("/api/v1/manager/generalQrCode") |
| 104 | Observable<ResponseBody> generalQrCode(); | 104 | Observable<ResponseBody> generalQrCode(); |
| 105 | 105 | ||
| 106 | @GET("/api/v1/parent/scanAndLogin") | 106 | @GET("/api/v1/parent/scanAndLogin") |
| 107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
| 108 | 108 | ||
| 109 | @GET("/api/v1/parent/getChildrenList") | 109 | @GET("/api/v1/parent/getChildrenList") |
| 110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | @Headers("Content-Type: application/json") | 113 | @Headers("Content-Type: application/json") |
| 114 | @POST("/api/v1/parent/registerParent") | 114 | @POST("/api/v1/parent/registerParent") |
| 115 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 115 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | @GET("/api/v1/parent/listChildren") | 118 | @GET("/api/v1/parent/listChildren") |
| 119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | @Headers("Content-Type: application/json") | 122 | @Headers("Content-Type: application/json") |
| 123 | @POST("/api/v1/parent/registerStudent") | 123 | @POST("/api/v1/parent/registerStudent") |
| 124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
| 125 | 125 | ||
| 126 | @Headers("Content-Type: application/json") | 126 | @Headers("Content-Type: application/json") |
| 127 | @POST("/api/v1/parent/bindTeacher") | 127 | @POST("/api/v1/parent/bindTeacher") |
| 128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
| 129 | 129 | ||
| 130 | @Multipart | 130 | @Multipart |
| 131 | @POST("/api/v1/user/upLoadAvatar") | 131 | @POST("/api/v1/user/upLoadAvatar") |
| 132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
| 133 | 133 | ||
| 134 | 134 | ||
| 135 | @Multipart | 135 | @Multipart |
| 136 | @POST("/api/v1/student/editStudentAvatar") | 136 | @POST("/api/v1/student/editStudentAvatar") |
| 137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
| 138 | 138 | ||
| 139 | @Headers("Content-Type: application/json") | 139 | @Headers("Content-Type: application/json") |
| 140 | @POST("/api/v1/parent/editChild") | 140 | @POST("/api/v1/parent/editChild") |
| 141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
| 142 | 142 | ||
| 143 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 143 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
| 144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
| 145 | 145 | ||
| 146 | @GET("api/v1/parent/searchTeacher") | 146 | @GET("api/v1/parent/searchTeacher") |
| 147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
| 148 | 148 | ||
| 149 | @POST("api/v1/question/listErrorBook") | 149 | @POST("api/v1/question/listErrorBook") |
| 150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
| 151 | 151 | ||
| 152 | @POST | 152 | @POST |
| 153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
| 154 | 154 | ||
| 155 | @POST | 155 | @POST |
| 156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
| 157 | 157 | ||
| 158 | @POST | 158 | @POST |
| 159 | Observable<JsonObject> getBaiduToken(@Url String url); | 159 | Observable<JsonObject> getBaiduToken(@Url String url); |
| 160 | 160 | ||
| 161 | @Multipart | 161 | @Multipart |
| 162 | @POST("api/v1/pad/addErrorBook") | 162 | @POST("api/v1/pad/addErrorBook") |
| 163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
| 164 | 164 | ||
| 165 | @POST("api/v1/pad/deleteStuErrorBook") | 165 | @POST("api/v1/pad/deleteStuErrorBook") |
| 166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
| 167 | 167 | ||
| 168 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 168 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
| 169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
| 170 | 170 | ||
| 171 | @POST("api/v1/question/editErrorBook") | 171 | @POST("api/v1/question/editErrorBook") |
| 172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
| 173 | 173 | ||
| 174 | @GET("api/v1/resource/checkUpdate") | 174 | @GET("api/v1/resource/checkUpdate") |
| 175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
| 176 | 176 | ||
| 177 | @GET("api/v1/teacher/getStudentList") | 177 | @GET("api/v1/teacher/getStudentList") |
| 178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
| 179 | 179 | ||
| 180 | @GET("api/v1/teacher/getStudentList") | 180 | @GET("api/v1/teacher/getStudentList") |
| 181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); | 181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); |
| 182 | 182 | ||
| 183 | @GET("api/v1/answer/listRecordForTeacher") | 183 | @GET("api/v1/answer/listRecordForTeacher") |
| 184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
| 185 | 185 | ||
| 186 | @GET("api/v1/homework/listHomeworkByStuId") | 186 | @GET("api/v1/homework/listHomeworkByStuId") |
| 187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | 187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); |
| 188 | 188 | ||
| 189 | @POST | 189 | @POST |
| 190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); | 190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); |
| 191 | 191 | ||
| 192 | @Multipart | 192 | @Multipart |
| 193 | @POST("api/v1/homework/uploadHomework") | 193 | @POST("api/v1/homework/uploadHomework") |
| 194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); | 194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); |
| 195 | 195 | ||
| 196 | @POST("api/v1/homework/uploadHomeworkAction") | 196 | @POST("api/v1/homework/uploadHomeworkAction") |
| 197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); | 197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); |
| 198 | 198 | ||
| 199 | @GET("api/v1/homework/removeHomework") | 199 | @GET("api/v1/homework/removeHomework") |
| 200 | Single<ResponseResult<Boolean>> deleteHomework( | 200 | Single<ResponseResult<Boolean>> deleteHomework( |
| 201 | @Header("Authorization") String token, | 201 | @Header("Authorization") String token, |
| 202 | @Query("homeworkId") String homeworkId | 202 | @Query("homeworkId") String homeworkId |
| 203 | ); | 203 | ); |
| 204 | 204 | ||
| 205 | @GET("api/v1/homework/listHomeworkById") | 205 | @GET("api/v1/homework/listHomeworkById") |
| 206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); | 206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); |
| 207 | 207 | ||
| 208 | @POST("api/v1/homework/uploadHomeworkFeedback") | 208 | @POST("api/v1/homework/uploadHomeworkFeedback") |
| 209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); | 209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); |
| 210 | 210 | ||
| 211 | @POST("api/v1/homework/editHomeworkInfo") | 211 | @POST("api/v1/homework/editHomeworkInfo") |
| 212 | Single<ResponseResult<Boolean>> editHomework( | 212 | Single<ResponseResult<Boolean>> editHomework( |
| 213 | @Header("Authorization") String token, | 213 | @Header("Authorization") String token, |
| 214 | @Body Object body | 214 | @Body Object body |
| 215 | ); | 215 | ); |
| 216 | 216 | ||
| 217 | @GET("api/v1/homework/listHomeworkDetailByStuId") | 217 | @GET("api/v1/homework/listHomeworkDetailByStuId") |
| 218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( | 218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( |
| 219 | @Header("Authorization") String token, | 219 | @Header("Authorization") String token, |
| 220 | @Query("stuId") String stuId, | 220 | @Query("stuId") String stuId, |
| 221 | @Query("homeworkId") String homeworkId, | 221 | @Query("homeworkId") String homeworkId, |
| 222 | // type 固定传true | 222 | // type 固定传true |
| 223 | @Query("type") boolean type | 223 | @Query("type") boolean type |
| 224 | ); | 224 | ); |
| 225 | 225 | ||
| 226 | @GET("api/v1/homework/listHomeworkStatistics") | 226 | @GET("api/v1/homework/listHomeworkStatistics") |
| 227 | Single<ResponseResult<List<StDetail>>> getHuyouList( | 227 | Single<ResponseResult<List<StDetail>>> getHuyouList( |
| 228 | @Header("Authorization") String token, | 228 | @Header("Authorization") String token, |
| 229 | @Query("stuId") String stuId, | 229 | @Query("stuId") String stuId, |
| 230 | @Query("type") int type //0: 周报, 1:阶段总结 | 230 | @Query("type") int type //0: 周报, 1:阶段总结 |
| 231 | ); | 231 | ); |
| 232 | 232 | ||
| 233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") | 233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") |
| 234 | Single<ResponseResult<StDetail>> getHuyouDetail( | 234 | Single<ResponseResult<StDetail>> getHuyouDetail( |
| 235 | @Header("Authorization") String token, | 235 | @Header("Authorization") String token, |
| 236 | @Query("homeworkStatisticsId") String homeworkId | 236 | @Query("homeworkStatisticsId") String homeworkId |
| 237 | ); | 237 | ); |
| 238 | 238 | ||
| 239 | @GET("api/v1/demo/generalStatisticsHomework") | 239 | @GET("api/v1/demo/generalStatisticsHomework") |
| 240 | Single<ResponseResult<Object>> generalHuyou(); | 240 | Single<ResponseResult<Object>> generalHuyou(); |
| 241 | 241 | ||
| 242 | @POST("api/v1/homework/generalHomeworkStageStatistics") | 242 | @POST("api/v1/homework/generalHomeworkStageStatistics") |
| 243 | Single<ResponseResult<Boolean>> generalStageHuyou( | 243 | Single<ResponseResult<Boolean>> generalStageHuyou( |
| 244 | @Header("Authorization") String token, | 244 | @Header("Authorization") String token, |
| 245 | @Body Object body | 245 | @Body Object body |
| 246 | ); | 246 | ); |
| 247 | 247 | ||
| 248 | @GET("api/v1/homework/removeHomeworkStatistics") | 248 | @GET("api/v1/homework/removeHomeworkStatistics") |
| 249 | Single<ResponseResult<Boolean>> deleteHuyou( | 249 | Single<ResponseResult<Boolean>> deleteHuyou( |
| 250 | @Header("Authorization") String token, | 250 | @Header("Authorization") String token, |
| 251 | @Query("homeworkStatisticsId") String homeworkId | 251 | @Query("homeworkStatisticsId") String homeworkId |
| 252 | ); | 252 | ); |
| 253 | 253 | ||
| 254 | @GET("api/v1/login/smsCode") | 254 | @GET("api/v1/login/smsCode") |
| 255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); | 255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); |
| 256 | 256 | ||
| 257 | @POST("api/v1/login/smsLogin") | 257 | @POST("api/v1/login/smsLogin") |
| 258 | Single<ResponseResult<User>> smsLogin(@Body Object body); | 258 | Single<ResponseResult<User>> smsLogin(@Body Object body); |
| 259 | 259 | ||
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | public static String getUserId() { | 262 | public static String getUserId() { |
| 263 | return (String) SharedPreferencesUtil.getData("userId", ""); | 263 | return (String) SharedPreferencesUtil.getData("userId", ""); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | public static String getHeader() { | 266 | public static String getHeader() { |
| 267 | return (String) SharedPreferencesUtil.getData("token", ""); | 267 | return (String) SharedPreferencesUtil.getData("token", ""); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | public static String getBaiduToken() { | 270 | public static String getBaiduToken() { |
| 271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | public static Single<BaiduInput> inputImage(String filePath, String id) { | 274 | public static Single<BaiduInput> inputImage(String filePath, String id) { |
| 275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
| 276 | String base64 = BitmapUtils.fileToBase64(filePath); | 276 | String base64 = BitmapUtils.fileToBase64(filePath); |
| 277 | File file = new File(filePath); | 277 | File file = new File(filePath); |
| 278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); | 278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); |
| 279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) | 279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) |
| 280 | .flatMap(token -> { | 280 | .flatMap(token -> { |
| 281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); | 281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); |
| 282 | }); | 282 | }); |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | public static Single<ResponseResult> uploadImage(String path, String id) { | 285 | public static Single<ResponseResult> uploadImage(String path, String id) { |
| 286 | File file = new File(path); | 286 | File file = new File(path); |
| 287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
| 288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
| 289 | return service_url.uploadImage(getHeader(), part, id); | 289 | return service_url.uploadImage(getHeader(), part, id); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | 292 | ||
| 293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
| 294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
| 298 | File file = new File(path); | 298 | File file = new File(path); |
| 299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
| 300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
| 301 | Map<String, Object> map = new HashMap<>(); | 301 | Map<String, Object> map = new HashMap<>(); |
| 302 | map.put("condition", param); | 302 | map.put("condition", param); |
| 303 | setSubscribe(service_url.addError(part, map), observer); | 303 | setSubscribe(service_url.addError(part, map), observer); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | 306 | ||
| 307 | public static void cut(String base64, Observer<CutPicBean> observer) { | 307 | public static void cut(String base64, Observer<CutPicBean> observer) { |
| 308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
| 309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
| 310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
| 314 | setSubscribe(service_url.editError(getHeader(), map), observer); | 314 | setSubscribe(service_url.editError(getHeader(), map), observer); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
| 318 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 318 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
| 322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | public static void getBaiduToken(Observer<JsonObject> observer) { | 325 | public static void getBaiduToken(Observer<JsonObject> observer) { |
| 326 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); | 326 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | public static Single<JsonObject> getBaiduTokenOcr() { | 329 | public static Single<JsonObject> getBaiduTokenOcr() { |
| 330 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); | 330 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
| 334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
| 335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
| 336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
| 340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | public static void logout(Observer<ResponseBody> observer) { | 343 | public static void logout(Observer<ResponseBody> observer) { |
| 344 | setSubscribe(service_url.logout(), observer); | 344 | setSubscribe(service_url.logout(), observer); |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
| 348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
| 352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
| 356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
| 357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
| 358 | Map<String, Object> map = new HashMap<>(); | 358 | Map<String, Object> map = new HashMap<>(); |
| 359 | map.put("stuId", stuId); | 359 | map.put("stuId", stuId); |
| 360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
| 364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
| 365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
| 366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
| 370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | 373 | ||
| 374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
| 375 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 375 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
| 379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | 382 | ||
| 383 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 383 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
| 384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | 387 | ||
| 388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
| 389 | setSubscribe(service_url.login(body), observer); | 389 | setSubscribe(service_url.login(body), observer); |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
| 393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | 396 | ||
| 397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
| 398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); |
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | public static void getChildrenList(Observer<ResponseBody> observer) { | 401 | public static void getChildrenList(Observer<ResponseBody> observer) { |
| 402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | 405 | ||
| 406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
| 407 | setSubscribe(service_url.registerParent(body), observer); | 407 | setSubscribe(service_url.registerParent(body), observer); |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | 410 | ||
| 411 | public static void listChildren(Observer<ResponseBody> observer) { | 411 | public static void listChildren(Observer<ResponseBody> observer) { |
| 412 | setSubscribe(service_url.listChildren(getHeader()), observer); | 412 | setSubscribe(service_url.listChildren(getHeader()), observer); |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | public static void listStudent(Observer<ResponseBody> observer) { | 415 | public static void listStudent(Observer<ResponseBody> observer) { |
| 416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | public static Single<ResponseResult<List<Student>>> listStudent() { | 419 | public static Single<ResponseResult<List<Student>>> listStudent() { |
| 420 | return service_url.getStudentList2(getHeader(), getUserId()); | 420 | return service_url.getStudentList2(getHeader(), getUserId()); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | public static void listRecord(Observer<ResponseBody> observer) { | 423 | public static void listRecord(Observer<ResponseBody> observer) { |
| 424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | 427 | ||
| 428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
| 429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
| 433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
| 437 | setSubscribe(service_url.getError(getHeader(), map), observer); | 437 | setSubscribe(service_url.getError(getHeader(), map), observer); |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | 440 | ||
| 441 | public static RequestBody getMapRequestBody(Map map) { | 441 | public static RequestBody getMapRequestBody(Map map) { |
| 442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | 445 | ||
| 446 | public static RequestBody getArrayRequestBody(List list) { | 446 | public static RequestBody getArrayRequestBody(List list) { |
| 447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | public static RequestBody getFileRequestBody(File file) { | 450 | public static RequestBody getFileRequestBody(File file) { |
| 451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | public static RequestBody getFileRequestBody(byte[] bytes) { | 454 | public static RequestBody getFileRequestBody(byte[] bytes) { |
| 455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | public static RequestBody getObjectRequestBody(Object obj) { | 458 | public static RequestBody getObjectRequestBody(Object obj) { |
| 459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | public static RequestBody getStringRequestBody(String str) { | 462 | public static RequestBody getStringRequestBody(String str) { |
| 463 | return RequestBody.create(MediaType.parse("text/plain"), str); | 463 | return RequestBody.create(MediaType.parse("text/plain"), str); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | 466 | ||
| 467 | /** | 467 | /** |
| 468 | * 插入观察者 | 468 | * 插入观察者 |
| 469 | * | 469 | * |
| 470 | * @param observable | 470 | * @param observable |
| 471 | * @param observer | 471 | * @param observer |
| 472 | * @param <T> | 472 | * @param <T> |
| 473 | */ | 473 | */ |
| 474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
| 475 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 475 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
| 476 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | 476 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
| 477 | .subscribe(observer); | 477 | .subscribe(observer); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | } | 480 | } |
| 481 | 481 |