登录注册修改密码,网络请求

This commit is contained in:
2026-05-14 14:59:45 +08:00
parent 14d1969903
commit 652e10ec62
12 changed files with 455 additions and 229 deletions

View File

@@ -1,14 +1,27 @@
package com.example.defenseapplication.utils
import com.google.gson.Gson
import okhttp3.OkHttpClient
import bean.ForgotRequest
import com.example.defenseapplication.bean.GetCodeBean
import bean.LoginBean
import bean.LoginRequest
import bean.RegisterRequest
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query
interface ApiService {
// 获取登录注册验证码
@GET("/resource/sms/code")
suspend fun getCode(): String
suspend fun getCode(@Query("userName") userName: String): GetCodeBean<String>
@POST("/app/login")
suspend fun login(@Body loginRequest: LoginRequest): GetCodeBean<LoginBean>
@POST("/app/register")
suspend fun register(@Body registerRequest: RegisterRequest): GetCodeBean<Any>
@PUT("/app/forgot")
suspend fun forgotPassword(@Body forgotRequest: ForgotRequest): GetCodeBean<Any>
}
}

View File

@@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit
//网络工具类
object HttpUtils {
val baseURL = "https://stem-boozy-margarine.ngrok-free.dev"
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.writeTimeout(3, TimeUnit.MINUTES)
@@ -30,7 +30,7 @@ object HttpUtils {
val retrofit = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.baseUrl("https://stem-boozy-margarine.ngrok-free.dev")
.baseUrl(baseURL)
.build()