加入formUrlEncode 形式参数

This commit is contained in:
renhaoting 2025-11-06 19:09:05 +08:00
parent d40644c6d2
commit 2788a41913
7 changed files with 52 additions and 6 deletions

View File

@ -8,7 +8,9 @@ import com.remax.visualnovel.entity.request.ChatAlbum
import com.remax.visualnovel.entity.request.ChatSetting
import com.remax.visualnovel.entity.request.HeartbeatBuy
import com.remax.visualnovel.entity.request.ParamBgUpload
import com.remax.visualnovel.entity.request.ParamLanguage
import com.remax.visualnovel.entity.request.ParamSoundList
import com.remax.visualnovel.entity.request.ParamUserid
import com.remax.visualnovel.entity.request.RTCRequest
import com.remax.visualnovel.entity.request.SearchPage
import com.remax.visualnovel.entity.request.SimpleDataDTO
@ -27,8 +29,14 @@ import com.remax.visualnovel.entity.response.Token
import com.remax.visualnovel.entity.response.VoiceASR
import com.remax.visualnovel.entity.response.base.Response
import com.remax.visualnovel.entity.response.basenew.ResponseNew
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
interface ChatService {
@ -170,12 +178,27 @@ interface ChatService {
suspend fun requestSoundList(@Body param: ParamSoundList): ResponseNew<List<ChatSound>>
@POST(BuildConfig.API_BASE + "/model/config/list")
suspend fun requestAiModelList(@Body language: Int = 1): ResponseNew<List<ChatAiModule>>
suspend fun requestAiModelList(@Body language: ParamLanguage): ResponseNew<List<ChatAiModule>>
@POST(BuildConfig.API_BASE + "/file/bgImage/upload")
suspend fun uploadCustomBgPic(@Body param: ParamBgUpload): ResponseNew<Any>
/*@Multipart
@POST(BuildConfig.API_BASE + "/file/bgImage/upload")
suspend fun uploadCustomBgPic(@Part("userId") title: RequestBody,
@Part file: MultipartBody.Part): ResponseNew<Any>*/
/*
@POST(BuildConfig.API_BASE + "/file/bgImage/list")
suspend fun requestChatBgList(@Body userId: Int): ResponseNew<List<ChatBackgroundBase.ChatBackground>>
suspend fun requestChatBgList(@Body userId: ParamUserid): ResponseNew<List<ChatBackgroundBase.ChatBackground>>
*/
@FormUrlEncoded
@POST(BuildConfig.API_BASE + "/file/bgImage/list")
suspend fun requestChatBgList(@Field("userId") userId: Int): ResponseNew<List<ChatBackgroundBase.ChatBackground>>
}

View File

@ -0,0 +1,6 @@
package com.remax.visualnovel.entity.request
data class ParamLanguage(
var language: Int = 1,
)

View File

@ -0,0 +1,6 @@
package com.remax.visualnovel.entity.request
data class ParamUserid(
var userId: Int = 1
)

View File

@ -1,6 +1,9 @@
package com.remax.visualnovel.entity.response
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
data class ChatAiModule(
val modelId: Long = 0,
val nameLanguage: String,
@ -11,4 +14,6 @@ data class ChatAiModule(
// others
var isSelected: Boolean = false,
)
) : Parcelable {
}

View File

@ -3,7 +3,9 @@ package com.remax.visualnovel.repository.api
import com.remax.visualnovel.api.service.ChatService
import com.remax.visualnovel.entity.request.ChatSetting
import com.remax.visualnovel.entity.request.ParamBgUpload
import com.remax.visualnovel.entity.request.ParamLanguage
import com.remax.visualnovel.entity.request.ParamSoundList
import com.remax.visualnovel.entity.request.ParamUserid
import com.remax.visualnovel.entity.request.SimpleDataDTO
import com.remax.visualnovel.repository.api.base.BaseRepositoryNew
import com.remax.visualnovel.ui.wallet.manager.WalletManager
@ -33,7 +35,7 @@ class ChatRepository @Inject constructor(private val chatService: ChatService) :
chatService.requestSoundList(param)
}
suspend fun getAiModelList(language: Int = 1) = executeHttp {
suspend fun getAiModelList(language: ParamLanguage) = executeHttp {
chatService.requestAiModelList(language)
}

View File

@ -23,7 +23,9 @@ import com.pengxr.modular.eventbus.generated.events.EventDefineOfUserEvents
import com.remax.visualnovel.R
import com.remax.visualnovel.databinding.ActivityActorChatBinding
import com.remax.visualnovel.entity.request.ChatSetting
import com.remax.visualnovel.entity.request.ParamLanguage
import com.remax.visualnovel.entity.request.ParamSoundList
import com.remax.visualnovel.entity.request.ParamUserid
import com.remax.visualnovel.event.model.OnLoginEvent
import com.remax.visualnovel.extension.countDownCoroutines
import com.remax.visualnovel.extension.launchAndCollect2
@ -80,7 +82,7 @@ class ChatActivity : BaseBindingActivity<ActivityActorChatBinding>() {
private fun loadAiModuleDatas() {
launchAndCollect2({
mViewModel.loadAiModelList(LanguageUtil.instance().getCurrentLanguageCode())
mViewModel.loadAiModelList(ParamLanguage(LanguageUtil.instance().getCurrentLanguageCode()))
}) {
onSuccess = {
val dataList = it?: emptyList()

View File

@ -16,7 +16,9 @@ import com.remax.visualnovel.repository.api.MessageRepository
import com.google.gson.Gson
import com.netease.nimlib.sdk.v2.message.V2NIMMessageCreator
import com.remax.visualnovel.entity.request.ParamBgUpload
import com.remax.visualnovel.entity.request.ParamLanguage
import com.remax.visualnovel.entity.request.ParamSoundList
import com.remax.visualnovel.entity.request.ParamUserid
import com.remax.visualnovel.entity.response.BucketBean
import com.remax.visualnovel.entity.response.Character
import dagger.hilt.android.lifecycle.HiltViewModel
@ -86,7 +88,7 @@ class ChatViewModel @Inject constructor(
//------------------------ new ------------------------
suspend fun loadSoundList(param: ParamSoundList) = chatRepository.getSoundList(param)
suspend fun loadAiModelList(language: Int = 1) = chatRepository.getAiModelList(language)
suspend fun loadAiModelList(language: ParamLanguage) = chatRepository.getAiModelList(language)
suspend fun loadChatBgList(userId: Int) = chatRepository.getChatBgList(userId)
suspend fun uploadCustomBgPic(param: ParamBgUpload) = chatRepository.uploadCustomBgPic(param)