dm-11
This commit is contained in:
parent
a1982de47a
commit
b78016826f
2 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package com.example.login_v3.data.repository.dm
|
package com.example.login_v3.data.repository.dm
|
||||||
|
|
||||||
import com.example.login_v3.data.api.TecnologiaApi
|
import com.example.login_v3.data.api.TecnologiaApi
|
||||||
|
import com.example.login_v3.data.api.api_class.MessageResponse
|
||||||
import com.example.login_v3.data.api.api_class.RoomListResponse
|
import com.example.login_v3.data.api.api_class.RoomListResponse
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
@ -21,4 +22,23 @@ class ChatRoomsRepository @Inject constructor(
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getChatMessages(roomId: String): Result<MessageResponse> {
|
||||||
|
return try {
|
||||||
|
val response = api.getChatMessages(roomId) // 確保 TecnologiaApi 裡有 getChatMessages 方法
|
||||||
|
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val body = response.body()
|
||||||
|
if (body != null) {
|
||||||
|
Result.success(body)
|
||||||
|
} else {
|
||||||
|
Result.failure(Exception("回應身體為空 (Empty response body)"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Result.failure(Exception("網路請求失敗,錯誤碼: ${response.code()}"))
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Result.failure(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.example.login_v3.home.Message.ViewModel.Detail
|
||||||
|
|
||||||
|
class Message_Messaging_ViewModel {
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue