Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ public struct DictionaryAllDTO: DictionaryDTOProtocol {
public let bookmarkId: Int?
public var id: Int { originalId }
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DomainInterface

public struct SearchCountDTO: Decodable {
public let counts: Int?

public func toDomain() -> SearchCountResponse {
return SearchCountResponse(count: counts)
}
Expand Down
13 changes: 8 additions & 5 deletions MLS/Data/Data/Network/Endpoints/DictionaryListEndPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public enum DictionaryListEndPoint {
return .init(baseURL: base, path: "/api/v1/\(type)/counts", method: .GET, query: query)
}
// 전체 리스트
public static func fetchAllList(keyword: String?, page: Int? = nil, size: Int? = nil) -> ResponsableEndPoint<PagedListResponseDTO<DictionaryAllDTO>>{
let query = DictionaryListQuery(keyword: keyword ?? "",page: page ?? 0, size: size ?? 20, sort: nil)
public static func fetchAllList(keyword: String?, page: Int? = nil, size: Int? = nil) -> ResponsableEndPoint<PagedListResponseDTO<DictionaryAllDTO>> {
let query = DictionaryListQuery(keyword: keyword ?? "", page: page ?? 0, size: size ?? 20, sort: nil)
return .init(baseURL: base, path: "/api/v1/search", method: .GET, query: query)
}
// 몬스터 리스트
public static func fetchMonsterList(keyword: String?, minLevel: Int?, maxLevel: Int?, page: Int, size: Int, sort: String?) -> ResponsableEndPoint<PagedListResponseDTO<DictionaryMonsterDTO>> {
let query = DictionaryListQuery(keyword: keyword ?? "", page: page, size: size, sort: sort, minLevel: minLevel ?? 1, maxLevel: maxLevel ?? 200)
let query = DictionaryListQuery(keyword: keyword ?? "", page: page, size: size, sort: sort, minLevel: minLevel, maxLevel: maxLevel)
return .init(baseURL: base, path: "/api/v1/monsters", method: .GET, query: query
)
}
Expand All @@ -34,8 +34,11 @@ public enum DictionaryListEndPoint {
)
}
// 아이템 리스트
public static func fetchItemList(keyword: String? = nil, jobId: Int? = nil, minLevel: Int? = nil, maxLevel: Int? = nil, categoryIds: [Int]? = nil, page: Int? = nil, size: Int? = nil, sort: String? = nil) -> ResponsableEndPoint<PagedListResponseDTO<DictionaryItemDTO>> {
let query = DictionaryListQuery(keyword: keyword, page: page ?? 0, size: size ?? 20, sort: sort, minLevel: minLevel, maxLevel: maxLevel, jobId: jobId)
public static func fetchItemList(keyword: String? = nil, jobId: [Int]? = nil, minLevel: Int? = nil, maxLevel: Int? = nil, categoryIds: [Int]? = nil, page: Int? = nil, size: Int? = nil, sort: String? = nil) -> ResponsableEndPoint<PagedListResponseDTO<DictionaryItemDTO>> {
let joinedCategoryIds = categoryIds?.map(String.init).joined(separator: ",")
let joinedJobIds = jobId?.map(String.init).joined(separator: ",")

let query = DictionaryListQuery(keyword: keyword, page: page ?? 0, size: size ?? 20, sort: sort, minLevel: minLevel, maxLevel: maxLevel, jobIds: joinedJobIds, categoryIds: joinedCategoryIds)
return .init(baseURL: base, path: "/api/v1/items", method: .GET, query: query
)
}
Expand Down
2 changes: 1 addition & 1 deletion MLS/Data/Data/Providers/Network/NetworkProviderImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class NetworkProviderImpl: NetworkProvider {
print("🚀 requestData: 요청 시작 - \(endPoint)")

self?.sendRequest(endPoint: endPoint, interceptor: interceptor, completion: { result in

switch result {
case .success(let data):
print("✅ requestData: 응답 수신")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class DictionaryListAPIRepositoryImpl: DictionaryListAPIRepository
}
// MARK: - 몬스터 리스트
public func fetchMonsterList(keyword: String?, minLevel: Int?, maxLevel: Int?, page: Int, size: Int, sort: String?) -> Observable<DictionaryMainResponse> {
let endPoint = DictionaryListEndPoint.fetchMonsterList(keyword: keyword, minLevel: minLevel ?? 1, maxLevel: maxLevel ?? 200, page: page, size: size, sort: sort ?? "ASC")
let endPoint = DictionaryListEndPoint.fetchMonsterList(keyword: keyword, minLevel: minLevel, maxLevel: maxLevel, page: page, size: size, sort: sort ?? "ASC")
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor)
.map { $0.toDomain() }
}
Expand All @@ -44,7 +44,7 @@ public final class DictionaryListAPIRepositoryImpl: DictionaryListAPIRepository
.map { $0.toDomain() }
}
// MARK: - Item 리스트
public func fetchItemList(keyword: String?, jobId: Int?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse> {
public func fetchItemList(keyword: String?, jobId: [Int]?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse> {
let endPoint = DictionaryListEndPoint.fetchItemList(keyword: keyword, jobId: jobId, minLevel: minLevel, maxLevel: maxLevel, categoryIds: categoryIds, page: page, size: size, sort: sort)
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor)
.map { $0.toDomain() }
Expand Down
8 changes: 4 additions & 4 deletions MLS/Data/Data/Repository/UserDefaultsRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public final class UserDefaultsRepositoryImpl: UserDefaultsRepository {
return Disposables.create()
}
}

public func addRecentSearch(keyword: String) -> Completable {
return Completable.create { completable in
var current = UserDefaults.standard.stringArray(forKey: self.key) ?? []

// 중복 제거
current.removeAll(where: { $0 == keyword})
current.insert(keyword, at: 0)

UserDefaults.standard.set(current, forKey: self.key)
completable(.completed)
return Disposables.create()
}
}

public func removeRecentSearch(keyword: String) -> Completable {
return Completable.create { completable in
var current = UserDefaults.standard.stringArray(forKey: self.key) ?? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import DomainInterface
import RxSwift

public final class FetchDictionaryAllListUseCaseImpl: FetchDictionaryAllListUseCase {

private let repository: DictionaryListAPIRepository

public init(repository: DictionaryListAPIRepository) {
self.repository = repository
}

public func execute(keyword: String?, page: Int?) -> Observable<DictionaryMainResponse> {
return repository.fetchAllList(keyword: keyword, page: page)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public final class FetchDictionaryItemListUseCaseImpl: FetchDictionaryItemListUs
self.repository = repository
}

public func execute(keyword: String?, jobId: Int?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse> {
public func execute(keyword: String?, jobId: [Int]?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse> {
return repository.fetchItemList(keyword: keyword, jobId: jobId, minLevel: minLevel, maxLevel: maxLevel, categoryIds: categoryIds, page: page, size: size, sort: sort)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import RxSwift

public final class FetchDictionarySearchListUseCaseImpl: FetchDictionarySearchListUseCase {
private let repository: DictionaryListAPIRepository

public init(repository: DictionaryListAPIRepository) {
self.repository = repository
}

public func execute(keyword: String) -> Observable<DictionaryMainResponse> {
return repository.fetchAllList(keyword: keyword, page: nil)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import DomainInterface

public final class ParseItemFilterResultUseCaseImpl: ParseItemFilterResultUseCase {

private let jobIdMap: [String: Int] = [
"전사": 100, "마법사": 200, "도적": 400, "궁수": 300
]
private let categoryIdMap: [String: Int] = [
"한손검": 7, "한손도끼": 8, "한손둔기": 9, "단검": 10, "완드": 12,
"스태프": 13, "두손검": 14, "두손도끼": 15, "두손둔기": 16, "창": 17,
"폴암": 18, "활": 19, "석궁": 20, "아대": 21, "모자": 24, "상의": 25,
"하의": 26, "전신갑옷": 27, "신발": 28, "장갑": 29, "방패": 31, "망토": 30,
"얼굴장식": 32, "눈장식": 33, "귀고리": 34, "반지": 35, "펜던트": 36,
"벨트": 37, "어깨장식": 38, "화살": 81, "표창": 83,
"한손검주문서": 50, "한손도끼주문서": 51, "한손둔기주문서": 52,
"단검주문서": 53, "완드주문서": 55, "스태프주문서": 56, "두손검주문서": 57,
"두손도끼주문서": 58, "두손둔기주문서": 59, "창주문서": 60, "폴암주문서": 61,
"활주문서": 62, "석궁주문서": 63, "아대주문서": 64, "투구주문서": 67, "상의주문서": 68, "하의주문서": 69, "전신갑옷주문서": 70, "신발주문서": 71, "장갑주문서": 72, "망토주문서": 73, "방패주문서": 74,
"귀장식주문서": 78, "펫장비주문서": 75, "연성서주문서": 76, "귀환주문서": 77,
"마스터리북": 42, "스킬북": 43, "소비": 44, "설치": 45, "이동수단": 46
]

public init() {}

public func execute(results: [(String, String)]) -> ItemFilterCriteria {
let initialCriteria = (jobIds: [Int](), startLevel: Int?(nil), endLevel: Int?(nil), categoryIds: [Int]())

let finalCriteria = results.reduce(into: initialCriteria) { criteria, result in
let (key, value) = result
switch key {
case "직업":
if let id = jobIdMap[value] {
criteria.jobIds.append(id)
}
case "레벨":
let levelText = value.replacingOccurrences(of: "레벨", with: "").trimmingCharacters(in: .whitespaces)
let parts = levelText.split(separator: "~").map { $0.trimmingCharacters(in: .whitespaces) }
if let low = Int(parts.first ?? ""), let high = Int(parts.last ?? "") {
criteria.startLevel = low
criteria.endLevel = high
}
case "무기", "발사체", "방어구", "장신구", "기타아이템":
if let id = categoryIdMap[value] {
criteria.categoryIds.append(id)
}
case "무기주문서", "방어구주문서", "기타주문서":
if let id = categoryIdMap[value + "주문서"] {
criteria.categoryIds.append(id)
}
default:
break
}
}

return ItemFilterCriteria(jobIds: finalCriteria.jobIds, startLevel: finalCriteria.startLevel, endLevel: finalCriteria.endLevel, categoryIds: finalCriteria.categoryIds)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import RxSwift

public final class FetchDictionaryListCountUseCaseImpl: FetchDictionaryListCountUseCase {
private let repository: DictionaryListAPIRepository

public init(repository: DictionaryListAPIRepository) {
self.repository = repository
}

public func execute(type: String, keyword: String?) -> Observable<SearchCountResponse> {
return repository.fetchSearchListCount(type: type, keyword: keyword)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import RxSwift

public class RecentSearchAddUseCaseImpl: RecentSearchAddUseCase {
var repository: UserDefaultsRepository

public init(repository: UserDefaultsRepository) {
self.repository = repository
}

public func add(keyword: String) -> Completable {
return repository.addRecentSearch(keyword: keyword)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import RxSwift

public final class RecentSearchFetchUseCaseImpl: RecentSearchFetchUseCase {
private let repository: UserDefaultsRepository

public init(repository: UserDefaultsRepository) {
self.repository = repository
}

public func fetch() -> Observable<[String]> {
return repository.fetchRecentSearch()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ public struct DictionaryListQuery: Encodable {
public var maxLevel: Int?

// item일 경우
public var jobId: Int?
public var categoryIds: [Int]?
public var jobIds: String?
public var categoryIds: String?

public init(keyword: String? = nil, page: Int, size: Int, sort: String?, minLevel: Int? = nil, maxLevel: Int? = nil, jobId: Int? = nil, categoryIds: [Int]? = nil) {
public init(keyword: String? = nil, page: Int, size: Int, sort: String?, minLevel: Int? = nil, maxLevel: Int? = nil, jobIds: String? = nil, categoryIds: String? = nil) {
self.keyword = keyword
self.page = page
self.size = size
self.sort = sort ?? "ASC"
self.minLevel = minLevel
self.maxLevel = maxLevel
self.jobId = jobId
self.jobIds = jobIds
self.categoryIds = categoryIds
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public struct ItemFilterCriteria {
public let jobIds: [Int]
public let startLevel: Int?
public let endLevel: Int?
public let categoryIds: [Int]

public init(jobIds: [Int], startLevel: Int?, endLevel: Int?, categoryIds: [Int]) {
self.jobIds = jobIds
self.startLevel = startLevel
self.endLevel = endLevel
self.categoryIds = categoryIds
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public struct SearchCountResponse: Decodable {
public let count: Int?

public init(count: Int?) {
self.count = count
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public protocol DictionaryListAPIRepository {
// Quest
func fetchQuestList(keyword: String, page: Int, size: Int, sort: String?) -> Observable<DictionaryMainResponse>
// Item
func fetchItemList(keyword: String?, jobId: Int?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse>
func fetchItemList(keyword: String?, jobId: [Int]?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse>
// Map
func fetchMapList(keyword: String, page: Int, size: Int, sort: String?) -> Observable<DictionaryMainResponse>
// 검색
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import RxSwift

public protocol FetchDictionaryItemListUseCase {
/// 어떤 타입인지에 따라서 쿼리가 결정됨 -> 타입 마다 쿼리가 댜름.
func execute(keyword: String?, jobId: Int?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse>
func execute(keyword: String?, jobId: [Int]?, minLevel: Int?, maxLevel: Int?, categoryIds: [Int]?, page: Int?, size: Int?, sort: String?) -> Observable<DictionaryMainResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol ParseItemFilterResultUseCase {
func execute(results: [(String, String)]) -> ItemFilterCriteria
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,21 @@ public extension BaseListView {
return button
}

func selectFilter(selectedType: SortType) {
func selectSort(selectedType: SortType) {
sortButton.setAttributedTitle(.makeStyledString(font: .b_s_r, text: selectedType.rawValue, color: .primary700), for: .normal)
sortButton.tintColor = .primary700
}

func selectFilter() {
filterButton.setAttributedTitle(.makeStyledString(font: .b_s_r, text: "필터", color: .primary700), for: .normal)
filterButton.tintColor = .primary700
}

func resetFilter() {
filterButton.setAttributedTitle(.makeStyledString(font: .b_s_r, text: "필터"), for: .normal)
filterButton.tintColor = .black
}

func checkEmptyData(isEmpty: Bool) {
emptyView.isHidden = !isEmpty
filterStackView.isHidden = isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ extension BookmarkListViewController {
owner.selectedSortIndex = index
let selectedFilter = reactor.currentState.type.bookmarkSortedFilter[index]
reactor.action.onNext(.sortOptionSelected(selectedFilter))
owner.mainView.selectFilter(selectedType: selectedFilter)
owner.mainView.selectSort(selectedType: selectedFilter)
}
owner.tabBarController?.presentModal(viewController)
case .filter(let type):
switch type {
case .item:
break
//let viewController = owner.itemFilterFactory.make()
//owner.present(viewController, animated: true)
// let viewController = owner.itemFilterFactory.make()
// owner.present(viewController, animated: true)
case .monster:
let viewController = owner.monsterFilterFactory.make(startLevel: reactor.currentState.startLevel ?? 1, endLevel: reactor.currentState.endLevel ?? 200) { startLevel, endLevel in

Expand Down
Loading