LNHttpManager+Profile.swift 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // LNHttpManager+Profile.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/11/12.
  6. //
  7. import Foundation
  8. private let kNetPath_Profile_MyInfo = "/user/my/info"
  9. private let kNetPath_Profile_EditMyInfo = "/user/my/info/edit"
  10. private let kNetPath_Profile_EditVoice = "/user/my/voiceBarApply"
  11. private let kNetPath_Profile_ResetVoice = "/user/clean/myVoiceBar"
  12. private let kNetPath_Profile_UsersInfo = "/user/get/infos"
  13. private let kNetPath_Profile_Random = "/user/info/random/profiles"
  14. private let kNetPath_Profile_Online = "/user/getUsersOnlineState"
  15. private let kNetPath_Profile_Bind_Captcha = "/user/bind/mobile/sendCode"
  16. private let kNetPath_Profile_Bind_Phone = "/user/bind/mobile"
  17. private let kNetPath_Report_Language = "/user/set/appLocaleLangSet"
  18. class LNProfileUpdateConfig {
  19. var avatar: String?
  20. var nickName: String?
  21. var gender: LNUserGender?
  22. var birthday: String?
  23. var interest: [String]?
  24. var bio: String?
  25. var photos: [String]?
  26. }
  27. extension LNHttpManager {
  28. func getMyProfileDetail(completion: @escaping (LNMyProfileResponseVO?, LNHttpError?) -> Void) {
  29. post(path: kNetPath_Profile_MyInfo, completion: completion)
  30. }
  31. func modifyMyProfile(config: LNProfileUpdateConfig,
  32. completion: @escaping (LNHttpError?) -> Void) {
  33. var params: [String: Any] = [:]
  34. if let avatar = config.avatar {
  35. params["avatar"] = avatar
  36. }
  37. if let nickname = config.nickName {
  38. params["nickname"] = nickname
  39. }
  40. if let gender = config.gender {
  41. params["gender"] = gender.rawValue
  42. }
  43. if let birthday = config.birthday {
  44. params["birthday"] = birthday
  45. }
  46. if let interest = config.interest {
  47. params["interestCateGores"] = interest
  48. }
  49. if let intro = config.bio {
  50. params["intro"] = intro
  51. }
  52. if let photos = config.photos {
  53. params["photos"] = photos
  54. }
  55. guard !params.isEmpty else {
  56. completion(nil)
  57. return
  58. }
  59. post(path: kNetPath_Profile_EditMyInfo, params: params, completion: completion)
  60. }
  61. func setMyVoiceBar(url: String, duration: Int, completion: @escaping (LNHttpError?) -> Void) {
  62. post(path: kNetPath_Profile_EditVoice, params: [
  63. "voiceBar": url,
  64. "voiceBarDuration": duration
  65. ], completion: completion)
  66. }
  67. func cleanVoiceBar(completion: @escaping (LNHttpError?) -> Void) {
  68. post(path: kNetPath_Profile_ResetVoice, completion: completion)
  69. }
  70. }
  71. extension LNHttpManager {
  72. func getUsersInfo(uids: [String], completion: @escaping(LNUsersProfileResponse?, LNHttpError?) -> Void) {
  73. post(path: kNetPath_Profile_UsersInfo, params: [
  74. "userNos": uids
  75. ], completion: completion)
  76. }
  77. func getRandomProfile(completion: @escaping (LNRandomProfileResponse?, LNHttpError?) -> Void) {
  78. post(path: kNetPath_Profile_Random, completion: completion)
  79. }
  80. func getUserOnlineState(uids: [String], completion: @escaping (LNUserOnlineStateResponse?, LNHttpError?) -> Void) {
  81. post(path: kNetPath_Profile_Online, params: [
  82. "userNos": uids
  83. ], completion: completion)
  84. }
  85. }
  86. extension LNHttpManager {
  87. func getBindPhoneCaptcha(code: String, phone: String, completion: @escaping (LNHttpError?) -> Void) {
  88. post(path: kNetPath_Profile_Bind_Captcha, params: [
  89. "code": code,
  90. "num": phone
  91. ], completion: completion)
  92. }
  93. func bindPhone(code: String, phone: String, captcha: String, completion: @escaping (LNHttpError?) -> Void) {
  94. post(path: kNetPath_Profile_Bind_Phone, params: [
  95. "code": captcha,
  96. "mobile": [
  97. "code": code,
  98. "num": phone
  99. ]
  100. ], completion: completion)
  101. }
  102. }
  103. extension LNHttpManager {
  104. func reportCurrentLanguage(code: String, completion: @escaping (LNHttpError?) -> Void) {
  105. post(path: kNetPath_Report_Language, params: [
  106. "langCode": code
  107. ], completion: completion)
  108. }
  109. }