-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecommendedRoutineDTO.swift
More file actions
56 lines (50 loc) · 1.67 KB
/
RecommendedRoutineDTO.swift
File metadata and controls
56 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// RecommendedRoutineDTO.swift
// DataSource
//
// Created by 최정인 on 7/27/25.
//
import Domain
struct RecommendedRoutineDTO: Decodable {
let id: Int
let routineName: String
let routineDescription: String
let routineLevel: String?
let routineType: String?
let subRoutines: [RecommendedSubRoutineDTO]
enum CodingKeys: String, CodingKey {
case id = "recommendedRoutineId"
case routineName = "recommendedRoutineName"
case routineDescription = "recommendedRoutineDescription"
case routineLevel = "recommendedRoutineLevel"
case routineType = "recommendedRoutineType"
case subRoutines = "recommendedSubRoutineSearchResult"
}
}
extension RecommendedRoutineDTO {
func toRecommendedRoutineEntity(category: String? = nil) -> RecommendedRoutineEntity {
var routineCategory: RoutineCategoryType?
if let category {
routineCategory = RoutineCategoryType(rawValue: category)
if routineCategory == .outdoorReport {
routineCategory = .outdoor
}
}
var type: RoutineCategoryType?
if let routineType {
type = RoutineCategoryType(rawValue: routineType)
}
var level: RoutineLevelType?
if let routineLevel {
level = RoutineLevelType(rawValue: routineLevel)
}
return RecommendedRoutineEntity(
id: id,
title: routineName,
description: routineDescription,
category: routineCategory,
type: type,
level: level,
subRoutines: subRoutines.compactMap({ $0.toRecommendedSubRoutineEntity() }))
}
}