Skip to content
Merged
13 changes: 13 additions & 0 deletions RecorDream-iOS/Projects/Core/Sources/Protocols/Cancellable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Cancellable.swift
// RD-Core
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

public protocol Cancellable {
func cancel()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DreamSearchResuestDTO.swift
// Data
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

struct DreamSearchResuestDTO: Encodable {
let query: String
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분은 저번에 수연이가 얘기한 것처럼 DTO는 제거해도 될 것 같아요!
@Suyeon9911 그런 의도가 맞을까요?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@L-j-h-c 네엡 ~~!!

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// DreamSearchEntity.swift
// DomainTests
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

public struct Records: Equatable, Identifiable {
public enum Genre: Int {
case comedy
case romance
case action
case thriller
case mystery
case fear
case sf
case fantasy
case family
case etc
case none
}
Comment on lines +12 to +24
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍


public let id: String
public let dreamColor: Int?
public let emotion: Int?
public let date: String?
public let title: String?
public let genre: Genre?
}

public struct DreamSearchEntity: Equatable {
public let recordsCount: Int
public let records: [Records]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DreamSearchQuery.swift
// DomainTests
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

public struct DreamSearchQuery: Equatable {
public let query: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// DreamSearchRepository.swift
// DomainTests
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

import RxSwift

public protocol DreamSearchRepository {
// @discardableResult
// func fetchDreamSearchList(query: DreamSearchQuery,
// completion: @escaping(Result<DreamSearchEntity, Error>) -> Void) -> Cancellable?
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. DreamSearchQuery, DreamSearchEntity 부분

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// DreamSearchUseCase.swift
// DomainTests
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

import RD_Core
import Domain

protocol DreamSearchUseCase {
func execute(requestValue: DreamSearchUseCaseRequestValue,
completion: @escaping (Result<DreamSearchQuery, Error>) -> Void) -> Cancellable?
}

//final class DefaultDreamSearchUseCase: DreamSearchUseCase {
// private let dreamSearchRepository: DreamSearchRepository
//
// init(dreamSearchRepository: DreamSearchRepository) {
// self.dreamSearchRepository = dreamSearchRepository
// }
//
// func execute(requestValue: DreamSearchUseCaseRequestValue,
// completion: @escaping (Result<DreamSearchEntity, Error>) -> Void) -> Cancellable? {
//
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. DreamSearchEntity

// return dreamSearchRepository.fetchDreamSearchList(query: requestValue.query,
// completion: { result in
// completion(result)
// })
// }
//}

struct DreamSearchUseCaseRequestValue {
let query: DreamSearchQuery
}
16 changes: 16 additions & 0 deletions RecorDream-iOS/Projects/Domain/Sources/UseCases/UseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// UseCase.swift
// DomainTests
//
// Created by 정은희 on 2022/11/09.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

import RD_Core

public protocol UseCase {
@discardableResult
func start() -> Cancellable?
}
Comment on lines +13 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start 메서드가 서버통신을 위한 UseCase에만 특별하게 사용 될 수 있을 것 같은데, 네이밍이 조금 넓은 범위를 포함하게 되는 것 같아요... 그리고 start 메서드는 하나의 기능만 가지고 있는 UseCase에 사용될 수 있을 것 같은데 어떤 식으로 사용하실 예정인가요?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유즈케이스에서 필요한 레포지터리 내의 데이터를 패치해올 때(동그라미 부분을 구현할 때) 사용할 예정입니다!
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하! 레포지토리 인터페이스만으로는 부족한 걸까요?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 부분에서만 의존성 역전이 일어나는 것이기 때문에 따로 만들었던 것인데요...!
생각을 해보니 네이밍이 범용적이기도 하고, 아직 사용하고 있지 않기 때문에 수정을 해야겠다고 느껴지네욥

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// DreamSearchResponseDTO.swift
// RD-Network
//
// Created by 정은희 on 2022/11/08.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

struct DreamSearchResponseDTO: Decodable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 DTO 제거 부탁드립니다...ㅎㅎ

let query: String
let results: [DreamSearchResultDTO]
}

extension DreamSearchResponseDTO {
struct DreamSearchResultDTO: Decodable {
private enum CodingKeys: String, CodingKey {
case recordsCount = "records_count"
case records
}

let recordsCount: Int
let records: [Records]
}

struct Records: Decodable {
private enum CodingKeys: String, CodingKey {
case id = "_id"
case dreamColor = "dream_color"
case emotion, date, title, genre
}
enum GenreDTO: Int, Decodable {
case comedy
case romance
case action
case thriller
case mystery
case fear
case sf
case fantasy
case family
case etc
case none
}

let id: String?
let dreamColor: Int?
let emotion: Int?
let date: String?
let title: String?
let genre: GenreDTO?
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// SearchRouter.swift
// RD-Network
//
// Created by 정은희 on 2022/11/08.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

import Alamofire

enum SearchRouter {
case searchRecord(keyword: String)
}

extension SearchRouter: BaseRouter {
var method: HTTPMethod {
switch self {
case .searchRecord:
return .get
}
}

var path: String {
switch self {
case .searchRecord:
return "/record/storage/search"
}
}

var parameters: RequestParams {
switch self {
case .searchRecord(let keyword):
let query: [String: Any] = [
"keyword": keyword
]
return .query(query)
default:
return .requestPlain
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// SearchService.swift
// RD-Network
//
// Created by 정은희 on 2022/11/08.
// Copyright © 2022 RecorDream. All rights reserved.
//

import Foundation

import Alamofire

public protocol SearchService {
func searchDreamRecords(keyword: String) throws -> DreamSearchResponse
}

public class DefaultSearchService: BaseService {
public static let shared = DefaultSearchService()

private override init() { }
}

extension DefaultSearchService: SearchService {
public func searchDreamRecords(keyword: String) throws -> DreamSearchResponse {
AFManager.request(SearchRouter.searchRecord(keyword: keyword))
.responseData { response in

}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네트워크 모듈 구현할 때 PR에서 서버 명세서 기준으로 path Parameter 기준으로 크게 5가지로 나뉘어 있어서 Service를 5개만 구현해 뒀었는데, SearchService를 하나 더 구현하는 것이 더 효율적이라고 판단하셨을까요?

image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사실 잘 모르겠어서 일단 만들었... 허허

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇다면 레코드 서비스에 넣어주시는건 어떤가요? ㅎㅎ 서비스 클래스가 많아지면 혼란이 올 것 같아서요~

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import RD_DSKit
final class DreamSearchBottomCVC: DreamSearchCollectionViewCell {
private lazy var rogoImageView: UIImageView = {
let iv = UIImageView()
iv.image = RDDSKitAsset.Images.rdRogoMark.image
iv.image = RDDSKitAsset.Images.rdgoroMark.image
iv.contentMode = .scaleAspectFit
return iv
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import RD_DSKit
final class DreamSearchCountCVC: DreamSearchCollectionViewCell {
private lazy var countLabel: UILabel = {
let lb = UILabel()
lb.text = "4개의 기록" // ✅
lb.textColor = RDDSKitColors.Color.white
lb.font = RDDSKitFontFamily.Pretendard.semiBold.font(size: 12)
return lb
Expand Down Expand Up @@ -41,3 +40,9 @@ final class DreamSearchCountCVC: DreamSearchCollectionViewCell {
}
}
}

extension DreamSearchCountCVC {
func configureCell(viewModel: DreamSearchResultViewModel) {
self.countLabel.text = "\(viewModel.recordsCount)개의 기록"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ final class DreamSearchExistCVC: DreamSearchCollectionViewCell {
}
}
}

extension DreamSearchExistCVC {
func configureCell(viewModel: DreamSearchResultViewModel) {
// self.backgroundImageView
// self.genreView
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit


@available(iOS 16.0, *)
extension DreamSearchVC {
func layout() -> UICollectionViewLayout {
return UICollectionViewCompositionalLayout { [weak self] sectionNumber, environment -> NSCollectionLayoutSection? in
Expand All @@ -34,7 +33,7 @@ extension DreamSearchVC {
heightDimension: .estimated(88.adjustedHeight)
)
let group = NSCollectionLayoutGroup.vertical(
layoutSize: groupSize, repeatingSubitem: item, count: 1)
layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
let sectionFooter = self.createSectionFooter()
section.orthogonalScrollingBehavior = .continuous
Expand All @@ -55,7 +54,7 @@ extension DreamSearchVC {
heightDimension: .fractionalHeight(1.0)
)
let group = NSCollectionLayoutGroup.vertical(
layoutSize: groupSize, repeatingSubitem: item, count: 1
layoutSize: groupSize, subitems: [item]
)
let sectionFooter = self.createSectionFooter()
let section = NSCollectionLayoutSection(group: group)
Expand All @@ -64,7 +63,6 @@ extension DreamSearchVC {
section.contentInsets = .init(
top: 208, leading: 113, bottom: 282, trailing: 113
)

return section
}
private func createSectionFooter() -> NSCollectionLayoutBoundarySupplementaryItem {
Expand Down
Loading