Skip to content

Commit

Permalink
[refactor] #177 포킷목록조회 2버전 API 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
stealmh committed Jan 5, 2025
1 parent ce56a7d commit b5dfcd4
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,7 +48,10 @@ public extension CategoryItemInquiryResponse {
imageUrl: Constants.mockImageUrl
),
contentCount: 90,
createdAt: ""
createdAt: "",
openType: "PRIVATE",
keywordType: "스포츠/레저",
userCount: 0
)
}

Expand All @@ -61,7 +67,10 @@ extension CategoryListInquiryResponse {
imageUrl: Constants.mockImageUrl
),
contentCount: 90,
createdAt: ""
createdAt: "",
openType: "PRIVATE",
keywordType: "스포츠/레저",
userCount: 0
),
CategoryItemInquiryResponse(
categoryId: 2,
Expand All @@ -72,7 +81,10 @@ extension CategoryListInquiryResponse {
imageUrl: Constants.mockImageUrl
),
contentCount: 90,
createdAt: ""
createdAt: "",
openType: "PRIVATE",
keywordType: "스포츠/레저",
userCount: 0
),
CategoryItemInquiryResponse(
categoryId: 3,
Expand All @@ -83,7 +95,10 @@ extension CategoryListInquiryResponse {
imageUrl: Constants.mockImageUrl
),
contentCount: 90,
createdAt: ""
createdAt: "",
openType: "PUBLIC",
keywordType: "스포츠/레저",
userCount: 0
)
],
page: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion Projects/Domain/Sources/Base/BaseCategoryItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@ 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,
userId: Int,
categoryName: String,
categoryImage: BaseCategoryImage,
contentCount: Int,
createdAt: String
createdAt: String,
openType: BaseOpenType,
keywordType: BaseInterestType,
userCount: Int
) {
self.id = id
self.userId = userId
self.categoryName = categoryName
self.categoryImage = categoryImage
self.contentCount = contentCount
self.createdAt = createdAt
self.openType = openType
self.keywordType = keywordType
self.userCount = userCount
}
}
31 changes: 31 additions & 0 deletions Projects/Domain/Sources/Base/BaseInterestType.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
13 changes: 13 additions & 0 deletions Projects/Domain/Sources/Base/BaseOpenType.swift
Original file line number Diff line number Diff line change
@@ -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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand Down
1 change: 1 addition & 0 deletions Projects/Util/Sources/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b5dfcd4

Please sign in to comment.