Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: (#674) ๊ณต์ง€์‚ฌํ•ญ ์ „๋ถ€ ์ฝ์—ˆ๋Š”์ง€ ํŒ๋ณ„ ๊ธฐ๋Šฅ #696

Merged
merged 13 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
b07d75e
๐ŸŽจ :: [#674] NoticeDomain API ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋Œ€์‘
youn9k Jun 27, 2024
469de30
๐ŸŽจ :: ์ฝ”๋“œ Formatting ์ ์šฉ
youn9k Jun 27, 2024
b1ce013
โšก๏ธ :: [#674] ์ฝ์€ ๊ณต์ง€ ์œ ์ €๋””ํดํŠธ ์ €์žฅ ๊ธฐ๋Šฅ ๊ตฌํ˜„์ค‘
youn9k Jun 27, 2024
197f4e2
โ™ป๏ธ :: [#674] ํŒ์—… ๋ฆฌ๋„ค์ด๋ฐ
youn9k Jun 27, 2024
f283cf3
๐ŸŽจ :: ์ฝ”๋“œ Formatting ์ ์šฉ
youn9k Jun 27, 2024
c25344a
โ™ป๏ธ :: [#674] ์ž˜๋ชป ์ˆ˜์ •ํ•œ ์ฝ”๋“œ ์›์ƒ๋ณต๊ตฌ
youn9k Jun 27, 2024
0b6ce0f
โšก๏ธ :: [#674] ๋ชจ๋“  ๊ณต์ง€์‚ฌํ•ญ์„ ์ฝ์—ˆ๋Š”์ง€ ํŒ๋ณ„๋กœ์ง
youn9k Jun 28, 2024
4a26eb9
โ™ป๏ธ :: [#674] ์•ก์…˜ ์ด๋ฆ„ ๋ณ€๊ฒฝ
youn9k Jun 28, 2024
d674176
๐ŸŽจ :: ์ฝ”๋“œ Formatting ์ ์šฉ
youn9k Jun 28, 2024
4f56281
โšก๏ธ :: [#674] ๊ณต์ง€์‚ฌํ•ญ ํŒ๋ณ„ ๋กœ์ง ์ˆ˜์ •
youn9k Jun 28, 2024
fe499fa
๐ŸŽจ :: ์ฝ”๋“œ Formatting ์ ์šฉ
youn9k Jun 28, 2024
7438e06
โšก๏ธ :: [#674] ๊ณต์ง€์‚ฌํ•ญ ์ฝ์Œ ์ฒ˜๋ฆฌ ๋กœ์ง ์ˆ˜์ •
youn9k Jun 28, 2024
fed9ce0
๐ŸŽจ :: ์ฝ”๋“œ Formatting ์ ์šฉ
youn9k Jun 28, 2024
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
24 changes: 14 additions & 10 deletions Projects/App/Sources/Application/AppComponent+Notice.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// AppComponent+Notice.swift
// WaktaverseMusic
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import BaseFeature
import MainTabFeature
import MyInfoFeature
Expand Down Expand Up @@ -39,9 +31,15 @@ public extension AppComponent {
}
}

var fetchNoticeUseCase: any FetchNoticeUseCase {
var fetchNoticeAllUseCase: any FetchNoticeAllUseCase {
shared {
FetchNoticeAllUseCaseImpl(noticeRepository: noticeRepository)
}
}

var fetchNoticePopupUseCase: any FetchNoticePopupUseCase {
shared {
FetchNoticeUseCaseImpl(noticeRepository: noticeRepository)
FetchNoticePopupUseCaseImpl(noticeRepository: noticeRepository)
}
}

Expand All @@ -50,4 +48,10 @@ public extension AppComponent {
FetchNoticeCategoriesUseCaseImpl(noticeRepository: noticeRepository)
}
}

var fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase {
shared {
FetchNoticeIDListUseCaseImpl(noticeRepository: noticeRepository)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Foundation
import RxSwift

public protocol RemoteNoticeDataSource {
func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]>
func fetchNoticeCategories() -> Single<FetchNoticeCategoriesEntity>
func fetchNoticePopup() -> Single<[FetchNoticeEntity]>
func fetchNoticeAll() -> Single<[FetchNoticeEntity]>
func fetchNoticeIDList() -> Single<FetchNoticeIDListEntity>
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchNoticeCategoriesEntity.swift
// DomainModuleTests
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation

public struct FetchNoticeCategoriesEntity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchNoticeEntity.swift
// DomainModuleTests
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation

public struct FetchNoticeEntity {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

public struct FetchNoticeIDListEntity {
public init(
status: String,
data: [Int]
) {
self.status = status
self.data = data
}

public let status: String
public let data: [Int]
}
14 changes: 0 additions & 14 deletions Projects/Domains/NoticeDomain/Interface/Enum/NoticeType.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
//
// NoticeRepository.swift
// DomainModuleTests
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift

public protocol NoticeRepository {
func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]>
func fetchNoticeCategories() -> Single<FetchNoticeCategoriesEntity>
func fetchNoticePopup() -> Single<[FetchNoticeEntity]>
func fetchNoticeAll() -> Single<[FetchNoticeEntity]>
func fetchNoticeIDList() -> Single<FetchNoticeIDListEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation
import RxSwift

public protocol FetchNoticeAllUseCase {
func execute() -> Single<[FetchNoticeEntity]>
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchNoticeCategoriesUseCase.swift
// DomainModuleTests
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation
import RxSwift

public protocol FetchNoticeIDListUseCase {
func execute() -> Single<FetchNoticeIDListEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation
import RxSwift

public protocol FetchNoticePopupUseCase {
func execute() -> Single<[FetchNoticeEntity]>
}

This file was deleted.

42 changes: 23 additions & 19 deletions Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,53 @@ import Moya
import NoticeDomainInterface

public enum NoticeAPI {
case fetchNotice(type: NoticeType)
case fetchNoticeCategories
case fetchNoticePopup
case fetchNoticeAll
case fetchNoticeIDList
}

extension NoticeAPI: WMAPI {
public var domain: WMDomain {
switch self {
case .fetchNotice,
.fetchNoticeCategories:
return .notice
}
return .notice
}

public var urlPath: String {
switch self {
case let .fetchNotice(type):
return "/\(type.rawValue)"
case .fetchNoticeCategories:
return "/categories"
case .fetchNoticePopup:
return "/popup"
case .fetchNoticeAll:
return "/all"
case .fetchNoticeIDList:
return "/ids"
}
}

public var method: Moya.Method {
switch self {
case .fetchNotice,
.fetchNoticeCategories:
case .fetchNoticeCategories:
return .get
case .fetchNoticePopup:
return .get
case .fetchNoticeAll:
return .get
case .fetchNoticeIDList:
return .get
}
}

public var task: Moya.Task {
switch self {
case .fetchNotice:
return .requestParameters(
parameters: [
"os": "ios",
"version": Bundle.main
.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
],
encoding: URLEncoding.queryString
)
case .fetchNoticeCategories:
return .requestPlain
case .fetchNoticePopup:
return .requestPlain
case .fetchNoticeAll:
return .requestPlain
case .fetchNoticeIDList:
return .requestPlain
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ import NoticeDomainInterface
import RxSwift

public final class RemoteNoticeDataSourceImpl: BaseRemoteDataSource<NoticeAPI>, RemoteNoticeDataSource {
public func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> {
request(.fetchNotice(type: type))
.map([FetchNoticeResponseDTO].self)
.map { $0.map { $0.toDomain() }}
}

public func fetchNoticeCategories() -> Single<FetchNoticeCategoriesEntity> {
request(.fetchNoticeCategories)
.map(FetchNoticeCategoriesResponseDTO.self)
.map { $0.toDomain() }
}

public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> {
request(.fetchNoticePopup)
.map([FetchNoticeResponseDTO].self)
.map { $0.map { $0.toDomain() } }
}

public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> {
request(.fetchNoticeAll)
.map([FetchNoticeResponseDTO].self)
.map { $0.map { $0.toDomain() } }
}

public func fetchNoticeIDList() -> Single<FetchNoticeIDListEntity> {
request(.fetchNoticeIDList)
.map(FetchNoticeIDListDTO.self)
.map { $0.toDomain() }
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// NoticeRepositoryImpl.swift
// DataModule
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation
import NoticeDomainInterface
import RxSwift
Expand All @@ -19,11 +11,19 @@ public final class NoticeRepositoryImpl: NoticeRepository {
self.remoteNoticeDataSource = remoteNoticeDataSource
}

public func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> {
remoteNoticeDataSource.fetchNotice(type: type)
}

public func fetchNoticeCategories() -> Single<FetchNoticeCategoriesEntity> {
remoteNoticeDataSource.fetchNoticeCategories()
}

public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> {
remoteNoticeDataSource.fetchNoticePopup()
}

public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> {
remoteNoticeDataSource.fetchNoticeAll()
}

public func fetchNoticeIDList() -> Single<FetchNoticeIDListEntity> {
remoteNoticeDataSource.fetchNoticeIDList()
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchNoticeCategoriesResponseDTO.swift
// DataMappingModule
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation
import NoticeDomainInterface

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation
import NoticeDomainInterface

public struct FetchNoticeIDListDTO: Decodable {
let status: String
let data: [Int]
}

public extension FetchNoticeIDListDTO {
func toDomain() -> FetchNoticeIDListEntity {
return FetchNoticeIDListEntity(status: status, data: data)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchNoticeResponseDTO.swift
// DataMappingModule
//
// Created by KTH on 2023/04/08.
// Copyright ยฉ 2023 yongbeomkwak. All rights reserved.
//

import Foundation
import NoticeDomainInterface

Expand Down Expand Up @@ -36,7 +28,7 @@
public let url: String?
public let link: String?

enum CodingKeys: String, CodingKey {

Check warning on line 31 in Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeResponseDTO.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Nesting Violation: Types should be nested at most 1 level deep (nesting)
case url = "imageUrl"
case link = "hyperlinkUrl"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import NoticeDomainInterface
import RxSwift

public struct FetchNoticeUseCaseImpl: FetchNoticeUseCase {
public struct FetchNoticeAllUseCaseImpl: FetchNoticeAllUseCase {
private let noticeRepository: any NoticeRepository

public init(
Expand All @@ -11,7 +11,7 @@ public struct FetchNoticeUseCaseImpl: FetchNoticeUseCase {
self.noticeRepository = noticeRepository
}

public func execute(type: NoticeType) -> Single<[FetchNoticeEntity]> {
noticeRepository.fetchNotice(type: type)
public func execute() -> Single<[FetchNoticeEntity]> {
return noticeRepository.fetchNoticeAll()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation
import NoticeDomainInterface
import RxSwift

public struct FetchNoticeIDListUseCaseImpl: FetchNoticeIDListUseCase {
private let noticeRepository: any NoticeRepository

public init(
noticeRepository: NoticeRepository
) {
self.noticeRepository = noticeRepository
}

public func execute() -> Single<FetchNoticeIDListEntity> {
return noticeRepository.fetchNoticeIDList()
}
}
Loading
Loading