更新代码

This commit is contained in:
2024-12-07 17:14:45 +08:00
parent 50fb1874e7
commit 9f93e6dc14
19 changed files with 744 additions and 171 deletions

View File

@@ -9,6 +9,7 @@ import com.aiosman.ravenow.data.api.GoogleRegisterRequestBody
import com.aiosman.ravenow.data.api.LoginUserRequestBody
import com.aiosman.ravenow.data.api.RegisterMessageChannelRequestBody
import com.aiosman.ravenow.data.api.RegisterRequestBody
import com.aiosman.ravenow.data.api.RemoveAccountRequestBody
import com.aiosman.ravenow.data.api.ResetPasswordRequestBody
import com.aiosman.ravenow.data.api.TrtcSignResponseBody
import com.aiosman.ravenow.data.api.UnRegisterMessageChannelRequestBody
@@ -386,6 +387,8 @@ interface AccountService {
suspend fun getMyTrtcSign(): TrtcSignResponseBody
suspend fun getAppConfig(): AppConfig
suspend fun removeAccount(password: String)
}
class AccountServiceImpl : AccountService {
@@ -554,4 +557,16 @@ class AccountServiceImpl : AccountService {
val body = resp.body() ?: throw ServiceException("Failed to get app config")
return body.data
}
override suspend fun removeAccount(password: String) {
val resp = ApiClient.api.deleteAccount(
RemoveAccountRequestBody(password)
)
if (!resp.isSuccessful) {
parseErrorResponse(resp.errorBody())?.let {
throw it.toServiceException()
}
throw ServiceException("Failed to remove account")
}
}
}

View File

@@ -200,6 +200,10 @@ data class CreateReportRequestBody(
val base64Images: List<String>,
)
data class RemoveAccountRequestBody(
@SerializedName("password")
val password: String,
)
interface RaveNowAPI {
@POST("register")
@@ -449,5 +453,11 @@ interface RaveNowAPI {
suspend fun createReport(
@Body body: CreateReportRequestBody
): Response<Unit>
@POST("account/my/delete")
suspend fun deleteAccount(
@Body body: RemoveAccountRequestBody
): Response<Unit>
}