-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat] 루틴 등록 / 수정 로직 구현 #33
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
Changes from all commits
e0afad1
82e80f9
ba1fc95
dacdd50
f629165
7ace127
b63c33a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // Encodable+.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension Encodable { | ||
| var dictionary: [String: Any] { | ||
| guard | ||
| let data = try? JSONEncoder().encode(self), | ||
| let dictionary = try? JSONSerialization.jsonObject(with: data) as? [String: Any] | ||
| else { return [:] } | ||
| return dictionary | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // RoutienCreationDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| struct RoutineCreationDTO: Codable { | ||
| let routineName: String | ||
| let repeatDay: [String] | ||
| let executionTime: String | ||
| let subRoutineName: [String] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // | ||
| // RoutineUpdateDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| struct RoutineUpdateDTO: Codable { | ||
| let routineId: String | ||
| let routineName: String | ||
| let repeatDay: [String] | ||
| let executionTime: String | ||
| let subRoutineInfos: [SubRoutineUpdateDTO] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // | ||
| // SubRoutineUpdateDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| struct SubRoutineUpdateDTO: Codable { | ||
| let subRoutineId: String? | ||
| let subRoutineName: String? | ||
| let sortOrder: Int? | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // | ||
| // Week.swift | ||
| // Domain | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| public enum WeekType: String, CaseIterable { | ||
| case monday = "MONDAY" | ||
| case tuesday = "TUESDAY" | ||
| case wednesday = "WEDNESDAY" | ||
| case thursday = "THURSDAY" | ||
| case friday = "FRIDAY" | ||
| case saturday = "SATURDAY" | ||
| case sunday = "SUNDAY" | ||
| } | ||
|
Comment on lines
+8
to
+16
Contributor
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. 요 WeekType이 Public인 이유가 있을까용 ??? 또한 Presentation에 Week과 WeekType이 비슷한 역할을 한다고 생각하는데
Collaborator
Author
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으로 활용하는 것은 좋아 입니다!! (생각지도 못한 방법 bbb) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // | ||
| // RoutineSummaryEntity.swift | ||
| // Domain | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
| public struct RoutineSummaryEntity { | ||
| public let routineId: String? | ||
| public let routineName: String | ||
| public let repeatDay: [WeekType] | ||
| public let executionTime: String | ||
|
|
||
| public init( | ||
| routineId: String?, | ||
| routineName: String, | ||
| repeatDay: [String]?, | ||
| executionTime: String | ||
| ) { | ||
| let weekType: [WeekType] = repeatDay?.compactMap(WeekType.init(rawValue:)) ?? [] | ||
|
|
||
| self.routineId = routineId | ||
| self.routineName = routineName | ||
| self.repeatDay = weekType | ||
| self.executionTime = executionTime | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SubRoutineSummaryEntity.swift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Created by 이동현 on 8/3/25. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public struct SubRoutineSummaryEntity: Decodable, Hashable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public let subRoutineId: String? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public let subRoutineName: String? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public let sortOrder: Int? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public init( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subRoutineId: String?, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subRoutineName: String?, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sortOrder: Int? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.subRoutineId = subRoutineId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.subRoutineName = subRoutineName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.sortOrder = sortOrder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+22
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. 🛠️ Refactor suggestion 엔티티 설계에서 비즈니스 규칙을 고려한 개선이 필요합니다. 현재 모든 프로퍼티가 옵셔널로 정의되어 있어 PR 목표에서 언급된 API DTO와의 tight coupling 우려가 현실화되고 있습니다. 도메인 관점에서 다음 사항들을 검토해보세요:
도메인 중심의 설계로 개선을 제안합니다: public struct SubRoutineSummaryEntity: Decodable, Hashable {
public let subRoutineId: String?
- public let subRoutineName: String?
+ public let subRoutineName: String
- public let sortOrder: Int?
+ public let sortOrder: Int
public init(
subRoutineId: String?,
- subRoutineName: String?,
+ subRoutineName: String,
- sortOrder: Int?
+ sortOrder: Int = 0
) {
self.subRoutineId = subRoutineId
self.subRoutineName = subRoutineName
self.sortOrder = sortOrder
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Collaborator
Author
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. 관련해서 회의 진행하고 리팩터링 예정입니다! 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. @taipaise 좋은 접근 방식이네요! 팀과 함께 엔티티 설계에 대해 논의하고 체계적으로 리팩터링을 진행하시는 것이 현명한 판단입니다. 도메인 무결성과 API와의 결합도 문제를 함께 고려하시면서 진행하시길 바랍니다. 추후 리팩터링 결과가 궁금하네요! 🚀 🧠 Learnings used |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // | ||
| // Untitled.swift | ||
| // Domain | ||
| // | ||
| // Created by 이동현 on 8/3/25. | ||
| // | ||
|
|
||
|
Comment on lines
+1
to
+7
Contributor
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. 엠티 파일 발견 !!!!!!!!!!!!!!! 🚨🚨🚨🚨🚨🚨🚨🚨🚨
Collaborator
Author
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. 악 이게 뭘까요.,.,.,.,.,.,.,.,.,. 수정하겠습니다 |
||
Uh oh!
There was an error while loading. Please reload this page.
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.
routineId가 nil일 때 조용히 실패하는 문제
현재
routineId가 nil일 경우 아무런 오류 없이 메서드가 종료됩니다. 이는 호출자가 업데이트 실패를 인지하지 못하게 할 수 있습니다.다음과 같이 오류를 던지는 것을 고려해보세요:
또는 메서드 시그니처를 변경하여 옵셔널 결과를 반환하거나, 완료 상태를 나타내는 Bool을 반환하는 것도 고려해볼 수 있습니다.
🤖 Prompt for AI Agents
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.
추후 디버깅을 위해서라도 추가하는 것이 좋을 것 같습니다. 감사합니다~!
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.
@taipaise 동의해주셔서 감사합니다! 명시적인 에러 처리는 디버깅 시 문제를 빠르게 파악하는 데 정말 도움이 됩니다.
구현 시 다음과 같은 형태로 진행하시면 됩니다:
이렇게 하면 호출하는 쪽에서도 업데이트 실패를 명확히 인지할 수 있어 더 안정적인 코드가 될 것입니다.
✏️ Learnings added
🧠 Learnings used
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!