Skip to content

Commit

Permalink
merge :: (#239) 자습실 자리 종류 보기 API에 QueryString 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
DSMInhyeKang authored Apr 2, 2023
2 parents 4ee66a5 + d32a5aa commit f9d8dbf
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ struct MyPageView: View {
} label: {
myPageOptionRowCardView(title: "비밀번호 변경")
.dmsFont(.body(.body2), color: .GrayScale.gray6)
.cornerRadius(10, corners: [ appState.features.pointService ? [.bottomLeft, .bottomRight] : .allCorners ])
.cornerRadius(10, corners: appState.features.pointService
? [.bottomLeft, .bottomRight] : .allCorners)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class StudyRoomDetailViewModel: BaseViewModel {

func fetchSeatType() {
addCancellable(
fetchSeatTypesUseCase.execute()
fetchSeatTypesUseCase.execute(studyroomID: studyRoomEntity.id)
) { [weak self] seatTypes in
self?.seatTypes = seatTypes
}
Expand Down
10 changes: 9 additions & 1 deletion Projects/Services/APIKit/Sources/StudyRoomsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Moya

public enum StudyRoomsAPI {
case fetchStudyAvailableTime
case fetchSeatTypes
case fetchSeatTypes(studyroomID: String)
case fetchStudyRoomList(timeSlot: String?)
case fetchDetailStudyRoom(roomID: String, timeSlot: String)
case fetchMyStudyRoomApplicationItems
Expand Down Expand Up @@ -64,6 +64,14 @@ extension StudyRoomsAPI: DmsAPI {

public var task: Moya.Task {
switch self {
case let .fetchSeatTypes(studyroomID):
return .requestParameters(
parameters: [
"study_room_id": studyroomID
],
encoding: URLEncoding.queryString
)

case let .fetchStudyRoomList(timeSlot):
return .requestParameters(
parameters: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public struct StudyRoomsRepositoryImpl: StudyRoomsRepository {
remoteStudyRoomsDataSource.fetchStudyAvailableTime()
}

public func fetchSeatTypes() -> AnyPublisher<[SeatTypeEntity], DmsError> {
remoteStudyRoomsDataSource.fetchSeatTypes()
public func fetchSeatTypes(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError> {
remoteStudyRoomsDataSource.fetchSeatTypes(studyroomID: studyroomID)
}

public func fetchStudyRoomList(timeSlot: String?) -> AnyPublisher<[StudyRoomEntity], DmsError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct FetchSeatTypesUseCaseImpl: FetchSeatTypesUseCase {
self.studyRoomsRepository = studyRoomsRepository
}

public func execute() -> AnyPublisher<[SeatTypeEntity], DmsError> {
studyRoomsRepository.fetchSeatTypes()
public func execute(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError> {
studyRoomsRepository.fetchSeatTypes(studyroomID: studyroomID)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ErrorModule

public protocol StudyRoomsRepository {
func fetchStudyAvailableTime() -> AnyPublisher<StudyAvailableTimeEntity, DmsError>
func fetchSeatTypes() -> AnyPublisher<[SeatTypeEntity], DmsError>
func fetchSeatTypes(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError>
func fetchStudyRoomList(timeSlot: String?) -> AnyPublisher<[StudyRoomEntity], DmsError>
func fetchDetailStudyRoom(roomID: String, timeSlot: String) -> AnyPublisher<DetailStudyRoomEntity, DmsError>
func applyStudyRoomSeat(seatID: String, timeSlot: String) -> AnyPublisher<Void, DmsError>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import DataMappingModule
import ErrorModule

public protocol FetchSeatTypesUseCase {
func execute() -> AnyPublisher<[SeatTypeEntity], DmsError>
func execute(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError>
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public final class RemoteStudyRoomsDataSourceImpl: BaseRemoteDataSource<StudyRoo
.eraseToAnyPublisher()
}

public func fetchSeatTypes() -> AnyPublisher<[SeatTypeEntity], DmsError> {
request(.fetchSeatTypes, dto: FetchSeatTypesResponseDTO.self)
public func fetchSeatTypes(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError> {
request(.fetchSeatTypes(studyroomID: studyroomID), dto: FetchSeatTypesResponseDTO.self)
.map { $0.toDomain() }
.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

public protocol RemoteStudyRoomsDataSource {
func fetchStudyAvailableTime() -> AnyPublisher<StudyAvailableTimeEntity, DmsError>
func fetchSeatTypes() -> AnyPublisher<[SeatTypeEntity], DmsError>
func fetchSeatTypes(studyroomID: String) -> AnyPublisher<[SeatTypeEntity], DmsError>
func fetchStudyRoomList(timeSlot: String?) -> AnyPublisher<[StudyRoomEntity], DmsError>
func fetchDetailStudyRoom(roomID: String, timeSlot: String) -> AnyPublisher<DetailStudyRoomEntity, DmsError>
func applyStudyRoomSeat(seatID: String, timeSlot: String) -> AnyPublisher<Void, DmsError>
Expand Down

0 comments on commit f9d8dbf

Please sign in to comment.