Skip to content

Commit

Permalink
Feature:
Browse files Browse the repository at this point in the history
    1. 好友详情
    2. 切换账号
  • Loading branch information
YuS1aN committed Mar 5, 2024
1 parent ab81e55 commit a1e8398
Show file tree
Hide file tree
Showing 35 changed files with 719 additions and 536 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

或者采用 `Nginx` 等Web服务器反向代理

## TODO
* 新版本适配中
## TODO (新版本适配中)
* 数据库管理
* 文件管理
239 changes: 0 additions & 239 deletions app/src/main/assets/info_charts.html

This file was deleted.

13 changes: 7 additions & 6 deletions app/src/main/java/me/kbai/zhenxunui/api/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import me.kbai.zhenxunui.model.RequestListResult
import me.kbai.zhenxunui.model.SendMessage
import me.kbai.zhenxunui.model.UpdateGroup
import me.kbai.zhenxunui.model.UpdatePlugin
import me.kbai.zhenxunui.model.UserDetail
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.Field
Expand Down Expand Up @@ -46,6 +47,12 @@ interface ApiService {
@Query("group_id") groupId: String
): ApiResponse<GroupInfo>

@GET("manage/get_friend_detail")
suspend fun getUserDetail(
@Query("bot_id") botId: String,
@Query("user_id") userId: String
): ApiResponse<UserDetail>

@POST("manage/update_group")
suspend fun updateGroup(@Body updateGroup: UpdateGroup): ApiResponse<Unit>

Expand Down Expand Up @@ -82,12 +89,6 @@ interface ApiService {
@POST("manage/delete_request")
suspend fun deleteRequest(@Body handleRequest: HandleRequest): ApiResponse<Unit>

@GET("system/disk")
suspend fun getDiskUsage(): RawApiResponse

@GET("system/statusList")
suspend fun getStatusList(): RawApiResponse

@GET("main/get_base_info")
suspend fun getBotList(): ApiResponse<List<BotBaseInfo>>

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/me/kbai/zhenxunui/model/UserDetail.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.kbai.zhenxunui.model

import com.google.gson.annotations.SerializedName

data class UserDetail(
@SerializedName("user_id")
val userId: String,
@SerializedName("ava_url")
val avatarUrl: String,
val nickname: String,
val remark: String,
@SerializedName("is_ban")
val banned: Boolean,
@SerializedName("chat_count")
val chatCount: Int,
@SerializedName("call_count")
val callCount: Int,
@SerializedName("like_plugin")
val favouritePlugins: Map<String, Int>
)
18 changes: 12 additions & 6 deletions app/src/main/java/me/kbai/zhenxunui/repository/ApiRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import me.kbai.zhenxunui.model.SendMessage
import me.kbai.zhenxunui.model.SystemStatus
import me.kbai.zhenxunui.model.UpdateGroup
import me.kbai.zhenxunui.model.UpdatePlugin
import org.json.JSONException
import org.json.JSONObject
import retrofit2.HttpException

Expand All @@ -41,6 +42,9 @@ object ApiRepository {
fun updateGroup(updateGroup: UpdateGroup) =
networkFlow { BotApi.service.updateGroup(updateGroup) }

fun getUserDetail(botId: String, userId: String) =
networkFlow { BotApi.service.getUserDetail(botId, userId) }

fun getPluginList(vararg types: PluginType, menuType: String? = null) = networkFlow {
BotApi.service.getPluginList(
types.map { it.string }.toTypedArray(),
Expand Down Expand Up @@ -69,10 +73,6 @@ object ApiRepository {

fun deleteRequest(handle: HandleRequest) = networkFlow { BotApi.service.deleteRequest(handle) }

fun getDiskUsage() = rawNetworkFlow { BotApi.service.getDiskUsage() }

fun getStatusList() = rawNetworkFlow { BotApi.service.getStatusList() }

fun getBotList() = networkFlow { BotApi.service.getBotList() }

fun getMessageCount(botId: String) = networkFlow { BotApi.service.getBotMessageCount(botId) }
Expand Down Expand Up @@ -133,8 +133,14 @@ object ApiRepository {
(e as HttpException).run {
val detail = response()
?.errorBody()
?.let { JSONObject(it.string()) }
?.optString("detail")
?.let {
try {
JSONObject(it.string()).optString("detail")
} catch (e: JSONException) {
it.string()
}
}
?.ifBlank { null }
emit(Resource.error(null, detail ?: message(), -1, code()))
}
}
Expand Down
Loading

0 comments on commit a1e8398

Please sign in to comment.