-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[team-07] Login - Home 화면 IssueCard 출력 흐름 구현 #267
base: team-07
Are you sure you want to change the base?
Changes from all commits
c88a3fd
504fdbc
6e71308
b329c09
17002f7
0bc7e9a
077e4e9
e2abbb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,48 @@ | |
|
||
import Foundation | ||
|
||
struct IssueCardDTO: Identifiable { | ||
let id: Int | ||
let title: String | ||
let content: String | ||
let isSelected: Bool | ||
let mileStone: String? | ||
let labels: [Label] | ||
// MARK: - Empty | ||
struct IssueCardArrayDTO: Codable { | ||
let issues: [IssueCardDTO] | ||
} | ||
|
||
struct Label: Identifiable { | ||
let id: Int | ||
let labelName: String | ||
let labelColor: String | ||
// MARK: - Issue | ||
struct IssueCardDTO: Codable { | ||
let issueID: Int | ||
let title, content: String | ||
let milestoneID: Int | ||
let milestoneName: String | ||
let labels: [LabelDTO] | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case issueID = "issueId" | ||
case title, content | ||
case milestoneID = "milestoneId" | ||
case milestoneName, labels | ||
} | ||
} | ||
|
||
// MARK: - Label | ||
struct LabelDTO: Codable { | ||
let labelID: Int? | ||
let labelName, labelColor: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case labelID = "labelId" | ||
case labelName, labelColor | ||
} | ||
} | ||
|
||
extension IssueCardDTO { | ||
|
||
func toDomain() -> IssueCardEntity { | ||
return .init(id: issueID, title: title, content: content, isSelected: false, mileStone: milestoneName, labels: labels.map { $0.toDomain() }) | ||
} | ||
} | ||
|
||
extension LabelDTO { | ||
|
||
func toDomain() -> LabelEntity { | ||
return .init(id: labelID, labelName: labelName, labelColor: labelColor) | ||
} | ||
} | ||
Comment on lines
+42
to
54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사소한 부분이긴 하지만 extension 작성 시엔 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ | |
import Foundation | ||
|
||
protocol EndPointable { | ||
var queryItems: [URLQueryItem]? {get} | ||
var url: URL {get} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// FetchIssueListURLConfiguration.swift | ||
// IssueTracker | ||
// | ||
// Created by Kai Kim on 2022/06/30. | ||
// | ||
|
||
import Foundation | ||
|
||
struct FetchOpenIssueListURLConfiguration: URLConfigurable { | ||
var scheme: String = "https" | ||
var host: String = "0e1f525b-4045-4a86-b2d7-b782850ccb9f.mock.pstmn.io" | ||
var path: String = "/issue-tracker/api/issues" | ||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이런 값들은 사실 상 변경될 일이 없지 않나요? |
||
var queryItem: [URLQueryItem]? = [URLQueryItem(name: "isOpened", value: "true")] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// FetchIssueCardRepository.swift | ||
// IssueTracker | ||
// | ||
// Created by Kai Kim on 2022/06/30. | ||
// | ||
|
||
import Foundation | ||
|
||
final class ViewFilteredIssueCardRepository: ViewIssueCardRepository { | ||
|
||
var endPoint: EndPoint | ||
|
||
init(endPoint: EndPoint = EndPoint(urlConfigure: FetchOpenIssueListURLConfiguration(), method: .GET, body: nil)) { | ||
self.endPoint = endPoint | ||
} | ||
|
||
func fetchIssueCard(completion: @escaping (IssueCardArrayDTO?) -> Void) { | ||
NetworkService.request(endPoint: endPoint) { result in | ||
switch result { | ||
case .success(let data): | ||
let decoder = Decoder<IssueCardArrayDTO>() | ||
let issuecards = decoder.decode(data: data) | ||
completion(issuecards) | ||
case .failure(let error): | ||
print(error) | ||
} | ||
} | ||
} | ||
Comment on lines
+18
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이번 프로젝트의 Repository에서는 사실 상 데이터를 decode해주는 역할만 하고 있긴 하네요 :) |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// DefaultIssueCardRepository.swift | ||
// IssueTracker | ||
// | ||
// Created by Kai Kim on 2022/06/30. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol ViewIssueCardRepository { | ||
var endPoint: EndPoint {get} | ||
func fetchIssueCard(completion: @escaping (IssueCardArrayDTO?) -> Void) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// IssueCardEntity.swift | ||
// IssueTracker | ||
// | ||
// Created by Kai Kim on 2022/06/30. | ||
// | ||
|
||
import Foundation | ||
|
||
struct IssueCardEntity: Identifiable { | ||
let id: Int | ||
let title: String | ||
let content: String | ||
let isSelected: Bool | ||
let mileStone: String? | ||
let labels: [LabelEntity] | ||
} | ||
|
||
struct LabelEntity: Identifiable { | ||
let id: Int? | ||
let labelName: String | ||
let labelColor: String | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// requestUserInfoUsecase.swift | ||
// IssueTracker | ||
// | ||
// Created by Kai Kim on 2022/06/28. | ||
// | ||
|
||
import Foundation | ||
|
||
final class DefaultRequestTokenInfoUsecase: RequestTokenInfoUsecase { | ||
|
||
var tokenInfoRepository: RequestTokenInfoRepository? | ||
|
||
init(userInfoRepository: RequestTokenInfoRepository? = DefaultRequestTokenInfoRepository(endPoint: EndPoint(urlConfigure: TokenURLConfiguration(), method: .POST, body: nil))) { | ||
self.tokenInfoRepository = userInfoRepository | ||
} | ||
|
||
func execute(completion: @escaping (TokenInfo?) -> Void) { | ||
tokenInfoRepository?.fetchTokenInfo(completion: { userInfo in | ||
guard let userInfo = userInfo else { | ||
completion(nil) | ||
return | ||
} | ||
completion(userInfo) | ||
}) | ||
Comment on lines
+19
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 옵셔널을 전달할 수 있으니 guard문은 불필요해보이네요ㅎㅎ |
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 네이밍에서는 Array와 같은 자료구조 이름을 직접 사용하기 보다는
복수형태로 사용해주는 게 더 자연스럽다는 생각입니다 :) (IssueCardsDTO)