MOHttpManager+Relation.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // MOHttpManager+Relation.swift
  3. // MiMoLive
  4. //
  5. // Created by OneeChan on 2025/10/14.
  6. //
  7. import Foundation
  8. let kNetPath_CheckContactFollow = "/contact/follow/check"
  9. let kNetPath_FollowSubmit = "/contact/follow/submit"
  10. extension MOHttpManager {
  11. func checkFollowStatus(uids: [String], handler: @escaping (MORelationStatusVo?, String?) -> Void) {
  12. sendPostRequest(path: kNetPath_CheckContactFollow, params: ["list": uids], handler: handler)
  13. }
  14. func checkFollowStatus(uid: String, handler: @escaping (Bool, String?) -> Void) {
  15. checkFollowStatus(uids: [uid]) { list, error in
  16. handler(list?.list.contains(uid) ?? false, error)
  17. }
  18. }
  19. private func submitFollow(uids: [String], type: Int, roomId: String? = nil, handler: @escaping (String?) -> Void) {
  20. var dic: MOHttpManagerParam = ["type": type, // 类型(1=关注,2=取关)
  21. "target": uids]
  22. if let roomId {
  23. dic["roomId"] = roomId
  24. }
  25. sendPostRequest(path: kNetPath_FollowSubmit, params: dic, handler: handler)
  26. }
  27. func followUsers(uids: [String], _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
  28. submitFollow(uids: uids, type: 1, roomId: roomId, handler: handler)
  29. }
  30. func followUser(uid: String, _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
  31. followUsers(uids: [uid], roomId, handler: handler)
  32. }
  33. func unfollowUsers(uids: [String], _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
  34. submitFollow(uids: uids, type: 2, roomId: roomId, handler: handler)
  35. }
  36. func unfollowUser(uid: String, _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
  37. unfollowUsers(uids: [uid], roomId, handler: handler)
  38. }
  39. }