Files
e-party-iOS/yana/APIs/DynamicsModels.swift
edwinQQQ 12bb4a5f8c feat: 更新Podfile和Podfile.lock,添加最新动态API文档和相关功能
- 在Podfile中添加Alamofire依赖,并更新Podfile.lock以反映更改。
- 新增动态内容API文档,详细描述`dynamic/square/latestDynamics`接口的请求参数、响应数据结构及示例。
- 实现动态内容的模型和API请求结构,支持获取最新动态列表。
- 更新FeedView和HomeView以集成动态内容展示,增强用户体验。
- 添加动态卡片组件,展示用户动态信息及互动功能。
2025-07-11 20:18:24 +08:00

160 lines
4.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Foundation
import ComposableArchitecture
// MARK: -
///
struct MomentsLatestResponse: Codable, Equatable {
let code: Int
let message: String
let data: MomentsListData?
let timestamp: Int?
}
///
struct MomentsListData: Codable, Equatable {
let dynamicList: [MomentsInfo]
let nextDynamicId: Int
}
///
struct MomentsInfo: Codable, Equatable {
let dynamicId: Int
let uid: Int
let nick: String
let avatar: String
let gender: Int
let type: Int
let content: String
let likeCount: Int
let isLike: Bool
let commentCount: Int
let publishTime: Int
let worldId: Int
let squareTop: Int
let topicTop: Int
let newUser: Bool
let defUser: Int
let status: Int
let scene: String
let dynamicResList: [MomentsPicture]?
let userVipInfoVO: UserVipInfo?
// -
let headwearPic: String?
let headwearEffect: String?
let headwearType: Int?
let headwearName: String?
let headwearId: Int?
// -
let experLevelPic: String?
let charmLevelPic: String?
//
let isCustomWord: Bool?
let labelList: [String]?
// IntBool
var isSquareTop: Bool { squareTop != 0 }
var isTopicTop: Bool { topicTop != 0 }
//
var formattedPublishTime: Date {
Date(timeIntervalSince1970: TimeInterval(publishTime) / 1000.0)
}
}
///
struct MomentsPicture: Codable, Equatable {
let id: Int
let resUrl: String
let format: String
let width: Int
let height: Int
let resDuration: Int? //
}
/// VIP -
struct UserVipInfo: Codable, Equatable {
let vipLevel: Int?
let vipName: String?
let vipIcon: String?
let vipLogo: String?
let nameplateId: Int?
let nameplateUrl: String?
let userCardBG: String?
let expireTime: Int?
let preventKick: Bool?
let preventTrace: Bool?
let preventFollow: Bool?
let micNickColour: String?
let micCircle: String?
let enterRoomEffects: String?
let medalSeat: Int?
let friendNickColour: String?
let visitHide: Bool?
let visitListView: Bool?
let privateChatLimit: Bool?
let roomPicScreen: Bool?
let uploadGifAvatar: Bool?
let enterHide: Bool?
}
// MARK: -
///
enum MomentsContentType: Int, CaseIterable {
case text = 0 //
case picture = 2 //
/// API
static func toAPIParameter(_ types: [MomentsContentType]) -> String {
return types.map { String($0.rawValue) }.joined(separator: ",")
}
}
// MARK: - API
/// API
struct LatestDynamicsRequest: APIRequestProtocol {
typealias Response = MomentsLatestResponse
let endpoint: String = APIEndpoint.latestDynamics.path
let method: HTTPMethod = .GET
let dynamicId: String
let pageSize: Int
let types: [MomentsContentType]
///
/// - Parameters:
/// - dynamicId: ID
/// - pageSize: 20
/// - types:
init(
dynamicId: String = "",
pageSize: Int = 20,
types: [MomentsContentType] = [.text, .picture]
) {
self.dynamicId = dynamicId
self.pageSize = pageSize
self.types = types
}
var queryParameters: [String: String]? {
return [
"dynamicId": dynamicId,
"pageSize": String(pageSize),
"types": MomentsContentType.toAPIParameter(types)
]
}
var bodyParameters: [String: Any]? { nil }
var includeBaseParameters: Bool { true }
// Loading
var shouldShowLoading: Bool { true }
var shouldShowError: Bool { true }
}