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

merge :: 잔류 신청 API 연동 #166

Merged
merged 30 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
beb148b
feat :: 잔류 신청 APIKit
HongSJae Feb 19, 2023
23d5661
feat :: 잔류신청 관련 Entity 생성
HongSJae Feb 19, 2023
49bc053
feat :: 잔류 신청 DataSourceImpl
HongSJae Feb 19, 2023
5d50009
feat :: 잔류 신청 Repository
HongSJae Feb 19, 2023
fbe2078
feat :: 잔류 신청 UseCase
HongSJae Feb 19, 2023
c588f54
feat :: 잔류신청 api 마무리 (AppCompoent)
HongSJae Feb 19, 2023
3929402
feat :: Remains Error Message
HongSJae Feb 19, 2023
dd05d25
feat :: Team Aliens SwiftStyleGuide
HongSJae Feb 19, 2023
b7c74f2
fix :: error 이름 변경
HongSJae Feb 19, 2023
c506c01
fix :: 필요없는 선언 제거
HongSJae Feb 19, 2023
8adc1df
fix :: 필요없는 줄바꿈 제거
HongSJae Feb 19, 2023
3c64159
fix :: 어색한 변수 이름 변경
HongSJae Feb 19, 2023
d6aa72b
fix :: shared 추가
HongSJae Feb 20, 2023
aa6cea1
refactor :: 줄바꿈 추가
HongSJae Feb 21, 2023
f934601
refactor :: error message 변경
HongSJae Feb 21, 2023
c86d0c4
refactor :: 공백 죽이기
HongSJae Feb 21, 2023
d7eb000
fix :: error 해결
HongSJae Feb 21, 2023
e1fc311
refactor :: 변수 이름 변경
HongSJae Feb 21, 2023
74afdc9
refactor :: 불필요한 프레임워크 명시 제거
HongSJae Feb 21, 2023
7a7f038
refactor :: 줄바꿈 추가
HongSJae Feb 21, 2023
ca0fe07
refactor :: guide 에 맞춰 코드 수정
HongSJae Feb 22, 2023
ab0176f
refactor :: 줄바꿈
HongSJae Feb 22, 2023
1b4a606
feat :: WeekDayType
HongSJae Feb 22, 2023
12c888a
refactor :: 공백 제거
HongSJae Feb 22, 2023
959edbe
refactor :: WeekType
HongSJae Feb 22, 2023
19ced42
feat :: DTO에 WeekType 적용
HongSJae Feb 22, 2023
9c830c0
feat :: Entity에 WeekType 적용
HongSJae Feb 22, 2023
99e898e
fix :: Error resolved
HongSJae Feb 22, 2023
19d5353
refactor :: RemoteRemainsDataSourcelmpl 코드 control + i (코드정리)
HongSJae Feb 22, 2023
49182e0
fix :: Error solved
HongSJae Feb 22, 2023
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
@@ -0,0 +1,30 @@
import NeedleFoundation
import NetworkModule
import DomainModule
import DataModule

public extension AppComponent {
var remoteRemainsDataSource: any RemoteRemainsDataSource {
RemoteRemainsDataSourceImpl(keychain: keychain)
}
HongSJae marked this conversation as resolved.
Show resolved Hide resolved

var remainsRepository: any RemainsRepository {
RemainsRepositoryImpl(remoteRemainsDataSource: remoteRemainsDataSource)
}

var remainingApplicationsChangesUseCase: any RemainingApplicationsChangesUseCase {
RemainingApplicationsChangesUseCaselmpl(remainsRepository: remainsRepository)
}

var fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase {
FetchMyRemainApplicationItemsUseCaselmpl(remainsRepository: remainsRepository)
}

var fetchListRemainApplicationItemsUseCase: any FetchListRemainApplicationItemsUseCase {
FetchListRemainApplicationItemsUseCaselmpl(remainsRepository: remainsRepository)
}

var fetchRemainsAvailableTimeUseCase: any FetchRemainsAvailableTimeUseCase {
FetchRemainsAvailableTimeUseCaselmpl(remainsRepository: remainsRepository)
}
}
162 changes: 84 additions & 78 deletions Projects/App/Sources/Application/NeedleGenerated.swift

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Projects/Services/APIKit/Sources/DmsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum DmsDomain: String {
case points
case users
case studyRooms = "study-rooms"
case remains
}

extension DmsDomain {
Expand Down
57 changes: 57 additions & 0 deletions Projects/Services/APIKit/Sources/RemainsAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Moya
import DataMappingModule
import ErrorModule
import Foundation

public enum RemainsAPI {
case remainingApplicationsChanges(id: String)
case fetchMyRemainApplicationItems
case fetchRemainsAvailableTime
case fetchListRemainApplicationItems
}

extension RemainsAPI: DmsAPI {
public var domain: DmsDomain {
.remains
}

public var urlPath: String {
switch self {
case .remainingApplicationsChanges(let id):
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
return "/\(id)"
case .fetchMyRemainApplicationItems:
return "/my"
case .fetchRemainsAvailableTime:
return "/available-time"
case .fetchListRemainApplicationItems:
return "/options"
}
}

public var method: Moya.Method {
switch self {
case .remainingApplicationsChanges:
return .put
case .fetchMyRemainApplicationItems, .fetchRemainsAvailableTime, .fetchListRemainApplicationItems:
return .get
}
}

public var task: Moya.Task {
.requestPlain
}

public var jwtTokenType: JwtTokenType {
.accessToken
}

public var errorMap: [Int: DmsError] {
switch self {
default:
return [
400: .badRequest,
500: .internalServerError
]
}
}
baekteun marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

public struct FetchListRemainAppItemsResponseDTO: Decodable {
public init(
selectedOption: String,
remainOptions: [RemainOptionResponseDTO]
) {
self.selectedOption = selectedOption
self.remainOptions = remainOptions
}
public let selectedOption: String
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
public let remainOptions: [RemainOptionResponseDTO]

enum CodingKeys: String, CodingKey {
case selectedOption = "selected_option"
case remainOptions = "remain_options"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

public struct FetchMyRemainApplicationItemsResponseDTO: Decodable {
public init(
title: String
) {
self.title = title
}
public let title: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

public struct FetchRemainsAvailableTimeResponseDTO: Decodable {
public init(
startDayOfWeek: String,
startAt: String,
endDayOfWeek: String,
endAt: String
) {
self.startDayOfWeek = startDayOfWeek
self.startAt = startAt
self.endDayOfWeek = endDayOfWeek
self.endAt = endAt
}
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
public let startDayOfWeek: String
public let startAt: String
public let endDayOfWeek: String
public let endAt: String
enum CodingKeys: String, CodingKey {
baekteun marked this conversation as resolved.
Show resolved Hide resolved
case startDayOfWeek = "start_day_of_week"
case startAt = "start_at"
case endDayOfWeek = "end_day_of_week"
case endAt = "end_at"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation

public struct RemainOptionResponseDTO: Decodable {
public init(
id: String,
title: String,
description: String
) {
self.id = id
self.title = title
self.description = description
}
public let id: String
public let title: String
public let description: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule
import NetworkModule

public struct RemainsRepositoryImpl: RemainsRepository {
private let remoteRemainsDataSource: any RemoteRemainsDataSource

public init(remoteRemainsDataSource: any RemoteRemainsDataSource) {
self.remoteRemainsDataSource = remoteRemainsDataSource
}

public func remainingApplicationsChanges(id: String) -> AnyPublisher<Void, ErrorModule.DmsError> {
remoteRemainsDataSource.remainingApplicationsChanges(id: id)
}

public func fetchMyRemainApplicationItems() -> AnyPublisher<DomainModule.MyRemainApplicationItemsEntity, ErrorModule.DmsError> {
remoteRemainsDataSource.fetchMyRemainApplicationItems()
}

public func fetchRemainsAvailableTime() -> AnyPublisher<DomainModule.RemainsAvailableTimeEntity, ErrorModule.DmsError> {
remoteRemainsDataSource.fetchRemainsAvailableTime()
}

public func fetchListRemainApplicationItems() -> AnyPublisher<DomainModule.ListRemainApplicationItemsEntity, ErrorModule.DmsError> {
remoteRemainsDataSource.fetchListRemainApplicationItems()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule

public struct FetchListRemainApplicationItemsUseCaselmpl: FetchListRemainApplicationItemsUseCase {
private let remainsRepository: any RemainsRepository

public init(remainsRepository: any RemainsRepository) {
self.remainsRepository = remainsRepository
}

public func execute() -> AnyPublisher<DomainModule.ListRemainApplicationItemsEntity, ErrorModule.DmsError> {
remainsRepository.fetchListRemainApplicationItems()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule

public struct FetchMyRemainApplicationItemsUseCaselmpl: FetchMyRemainApplicationItemsUseCase {
private let remainsRepository: any RemainsRepository

public init(remainsRepository: any RemainsRepository) {
self.remainsRepository = remainsRepository
}

public func execute() -> AnyPublisher<DomainModule.MyRemainApplicationItemsEntity, ErrorModule.DmsError> {
remainsRepository.fetchMyRemainApplicationItems()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule

public struct FetchRemainsAvailableTimeUseCaselmpl: FetchRemainsAvailableTimeUseCase {
private let remainsRepository: any RemainsRepository

public init(remainsRepository: any RemainsRepository) {
self.remainsRepository = remainsRepository
}

public func execute() -> AnyPublisher<DomainModule.RemainsAvailableTimeEntity, ErrorModule.DmsError> {
remainsRepository.fetchRemainsAvailableTime()
}
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule

public struct RemainingApplicationsChangesUseCaselmpl: RemainingApplicationsChangesUseCase {
private let remainsRepository: any RemainsRepository

public init(remainsRepository: any RemainsRepository) {
self.remainsRepository = remainsRepository
}
public func execute(id: String) -> AnyPublisher<Void, ErrorModule.DmsError> {
remainsRepository.remainingApplicationsChanges(id: id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

public struct ListRemainApplicationItemsEntity: Equatable, Hashable {
public init(
selectedOption: String,
remainOptions: [RemainOptionEntity]
) {
self.selectedOption = selectedOption
self.remainOptions = remainOptions
}
public let selectedOption: String
public let remainOptions: [RemainOptionEntity]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

public struct MyRemainApplicationItemsEntity: Equatable, Hashable {
public init(
title: String
) {
baekteun marked this conversation as resolved.
Show resolved Hide resolved
self.title = title
}
public let title: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation

public struct RemainOptionEntity: Equatable, Hashable {
public init(
id: String,
title: String,
description: String
) {
self.id = id
self.title = title
self.description = description
}
public let id: String
public let title: String
public let description: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

public struct RemainsAvailableTimeEntity: Equatable, Hashable {
public init(
startDayOfWeek: String,
startAt: String,
endDayOfWeek: String,
endAt: String
) {
self.startDayOfWeek = startDayOfWeek
self.startAt = startAt
self.endDayOfWeek = endDayOfWeek
self.endAt = endAt
}
public let startDayOfWeek: String
public let startAt: String
public let endDayOfWeek: String
public let endAt: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Combine
import DataMappingModule
import ErrorModule

public protocol RemainsRepository {
func remainingApplicationsChanges(id: String) -> AnyPublisher<Void, DmsError>
func fetchMyRemainApplicationItems() -> AnyPublisher<MyRemainApplicationItemsEntity, DmsError>
func fetchRemainsAvailableTime() -> AnyPublisher<RemainsAvailableTimeEntity, DmsError>
func fetchListRemainApplicationItems() -> AnyPublisher<ListRemainApplicationItemsEntity,
DmsError>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Combine
import DataMappingModule
import ErrorModule

public protocol FetchListRemainApplicationItemsUseCase {
baekteun marked this conversation as resolved.
Show resolved Hide resolved
func execute() -> AnyPublisher<ListRemainApplicationItemsEntity,
DmsError>
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Combine
import DataMappingModule
import ErrorModule

public protocol FetchMyRemainApplicationItemsUseCase {
func execute() -> AnyPublisher<MyRemainApplicationItemsEntity, DmsError>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Combine
import DataMappingModule
import ErrorModule

public protocol FetchRemainsAvailableTimeUseCase {
func execute() -> AnyPublisher<RemainsAvailableTimeEntity, DmsError>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Combine
import DataMappingModule
import ErrorModule

public protocol RemainingApplicationsChangesUseCase {
func execute(id: String) -> AnyPublisher<Void, DmsError>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import DataMappingModule
import DomainModule

public extension FetchListRemainAppItemsResponseDTO {
func toDomain() -> ListRemainApplicationItemsEntity {
ListRemainApplicationItemsEntity(
selectedOption: selectedOption,
remainOptions: remainOptions.map { $0.toDomain() }
)
}
}

public extension RemainOptionResponseDTO {
func toDomain() -> RemainOptionEntity {
RemainOptionEntity(
id: id,
title: title,
description: description
)
}
}
Loading