-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
963 additions
and
225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/MyPageScene/MyPage.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ChaRo-iOS/ChaRo-iOS/Source/Models/MypageInfinityDataModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This file was generated from JSON Schema using quicktype, do not modify it directly. | ||
// To parse the JSON, add this file to your project and do: | ||
// | ||
// let login = try? newJSONDecoder().decode(Login.self, from: jsonData) | ||
|
||
import Foundation | ||
|
||
// MARK: - MypageLikeWrite | ||
struct MypageInpinityModel: Codable { | ||
let success: Bool | ||
let msg: String | ||
let data: MyPagePost | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
ChaRo-iOS/ChaRo-iOS/Source/Services/MypageInfinityService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//MARK: made by Jack | ||
|
||
import Alamofire | ||
import Foundation | ||
|
||
struct MypageInfinityService | ||
{ | ||
var userId = UserDefaults.standard.string(forKey: "userId") ?? "[email protected]" | ||
|
||
static let MyPageInfinityData = MypageInfinityService() | ||
func getRecommendInfo(addURL: String, likeOrNew: String, completion : @escaping (NetworkResult<Any>) -> Void) | ||
{ | ||
// completion ํด๋ก์ ๋ฅผ @escaping closure๋ก ์ ์ํฉ๋๋ค. | ||
var URL = Constants.myPageURL + likeOrNew + userId + addURL; | ||
let header : HTTPHeaders = ["Content-Type": "application/json"] | ||
let dataRequest = AF.request(URL, | ||
method: .get, | ||
encoding: JSONEncoding.default, | ||
headers: header) | ||
|
||
dataRequest.responseData { dataResponse in | ||
// dump(dataResponse) | ||
switch dataResponse.result { | ||
|
||
case .success: | ||
guard let statusCode = dataResponse.response?.statusCode else {return} | ||
guard let value = dataResponse.value else {return} | ||
let networkResult = self.judgeStatus(by: statusCode, value) | ||
completion(networkResult) | ||
|
||
|
||
case .failure: completion(.pathErr) | ||
print("์คํจ ์ฌ์ ") | ||
|
||
|
||
} | ||
} | ||
|
||
} | ||
private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> { | ||
switch statusCode { | ||
case 200: return isValidData(data: data) | ||
case 400: return .pathErr | ||
case 500: return .serverErr | ||
default: return .networkFail | ||
} | ||
} | ||
|
||
private func isValidData(data : Data) -> NetworkResult<Any> { | ||
|
||
let decoder = JSONDecoder() | ||
guard let decodedData = try? decoder.decode(MypageInpinityModel.self, from: data) | ||
else {return .pathErr} | ||
// ์ฐ์ PersonDataModel ํํ๋ก decode(ํด๋ )์ ํ๋ฒ ๊ฑฐ์นฉ๋๋ค. ์คํจํ๋ฉด pathErr | ||
// ํด๋ ์ ์ฑ๊ณตํ๋ฉด Person data๋ฅผ success์ ๋ฃ์ด์ค๋๋ค. | ||
|
||
|
||
return .success(decodedData) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.