feat: 新增我的动态信息结构和相关API请求逻辑
- 在DynamicsModels.swift中新增MyMomentInfo结构,专门用于处理/dynamic/getMyDynamic接口的响应数据。 - 更新MyMomentsResponse结构以使用MyMomentInfo,确保数据类型一致性。 - 在LoginModels.swift中重构IDLoginAPIRequest和EmailLoginRequest,优化queryParameters的实现方式,提升代码可读性。 - 在RecoverPasswordFeature中重构ResetPasswordRequest,优化queryParameters的实现方式,确保一致性。 - 在多个视图中添加调试信息,增强调试能力和用户体验。 - 更新Localizable.strings文件,新增动态列表为空时的提示信息,提升用户交互体验。
This commit is contained in:
@@ -241,12 +241,56 @@ struct PublishFeedData: Codable, Equatable {
|
||||
|
||||
// MARK: - 我的动态 API 请求
|
||||
|
||||
/// 我的动态信息结构 - 专门用于 /dynamic/getMyDynamic 接口
|
||||
struct MyMomentInfo: Codable, Equatable, Sendable {
|
||||
let content: String
|
||||
let uid: Int
|
||||
let publishTime: Int64
|
||||
let type: Int
|
||||
|
||||
// 转换为 MomentsInfo 的辅助方法
|
||||
func toMomentsInfo() -> MomentsInfo {
|
||||
return MomentsInfo(
|
||||
dynamicId: 0, // 我的动态接口没有返回 dynamicId
|
||||
uid: uid,
|
||||
nick: "", // 需要从用户信息中获取
|
||||
avatar: "", // 需要从用户信息中获取
|
||||
type: type,
|
||||
content: content,
|
||||
likeCount: 0, // 我的动态接口没有返回点赞数
|
||||
isLike: false, // 我的动态接口没有返回点赞状态
|
||||
commentCount: 0, // 我的动态接口没有返回评论数
|
||||
publishTime: Int(publishTime / 1000), // 转换为秒
|
||||
worldId: 0, // 我的动态接口没有返回 worldId
|
||||
status: 1, // 默认状态
|
||||
playCount: nil,
|
||||
dynamicResList: nil,
|
||||
gender: nil,
|
||||
squareTop: nil,
|
||||
topicTop: nil,
|
||||
newUser: nil,
|
||||
defUser: nil,
|
||||
scene: nil,
|
||||
userVipInfoVO: nil,
|
||||
headwearPic: nil,
|
||||
headwearEffect: nil,
|
||||
headwearType: nil,
|
||||
headwearName: nil,
|
||||
headwearId: nil,
|
||||
experLevelPic: nil,
|
||||
charmLevelPic: nil,
|
||||
isCustomWord: nil,
|
||||
labelList: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// 我的动态响应结构
|
||||
struct MyMomentsResponse: Codable, Equatable, Sendable {
|
||||
let code: Int
|
||||
let message: String
|
||||
let data: [MomentsInfo]?
|
||||
let timestamp: Int?
|
||||
let data: [MyMomentInfo]?
|
||||
let timestamp: Int64?
|
||||
}
|
||||
|
||||
struct GetMyDynamicRequest: APIRequestProtocol {
|
||||
|
@@ -77,10 +77,29 @@ struct IDLoginAPIRequest: APIRequestProtocol {
|
||||
let endpoint = APIEndpoint.login.path // 使用枚举定义的登录端点
|
||||
let method: HTTPMethod = .POST
|
||||
let includeBaseParameters = true
|
||||
let queryParameters: [String: String]?
|
||||
var bodyParameters: [String: Any]? { nil }
|
||||
let timeout: TimeInterval = 30.0
|
||||
|
||||
// MARK: - Private Properties
|
||||
private let phone: String
|
||||
private let password: String
|
||||
private let clientSecret: String
|
||||
private let version: String
|
||||
private let clientId: String
|
||||
private let grantType: String
|
||||
|
||||
// MARK: - Computed Properties
|
||||
var queryParameters: [String: String]? {
|
||||
return [
|
||||
"phone": phone,
|
||||
"password": password,
|
||||
"client_secret": clientSecret,
|
||||
"version": version,
|
||||
"client_id": clientId,
|
||||
"grant_type": grantType
|
||||
]
|
||||
}
|
||||
|
||||
/// 初始化ID登录请求
|
||||
/// - Parameters:
|
||||
/// - phone: DES加密后的用户ID/手机号
|
||||
@@ -90,14 +109,12 @@ struct IDLoginAPIRequest: APIRequestProtocol {
|
||||
/// - clientId: 客户端ID,固定为"erban-client"
|
||||
/// - grantType: 授权类型,固定为"password"
|
||||
init(phone: String, password: String, clientSecret: String = "uyzjdhds", version: String = "1", clientId: String = "erban-client", grantType: String = "password") {
|
||||
self.queryParameters = [
|
||||
"phone": phone,
|
||||
"password": password,
|
||||
"client_secret": clientSecret,
|
||||
"version": version,
|
||||
"client_id": clientId,
|
||||
"grant_type": grantType
|
||||
];
|
||||
self.phone = phone
|
||||
self.password = password
|
||||
self.clientSecret = clientSecret
|
||||
self.version = version
|
||||
self.clientId = clientId
|
||||
self.grantType = grantType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,10 +544,29 @@ struct EmailLoginRequest: APIRequestProtocol {
|
||||
let endpoint = APIEndpoint.login.path
|
||||
let method: HTTPMethod = .POST
|
||||
let includeBaseParameters = true
|
||||
let queryParameters: [String: String]?
|
||||
var bodyParameters: [String: Any]? { nil }
|
||||
let timeout: TimeInterval = 30.0
|
||||
|
||||
// MARK: - Private Properties
|
||||
private let email: String
|
||||
private let code: String
|
||||
private let clientSecret: String
|
||||
private let version: String
|
||||
private let clientId: String
|
||||
private let grantType: String
|
||||
|
||||
// MARK: - Computed Properties
|
||||
var queryParameters: [String: String]? {
|
||||
return [
|
||||
"email": email,
|
||||
"code": code,
|
||||
"client_secret": clientSecret,
|
||||
"version": version,
|
||||
"client_id": clientId,
|
||||
"grant_type": grantType
|
||||
]
|
||||
}
|
||||
|
||||
/// 初始化邮箱验证码登录请求
|
||||
/// - Parameters:
|
||||
/// - email: DES加密后的邮箱地址
|
||||
@@ -540,14 +576,12 @@ struct EmailLoginRequest: APIRequestProtocol {
|
||||
/// - clientId: 客户端ID,固定为"erban-client"
|
||||
/// - grantType: 授权类型,固定为"email"
|
||||
init(email: String, code: String, clientSecret: String = "uyzjdhds", version: String = "1", clientId: String = "erban-client", grantType: String = "email") {
|
||||
self.queryParameters = [
|
||||
"email": email,
|
||||
"code": code,
|
||||
"client_secret": clientSecret,
|
||||
"version": version,
|
||||
"client_id": clientId,
|
||||
"grant_type": grantType
|
||||
]
|
||||
self.email = email
|
||||
self.code = code
|
||||
self.clientSecret = clientSecret
|
||||
self.version = version
|
||||
self.clientId = clientId
|
||||
self.grantType = grantType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,18 +637,25 @@ struct GetUserInfoRequest: APIRequestProtocol {
|
||||
let endpoint = APIEndpoint.getUserInfo.path
|
||||
let method: HTTPMethod = .GET
|
||||
let includeBaseParameters = true
|
||||
let queryParameters: [String: String]?
|
||||
var bodyParameters: [String: Any]? { nil }
|
||||
let timeout: TimeInterval = 30.0
|
||||
let shouldShowLoading: Bool = false // 不显示loading,避免影响用户体验
|
||||
let shouldShowError: Bool = false // 不显示错误,静默处理
|
||||
|
||||
// MARK: - Private Properties
|
||||
private let uid: String
|
||||
|
||||
// MARK: - Computed Properties
|
||||
var queryParameters: [String: String]? {
|
||||
return [
|
||||
"uid": uid
|
||||
]
|
||||
}
|
||||
|
||||
/// 初始化获取用户信息请求
|
||||
/// - Parameter uid: 要查询的用户ID
|
||||
init(uid: String) {
|
||||
self.queryParameters = [
|
||||
"uid": uid
|
||||
]
|
||||
self.uid = uid
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user