Skip to content

Commit

Permalink
🐛 开放空教室,修复ci action异常
Browse files Browse the repository at this point in the history
🐛 修复ci action异常

🎨 开放空教室
  • Loading branch information
lytMoon committed Sep 18, 2024
1 parent cec102d commit a528d54
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
run: ./gradlew assembleRelease

- name: Archive production artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: result_apk
path: module_app/build/outputs/apk/release/module_app-release.apk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mredrock.cyxbs.account

import android.content.Context
import android.util.Log
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
import androidx.core.content.edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DefaultPageInterceptor: IInterceptor {
DISCOVER_SPORT,
DISCOVER_SPORT_FEED,
//空教室
DISCOVER_EMPTY_ROOM,
// DISCOVER_EMPTY_ROOM,
//我的考试
DISCOVER_GRADES,
//志愿服务
Expand All @@ -42,6 +42,7 @@ class DefaultPageInterceptor: IInterceptor {
QA_DYNAMIC_MINE_FRAGMENT,
//个人中心
MINE_PERSON_PAGE,
""
)
override fun init(context: Context) {
println(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import retrofit2.http.*
interface ApiService {
@FormUrlEncoded
@POST("/magipoke-jwzx/roomEmpty")
fun getEmpyRooms(@Field("week") week: Int,
@Field("weekDayNum") weekday: Int,
@Field("buildNum") buildNum: Int,
@Field("sectionNum") section: String): Observable<RedrockApiWrapper<List<String>>>
fun getEmpyRooms(
@Field("weekDayNum") weekday: String,
@Field("sectionNum") section: String,
@Field("buildNum") buildNum: String,
@Field("week") week: String
): Observable<RedrockApiWrapper<List<String>>>

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.mredrock.cyxbs.discover.emptyroom.viewmodel

import androidx.lifecycle.MutableLiveData
import com.mredrock.cyxbs.common.network.ApiGenerator
import com.mredrock.cyxbs.common.utils.extensions.unsafeSubscribeBy
import com.mredrock.cyxbs.common.utils.extensions.setSchedulers
import com.mredrock.cyxbs.common.utils.extensions.unsafeSubscribeBy
import com.mredrock.cyxbs.common.viewmodel.BaseViewModel
import com.mredrock.cyxbs.discover.emptyroom.bean.EmptyRoom
import com.mredrock.cyxbs.discover.emptyroom.network.ApiService
Expand Down Expand Up @@ -36,26 +36,28 @@ class EmptyRoomViewModel : BaseViewModel() {
}

fun getData(week: Int, weekday: Int, building: Int, section: List<Int>) {
val tag = section.joinToString(",", " ", " ").replace(" ", "")
val tag = section.map { it - 1 }//新接口从0开始
.joinToString(",", " ", " ")
.replace(" ", "")
if (section.isEmpty()) {
status.value = DEFAULT
return
}
status.value = LOADING
d?.dispose()
d = apiService.getEmpyRooms(week, weekday, building, tag)
.delay(300, TimeUnit.MILLISECONDS)
.setSchedulers()
.unsafeSubscribeBy(
onNext = {
status.value = FINISH
val converter = EmptyConverter()
converter.setEmptyData(it.data)
rooms.value = converter.convert()
},
onError = {
status.value = ERROR
})
d = apiService.getEmpyRooms(weekday.toString(), tag, building.toString(), week.toString())
.delay(300, TimeUnit.MILLISECONDS)
.setSchedulers()
.unsafeSubscribeBy(
onNext = {
status.value = FINISH
val converter = EmptyConverter()
converter.setEmptyData(it.data)
rooms.value = converter.convert()
},
onError = {
status.value = ERROR
})
d?.lifeCycle()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ interface ApiService {
fun getReExam(@Field("stuNum") stu: String): Observable<RedrockApiWrapper<List<Exam>>>

@POST("/magipoke/ids/unbind")
fun unbindIds() : Observable<RedrockApiStatus>
fun unbindIds(): Observable<RedrockApiStatus>

@GET("/magipoke/gpa")
fun getAnalyzeData(): Observable<GPAStatus>

/**
* 获取考试成绩,2024接口新增
* 参数 学号 认证密码
*/
@FormUrlEncoded
@POST("/magipoke-jwzx/examGrade")
fun getExamGrades(@Field("stuNum") stuNum: String, @Field("inNum") inNum: String)

@GET("/magipoke-jwzx/nowStatus")
fun getNowStatus(): Observable<RedrockApiWrapper<Status>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package com.mredrock.cyxbs.discover.grades.ui.viewModel

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mredrock.cyxbs.common.BaseApp
import com.mredrock.cyxbs.common.network.ApiGenerator
import com.mredrock.cyxbs.common.utils.extensions.*
import com.mredrock.cyxbs.common.viewmodel.BaseViewModel
Expand All @@ -17,6 +17,7 @@ import com.mredrock.cyxbs.discover.grades.bean.Exam
import com.mredrock.cyxbs.discover.grades.bean.Status
import com.mredrock.cyxbs.discover.grades.bean.analyze.GPAStatus
import com.mredrock.cyxbs.discover.grades.network.ApiService
import com.mredrock.cyxbs.lib.utils.extensions.unsafeSubscribeBy
import io.reactivex.rxjava3.core.Observable
import retrofit2.HttpException

Expand All @@ -41,6 +42,7 @@ class ContainerViewModel : BaseViewModel() {
fun loadData(stuNum: String) {
val exam = apiService.getExam(stuNum)
val reExam = apiService.getReExam(stuNum)

Observable.merge(exam, reExam)
.setSchedulers()
.mapOrThrowApiException()
Expand All @@ -51,6 +53,7 @@ class ContainerViewModel : BaseViewModel() {
.unsafeSubscribeBy {
examData.value = it
}.lifeCycle()

}

/**
Expand All @@ -77,10 +80,10 @@ class ContainerViewModel : BaseViewModel() {
if (it is HttpException) {
val errorBody = it.response()?.errorBody()?.string() ?: ""
try {
isBinding.value = false
// 防止后端返回的status不符合json格式报错
val gpaStatus = Gson().fromJson(errorBody, GPAStatus::class.java)
_analyzeData.postValue(gpaStatus)
isBinding.value = false
} catch (e: Exception) {
toast("加载绩点失败")
}
Expand Down

0 comments on commit a528d54

Please sign in to comment.