Skip to content

Commit f7ec38a

Browse files
authored
[#321] TodoKind 대신 TodoCategory라는 타입으로 변경한다 (#322)
* style: TodoKind -> TodoCategory 형태로 타입, 변수명 수정 * style: 문자열 키 수정
1 parent 2853c53 commit f7ec38a

32 files changed

Lines changed: 174 additions & 170 deletions

DevLog/Data/DTO/PushNotificationResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct PushNotificationResponse {
1414
let receivedAt: Date
1515
let isRead: Bool
1616
let todoId: String
17-
let todoKind: String
17+
let todoCategory: String
1818
}

DevLog/Data/DTO/TodoDTO.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ struct TodoRequest: Encodable {
2020
let completedAt: Date?
2121
let dueDate: Date?
2222
let tags: [String]
23-
let kind: TodoKind
24-
23+
let category: TodoCategory
2524
}
2625

2726
struct TodoResponse {
@@ -37,5 +36,5 @@ struct TodoResponse {
3736
let completedAt: Date?
3837
let dueDate: Date?
3938
let tags: [String]
40-
let kind: String
39+
let category: String
4140
}

DevLog/Data/Mapper/PushNotificationMapping.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
extension PushNotificationResponse {
99
func toDomain() throws -> PushNotification {
10-
guard let todoKind = TodoKind(rawValue: self.todoKind) else {
11-
throw DataError.invalidData("PushNotificationResponse.todoKind is invalid: \(self.todoKind)")
10+
guard let todoCategory = TodoCategory(rawValue: self.todoCategory) else {
11+
throw DataError.invalidData("PushNotificationResponse.todoCategory is invalid: \(self.todoCategory)")
1212
}
1313

1414
return PushNotification(
@@ -18,7 +18,7 @@ extension PushNotificationResponse {
1818
receivedAt: self.receivedAt,
1919
isRead: self.isRead,
2020
todoId: self.todoId,
21-
todoKind: todoKind
21+
todoCategory: todoCategory
2222
)
2323
}
2424
}

DevLog/Data/Mapper/TodoMapping.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ extension TodoRequest {
2020
completedAt: entity.completedAt,
2121
dueDate: entity.dueDate,
2222
tags: entity.tags,
23-
kind: entity.kind
23+
category: entity.category
2424
)
2525
}
2626
}
2727

2828
extension TodoResponse {
2929
func toDomain() throws -> Todo {
30-
guard let kind = TodoKind(rawValue: self.kind) else {
31-
throw DataError.invalidData("TodoResponse.kind is invalid: \(self.kind)")
30+
guard let category = TodoCategory(rawValue: self.category) else {
31+
throw DataError.invalidData("TodoResponse.category is invalid: \(self.category)")
3232
}
3333

3434
return Todo(
@@ -44,7 +44,7 @@ extension TodoResponse {
4444
completedAt: self.completedAt,
4545
dueDate: self.dueDate,
4646
tags: self.tags,
47-
kind: kind
47+
category: category
4848
)
4949
}
5050
}

DevLog/Domain/Entity/PushNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct PushNotification {
1414
let receivedAt: Date
1515
var isRead: Bool
1616
let todoId: String
17-
let todoKind: TodoKind
17+
let todoCategory: TodoCategory
1818
}

DevLog/Domain/Entity/Todo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ struct Todo: Identifiable, Hashable {
2020
var completedAt: Date? // 할 일 완료 날짜
2121
var dueDate: Date? // 할 일의 마감 날짜 (선택 사항)
2222
var tags: [String] // 할 일에 연결된 태그들
23-
var kind: TodoKind // 할 일의 종류
23+
var category: TodoCategory // 할 일의 종류
2424
}

DevLog/Domain/Entity/TodoQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct TodoQuery: Equatable {
5757
case withoutDueDate
5858
}
5959

60-
var kind: TodoKind?
60+
var category: TodoCategory?
6161
var keyword: String?
6262
var isPinned: Bool?
6363
var completionFilter: CompletionFilter
@@ -70,7 +70,7 @@ struct TodoQuery: Equatable {
7070
var fetchAllPages: Bool
7171

7272
init(
73-
kind: TodoKind? = nil,
73+
category: TodoCategory? = nil,
7474
keyword: String? = nil,
7575
isPinned: Bool? = nil,
7676
completionFilter: CompletionFilter = .all,
@@ -82,7 +82,7 @@ struct TodoQuery: Equatable {
8282
pageSize: Int = 20,
8383
fetchAllPages: Bool = false
8484
) {
85-
self.kind = kind
85+
self.category = category
8686
self.keyword = keyword
8787
self.isPinned = isPinned
8888
self.completionFilter = completionFilter

DevLog/Domain/Entity/TodoReferenceItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import Foundation
1010
struct TodoReferenceItem: Identifiable, Equatable {
1111
let id: String
1212
let title: String
13-
let kind: TodoKind
13+
let category: TodoCategory
1414
}

DevLog/Infra/Service/PushNotificationService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private extension PushNotificationService {
307307
let receivedAt = data[Key.receivedAt.rawValue] as? Timestamp,
308308
let isRead = data[Key.isRead.rawValue] as? Bool,
309309
let todoId = data[Key.todoId.rawValue] as? String,
310-
let todoKind = data[Key.todoKind.rawValue] as? String else {
310+
let todoCategory = data[Key.todoCategory.rawValue] as? String else {
311311
return nil
312312
}
313313

@@ -318,7 +318,7 @@ private extension PushNotificationService {
318318
receivedAt: receivedAt.dateValue(),
319319
isRead: isRead,
320320
todoId: todoId,
321-
todoKind: todoKind
321+
todoCategory: todoCategory
322322
)
323323
}
324324

@@ -328,7 +328,7 @@ private extension PushNotificationService {
328328
case receivedAt
329329
case isRead
330330
case todoId
331-
case todoKind
331+
case todoCategory
332332
case deletingAt // 삭제 요청은 되었지만, 5초 유예 후 최종 삭제되기 전 상태
333333
}
334334
}

DevLog/Infra/Service/TodoService.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class TodoService {
3232
"sortTarget=\(query.sortTarget.fieldName)",
3333
"sortOrder=\(query.sortOrder == .latest ? "latest" : "oldest")",
3434
query.keyword != nil ? "keywordLength=\(trimmedKeyword.count)" : nil,
35-
query.kind != nil ? "kind=\(query.kind!.rawValue)" : nil,
35+
query.category != nil ? "category=\(query.category!.rawValue)" : nil,
3636
query.isPinned != nil ? "pinned=\(query.isPinned!)" : nil,
3737
query.completionFilter.isCompletedValue != nil ? "completed=\(query.completionFilter.isCompletedValue!)" : nil,
3838
query.dueDateFilter != .all ? "dueDateFilter=\(query.dueDateFilter)" : nil,
@@ -46,8 +46,11 @@ final class TodoService {
4646

4747
var firestoreQuery = makeQuery(uid: uid, query: query)
4848

49-
if let kind = query.kind {
50-
firestoreQuery = firestoreQuery.whereField("kind", isEqualTo: kind.rawValue)
49+
if let category = query.category {
50+
firestoreQuery = firestoreQuery.whereField(
51+
TodoFieldKey.category.rawValue,
52+
isEqualTo: category.rawValue
53+
)
5154
}
5255

5356
if let isPinned = query.isPinned {
@@ -267,15 +270,15 @@ final class TodoService {
267270
guard
268271
!(data[TodoFieldKey.deletingAt.rawValue] is Timestamp),
269272
let response = makeResponse(from: document),
270-
let kind = TodoKind(rawValue: response.kind)
273+
let category = TodoCategory(rawValue: response.category)
271274
else {
272275
return
273276
}
274277

275278
partialResult[response.number] = TodoReferenceItem(
276279
id: response.id,
277280
title: response.title,
278-
kind: kind
281+
category: category
279282
)
280283
}
281284
}
@@ -447,7 +450,7 @@ private extension TodoService {
447450
let createdAtTimestamp = data[TodoFieldKey.createdAt.rawValue] as? Timestamp,
448451
let updatedAtTimestamp = data[TodoFieldKey.updatedAt.rawValue] as? Timestamp,
449452
let tags = data[TodoFieldKey.tags.rawValue] as? [String],
450-
let kind = data[TodoFieldKey.kind.rawValue] as? String else {
453+
let category = data[TodoFieldKey.category.rawValue] as? String else {
451454
return nil
452455
}
453456

@@ -466,7 +469,7 @@ private extension TodoService {
466469
completedAt: completedAt,
467470
dueDate: dueDate,
468471
tags: tags,
469-
kind: kind
472+
category: category
470473
)
471474
}
472475

@@ -483,7 +486,7 @@ private extension TodoService {
483486
case completedAt
484487
case dueDate
485488
case tags
486-
case kind
489+
case category
487490
case deletingAt // 삭제 요청은 되었지만, 5초 유예 후 최종 삭제되기 전 상태
488491
}
489492

0 commit comments

Comments
 (0)