From b5dfcd432993904536f61b4270f88514102e263a Mon Sep 17 00:00:00 2001 From: minhokim Date: Mon, 6 Jan 2025 00:25:57 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20#177=20=ED=8F=AC=ED=82=B7=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=A1=B0=ED=9A=8C=202=EB=B2=84=EC=A0=84=20API=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CategoryListInquiryResponse.swift | 23 +++++++++++--- .../Network/Category/CategoryEndpoint.swift | 8 ++++- .../Sources/Base/BaseCategoryItem.swift | 11 ++++++- .../Sources/Base/BaseInterestType.swift | 31 +++++++++++++++++++ .../Domain/Sources/Base/BaseOpenType.swift | 13 ++++++++ ...ategoryListInquiryResponse+Extention.swift | 5 ++- Projects/Util/Sources/Constants.swift | 1 + 7 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 Projects/Domain/Sources/Base/BaseInterestType.swift create mode 100644 Projects/Domain/Sources/Base/BaseOpenType.swift diff --git a/Projects/CoreKit/Sources/Data/DTO/Category/CategoryListInquiryResponse.swift b/Projects/CoreKit/Sources/Data/DTO/Category/CategoryListInquiryResponse.swift index c1344341..233540b8 100644 --- a/Projects/CoreKit/Sources/Data/DTO/Category/CategoryListInquiryResponse.swift +++ b/Projects/CoreKit/Sources/Data/DTO/Category/CategoryListInquiryResponse.swift @@ -25,6 +25,9 @@ public struct CategoryItemInquiryResponse: Decodable { public let categoryImage: CategoryImageResponse public let contentCount: Int public let createdAt: String + public let openType: String + public let keywordType: String + public let userCount: Int } /// Sort public struct ItemInquirySortResponse: Decodable { @@ -45,7 +48,10 @@ public extension CategoryItemInquiryResponse { imageUrl: Constants.mockImageUrl ), contentCount: 90, - createdAt: "" + createdAt: "", + openType: "PRIVATE", + keywordType: "스포츠/레저", + userCount: 0 ) } @@ -61,7 +67,10 @@ extension CategoryListInquiryResponse { imageUrl: Constants.mockImageUrl ), contentCount: 90, - createdAt: "" + createdAt: "", + openType: "PRIVATE", + keywordType: "스포츠/레저", + userCount: 0 ), CategoryItemInquiryResponse( categoryId: 2, @@ -72,7 +81,10 @@ extension CategoryListInquiryResponse { imageUrl: Constants.mockImageUrl ), contentCount: 90, - createdAt: "" + createdAt: "", + openType: "PRIVATE", + keywordType: "스포츠/레저", + userCount: 0 ), CategoryItemInquiryResponse( categoryId: 3, @@ -83,7 +95,10 @@ extension CategoryListInquiryResponse { imageUrl: Constants.mockImageUrl ), contentCount: 90, - createdAt: "" + createdAt: "", + openType: "PUBLIC", + keywordType: "스포츠/레저", + userCount: 0 ) ], page: 1, diff --git a/Projects/CoreKit/Sources/Data/Network/Category/CategoryEndpoint.swift b/Projects/CoreKit/Sources/Data/Network/Category/CategoryEndpoint.swift index b78f1cc9..ff55cc14 100644 --- a/Projects/CoreKit/Sources/Data/Network/Category/CategoryEndpoint.swift +++ b/Projects/CoreKit/Sources/Data/Network/Category/CategoryEndpoint.swift @@ -25,7 +25,13 @@ public enum CategoryEndpoint { extension CategoryEndpoint: TargetType { public var baseURL: URL { - return Constants.serverURL.appendingPathComponent(Constants.categoryPath, conformingTo: .url) + switch self { + case .카테고리_목록_조회, .카테고리생성, .카테고리_수정: + return Constants.serverURL.appendingPathComponent(Constants.categoryPathV2, conformingTo: .url) + + default: + return Constants.serverURL.appendingPathComponent(Constants.categoryPath, conformingTo: .url) + } } public var path: String { diff --git a/Projects/Domain/Sources/Base/BaseCategoryItem.swift b/Projects/Domain/Sources/Base/BaseCategoryItem.swift index e1f05970..e4624dd7 100644 --- a/Projects/Domain/Sources/Base/BaseCategoryItem.swift +++ b/Projects/Domain/Sources/Base/BaseCategoryItem.swift @@ -16,6 +16,9 @@ public struct BaseCategoryItem: Identifiable, Equatable, PokitSelectItem, PokitC public let categoryImage: BaseCategoryImage public var contentCount: Int public let createdAt: String + public let openType: BaseOpenType + public let keywordType: BaseInterestType + public let userCount: Int public init( id: Int, @@ -23,7 +26,10 @@ public struct BaseCategoryItem: Identifiable, Equatable, PokitSelectItem, PokitC categoryName: String, categoryImage: BaseCategoryImage, contentCount: Int, - createdAt: String + createdAt: String, + openType: BaseOpenType, + keywordType: BaseInterestType, + userCount: Int ) { self.id = id self.userId = userId @@ -31,5 +37,8 @@ public struct BaseCategoryItem: Identifiable, Equatable, PokitSelectItem, PokitC self.categoryImage = categoryImage self.contentCount = contentCount self.createdAt = createdAt + self.openType = openType + self.keywordType = keywordType + self.userCount = userCount } } diff --git a/Projects/Domain/Sources/Base/BaseInterestType.swift b/Projects/Domain/Sources/Base/BaseInterestType.swift new file mode 100644 index 00000000..46a47fb0 --- /dev/null +++ b/Projects/Domain/Sources/Base/BaseInterestType.swift @@ -0,0 +1,31 @@ +// +// BaseInterestType.swift +// Domain +// +// Created by 김민호 on 1/6/25. +// + +public enum BaseInterestType: String { + case `default` + case 스포츠_레저 + case 문구_오피스 + case 패션 + case 여행 + case 경제_시사 + case 영화_드라마 + case 맛집 + case 인테리어 + case IT + case 디자인 + case 자기계발 + case 유머 + case 음악 + case 취업정보 + + var title: String { + if self.rawValue.contains("_") { + return self.rawValue.replacingOccurrences(of: "_", with: "/") + } + return self.rawValue + } +} diff --git a/Projects/Domain/Sources/Base/BaseOpenType.swift b/Projects/Domain/Sources/Base/BaseOpenType.swift new file mode 100644 index 00000000..a8e28d53 --- /dev/null +++ b/Projects/Domain/Sources/Base/BaseOpenType.swift @@ -0,0 +1,13 @@ +// +// BaseOpenType.swift +// Domain +// +// Created by 김민호 on 1/6/25. +// + +public enum BaseOpenType: String { + case 공개 = "PUBLIC" + case 비공개 = "PRIVATE" + + var title: String { self.rawValue } +} diff --git a/Projects/Domain/Sources/DTO/Category/CategoryListInquiryResponse+Extention.swift b/Projects/Domain/Sources/DTO/Category/CategoryListInquiryResponse+Extention.swift index 8dfa9c65..fb323dd2 100644 --- a/Projects/Domain/Sources/DTO/Category/CategoryListInquiryResponse+Extention.swift +++ b/Projects/Domain/Sources/DTO/Category/CategoryListInquiryResponse+Extention.swift @@ -29,7 +29,10 @@ public extension CategoryItemInquiryResponse { categoryName: self.categoryName, categoryImage: self.categoryImage.toDomain(), contentCount: self.contentCount, - createdAt: self.createdAt + createdAt: self.createdAt, + openType: BaseOpenType(rawValue: self.openType) ?? .비공개, + keywordType: BaseInterestType(rawValue: self.keywordType) ?? .default, + userCount: self.userCount ) } } diff --git a/Projects/Util/Sources/Constants.swift b/Projects/Util/Sources/Constants.swift index b9da10f5..1abaa34f 100644 --- a/Projects/Util/Sources/Constants.swift +++ b/Projects/Util/Sources/Constants.swift @@ -12,6 +12,7 @@ public enum Constants { public static let userPath: String = "/api/v1/user" public static let authPath: String = "/api/v1/auth" public static let categoryPath: String = "/api/v1/category" + public static let categoryPathV2: String = "/api/v2/category" public static let contentPath: String = "/api/v1/content" public static let remindPath: String = "api/v1/remind" public static let alertPath: String = "/api/v1/alert"