|
|
|
@ -41,10 +41,13 @@ enum APIConfig {
|
|
|
|
|
case followerList(String, Int, Int)
|
|
|
|
|
case blackList(Int, Int)
|
|
|
|
|
case checkVersion([String: Any])
|
|
|
|
|
case commentList(String, Int, Int)
|
|
|
|
|
case hotCommentList(String, Int, Int)
|
|
|
|
|
case latestCommentList(String, Int, Int)
|
|
|
|
|
|
|
|
|
|
case subCommentList(String, Int, Int)
|
|
|
|
|
|
|
|
|
|
case commentLike(String, [String: Any])
|
|
|
|
|
case sendComment([String: Any])
|
|
|
|
|
|
|
|
|
|
case filterMenu
|
|
|
|
|
case journalRecommend(String)
|
|
|
|
@ -111,13 +114,16 @@ extension APIConfig: TargetType {
|
|
|
|
|
case .checkVersion:
|
|
|
|
|
return "luoo-user/update/checkVersion"
|
|
|
|
|
|
|
|
|
|
case .commentList(let journalId, let page, let size):
|
|
|
|
|
return "luoo-comment/comment/\(journalId)/\(page)/\(size)"
|
|
|
|
|
case .hotCommentList(let journalId, let page, let size):
|
|
|
|
|
return "luoo-comment/comment/hot/\(journalId)/\(page)/\(size)"
|
|
|
|
|
case .latestCommentList(let journalId, let page, let size):
|
|
|
|
|
return "luoo-comment/comment/new/\(journalId)/\(page)/\(size)"
|
|
|
|
|
case .subCommentList(let parentId, let page, let size):
|
|
|
|
|
return "luoo-comment/comment/comment/\(parentId)/\(page)/\(size)"
|
|
|
|
|
case .commentLike(let commentID, _):
|
|
|
|
|
return "luoo-comment/comment/thumbup/\(commentID)"
|
|
|
|
|
|
|
|
|
|
case .sendComment:
|
|
|
|
|
return "luoo-comment/comment"
|
|
|
|
|
case .filterMenu:
|
|
|
|
|
return "luoo-music/journal/filter"
|
|
|
|
|
case .journalRecommend(let journalID):
|
|
|
|
@ -135,9 +141,9 @@ extension APIConfig: TargetType {
|
|
|
|
|
|
|
|
|
|
var method: Moya.Method {
|
|
|
|
|
switch self {
|
|
|
|
|
case .wechatAccessToken, .journalList, .journalMusic, .countryCode, .imageCheckCode, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .commentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
case .wechatAccessToken, .journalList, .journalMusic, .countryCode, .imageCheckCode, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .hotCommentList, .latestCommentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
return .get
|
|
|
|
|
case .sendsms, .login, .autoLogin, .editAvatar, .like, .checkVersion, .logout:
|
|
|
|
|
case .sendsms, .login, .autoLogin, .editAvatar, .like, .checkVersion, .logout, .sendComment:
|
|
|
|
|
return .post
|
|
|
|
|
case .editUserInfo, .commentLike:
|
|
|
|
|
return .put
|
|
|
|
@ -149,10 +155,10 @@ extension APIConfig: TargetType {
|
|
|
|
|
|
|
|
|
|
var parameterEncoding: ParameterEncoding {
|
|
|
|
|
switch self {
|
|
|
|
|
case .wechatAccessToken, .journalList, .journalMusic, .countryCode, .sendsms, .imageCheckCode, .login, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .like, .cancelLike, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .commentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
case .wechatAccessToken, .journalList, .journalMusic, .countryCode, .sendsms, .imageCheckCode, .login, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .like, .cancelLike, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .hotCommentList, .latestCommentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
return URLEncoding.default
|
|
|
|
|
|
|
|
|
|
case .autoLogin, .editUserInfo, .editAvatar, .checkVersion, .logout, .commentLike:
|
|
|
|
|
case .autoLogin, .editUserInfo, .editAvatar, .checkVersion, .logout, .commentLike, .sendComment:
|
|
|
|
|
return JSONEncoding.default
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -161,10 +167,10 @@ extension APIConfig: TargetType {
|
|
|
|
|
var task: Task {
|
|
|
|
|
var parameters: [String: Any] = [:]
|
|
|
|
|
switch self {
|
|
|
|
|
case .wechatAccessToken, .countryCode, .journalMusic, .imageCheckCode, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .commentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
case .wechatAccessToken, .countryCode, .journalMusic, .imageCheckCode, .getUserInfo, .carousel, .otherUserInfo, .single, .journal, .messageList, .collectSongList, .journalCollectList, .followingList, .followerList, .blackList, .hotCommentList, .latestCommentList, .subCommentList, .filterMenu, .journalRecommend, .searchCategory, .serach, .randomAudioTrack:
|
|
|
|
|
return .requestPlain
|
|
|
|
|
|
|
|
|
|
case .login(let dic), .journalList(let dic), .sendsms(let dic), .autoLogin(let dic), .editUserInfo(let dic), .like(let dic), .cancelLike(let dic), .logout(let dic), .checkVersion(let dic), .commentLike(_, let dic):
|
|
|
|
|
case .login(let dic), .journalList(let dic), .sendsms(let dic), .autoLogin(let dic), .editUserInfo(let dic), .like(let dic), .cancelLike(let dic), .logout(let dic), .checkVersion(let dic), .commentLike(_, let dic), .sendComment(let dic):
|
|
|
|
|
|
|
|
|
|
parameters = dic
|
|
|
|
|
return .requestParameters(parameters: parameters, encoding: parameterEncoding)
|
|
|
|
@ -190,7 +196,7 @@ extension APIConfig: TargetType {
|
|
|
|
|
|
|
|
|
|
var headers : [String : String]? {
|
|
|
|
|
switch self {
|
|
|
|
|
case .autoLogin, .getUserInfo, .journalList, .journalMusic, .otherUserInfo, .like, .cancelLike, .single, .journal, .collectSongList, .journalCollectList, .followingList, .messageList, .followerList, .blackList, .editUserInfo, .logout, .editAvatar, .commentList, .subCommentList, .commentLike, .filterMenu, .journalRecommend, .serach, .randomAudioTrack:
|
|
|
|
|
case .autoLogin, .getUserInfo, .journalList, .journalMusic, .otherUserInfo, .like, .cancelLike, .single, .journal, .collectSongList, .journalCollectList, .followingList, .messageList, .followerList, .blackList, .editUserInfo, .logout, .editAvatar, .hotCommentList, .latestCommentList, .subCommentList, .commentLike, .filterMenu, .journalRecommend, .serach, .randomAudioTrack, .sendComment:
|
|
|
|
|
return ["Authorization": AuthManager.shared.token?.basicToken ?? ""]
|
|
|
|
|
default:
|
|
|
|
|
return nil
|
|
|
|
|