-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat-T3-121] 추천 루틴 API 연동 #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3b2f732
Style: 일부 파일들 import 컨벤션 맞추기
choijungp 2b6d57e
Feat: RecommendedRoutineRepository 구현 (#T3-121)
choijungp beef83b
Feat: RecommendedRoutineUseCase 구현 (#T3-121)
choijungp 1a8f7bd
Refactor: 추천 루틴 뷰 수정 (#T3-121)
choijungp 31034aa
Refactor: RoutineLevelType, RoutineCategoryType 모듈 위치 변경으로 인한 Present…
choijungp adb750e
Feat: RecommendedRoutineView 및 RecommendedRoutineViewModel 로직 구현 (#T3…
choijungp a261e70
Feat: FloatingButton, FloatingMenuView UI 구현
choijungp 76fbf18
Feat: 추천 루틴 화면에 FloatingButton 추가 및 등록 화면 이동 (#T3-121)
choijungp 49c8ca6
Style: 오타 수정
choijungp a579154
Refactor: 맞춤 추천 카테고리인 경우 감정 등록 버튼 보여주기
choijungp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
Projects/DataSource/Sources/DTO/RecommendedRoutineDictionaryResponseDTO.swift
This file contains hidden or 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,10 @@ | ||
| // | ||
| // RecommendedRoutineDictionaryResponseDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| struct RecommendedRoutineDictionaryResponseDTO: Decodable { | ||
| let recommendedRoutines: [String: [RecommendedRoutineDTO]] | ||
| } |
10 changes: 10 additions & 0 deletions
10
Projects/DataSource/Sources/DTO/RecommendedRoutineListResponseDTO.swift
This file contains hidden or 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,10 @@ | ||
| // | ||
| // RecommendedRoutineListResponseDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 최정인 on 7/15/25. | ||
| // | ||
|
|
||
| struct RecommendedRoutineListResponseDTO: Decodable { | ||
| let recommendedRoutines: [RecommendedRoutineDTO] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| // Created by 최정인 on 6/30/25. | ||
| // | ||
|
|
||
| import Foundation | ||
| import Domain | ||
|
|
||
| enum AuthEndpoint { | ||
|
|
||
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
Projects/DataSource/Sources/Endpoint/RecommendedRoutineEndpoint.swift
This file contains hidden or 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,46 @@ | ||
| // | ||
| // RecommendedRoutineEndpoint.swift | ||
| // DataSource | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| enum RecommendedRoutineEndpoint { | ||
| case fetchRecommendedRoutines | ||
| } | ||
|
|
||
| extension RecommendedRoutineEndpoint: Endpoint { | ||
| var baseURL: String { | ||
| return AppProperties.baseURL + "/api/v1/recommend-routines" | ||
| } | ||
|
|
||
| var path: String { | ||
| switch self { | ||
| case .fetchRecommendedRoutines: baseURL | ||
| } | ||
| } | ||
|
|
||
| var method: HTTPMethod { | ||
| return .get | ||
| } | ||
|
|
||
| var headers: [String : String] { | ||
| let headers: [String: String] = [ | ||
| "Content-Type": "application/json", | ||
| "accept": "*/*" | ||
| ] | ||
| return headers | ||
| } | ||
|
|
||
| var queryParameters: [String : String] { | ||
| return [:] | ||
| } | ||
|
|
||
| var bodyParameters: [String : Any] { | ||
| return [:] | ||
| } | ||
|
|
||
| var isAuthorized: Bool { | ||
| return true | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
Projects/DataSource/Sources/Repository/RecommendedRoutineRepository.swift
This file contains hidden or 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,26 @@ | ||
| // | ||
| // RecommendedRoutineRepository.swift | ||
| // DataSource | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| import Domain | ||
|
|
||
| final class RecommendedRoutineRepository: RecommendedRoutineRepositoryProtocol { | ||
| private let networkService = NetworkService.shared | ||
|
|
||
| func fetchRecommendedRoutines() async throws -> [RecommendedRoutineEntity] { | ||
| let endpoint = RecommendedRoutineEndpoint.fetchRecommendedRoutines | ||
| guard let response = try await networkService.request(endpoint: endpoint, type: RecommendedRoutineDictionaryResponseDTO.self) | ||
| else { return [] } | ||
|
|
||
| var entities: [RecommendedRoutineEntity] = [] | ||
| for (category, recommendedRoutines) in response.recommendedRoutines { | ||
| let recommendedRoutineEntity = recommendedRoutines.compactMap({ $0.toRecommendedRoutineEntity(category: category) }) | ||
| entities.append(contentsOf: recommendedRoutineEntity) | ||
| } | ||
|
|
||
| return entities | ||
| } | ||
| } |
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
Projects/Domain/Sources/Entity/Enum/RoutineCategoryType.swift
This file contains hidden or 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,16 @@ | ||
| // | ||
| // RoutineCategoryType.swift | ||
| // Domain | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| public enum RoutineCategoryType: String, CaseIterable { | ||
| case recommendation = "PERSONALIZED" | ||
| case outdoor = "OUTING" | ||
| case outdoorReport = "OUTING_REPORT" | ||
| case wakeup = "WAKE_UP" | ||
| case connection = "CONNECT" | ||
| case rest = "REST" | ||
| case growth = "GROW" | ||
| } |
12 changes: 12 additions & 0 deletions
12
Projects/Domain/Sources/Entity/Enum/RoutineLevelType.swift
This file contains hidden or 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,12 @@ | ||
| // | ||
| // RoutineLevelType.swift | ||
| // Domain | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| public enum RoutineLevelType: String, CaseIterable { | ||
| case easy = "LEVEL1" | ||
| case normal = "LEVEL2" | ||
| case hard = "LEVEL3" | ||
| } |
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
Projects/Domain/Sources/Protocol/Repository/RecommendedRoutineRepositoryProtocol.swift
This file contains hidden or 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,13 @@ | ||
| // | ||
| // RecommendedRoutineRepositoryProtocol.swift | ||
| // Domain | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| // 추천 루틴에 관련된 데이터를 가져오는 Repository | ||
| public protocol RecommendedRoutineRepositoryProtocol { | ||
| /// 추천 루틴 데이터를 가져옵니다. | ||
| /// - Returns: 추천 루틴 목록 | ||
| func fetchRecommendedRoutines() async throws -> [RecommendedRoutineEntity] | ||
| } |
12 changes: 12 additions & 0 deletions
12
Projects/Domain/Sources/Protocol/UseCase/RecommendedRoutineUseCaseProtocol.swift
This file contains hidden or 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,12 @@ | ||
| // | ||
| // RecommendedRoutineUseCaseProtocol.swift | ||
| // Domain | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| public protocol RecommendedRoutineUseCaseProtocol { | ||
| /// 추천 루틴 데이터를 가져옵니다. | ||
| /// - Returns: 추천 루틴 목록 | ||
| func fetchRecommendedRoutines() async throws -> [RecommendedRoutineEntity] | ||
| } |
19 changes: 19 additions & 0 deletions
19
Projects/Domain/Sources/UseCase/RecommendedRoutine/RecommendedRoutineUseCase.swift
This file contains hidden or 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,19 @@ | ||
| // | ||
| // RecommendedRoutineUseCase.swift | ||
| // Domain | ||
| // | ||
| // Created by 최정인 on 7/27/25. | ||
| // | ||
|
|
||
| public final class RecommendedRoutineUseCase: RecommendedRoutineUseCaseProtocol { | ||
| private let recommendedRoutineRepository: RecommendedRoutineRepositoryProtocol | ||
|
|
||
| public init(recommendedRoutineRepository: RecommendedRoutineRepositoryProtocol) { | ||
| self.recommendedRoutineRepository = recommendedRoutineRepository | ||
| } | ||
|
|
||
| public func fetchRecommendedRoutines() async throws -> [RecommendedRoutineEntity] { | ||
| let recommendedRoutines = try await recommendedRoutineRepository.fetchRecommendedRoutines() | ||
| return recommendedRoutines | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
Projects/Presentation/Resources/Images.xcassets/add_routine_icon.imageset/Contents.json
This file contains hidden or 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,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "add_routine_icon.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "add_routine_icon@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "add_routine_icon@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
Binary file added
BIN
+630 Bytes
...tation/Resources/Images.xcassets/add_routine_icon.imageset/add_routine_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.02 KB
...ion/Resources/Images.xcassets/add_routine_icon.imageset/add_routine_icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.41 KB
...ion/Resources/Images.xcassets/add_routine_icon.imageset/add_routine_icon@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
엔티티 변환 로직 개선을 검토해주세요.
변환 메서드가 향상되었지만 몇 가지 개선점이 있습니다:
RoutineCategoryType(rawValue:)초기화가 실패할 수 있으나 이에 대한 처리가 없습니다.compactMap을 사용하고 있지만SubRoutineDTO.toSubRoutineEntity()가 실패하지 않는 것 같습니다.다음과 같이 개선을 제안합니다:
func toRecommendedRoutineEntity(category: String? = nil) -> RecommendedRoutineEntity { var routineCategory: RoutineCategoryType? if let category { - routineCategory = RoutineCategoryType(rawValue: category) + routineCategory = RoutineCategoryType(rawValue: category) + // 로깅 추가: 유효하지 않은 카테고리인 경우 + if routineCategory == nil { + print("Warning: Invalid category value: \(category)") + } } var level: RoutineLevelType? if let routineLevel { - level = RoutineLevelType(rawValue: routineLevel) + level = RoutineLevelType(rawValue: routineLevel) + // 로깅 추가: 유효하지 않은 레벨인 경우 + if level == nil { + print("Warning: Invalid level value: \(routineLevel)") + } } return RecommendedRoutineEntity( id: id, title: routineName, description: routineDescription, category: routineCategory, level: level, - subRoutines: subRoutines.compactMap({ $0.toSubRoutineEntity() })) + subRoutines: subRoutines.map({ $0.toSubRoutineEntity() })) }📝 Committable suggestion
🤖 Prompt for AI Agents