Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Projects/DataSource/Sources/DTO/LoginResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TokenResponseDTO.swift
// LoginResponseDTO.swift
// DataSource
//
// Created by 최정인 on 6/30/25.
Expand Down
46 changes: 46 additions & 0 deletions Projects/DataSource/Sources/DTO/RoutineDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// RoutineDTO.swift
// DataSource
//
// Created by 최정인 on 8/19/25.
//

import Domain

struct RoutineDictionaryDTO: Decodable {
let routines: [String: RoutineDateDTO]
}

struct RoutineDateDTO: Decodable {
let routineList: [RoutineDTO]
let allCompleted: Bool
}

struct RoutineDTO: Decodable {
let routineId: String
let routineName: String
let repeatDay: [String]
let executionTime: String
let routineCompleteYn: Bool
let subRoutineNames: [String]
let subRoutineCompleteYn: [Bool]
let recommendedRoutineType: String?
let routineDeletedYn: Bool
let routineStartDate: String
let routineEndDate: String

func toRoutineEntity() -> RoutineEntity {
return RoutineEntity(
routineId: routineId,
routineName: routineName,
repeatDay: repeatDay,
executionTime: executionTime,
routineCompleteYn: routineCompleteYn,
subRoutineNames: subRoutineNames,
subRoutineCompleteYn: subRoutineCompleteYn,
recommendedRoutineType: recommendedRoutineType,
routineDeletedYn: routineDeletedYn,
routineStartDate: routineStartDate,
routineEndDate: routineEndDate)
}
}
43 changes: 0 additions & 43 deletions Projects/DataSource/Sources/DTO/RoutineResponseDTO.swift

This file was deleted.

14 changes: 6 additions & 8 deletions Projects/DataSource/Sources/Endpoint/RoutineEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ enum RoutineEndpoint {
case fetchRoutines(startDate: String, endDate: String)
case updateRoutine(routine: RoutineCreationDTO)
case deleteAllRoutine(routineId: String)
case deleteDailyRoutine(routine: DeleteRoutineDTO)
case deleteDailyRoutine(routineId: String)
case updateRoutineCompletion(routines: RoutineCompletionListDTO)
}
Comment on lines +14 to 16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

시그니처 변경 자체는 일관성 있게 반영됨

deleteDailyRoutine(routineId:)로 단순화된 파라미터는 Repository/UseCase 계층과도 정합성이 맞습니다. 다만 하위 호출처에 기존 DeleteRoutineEntity 기반 호출이 남아 있지 않은지 확인이 필요합니다.

다음 스크립트로 이전 시그니처 사용 및 관련 엔티티 잔존 여부를 빠르게 점검해 주세요.


🏁 Script executed:

#!/bin/bash
# 1) 이전 시그니처 사용 여부
rg -nP 'deleteDailyRoutine\s*\(\s*routine\s*:' -C2

# 2) 삭제된(예정) 엔티티/DTO 흔적
rg -n 'DeleteRoutineEntity|DeleteSubRoutineEntity|DeleteRoutineDTO' -C2

Length of output: 2066


HomeViewModel에서 deleteDailyRoutine 호출 시그니처와 레거시 엔티티/DTO 제거 필요

다음 사항을 반영해 주세요:

  • Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift
    • 라인 247:
    현재

    try await routineUseCase.deleteDailyRoutine(routine: deleteRoutinEntity)

    수정 후

    try await routineUseCase.deleteDailyRoutine(routineId: deleteRoutinEntity.routineId)

    • 관련 변수명(deleteRoutinEntitydeleteRoutineEntity) 오타도 함께 정정 필요합니다.

  • 레거시 엔티티/DTO 제거 또는 리팩터링
    DeleteSubRoutineEntity, DeleteRoutineEntity (라인 235–239)
    Projects/DataSource/Sources/DTO/DeleteRoutineDTO.swift

    이제 API 호출 계층에서 DeleteRoutineDTO를 직접 사용하거나, 별도 변환 로직 없이 routineId만 넘기는 구조로 통일하시면 됩니다.

🤖 Prompt for AI Agents
In Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift around lines
235–247, the HomeViewModel still calls deleteDailyRoutine with a legacy entity
and has a typo in the variable name; change the call to pass only the routineId
(try await routineUseCase.deleteDailyRoutine(routineId:
deleteRoutineEntity.routineId)) and rename the variable deleteRoutinEntity →
deleteRoutineEntity; also remove or refactor legacy types DeleteSubRoutineEntity
and DeleteRoutineEntity (lines ~235–239) and the obsolete
Projects/DataSource/Sources/DTO/DeleteRoutineDTO.swift so the code either uses
the Endpoint's deleteDailyRoutine(routineId: String) directly or accepts the
current DeleteRoutineDTO at the API layer with no intermediate entity
conversion.


extension RoutineEndpoint: Endpoint {
var baseURL: String {
switch self {
case .createRoutine, .updateRoutine:
return AppProperties.baseURL + "/api/v2/routines"
default:
case .deleteAllRoutine:
return AppProperties.baseURL + "/api/v1/routines"
default:
return AppProperties.baseURL + "/api/v2/routines"
}
}

Expand All @@ -31,8 +31,8 @@ extension RoutineEndpoint: Endpoint {
"\(baseURL)/\(routineId)"
case .deleteAllRoutine(let routineId):
"\(baseURL)/\(routineId)"
case .deleteDailyRoutine:
"\(baseURL)/day"
case .deleteDailyRoutine(let routineId):
"\(baseURL)/day/\(routineId)"
case .updateRoutineCompletion:
"\(baseURL)/completions"
default:
Expand Down Expand Up @@ -78,8 +78,6 @@ extension RoutineEndpoint: Endpoint {
return routine.dictionary
case .updateRoutine(let routine):
return routine.dictionary
case .deleteDailyRoutine(let routine):
return routine.dictionary
case .updateRoutineCompletion(let routines):
return routines.dictionary
default:
Expand Down
28 changes: 9 additions & 19 deletions Projects/DataSource/Sources/Repository/RoutineRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ final class RoutineRepository: RoutineRepositoryProtocol {

func fetchRoutine(routineId: String) async throws -> RoutineEntity? {
let endpoint = RoutineEndpoint.fetchRoutine(routineId: routineId)
guard let response = try await networkService.request(endpoint: endpoint, type: RoutineResponseDTO.self) else { return nil }
guard let response = try await networkService.request(endpoint: endpoint, type: RoutineDTO.self) else { return nil }

return response.toRoutineEntity()
}

func fetchRoutines(from startDate: String, to endDate: String) async throws -> [String: [RoutineEntity]] {
func fetchRoutines(from startDate: String, to endDate: String) async throws -> [String: (routines: [RoutineEntity], allCompleted: Bool)] {
let endpoint = RoutineEndpoint.fetchRoutines(startDate: startDate, endDate: endDate)
guard let response = try await networkService.request(endpoint: endpoint, type: RoutineDictionaryDTO.self)
else { return [:] }

var result: [String: [RoutineEntity]] = [:]
var result: [String: ([RoutineEntity], Bool)] = [:]
for (date, routineDTO) in response.routines {
result[date] = routineDTO.compactMap({ $0.toRoutineEntity() })
let allCompleted = routineDTO.allCompleted
let routines = routineDTO.routineList.compactMap({ $0.toRoutineEntity() })
result[date] = (routines, allCompleted)
}
return result
}

func updateRoutine(routine: RoutineCreationEntity) async throws {
let routineUpdateDTO = RoutineCreationDTO(
routineId: routine.id,
Expand All @@ -67,20 +69,8 @@ final class RoutineRepository: RoutineRepositoryProtocol {
_ = try await networkService.request(endpoint: endpoint, type: EmptyResponseDTO.self)
}

func deleteDailyRoutine(routine: DeleteRoutineEntity) async throws {
let deleteSubRoutineDTO = routine
.subRoutineInfosForDelete
.map({ DeleteSubRoutineDTO(subRoutineId: $0.subRoutineId, routineCompletionId: $0.routineCompletionId) })

let deleteRoutineDTO = DeleteRoutineDTO(
routineId: routine.routineId,
routineCompletionId: routine.routineCompletionId,
historySeq: routine.historySeq,
routineType: routine.routineType,
performedDate: routine.performedDate,
subRoutineInfosForDelete: deleteSubRoutineDTO)

let endpoint = RoutineEndpoint.deleteDailyRoutine(routine: deleteRoutineDTO)
func deleteDailyRoutine(routineId: String) async throws {
let endpoint = RoutineEndpoint.deleteDailyRoutine(routineId: routineId)
_ = try await networkService.request(endpoint: endpoint, type: EmptyResponseDTO.self)
}

Expand Down
41 changes: 0 additions & 41 deletions Projects/Domain/Sources/Entity/DeleteRoutineEntity.swift

This file was deleted.

53 changes: 27 additions & 26 deletions Projects/Domain/Sources/Entity/RoutineEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,45 @@
// RoutineEntity.swift
// Domain
//
// Created by 최정인 on 7/30/25.
// Created by 최정인 on 8/19/25.
//

public struct RoutineEntity {
public let routineId: String?
public let historySeq: Int
public let routineId: String
public let routineName: String
public let repeatDay: [Week]
public let repeatDay: [String]
public let executionTime: String
public let subRoutineSearchResultDto: [SubRoutineEntity]
public let modifiedYn: Bool
public let routineCompletionId: Int?
public let completeYn: Bool
public let routineType: String
public let routineCompleteYn: Bool
public let subRoutineNames: [String]
public let subRoutineCompleteYn: [Bool]
public let recommendedRoutineType: String?
public let routineDeletedYn: Bool
public let routineStartDate: String
public let routineEndDate: String

public init(
routineId: String?,
historySeq: Int,
routineId: String,
routineName: String,
repeatDay: [String]?,
repeatDay: [String],
executionTime: String,
subRoutineSearchResultDto: [SubRoutineEntity],
modifiedYn: Bool,
routineCompletionId: Int?,
completeYn: Bool,
routineType: String
routineCompleteYn: Bool,
subRoutineNames: [String],
subRoutineCompleteYn: [Bool],
recommendedRoutineType: String?,
routineDeletedYn: Bool,
routineStartDate: String,
routineEndDate: String
) {
let weekType: [Week] = repeatDay?.compactMap(Week.init(rawValue:)) ?? []

self.routineId = routineId
self.historySeq = historySeq
self.routineName = routineName
self.repeatDay = weekType
self.repeatDay = repeatDay
self.executionTime = executionTime
self.subRoutineSearchResultDto = subRoutineSearchResultDto
self.modifiedYn = modifiedYn
self.routineCompletionId = routineCompletionId
self.completeYn = completeYn
self.routineType = routineType
self.routineCompleteYn = routineCompleteYn
self.subRoutineNames = subRoutineNames
self.subRoutineCompleteYn = subRoutineCompleteYn
self.recommendedRoutineType = recommendedRoutineType
self.routineDeletedYn = routineDeletedYn
self.routineStartDate = routineStartDate
self.routineEndDate = routineEndDate
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public protocol RoutineRepositoryProtocol {
/// - Parameters:
/// - startDate: 조회 시작 날짜
/// - endDate: 조회 종료 날짜
func fetchRoutines(from startDate: String, to endDate: String) async throws -> [String: [RoutineEntity]]
func fetchRoutines(from startDate: String, to endDate: String) async throws -> [String: (routines: [RoutineEntity], allCompleted: Bool)]

/// 루틴을 수정합니다.
/// - Parameters:
Expand All @@ -34,7 +34,7 @@ public protocol RoutineRepositoryProtocol {

/// 당일 루틴을 삭제합니다.
/// - Parameter routine: 삭제할 루틴 정보
func deleteDailyRoutine(routine: DeleteRoutineEntity) async throws
func deleteDailyRoutine(routineId: String) async throws

/// 루틴 완료 여부를 업데이트 합니다.
/// - Parameter routines: 완료 여부를 업데이트할 루틴 배열
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Foundation
public protocol RoutineUseCaseProtocol {
func fetchRoutine(routineId: String) async throws -> RoutineEntity?

func fetchRoutines(startDate: Date, endDate: Date) async throws -> [String: [RoutineEntity]]
func fetchRoutines(startDate: Date, endDate: Date) async throws -> [String: (routines: [RoutineEntity], allCompleted: Bool)]

func saveRoutine(routine: RoutineCreationEntity) async throws

func deleteAllRoutine(routineId: String) async throws

func deleteDailyRoutine(routine: DeleteRoutineEntity) async throws
func deleteDailyRoutine(routineId: String) async throws

Comment on lines +19 to 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

삭제 유스케이스 시그니처 단순화 OK — 호출처 정리 여부 확인

deleteDailyRoutine(routineId:)로 통일된 점은 👍. HomeViewModel의 옛 구현(주석 처리된 DeleteRoutineEntity 기반) 정리는 후속 PR에서라도 완료해 주세요.

다음 스크립트로 남아있는 구 호출 패턴을 점검할 수 있습니다.


🏁 Script executed:

#!/bin/bash
rg -nP 'deleteDailyRoutine\s*\(\s*routine:' -C2
rg -n 'DeleteRoutineEntity' -C2

Length of output: 1282


HomeViewModel 호출부 및 DeleteRoutineEntity 정리 필요

HomeViewModel에서 여전히 구 버전 시그니처(deleteDailyRoutine(routine:) + DeleteRoutineEntity)를 사용 중입니다. 아래 항목을 반영해 주세요.

  • 파일: Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift
    • line 237–239:
      let deleteRoutinEntity = DeleteRoutineEntity(
          routineId: routine.id,
          routineCompletionId: routine.completionId,
      )
      ⇒ 더 이상 사용되지 않으므로 삭제 또는 불필요해진 생성 로직 정리
    • line 247:
      try await routineUseCase.deleteDailyRoutine(routine: deleteRoutinEntity)
      ⇒ 신규 시그니처에 맞춰 deleteDailyRoutine(routineId:) 호출로 변경
      예시:
      try await routineUseCase.deleteDailyRoutine(routineId: routine.id)
  • DeleteRoutineEntity(및 연관 서브루틴 엔티티) 정의와 임포트도 사용하지 않는다면 함께 제거 바랍니다.

이렇게 변경하면 삭제 유스케이스 시그니처 단순화 작업이 완결됩니다.

🤖 Prompt for AI Agents
In Projects/Domain/Sources/Protocol/UseCase/RoutineUseCaseProtocol.swift around
lines 19–20, the protocol already exposes deleteDailyRoutine(routineId: String)
async throws but Presentation still uses the old DeleteRoutineEntity and call
signature; update
Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift (around lines
237–247) to stop constructing DeleteRoutineEntity, remove or delete that
creation block, replace the call try await
routineUseCase.deleteDailyRoutine(routine: deleteRoutinEntity) with try await
routineUseCase.deleteDailyRoutine(routineId: routine.id), and then remove the
unused DeleteRoutineEntity type (and any related sub-entities) and their imports
from the project files where they are no longer referenced.

func updateRoutineCompletions(routines: [RoutineCompletionEntity]) async throws
}
6 changes: 3 additions & 3 deletions Projects/Domain/Sources/UseCase/Routine/RoutineUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class RoutineUseCase: RoutineUseCaseProtocol {
return routineEnity
}

public func fetchRoutines(startDate: Date, endDate: Date) async throws -> [String: [RoutineEntity]] {
public func fetchRoutines(startDate: Date, endDate: Date) async throws -> [String: (routines: [RoutineEntity], allCompleted: Bool)] {
let start = startDate.convertToString(dateType: .yearMonthDate)
let end = endDate.convertToString(dateType: .yearMonthDate)

Expand Down Expand Up @@ -59,8 +59,8 @@ public final class RoutineUseCase: RoutineUseCaseProtocol {
try await routineRepository.deleteAllRoutine(routineId: routineId)
}

public func deleteDailyRoutine(routine: DeleteRoutineEntity) async throws {
try await routineRepository.deleteDailyRoutine(routine: routine)
public func deleteDailyRoutine(routineId: String) async throws {
try await routineRepository.deleteDailyRoutine(routineId: routineId)
}

public func updateRoutineCompletions(routines: [RoutineCompletionEntity]) async throws {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "repeat_icon.png",
"filename" : "close_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "repeat_icon@2x.png",
"filename" : "close_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "repeat_icon@3x.png",
"filename" : "close_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading