From 0f9589b9c26ff18996874d1c7ac18cbf9ef1f87e Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:32:40 +0900 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationsAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSource/API/NotificationsAPI.swift | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Projects/Data/Sources/DataSource/API/NotificationsAPI.swift diff --git a/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift b/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift new file mode 100644 index 00000000..169a5074 --- /dev/null +++ b/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift @@ -0,0 +1,59 @@ +import Moya +import AppNetwork +import Domain + +public enum NotificationsAPI { + case fetchNotificationList + case patchReadNotification(id: Int) +} + +extension NotificationsAPI: JobisAPI { + public typealias ErrorType = JobisError + + public var domain: JobisDomain { + return .notifications + } + + public var urlPath: String { + switch self { + case .fetchNotificationList: + return "" + + case let .patchReadNotification(id): + return "/\(id)" + } + } + + public var method: Method { + switch self { + case .fetchNotificationList: + return .get + + case .patchReadNotification: + return .patch + } + } + + public var task: Task { + switch self { + case .fetchNotificationList: + return .requestParameters( + parameters: + ["is_new": ""], + encoding: URLEncoding.queryString) + default: + return .requestPlain + } + } + + public var jwtTokenType: JwtTokenType { + switch self { + default: + return .accessToken + } + } + + public var errorMap: [Int: ErrorType]? { + return [:] + } +} From cf876f5f770404db802d2867e5b1e257d9112f4d Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:32:52 +0900 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20Assembly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Data/Sources/DI/DataSourceAssembly.swift | 4 ++++ Projects/Data/Sources/DI/RepositoryAssembly.swift | 6 ++++++ Projects/Data/Sources/DI/UseCaseAssembly.swift | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/Projects/Data/Sources/DI/DataSourceAssembly.swift b/Projects/Data/Sources/DI/DataSourceAssembly.swift index 29285800..00333cc2 100644 --- a/Projects/Data/Sources/DI/DataSourceAssembly.swift +++ b/Projects/Data/Sources/DI/DataSourceAssembly.swift @@ -69,5 +69,9 @@ public final class DataSourceAssembly: Assembly { container.register(RemoteNoticesDataSource.self) { resolver in RemoteNoticesDataSourceDataSourceImpl(keychain: self.keychain(resolver)) } + + container.register(RemoteNotificationsDataSource.self) { resolver in + RemoteNotificationsDataSourceImpl(keychain: self.keychain(resolver)) + } } } diff --git a/Projects/Data/Sources/DI/RepositoryAssembly.swift b/Projects/Data/Sources/DI/RepositoryAssembly.swift index b8f83120..b7f9d05c 100644 --- a/Projects/Data/Sources/DI/RepositoryAssembly.swift +++ b/Projects/Data/Sources/DI/RepositoryAssembly.swift @@ -88,6 +88,12 @@ public final class RepositoryAssembly: Assembly { remoteNoticesDataSource: resolver.resolve(RemoteNoticesDataSource.self)! ) } + + container.register(NotificationsRepository.self) { resolver in + NotificationsRepositoryImpl( + remoteNotificationsDataSource: resolver.resolve(RemoteNotificationsDataSource.self)! + ) + } } // swiftlint:enable function_body_length } diff --git a/Projects/Data/Sources/DI/UseCaseAssembly.swift b/Projects/Data/Sources/DI/UseCaseAssembly.swift index 3d60ebfb..e1f0fbbb 100644 --- a/Projects/Data/Sources/DI/UseCaseAssembly.swift +++ b/Projects/Data/Sources/DI/UseCaseAssembly.swift @@ -217,6 +217,18 @@ public final class UseCaseAssembly: Assembly { noticesRepository: resolver.resolve(NoticesRepository.self)! ) } + + // Notifications + container.register(FetchNotificationListUseCase.self) { resolver in + FetchNotificationListUseCase( + notificationsRepository: resolver.resolve(NotificationsRepository.self)! + ) + } + container.register(ReadNotificationUseCase.self) { resolver in + ReadNotificationUseCase( + notificationsRepository: resolver.resolve(NotificationsRepository.self)! + ) + } } // swiftlint:enable function_body_length } From eb102d370957b858b013b13b18ff079717775899 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:33:03 +0900 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20notifications=20domai?= =?UTF-8?q?n=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Modules/AppNetwork/Sources/JobisAPI.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Modules/AppNetwork/Sources/JobisAPI.swift b/Projects/Modules/AppNetwork/Sources/JobisAPI.swift index 62ac3d19..986937a8 100644 --- a/Projects/Modules/AppNetwork/Sources/JobisAPI.swift +++ b/Projects/Modules/AppNetwork/Sources/JobisAPI.swift @@ -43,6 +43,7 @@ public enum JobisDomain: String { case presignedURL = "" case banners case notices + case notifications } extension JobisDomain { From 3b4e9bb353adb2bbaf291ef48dd55deee6311441 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:33:23 +0900 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20api=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Alarm/AlarmViewController.swift | 45 ++++++------- .../Sources/Home/Alarm/AlarmViewModel.swift | 53 ++++++++++++--- .../Home/Alarm/Cell/AlarmTableViewCell.swift | 67 +++++++++++++------ 3 files changed, 111 insertions(+), 54 deletions(-) diff --git a/Projects/Presentation/Sources/Home/Alarm/AlarmViewController.swift b/Projects/Presentation/Sources/Home/Alarm/AlarmViewController.swift index 811e1680..890f2f79 100644 --- a/Projects/Presentation/Sources/Home/Alarm/AlarmViewController.swift +++ b/Projects/Presentation/Sources/Home/Alarm/AlarmViewController.swift @@ -26,10 +26,28 @@ public final class AlarmViewController: BaseViewController { } } - public override func configureViewController() { - alarmTableView.dataSource = self - alarmTableView.delegate = self + public override func bind() { + let input = AlarmViewModel.Input( + viewAppear: viewDidAppearPublisher, + readNotification: + Observable.zip( + alarmTableView.rx.modelSelected(NotificationEntity.self), + alarmTableView.rx.itemSelected + ) + ) + let output = viewModel.transform(input) + + output.notificationList.asObservable() + .bind(to: alarmTableView.rx.items( + cellIdentifier: AlarmTableViewCell.identifier, + cellType: AlarmTableViewCell.self + )) { _, element, cell in + cell.adapt(model: element) + } + .disposed(by: disposeBag) + } + public override func configureViewController() { self.viewWillDisappearPublisher.asObservable() .subscribe(onNext: { [weak self] in self?.showTabbar() @@ -41,24 +59,3 @@ public final class AlarmViewController: BaseViewController { setSmallTitle(title: "알림") } } - -extension AlarmViewController: UITableViewDelegate, UITableViewDataSource { - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 30 - } - - public func tableView( - _ tableView: UITableView, - cellForRowAt indexPath: IndexPath - ) -> UITableViewCell { - guard let cell = tableView.dequeueReusableCell( - withIdentifier: AlarmTableViewCell.identifier, - for: indexPath - ) as? AlarmTableViewCell else { return UITableViewCell() } - - cell.setCell() - cell.layoutIfNeeded() - - return cell - } -} diff --git a/Projects/Presentation/Sources/Home/Alarm/AlarmViewModel.swift b/Projects/Presentation/Sources/Home/Alarm/AlarmViewModel.swift index 6d0e7523..909a9e20 100644 --- a/Projects/Presentation/Sources/Home/Alarm/AlarmViewModel.swift +++ b/Projects/Presentation/Sources/Home/Alarm/AlarmViewModel.swift @@ -9,21 +9,56 @@ public final class AlarmViewModel: BaseViewModel, Stepper { public let steps = PublishRelay() private let disposeBag = DisposeBag() -// private let fetchStudentInfoUseCase: FetchStudentInfoUseCase -// -// init( -// fetchStudentInfoUseCase: FetchStudentInfoUseCase -// ) { -// self.fetchStudentInfoUseCase = fetchStudentInfoUseCase -// } + private let fetchNotificationListUseCase: FetchNotificationListUseCase + private let readNotificationUseCase: ReadNotificationUseCase + + init( + fetchNotificationListUseCase: FetchNotificationListUseCase, + readNotificationUseCase: ReadNotificationUseCase + ) { + self.readNotificationUseCase = readNotificationUseCase + self.fetchNotificationListUseCase = fetchNotificationListUseCase + } public struct Input { let viewAppear: PublishRelay + let readNotification: Observable<(NotificationEntity, IndexPath)> } - public struct Output {} + public struct Output { + let notificationList: BehaviorRelay<[NotificationEntity]> + } public func transform(_ input: Input) -> Output { - return Output() + let notificationList = BehaviorRelay<[NotificationEntity]>(value: []) + + input.viewAppear.asObservable() + .flatMap { + self.fetchNotificationListUseCase.execute() + } + .bind(to: notificationList) + .disposed(by: disposeBag) + + input.readNotification.asObservable() + .do(onNext: { + var oldList = notificationList.value + oldList[$0.1.row] = .init( + notificationID: $0.0.notificationID, + title: $0.0.title, + content: $0.0.content, + topic: $0.0.topic, + detailID: $0.0.detailID, + createdAt: $0.0.createdAt, + new: false + ) + notificationList.accept(oldList) + }) + .flatMap { + self.readNotificationUseCase.execute(id: $0.0.notificationID) + } + .subscribe() + .disposed(by: disposeBag) + + return Output(notificationList: notificationList) } } diff --git a/Projects/Presentation/Sources/Home/Alarm/Cell/AlarmTableViewCell.swift b/Projects/Presentation/Sources/Home/Alarm/Cell/AlarmTableViewCell.swift index f77dfc27..366ee4cd 100644 --- a/Projects/Presentation/Sources/Home/Alarm/Cell/AlarmTableViewCell.swift +++ b/Projects/Presentation/Sources/Home/Alarm/Cell/AlarmTableViewCell.swift @@ -4,43 +4,38 @@ import Then import Domain import DesignSystem -// TODO: 추후 BaseTableViewCell로 변경 -final class AlarmTableViewCell: UITableViewCell { +final class AlarmTableViewCell: BaseTableViewCell { static let identifier = "AlarmTableViewCell" - private let companyNameLabel = UILabel() - private let messageLabel = UILabel() + private let messageLabel = UILabel().then { + $0.numberOfLines = 0 + } private let dateLabel = UILabel() - - func setCell() { - self.companyNameLabel.setJobisText( - "㈜비바리퍼블리카", - font: .description, - color: .Primary.blue20 - ) - self.messageLabel.setJobisText( - "지원서가 승인으로 변경되었습니다", - font: .subHeadLine, - color: .GrayScale.gray80 - ) - self.dateLabel.setJobisText("2023.07.27", font: .description, color: .GrayScale.gray60) + private let readStateView = UIView().then { + $0.backgroundColor = .Sub.red20 + $0.layer.cornerRadius = 2 + $0.clipsToBounds = true + $0.isHidden = true } - override func layoutSubviews() { + override func addView() { [ companyNameLabel, messageLabel, - dateLabel + dateLabel, + readStateView ].forEach(self.addSubview(_:)) + } + override func setLayout() { companyNameLabel.snp.makeConstraints { $0.top.equalToSuperview().inset(16) - $0.leading.equalToSuperview().inset(24) + $0.leading.trailing.equalToSuperview().inset(24) } messageLabel.snp.makeConstraints { $0.top.equalTo(companyNameLabel.snp.bottom) - $0.leading.equalToSuperview().inset(24) + $0.leading.trailing.equalToSuperview().inset(24) } dateLabel.snp.makeConstraints { @@ -48,5 +43,35 @@ final class AlarmTableViewCell: UITableViewCell { $0.leading.equalToSuperview().inset(24) $0.bottom.equalToSuperview().inset(16) } + + readStateView.snp.makeConstraints { + $0.centerY.equalTo(dateLabel.snp.centerY) + $0.leading.equalTo(dateLabel.snp.trailing).offset(4) + $0.width.height.equalTo(4) + } + } + + override func configureView() { + self.selectionStyle = .none + } + + override func adapt(model: NotificationEntity) { + super.adapt(model: model) + self.companyNameLabel.setJobisText( + model.title, + font: .description, + color: .Primary.blue30 + ) + self.messageLabel.setJobisText( + model.content, + font: .subHeadLine, + color: .GrayScale.gray80 + ) + self.dateLabel.setJobisText( + model.createdAt, + font: .description, + color: .GrayScale.gray60 + ) + readStateView.isHidden = !model.new } } From 566096e2df97261f48866bddbab877fcad37064f Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:33:43 +0900 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20PresentationAssembly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Presentation/Sources/DI/PresentationAssembly.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Projects/Presentation/Sources/DI/PresentationAssembly.swift b/Projects/Presentation/Sources/DI/PresentationAssembly.swift index a98c4459..8ab40ddd 100644 --- a/Projects/Presentation/Sources/DI/PresentationAssembly.swift +++ b/Projects/Presentation/Sources/DI/PresentationAssembly.swift @@ -22,9 +22,10 @@ public final class PresentationAssembly: Assembly { container.register(AlarmViewController.self) { resolver in AlarmViewController(resolver.resolve(AlarmViewModel.self)!) } - container.register(AlarmViewModel.self) { _ in + container.register(AlarmViewModel.self) { resolver in AlarmViewModel( -// fetchStudentInfoUseCase: resolver.resolve(FetchStudentInfoUseCase.self)! + fetchNotificationListUseCase: resolver.resolve(FetchNotificationListUseCase.self)!, + readNotificationUseCase: resolver.resolve(ReadNotificationUseCase.self)! ) } From 80777054c806a1a4ede1a5afddd253910fdc20e7 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:33:57 +0900 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationsReposito?= =?UTF-8?q?ry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationsRepositoryImpl.swift | 20 +++++++++++++++++++ .../NotificationsRepository.swift | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 Projects/Data/Sources/Repositories/NotificationsRepositoryImpl.swift create mode 100644 Projects/Domain/Sources/Repositories/NotificationsRepository.swift diff --git a/Projects/Data/Sources/Repositories/NotificationsRepositoryImpl.swift b/Projects/Data/Sources/Repositories/NotificationsRepositoryImpl.swift new file mode 100644 index 00000000..06c16292 --- /dev/null +++ b/Projects/Data/Sources/Repositories/NotificationsRepositoryImpl.swift @@ -0,0 +1,20 @@ +import RxSwift +import Domain + +struct NotificationsRepositoryImpl: NotificationsRepository { + private let remoteNotificationsDataSource: any RemoteNotificationsDataSource + + init( + remoteNotificationsDataSource: any RemoteNotificationsDataSource + ) { + self.remoteNotificationsDataSource = remoteNotificationsDataSource + } + + func fetchNotificationsList() -> Single<[NotificationEntity]> { + remoteNotificationsDataSource.fetchNotificationList() + } + + func patchReadNotification(id: Int) -> Completable { + remoteNotificationsDataSource.patchReadNotification(id: id) + } +} diff --git a/Projects/Domain/Sources/Repositories/NotificationsRepository.swift b/Projects/Domain/Sources/Repositories/NotificationsRepository.swift new file mode 100644 index 00000000..0b77a5f5 --- /dev/null +++ b/Projects/Domain/Sources/Repositories/NotificationsRepository.swift @@ -0,0 +1,6 @@ +import RxSwift + +public protocol NotificationsRepository { + func fetchNotificationsList() -> Single<[NotificationEntity]> + func patchReadNotification(id: Int) -> Completable +} From 9ba4b2944b73490f9bb0ab4f78229b6462bc1a53 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:34:10 +0900 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationEntity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Notifications/NotificationEntity.swift | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Projects/Domain/Sources/Entities/Notifications/NotificationEntity.swift diff --git a/Projects/Domain/Sources/Entities/Notifications/NotificationEntity.swift b/Projects/Domain/Sources/Entities/Notifications/NotificationEntity.swift new file mode 100644 index 00000000..c6662765 --- /dev/null +++ b/Projects/Domain/Sources/Entities/Notifications/NotificationEntity.swift @@ -0,0 +1,27 @@ +import Foundation + +public struct NotificationEntity: Equatable, Hashable { + public let notificationID: Int + public let title, content, topic: String + public let detailID: Int + public let createdAt: String + public let new: Bool + + public init( + notificationID: Int, + title: String, + content: String, + topic: String, + detailID: Int, + createdAt: String, + new: Bool + ) { + self.notificationID = notificationID + self.title = title + self.content = content + self.topic = topic + self.detailID = detailID + self.createdAt = createdAt + self.new = new + } +} From 43ecf3b17ed7a7b2eb8ce64f76682a2d1dc55505 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:34:21 +0900 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationUseCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FetchNotificationListUseCase.swift | 13 +++++++++++++ .../Notifications/ReadNotificationUseCase.swift | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Projects/Domain/Sources/UseCases/Notifications/FetchNotificationListUseCase.swift create mode 100644 Projects/Domain/Sources/UseCases/Notifications/ReadNotificationUseCase.swift diff --git a/Projects/Domain/Sources/UseCases/Notifications/FetchNotificationListUseCase.swift b/Projects/Domain/Sources/UseCases/Notifications/FetchNotificationListUseCase.swift new file mode 100644 index 00000000..f30d0da3 --- /dev/null +++ b/Projects/Domain/Sources/UseCases/Notifications/FetchNotificationListUseCase.swift @@ -0,0 +1,13 @@ +import RxSwift + +public struct FetchNotificationListUseCase { + private let notificationsRepository: any NotificationsRepository + + public init(notificationsRepository: any NotificationsRepository) { + self.notificationsRepository = notificationsRepository + } + + public func execute() -> Single<[NotificationEntity]> { + notificationsRepository.fetchNotificationsList() + } +} diff --git a/Projects/Domain/Sources/UseCases/Notifications/ReadNotificationUseCase.swift b/Projects/Domain/Sources/UseCases/Notifications/ReadNotificationUseCase.swift new file mode 100644 index 00000000..5ea15e08 --- /dev/null +++ b/Projects/Domain/Sources/UseCases/Notifications/ReadNotificationUseCase.swift @@ -0,0 +1,13 @@ +import RxSwift + +public struct ReadNotificationUseCase { + private let notificationsRepository: any NotificationsRepository + + public init(notificationsRepository: any NotificationsRepository) { + self.notificationsRepository = notificationsRepository + } + + public func execute(id: Int) -> Completable { + notificationsRepository.patchReadNotification(id: id) + } +} From 5a96f5361b4ee5e443788f66e1603b57083c8047 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:34:33 +0900 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationsListDTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Notifications/NotificationListDTO.swift | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Projects/Data/Sources/DTO/Notifications/NotificationListDTO.swift diff --git a/Projects/Data/Sources/DTO/Notifications/NotificationListDTO.swift b/Projects/Data/Sources/DTO/Notifications/NotificationListDTO.swift new file mode 100644 index 00000000..b4d99bf6 --- /dev/null +++ b/Projects/Data/Sources/DTO/Notifications/NotificationListDTO.swift @@ -0,0 +1,38 @@ +import Foundation +import Domain + +struct NotificationListResponseDTO: Codable { + let notifications: [NotificationResponseDTO] +} + +public struct NotificationResponseDTO: Codable { + public let notificationID: Int + public let title, content, topic: String + public let detailID: Int + public let createdAt: String + public let new: Bool + + enum CodingKeys: String, CodingKey { + case notificationID = "notification_id" + case title, content, topic + case detailID = "detail_id" + case createdAt = "created_at" + case new + } +} + +extension NotificationListResponseDTO { + func toDomain() -> [NotificationEntity] { + notifications.map { + NotificationEntity( + notificationID: $0.notificationID, + title: $0.title, + content: $0.content, + topic: $0.topic, + detailID: $0.detailID, + createdAt: $0.createdAt.toJobisDate().toStringFormat("yyyy.MM.dd"), + new: $0.new + ) + } + } +} From ac55dc572fbefd697f5bde17f1af73d1b056f68d Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:34:45 +0900 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20NotificationsDataSour?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemoteNotificationsDataSource.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Projects/Data/Sources/DataSource/Remote/RemoteNotificationsDataSource.swift diff --git a/Projects/Data/Sources/DataSource/Remote/RemoteNotificationsDataSource.swift b/Projects/Data/Sources/DataSource/Remote/RemoteNotificationsDataSource.swift new file mode 100644 index 00000000..f0c78752 --- /dev/null +++ b/Projects/Data/Sources/DataSource/Remote/RemoteNotificationsDataSource.swift @@ -0,0 +1,21 @@ +import RxSwift +import RxCocoa +import Domain + +public protocol RemoteNotificationsDataSource { + func fetchNotificationList() -> Single<[NotificationEntity]> + func patchReadNotification(id: Int) -> Completable +} + +final class RemoteNotificationsDataSourceImpl: RemoteBaseDataSource, RemoteNotificationsDataSource { + public func fetchNotificationList() -> Single<[NotificationEntity]> { + request(.fetchNotificationList) + .map(NotificationListResponseDTO.self) + .map { $0.toDomain() } + } + + public func patchReadNotification(id: Int) -> Completable { + request(.patchReadNotification(id: id)) + .asCompletable() + } +} From 8f9da5ab93a602608f924252c624a3e23e6bc856 Mon Sep 17 00:00:00 2001 From: juyeongno1 Date: Fri, 29 Mar 2024 08:49:17 +0900 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=A7=A9=20::=20todo=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Data/Sources/DataSource/API/NotificationsAPI.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift b/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift index 169a5074..84926f86 100644 --- a/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift +++ b/Projects/Data/Sources/DataSource/API/NotificationsAPI.swift @@ -39,6 +39,7 @@ extension NotificationsAPI: JobisAPI { case .fetchNotificationList: return .requestParameters( parameters: +// // TODO: 추후 읽음와 안읽음 분기처리 필요 ["is_new": ""], encoding: URLEncoding.queryString) default: