// // SPVideoAPI.swift // ShortPlay // // Created by 曾觉新 on 2025/4/10. // import UIKit class SPVideoAPI: NSObject { ///获取视频详情 static func requestVideoDetail(videoId: String?, shortPlayId: String, completer: ((_ model: SPVideoDetailModel?) -> Void)?) { var parameters: [String : Any] = [ "short_play_id" : shortPlayId ] if let videoId = videoId { parameters["video_id"] = videoId } var param = SPNetworkParameters(path: "/getVideoDetails") param.method = .get param.parameters = parameters SPNetwork.request(parameters: param) { (response: SPNetworkResponse) in completer?(response.data) } } ///创建播放记录 static func requestRequestVideoPlayHistory(videoId: String, shortPlayId: String) { var param = SPNetworkParameters(path: "/createHistory") param.isLoding = false param.isToast = false param.parameters = [ "video_id" : videoId, "short_play_id" : shortPlayId ] SPNetwork.request(parameters: param) { (response: SPNetworkResponse) in } } ///收藏短剧 static func requestCollectShort(isCollect: Bool, shortPlayId: String, success: (() -> Void)?) { let path: String if isCollect { path = "/collect" } else { path = "/cancelCollect" } var param = SPNetworkParameters(path: path) param.isLoding = true param.parameters = [ "short_play_id" : shortPlayId ] SPNetwork.request(parameters: param) { (response: SPNetworkResponse) in if response.code == SPNetworkCodeSucceed { success?() NotificationCenter.default.post(name: SPVideoAPI.updateShortCollectStateNotification, object: nil, userInfo: [ "state" : isCollect, "id" : shortPlayId, ]) } } } } extension SPVideoAPI { ///更新短剧关注状态 [ "state" : isCollect, "id" : shortPlayId,] @objc static let updateShortCollectStateNotification = NSNotification.Name(rawValue: "SPVideoAPI.updateShortCollectStateNotification") }