Skip to content

Commit 4fb2e5d

Browse files
authored
Merge pull request #310 from Team-return/feature/(#295)-interest_choose
🔗 :: (#295) 관심분야 기능 개발
2 parents 4dfa4c8 + 9f273f8 commit 4fb2e5d

33 files changed

+902
-6
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import RxFlow
2+
3+
public enum InterestFieldCheckStep: Step {
4+
case interestFieldIsRequired
5+
case interestFieldCheckIsRequired
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import RxFlow
2+
3+
public enum InterestFieldStep: Step {
4+
case interestFieldIsRequired
5+
case interestFieldCheckIsRequired
6+
}

Projects/Core/Sources/Steps/MyPageStep.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public enum MyPageStep: Step {
99
case confirmIsRequired
1010
case bugReportIsRequired
1111
case bugReportListIsRequired
12+
case interestFieldIsRequired
1213
}

Projects/Data/Sources/DI/DataSourceAssembly.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@ public final class DataSourceAssembly: Assembly {
8181
container.register(RemoteSystemDataSource.self) { resolver in
8282
RemoteSystemDataSourceImpl(keychain: self.keychain(resolver))
8383
}
84+
85+
container.register(RemoteInterestsDataSource.self) { resolver in
86+
RemoteInterestsDataSourceImpl(keychain: self.keychain(resolver))
87+
}
8488
}
8589
}

Projects/Data/Sources/DI/RepositoryAssembly.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,11 @@ public final class RepositoryAssembly: Assembly {
105105
remoteSystemDataSource: resolver.resolve(RemoteSystemDataSource.self)!
106106
)
107107
}
108+
109+
container.register(InterestsRepository.self) { resolver in
110+
InterestsRepositoryImpl(
111+
remoteInterestsDataSource: resolver.resolve(RemoteInterestsDataSource.self)!
112+
)
113+
}
108114
}
109115
}

Projects/Data/Sources/DI/UseCaseAssembly.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public final class UseCaseAssembly: Assembly {
4040
)
4141
}
4242

43-
4443
// Students
4544
container.register(ChangePasswordUseCase.self) { reslover in
4645
ChangePasswordUseCase(
@@ -268,5 +267,12 @@ public final class UseCaseAssembly: Assembly {
268267
systemRepository: resolver.resolve(SystemRepository.self)!
269268
)
270269
}
270+
271+
// Interests
272+
container.register(ChangeInterestsUseCase.self) { resolver in
273+
ChangeInterestsUseCase(
274+
interestsRepository: resolver.resolve(InterestsRepository.self)!
275+
)
276+
}
271277
}
272278
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Foundation
2+
import Domain
3+
4+
struct InterestsResponseDTO: Decodable {
5+
let studentName: String
6+
let interests: [InterestResponseDTO]
7+
8+
enum CodingKeys: String, CodingKey {
9+
case studentName = "student_name"
10+
case interests
11+
}
12+
}
13+
14+
struct InterestResponseDTO: Decodable {
15+
let id: Int
16+
let studentID: Int
17+
let code: Int
18+
let keyword: String
19+
20+
enum CodingKeys: String, CodingKey {
21+
case id
22+
case studentID = "student_id"
23+
case code
24+
case keyword
25+
}
26+
}
27+
28+
extension InterestsResponseDTO {
29+
func toDomain() -> [InterestsEntity] {
30+
return interests.map {
31+
InterestsEntity(
32+
studentName: studentName,
33+
interestID: $0.id,
34+
studentID: $0.studentID,
35+
code: $0.code,
36+
keyword: $0.keyword
37+
)
38+
}
39+
}
40+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import Moya
2+
import Domain
3+
import AppNetwork
4+
5+
enum InterestsAPI {
6+
case updateInterests(interestsIDs: [Int])
7+
}
8+
9+
extension InterestsAPI: JobisAPI {
10+
typealias ErrorType = JobisError
11+
12+
var domain: JobisDomain {
13+
.interests
14+
}
15+
16+
var urlPath: String {
17+
switch self {
18+
case .updateInterests:
19+
return ""
20+
}
21+
}
22+
23+
var method: Method {
24+
switch self {
25+
case .updateInterests:
26+
return .patch
27+
}
28+
}
29+
30+
var task: Task {
31+
switch self {
32+
case .updateInterests(let interestsIDs):
33+
return .requestParameters(
34+
parameters: [
35+
"code_ids": interestsIDs
36+
],
37+
encoding: JSONEncoding.default
38+
)
39+
}
40+
}
41+
42+
var jwtTokenType: JwtTokenType {
43+
switch self {
44+
case .updateInterests:
45+
return .accessToken
46+
}
47+
}
48+
49+
var errorMap: [Int: ErrorType]? {
50+
return [:]
51+
}
52+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import RxSwift
2+
import RxCocoa
3+
import Foundation
4+
import Domain
5+
6+
public protocol RemoteInterestsDataSource {
7+
func updateInterests(interestsIDs: [Int]) -> Completable
8+
}
9+
10+
final class RemoteInterestsDataSourceImpl: RemoteBaseDataSource<InterestsAPI>, RemoteInterestsDataSource {
11+
func updateInterests(interestsIDs: [Int]) -> Completable {
12+
request(.updateInterests(interestsIDs: interestsIDs))
13+
.asCompletable()
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import RxSwift
2+
import Domain
3+
4+
struct InterestsRepositoryImpl: InterestsRepository {
5+
private let remoteInterestsDataSource: any RemoteInterestsDataSource
6+
7+
init(remoteInterestsDataSource: any RemoteInterestsDataSource) {
8+
self.remoteInterestsDataSource = remoteInterestsDataSource
9+
}
10+
11+
func updateInterests(interestsIDs: [Int]) -> Completable {
12+
remoteInterestsDataSource.updateInterests(interestsIDs: interestsIDs)
13+
}
14+
}

0 commit comments

Comments
 (0)