-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#125 Flowstate, 시술 일정 추가 API 연결 #128
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
481a5e3
5e8482a
aa5fc71
0019d9e
d7379f6
4d89fac
d6f7755
d8546f4
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,19 @@ | ||
| // | ||
| // UserProcedureItemRequestDTO.swift | ||
| // Cherrish-iOS | ||
| // | ||
| // Created by 어재선 on 1/21/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct UserProcedureItemRequestDTO: Encodable { | ||
| let procedureId: Int | ||
| let downtimeDays: Int | ||
| } | ||
|
|
||
| struct CreateUserProcedureRequestDTO: Encodable { | ||
| let scheduledAt: String | ||
| let recoveryTargetDate: String | ||
| let procedures: [UserProcedureItemRequestDTO] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // | ||
| // CreateUserProcedureResponseDTO.swift | ||
| // Cherrish-iOS | ||
| // | ||
| // Created by 어재선 on 1/21/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
|
|
||
| struct CreateUserProcedureResponseDTO: Decodable { | ||
| let userProcedureId: Int | ||
| let procedureId: Int | ||
| let procedureName: String | ||
| let scheduledAt: String | ||
| let downtimeDays: Int | ||
| let recoveryTargetDate: String | ||
| } | ||
|
|
||
| struct CreateUserProceduresResponseDTO: Decodable { | ||
| let procedures: [CreateUserProcedureResponseDTO] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,14 +11,16 @@ import Alamofire | |
| enum TreatmentAPI: EndPoint { | ||
| case fetchCategories(userId: Int) | ||
| case fetchProcedures(userId: Int, id: Int? = nil, text: String? = nil) | ||
| case createUserProcedure(userId: Int, request: CreateUserProcedureRequestDTO) | ||
|
|
||
| var basePath: String { | ||
| switch self { | ||
| case .fetchCategories: | ||
| return "/api" | ||
|
|
||
| case .fetchProcedures: | ||
| return "/api" | ||
| case .createUserProcedure: | ||
| return "/api" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -28,6 +30,8 @@ enum TreatmentAPI: EndPoint { | |
| return "/worries" | ||
| case .fetchProcedures: | ||
| return "/procedures" | ||
| case .createUserProcedure: | ||
| return "/user-procedures" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -37,6 +41,8 @@ enum TreatmentAPI: EndPoint { | |
| return .get | ||
| case .fetchProcedures: | ||
| return .get | ||
| case .createUserProcedure: | ||
| return .post | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -46,6 +52,9 @@ enum TreatmentAPI: EndPoint { | |
| return .withAuth(userID: userId) | ||
| case .fetchProcedures(let userId, _, _): | ||
| return .withAuth(userID: userId) | ||
| case .createUserProcedure(let userId, _): | ||
| return .withAuth(userID: userId) | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -56,6 +65,8 @@ enum TreatmentAPI: EndPoint { | |
| return URLEncoding.default | ||
| case .fetchProcedures: | ||
| return URLEncoding.default | ||
| case .createUserProcedure: | ||
| return JSONEncoding.default | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -65,22 +76,36 @@ enum TreatmentAPI: EndPoint { | |
| return nil | ||
| case .fetchProcedures(_, let id, let text): | ||
| var params: [String: Any] = [:] | ||
| if let id = id { | ||
| params["worryId"] = id | ||
| } | ||
| if let text = text { | ||
| params["keyword"] = "\(text)" | ||
| } | ||
| return params | ||
| if let id = id { | ||
| params["worryId"] = id | ||
| } | ||
| if let text = text { | ||
| params["keyword"] = "\(text)" | ||
| } | ||
| return params | ||
| case .createUserProcedure: | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
|
|
||
| var bodyParameters: Alamofire.Parameters? { | ||
| switch self { | ||
| case .fetchCategories: | ||
| return .none | ||
| case .fetchProcedures: | ||
| return .none | ||
| case .createUserProcedure(_, let request): | ||
| return [ | ||
| "scheduledAt": request.scheduledAt, | ||
| "recoveryTargetDate": request.recoveryTargetDate, | ||
| "procedures": request.procedures.map { | ||
| [ | ||
| "procedureId": $0.procedureId, | ||
| "downtimeDays": $0.downtimeDays | ||
| ] | ||
| } | ||
| ] | ||
|
Comment on lines
+98
to
+108
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. 🧹 Nitpick | 🔵 Trivial DTO의 Encodable 준수를 활용하는 것을 고려하세요
♻️ 대안 제안Alamofire와 함께 사용할 수 있도록 DTO를 // 옵션 1: DTO에 extension 추가
extension CreateUserProcedureRequestDTO {
var asParameters: Parameters {
guard let data = try? JSONEncoder().encode(self),
let dict = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
return [:]
}
return dict
}
}
// 옵션 2: bodyParameters에서 사용
case .createUserProcedure(_, let request):
return request.asParameters🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ | |||||||||||||
| import Foundation | ||||||||||||||
|
|
||||||||||||||
| struct DefaultTreatmentRepository: TreatmentInterface { | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| private let networkService: NetworkService | ||||||||||||||
| private let userDefaultService: UserDefaultService | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -29,12 +31,40 @@ struct DefaultTreatmentRepository: TreatmentInterface { | |||||||||||||
|
|
||||||||||||||
| func fetchTreatment(id: Int?, keyword: String?) async throws -> [TreatmentEntity] { | ||||||||||||||
| let userId: Int = userDefaultService.load(key: .userID) ?? 1 | ||||||||||||||
| let response = try await networkService.request(TreatmentAPI.fetchProcedures(userId: userId,id: id, text: keyword), decodingType: ProceduresResponseDTO.self) | ||||||||||||||
| let response = try await networkService.request( | ||||||||||||||
| TreatmentAPI.fetchProcedures( | ||||||||||||||
| userId: userId, | ||||||||||||||
| id: id, | ||||||||||||||
| text: keyword | ||||||||||||||
| ), | ||||||||||||||
| decodingType: ProceduresResponseDTO.self | ||||||||||||||
| ) | ||||||||||||||
| return response.procedures.map { $0.toEntity() } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws { | ||||||||||||||
| let userId: Int = userDefaultService.load(key: .userID) ?? 1 | ||||||||||||||
| let request = CreateUserProcedureRequestDTO( | ||||||||||||||
| scheduledAt: scheduledDate, | ||||||||||||||
| recoveryTargetDate: recoveryDate, | ||||||||||||||
| procedures: treatments.compactMap { $0.toRequestDTO() } | ||||||||||||||
| ) | ||||||||||||||
| let _ = try await networkService.request( | ||||||||||||||
| TreatmentAPI.createUserProcedure( | ||||||||||||||
| userId: userId, | ||||||||||||||
| request: request | ||||||||||||||
| ), | ||||||||||||||
| decodingType: CreateProfileResponseDTO.self | ||||||||||||||
| ) | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
45
to
59
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. 🧩 Analysis chain🏁 Script executed: # First, find and read the TreatmentRepository.swift file to understand the full context
find . -name "TreatmentRepository.swift" -type fRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 139 🏁 Script executed: # Search for TreatmentInterface protocol definition
rg -n "protocol TreatmentInterface" --type swift -A 20Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 729 🏁 Script executed: # Search for UserProcedureItemRequestDTO definition
rg -n "struct UserProcedureItemRequestDTO\|class UserProcedureItemRequestDTO" --type swift -A 5Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 52 🏁 Script executed: # Search for response DTOs related to user procedures
rg -n "UserProcedure.*ResponseDTO\|UserProcedure.*Response\|.*ProcedureResponse" --type swift -A 5Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 52 🏁 Script executed: # Search for TreatmentEntity and its toRequestDTO method
rg -n "func toRequestDTO" --type swift -B 2 -A 10Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 1048 🏁 Script executed: # Search for MockTreatmentRepository
rg -n "class MockTreatmentRepository\|struct MockTreatmentRepository" --type swift -A 30Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 52 🏁 Script executed: # Find UserProcedureItemRequestDTO definition with broader search
rg -n "UserProcedureItemRequestDTO" --type swift -B 2 -A 5Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 3706 🏁 Script executed: # Read the full TreatmentRepository.swift file
cat -n ./Cherrish-iOS/Cherrish-iOS/Data/Repository/TreatmentRepository.swiftRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 3175 🏁 Script executed: # Search for MockTreatmentRepository without exact class/struct syntax
rg -n "MockTreatmentRepository" --type swift -B 2 -A 20Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 2471 🏁 Script executed: # Search for any DTO that contains "Procedure" in name
rg -n "struct.*Procedure.*DTO\|class.*Procedure.*DTO" --type swift -A 3Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 52
또한 Line 45의 응답 타입으로 추가로 MockTreatmentRepository의 🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| struct MockTreatmentRepository: TreatmentInterface { | ||||||||||||||
|
|
||||||||||||||
| func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) { | ||||||||||||||
|
|
||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+64
to
+66
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.
🐛 수정 제안- func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) {
-
+ func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws {
+ // Mock implementation - no-op
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| func fetchTreatment(id: Int?, keyword: String?) async throws -> [TreatmentEntity] { | ||||||||||||||
| return [] | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,10 +25,6 @@ final class DomainDependencyAssembler: DependencyAssembler { | |||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| guard let treatmentCategoryRepository = DIContainer.shared.resolve(type: TreatmentInterface.self) else { | ||||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| DIContainer.shared.register(type: FetchProcedureCountOfMonth.self) { | ||||||||||||||
| return DefaultFetchProcedureCountOfMonth(repository: calendarRepository) | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -76,5 +72,9 @@ final class DomainDependencyAssembler: DependencyAssembler { | |||||||||||||
| DIContainer.shared.register(type: FetchUserInfoUseCase.self) { | ||||||||||||||
| return DefaultFetchUserInfoUserCase(repository: myPageRepository) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| DIContainer.shared .register(type: CreateUserProcedureUseCase.self) { | ||||||||||||||
| return DefaultCreateUserProcedureUseCase(repository: treatmentRepository) | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+76
to
+78
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. 🧹 Nitpick | 🔵 Trivial 포맷팅 수정 필요
🧹 포맷팅 수정- DIContainer.shared .register(type: CreateUserProcedureUseCase.self) {
+ DIContainer.shared.register(type: CreateUserProcedureUseCase.self) {
return DefaultCreateUserProcedureUseCase(repository: treatmentRepository)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||
| // | ||||||||||||||
| // CreateUserProcedureUseCase.swift | ||||||||||||||
| // Cherrish-iOS | ||||||||||||||
| // | ||||||||||||||
| // Created by 어재선 on 1/21/26. | ||||||||||||||
| // | ||||||||||||||
|
|
||||||||||||||
| import Foundation | ||||||||||||||
|
|
||||||||||||||
| protocol CreateUserProcedureUseCase { | ||||||||||||||
| func execute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
10
to
12
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. 오타: 메서드 이름에 오타가 있습니다. 관련 코드 스니펫에서 확인된 ✏️ 수정 제안 protocol CreateUserProcedureUseCase {
- func excute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
+ func execute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
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. 오타 고쳐주세욤 |
||||||||||||||
|
|
||||||||||||||
| struct DefaultCreateUserProcedureUseCase: CreateUserProcedureUseCase { | ||||||||||||||
|
|
||||||||||||||
| private let repository: TreatmentInterface | ||||||||||||||
|
|
||||||||||||||
| init(repository: TreatmentInterface) { | ||||||||||||||
| self.repository = repository | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func execute( | ||||||||||||||
| scheduledDate: String, | ||||||||||||||
| recoveryDate: String, | ||||||||||||||
| treatments: [TreatmentEntity] | ||||||||||||||
| ) async throws { | ||||||||||||||
| return try await repository | ||||||||||||||
| .createUserProcedure( | ||||||||||||||
| scheduledDate: scheduledDate, | ||||||||||||||
| recoveryDate: recoveryDate, | ||||||||||||||
| treatments: treatments | ||||||||||||||
| ) | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||
| // | ||||||||||||||
| // CalendarTreatmentFlowState.swift | ||||||||||||||
| // Cherrish-iOS | ||||||||||||||
| // | ||||||||||||||
| // Created by 이나연 on 1/21/26. | ||||||||||||||
| // | ||||||||||||||
|
|
||||||||||||||
| import Foundation | ||||||||||||||
|
|
||||||||||||||
| final class CalendarTreatmentFlowState: ObservableObject { | ||||||||||||||
| @Published var selectedDate: Date? | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
10
to
12
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. 오타 수정 필요: 프로퍼티 이름에 오타가 있습니다. 🔧 수정 제안 final class CalendarTreatmentFlowState: ObservableObject {
- `@Published` var selectedDaet: Date?
+ `@Published` var selectedDate: Date?
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
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. 확인해주세영 |
||||||||||||||
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.
파일 헤더 주석의 파일명이 실제 파일명과 불일치합니다.
주석에는
UserProcedureItemRequestDTO.swift로 되어 있으나, 실제 파일명은CreateUserProcedureRequestDTO.swift입니다.✏️ 수정 제안
📝 Committable suggestion
🤖 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.
이거한번만봐주세염