Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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.

2 changes: 1 addition & 1 deletion Projects/DataSource/Sources/Endpoint/RoutineEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum RoutineEndpoint {
extension RoutineEndpoint: Endpoint {
var baseURL: String {
switch self {
case .createRoutine, .updateRoutine:
case .createRoutine, .updateRoutine, .fetchRoutines:
return AppProperties.baseURL + "/api/v2/routines"
default:
return AppProperties.baseURL + "/api/v1/routines"
Expand Down
12 changes: 7 additions & 5 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 Down
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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

Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
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.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading