LNHttpManager+Feed.swift 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // LNHttpManager+Feed.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/2/28.
  6. //
  7. import Foundation
  8. private let kNetPath_Feed_Like = "/trend/trend/like"
  9. private let kNetPath_Feed_List = "/trend/list"
  10. private let kNetPath_Feed_Detail = "/trend/detail"
  11. private let kNetPath_Feed_Create = "/trend/create"
  12. private let kNetPath_Feed_Comment = "/trend/comment"
  13. private let kNetPath_Feed_Comment_List = "/trend/comment/list"
  14. private let kNetPath_Feed_Comment_Like = "/trend/comment/like"
  15. private let kNetPath_Feed_Del = "/trend/trend/del"
  16. struct LNPostFeedItem {
  17. var text: String
  18. var medias: [LNFeedMediaVO]
  19. }
  20. extension LNHttpManager {
  21. func likeFeed(id: String, completion: @escaping (LNFeedLikeResponse?, LNHttpError?) -> Void) {
  22. post(path: kNetPath_Feed_Like, params: [
  23. "id": id
  24. ], completion: completion)
  25. }
  26. func getFeedList(uid: String, size: Int, next: String, completion: @escaping (LNFeedListResponse?, LNHttpError?) -> Void) {
  27. post(path: kNetPath_Feed_List, params: [
  28. "userNo": uid,
  29. "page": [
  30. "size": size,
  31. "next": next
  32. ]
  33. ], completion: completion)
  34. }
  35. func getFeedDetail(id: String, completion: @escaping (LNFeedDetailVO?, LNHttpError?) -> Void) {
  36. post(path: kNetPath_Feed_Detail, params: [
  37. "id": id
  38. ], completion: completion)
  39. }
  40. func postFeed(item: LNPostFeedItem, completion: @escaping (LNHttpError?) -> Void) {
  41. var param: [String: Any] = [
  42. "content": item.text,
  43. ]
  44. var medias: [[String: Any]] = []
  45. for media in item.medias {
  46. medias.append(
  47. [
  48. "url": media.url,
  49. "type": media.type.rawValue,
  50. "videoCover": media.videoCover
  51. ]
  52. )
  53. }
  54. // if !medias.isEmpty {
  55. param["medias"] = medias
  56. // }
  57. post(path: kNetPath_Feed_Create, params: param, completion: completion)
  58. }
  59. func sendFeedComment(id: String, content: String, completion: @escaping (LNHttpError?) -> Void) {
  60. post(path: kNetPath_Feed_Comment, params: [
  61. "trendId": id,
  62. "content": content
  63. ], completion: completion)
  64. }
  65. func getFeedCommentList(id: String, size: Int, next: String, completion: @escaping (LNFeedCommentListResponse?, LNHttpError?) -> Void) {
  66. post(path: kNetPath_Feed_Comment_List, params: [
  67. "trendId": id,
  68. "page": [
  69. "size": size,
  70. "next": next
  71. ]
  72. ], completion: completion)
  73. }
  74. func listFeedComment(id: String, completion: @escaping (LNHttpError?) -> Void) {
  75. post(path: kNetPath_Feed_Comment_Like, params: [
  76. "id": id
  77. ], completion: completion)
  78. }
  79. func deleteFeed(id: String, completion: @escaping (LNHttpError?) -> Void) {
  80. post(path: kNetPath_Feed_Del, params: [
  81. "id": id
  82. ], completion: completion)
  83. }
  84. }