refactor: 优化前端网络层
- 优化AuthService认证服务 - 更新AuthModels数据模型 - 更新MemoirModels数据模型
This commit is contained in:
@@ -326,13 +326,14 @@ class AuthService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
* 验证码登录/注册(统一接口)
|
||||
* 如果用户不存在,会自动注册(需要提供nickname)
|
||||
*/
|
||||
suspend fun loginWithSms(phone: String, code: String, agreedToTerms: Boolean): Result<TokenResponse> {
|
||||
suspend fun loginWithSms(phone: String, code: String, agreedToTerms: Boolean, nickname: String? = null): Result<TokenResponse> {
|
||||
return try {
|
||||
val response = client.post("$AUTH_BASE/login/sms") {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(SmsLoginRequest(phone, code, agreedToTerms))
|
||||
setBody(SmsLoginRequest(phone, code, agreedToTerms, nickname))
|
||||
}
|
||||
|
||||
when (response.status) {
|
||||
|
||||
@@ -89,12 +89,13 @@ data class SmsResponse(
|
||||
val expires_in: Int
|
||||
)
|
||||
|
||||
// 验证码登录请求
|
||||
// 验证码登录/注册请求(统一接口)
|
||||
@Serializable
|
||||
data class SmsLoginRequest(
|
||||
val phone: String,
|
||||
val code: String,
|
||||
val agreed_to_terms: Boolean
|
||||
val agreed_to_terms: Boolean,
|
||||
val nickname: String? = null // 昵称(首次登录/注册时必填)
|
||||
)
|
||||
|
||||
// 验证码注册请求
|
||||
|
||||
@@ -44,7 +44,8 @@ data class ChapterContentDto(
|
||||
val category: String,
|
||||
val pageCount: Int?,
|
||||
val updatedAt: Long,
|
||||
val quotes: List<String> = emptyList() // 引用内容列表
|
||||
val quotes: List<String> = emptyList(), // 引用内容列表
|
||||
val images: List<String> = emptyList() // 图片列表
|
||||
)
|
||||
|
||||
// 回忆录状态DTO
|
||||
|
||||
Reference in New Issue
Block a user