Skip to content

Commit

Permalink
Merge pull request #339 from OMZigak/refactor/#336-meetingList
Browse files Browse the repository at this point in the history
[refactor] 내 모임 리스트 QA 반영
  • Loading branch information
mmaybei authored Aug 26, 2024
2 parents d04adba + daf90e5 commit ae05ccb
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 74 deletions.
33 changes: 20 additions & 13 deletions KkuMulKum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
A3DD9C402C41BAD000E58A13 /* MeetingListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DD9C382C41BAD000E58A13 /* MeetingListViewController.swift */; };
A3DD9C412C41BAD000E58A13 /* MeetingListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DD9C3A2C41BAD000E58A13 /* MeetingListViewModel.swift */; };
A3DD9C682C45C78300E58A13 /* HomeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DD9C672C45C78300E58A13 /* HomeService.swift */; };
A3DF8EC72C7C93CD00207BCC /* MeetingListServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DF8EC62C7C93CD00207BCC /* MeetingListServiceProtocol.swift */; };
A3DF8EC92C7C987200207BCC /* MeetingListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DF8EC82C7C987200207BCC /* MeetingListService.swift */; };
A3DF8ECB2C7C98A200207BCC /* MeetingListTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DF8ECA2C7C98A200207BCC /* MeetingListTargetType.swift */; };
A3FB02442C788A790026DE0E /* HomeServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3FB02432C788A790026DE0E /* HomeServiceProtocol.swift */; };
A3FB184D2C3BF45F001483E5 /* MakeMeetingsRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3FB184C2C3BF45F001483E5 /* MakeMeetingsRequestModel.swift */; };
A3FB184F2C3BF4BC001483E5 /* MakeMeetingsResponseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3FB184E2C3BF4BB001483E5 /* MakeMeetingsResponseModel.swift */; };
Expand Down Expand Up @@ -128,7 +131,6 @@
DD39768A2C41C2AD00E2A4C4 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3976822C41C2AD00E2A4C4 /* HomeViewController.swift */; };
DD39768C2C41C36B00E2A4C4 /* Color.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DD39768B2C41C36B00E2A4C4 /* Color.xcassets */; };
DD3F9DC62C484DEB008E1FF7 /* PromiseService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3F9DC52C484DEB008E1FF7 /* PromiseService.swift */; };
DD3F9DD02C48571A008E1FF7 /* MeetingListServiceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3F9DCF2C48571A008E1FF7 /* MeetingListServiceType.swift */; };
DD3F9DD22C485753008E1FF7 /* UtilService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3F9DD12C485753008E1FF7 /* UtilService.swift */; };
DD3F9DD42C4858A3008E1FF7 /* UtilTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3F9DD32C4858A3008E1FF7 /* UtilTargetType.swift */; };
DD3F9DD62C4988E2008E1FF7 /* RegisterMeetingsResponseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3F9DD52C4988E2008E1FF7 /* RegisterMeetingsResponseModel.swift */; };
Expand Down Expand Up @@ -307,6 +309,9 @@
A3DD9C382C41BAD000E58A13 /* MeetingListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeetingListViewController.swift; sourceTree = "<group>"; };
A3DD9C3A2C41BAD000E58A13 /* MeetingListViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeetingListViewModel.swift; sourceTree = "<group>"; };
A3DD9C672C45C78300E58A13 /* HomeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeService.swift; sourceTree = "<group>"; };
A3DF8EC62C7C93CD00207BCC /* MeetingListServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingListServiceProtocol.swift; sourceTree = "<group>"; };
A3DF8EC82C7C987200207BCC /* MeetingListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingListService.swift; sourceTree = "<group>"; };
A3DF8ECA2C7C98A200207BCC /* MeetingListTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingListTargetType.swift; sourceTree = "<group>"; };
A3FB02432C788A790026DE0E /* HomeServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeServiceProtocol.swift; sourceTree = "<group>"; };
A3FB184C2C3BF45F001483E5 /* MakeMeetingsRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MakeMeetingsRequestModel.swift; sourceTree = "<group>"; };
A3FB184E2C3BF4BB001483E5 /* MakeMeetingsResponseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MakeMeetingsResponseModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -337,7 +342,6 @@
DD3976822C41C2AD00E2A4C4 /* HomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = "<group>"; };
DD39768B2C41C36B00E2A4C4 /* Color.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Color.xcassets; sourceTree = "<group>"; };
DD3F9DC52C484DEB008E1FF7 /* PromiseService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromiseService.swift; sourceTree = "<group>"; };
DD3F9DCF2C48571A008E1FF7 /* MeetingListServiceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingListServiceType.swift; sourceTree = "<group>"; };
DD3F9DD12C485753008E1FF7 /* UtilService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilService.swift; sourceTree = "<group>"; };
DD3F9DD32C4858A3008E1FF7 /* UtilTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilTargetType.swift; sourceTree = "<group>"; };
DD3F9DD52C4988E2008E1FF7 /* RegisterMeetingsResponseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterMeetingsResponseModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -739,7 +743,7 @@
A3DD9C3C2C41BAD000E58A13 /* MeetingList */ = {
isa = PBXGroup;
children = (
DD3F9DCE2C485700008E1FF7 /* ServiceType */,
A3DF8EC52C7C938C00207BCC /* ServiceProtocol */,
A3DD9C3B2C41BAD000E58A13 /* ViewModel */,
A3DD9C392C41BAD000E58A13 /* ViewController */,
A3DD9C372C41BAD000E58A13 /* View */,
Expand All @@ -751,6 +755,7 @@
isa = PBXGroup;
children = (
DDD62FFA2C5FA4FE00174B57 /* MeetingService.swift */,
A3DF8EC82C7C987200207BCC /* MeetingListService.swift */,
78BD61332C45B4A7005752FD /* AuthService.swift */,
A3DD9C672C45C78300E58A13 /* HomeService.swift */,
DD3F9DC52C484DEB008E1FF7 /* PromiseService.swift */,
Expand All @@ -760,6 +765,14 @@
path = Service;
sourceTree = "<group>";
};
A3DF8EC52C7C938C00207BCC /* ServiceProtocol */ = {
isa = PBXGroup;
children = (
A3DF8EC62C7C93CD00207BCC /* MeetingListServiceProtocol.swift */,
);
path = ServiceProtocol;
sourceTree = "<group>";
};
A3FB02422C788A520026DE0E /* ServiceProtocol */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -957,14 +970,6 @@
path = ViewController;
sourceTree = "<group>";
};
DD3F9DCE2C485700008E1FF7 /* ServiceType */ = {
isa = PBXGroup;
children = (
DD3F9DCF2C48571A008E1FF7 /* MeetingListServiceType.swift */,
);
path = ServiceType;
sourceTree = "<group>";
};
DD3F9DD92C49CF05008E1FF7 /* ServiceProtocol */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1199,6 +1204,7 @@
children = (
789196392C49697F00FF8CDF /* Auth */,
DDE7D2C52C47D2BB005A921F /* MeetingTargetType.swift */,
A3DF8ECA2C7C98A200207BCC /* MeetingListTargetType.swift */,
DDE7D2C92C47EE81005A921F /* PromiseTargetType.swift */,
A39F2B1C2C47F3D0008DA5F5 /* HomeTargetType.swift */,
DD3F9DD32C4858A3008E1FF7 /* UtilTargetType.swift */,
Expand Down Expand Up @@ -1838,6 +1844,7 @@
DD8626632C4606A300E4F980 /* EnterReadyInfoButtonView.swift in Sources */,
789AD4B32C3C0093002E2688 /* SocialLoginResponseModel.swift in Sources */,
DD43937F2C41357800EC1799 /* InviteCodeViewModel.swift in Sources */,
A3DF8EC72C7C93CD00207BCC /* MeetingListServiceProtocol.swift in Sources */,
DE9E188B2C3BC92500DB76B4 /* EmptyModel.swift in Sources */,
784824FE2C75F25900FE07A0 /* MyPageEditViewController.swift in Sources */,
DDA2EE732C385EB9007C6059 /* MainTabBarController.swift in Sources */,
Expand Down Expand Up @@ -1878,9 +1885,9 @@
DED5DBF02C345317006ECE7E /* BaseCollectionViewCell.swift in Sources */,
DDA303802C73353300D1045E /* RemovePromiseViewController.swift in Sources */,
DE32D1D42C3BFB56006848DF /* UpdateProfileNameModel.swift in Sources */,
DD3F9DD02C48571A008E1FF7 /* MeetingListServiceType.swift in Sources */,
A39F2B212C499CE5008DA5F5 /* SetReadyStatusInfoServiceType.swift in Sources */,
DE6D4D132C3F14D80005584B /* MeetingMemberCell.swift in Sources */,
A3DF8ECB2C7C98A200207BCC /* MeetingListTargetType.swift in Sources */,
DD3F9DD82C49C25D008E1FF7 /* PromiseServiceProtocol.swift in Sources */,
784825072C77215B00FE07A0 /* MyPageTermsViewController.swift in Sources */,
DDAF1C932C3D6E3D008A37D3 /* PromiseViewController.swift in Sources */,
Expand Down Expand Up @@ -1916,7 +1923,6 @@
DECB845E2C4442AF0022A003 /* FindPlaceView.swift in Sources */,
DE6D4D0F2C3F14D80005584B /* MeetingInfoService.swift in Sources */,
DD3F9DD62C4988E2008E1FF7 /* RegisterMeetingsResponseModel.swift in Sources */,
DD3F9DCC2C485614008E1FF7 /* HomeServiceType.swift in Sources */,
7848250B2C77627200FE07A0 /* UserService.swift in Sources */,
DD39768A2C41C2AD00E2A4C4 /* HomeViewController.swift in Sources */,
DED5DBF42C34539A006ECE7E /* BaseTableViewCell.swift in Sources */,
Expand Down Expand Up @@ -1946,6 +1952,7 @@
DECB84582C43FBEB0022A003 /* AddPromiseViewController.swift in Sources */,
DDE7D2C62C47D2BB005A921F /* MeetingTargetType.swift in Sources */,
A39F2B1D2C47F3D0008DA5F5 /* HomeTargetType.swift in Sources */,
A3DF8EC92C7C987200207BCC /* MeetingListService.swift in Sources */,
DDFA507F2C4693BD000A62E2 /* ProfileSetupViewModel.swift in Sources */,
A3DD9C3D2C41BAD000E58A13 /* MeetingTableViewCell.swift in Sources */,
DE558C5B2C4595A7008DAC4A /* SelectMemberView.swift in Sources */,
Expand Down
89 changes: 89 additions & 0 deletions KkuMulKum/Network/Service/MeetingListService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// MeetingListService.swift
// KkuMulKum
//
// Created by 예삐 on 8/26/24.
//

import Foundation

import Moya

final class MeetingListService {
let provider: MoyaProvider<MeetingListTargetType>

init(provider: MoyaProvider<MeetingListTargetType> = MoyaProvider(plugins: [MoyaLoggingPlugin()])) {
self.provider = provider
}

func request<T: ResponseModelType>(
with request: MeetingListTargetType
) async throws -> ResponseBodyDTO<T>? {
return try await withCheckedThrowingContinuation { continuation in
provider.request(request) { result in
switch result {
case .success(let response):
do {
let decodedData = try JSONDecoder().decode(
ResponseBodyDTO<T>.self,
from: response.data
)
continuation.resume(returning: decodedData)
} catch {
continuation.resume(throwing: error)
}
case .failure(let error):
continuation.resume(throwing: error)
}
}
}
}
}

extension MeetingListService: MeetingListServiceProtocol {
func fetchLoginUser() async throws -> ResponseBodyDTO<LoginUserModel>? {
return try await request(with: .fetchLoginUser)
}

func fetchMeetingList() async throws -> ResponseBodyDTO<MeetingListModel>? {
return try await request(with: .fetchMeetingList)
}
}

final class MockMeetingListService: MeetingListServiceProtocol {
func fetchLoginUser() async throws -> ResponseBodyDTO<LoginUserModel>? {
let mockData = ResponseBodyDTO<LoginUserModel>(
success: true,
data: LoginUserModel(
userID: 1,
name: "꾸물리안",
level: 4,
promiseCount: 8,
tardyCount: 2,
tardySum: 72,
profileImageURL: ""
),
error: nil
)
return mockData
}

func fetchMeetingList() async throws -> ResponseBodyDTO<MeetingListModel>? {
let mockData = ResponseBodyDTO<MeetingListModel>(
success: true,
data: MeetingListModel(
count: 6,
meetings: [
Meeting(meetingID: 1, name: "꾸물이들", memberCount: 14),
Meeting(meetingID: 2, name: "아요레디", memberCount: 28),
Meeting(meetingID: 3, name: "안드가자", memberCount: 26),
Meeting(meetingID: 4, name: "난이서버", memberCount: 30),
Meeting(meetingID: 5, name: "캔디팟", memberCount: 24),
Meeting(meetingID: 6, name: "열기팟", memberCount: 24)
]
),
error: nil
)
return mockData
}
}
1 change: 0 additions & 1 deletion KkuMulKum/Network/Service/MeetingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ final class MockMeetingInfoService: MeetingInfoServiceProtocol {
}
}


final class MockInviteCodeService: InviteCodeServiceProtocol {
func joinMeeting(with request: RegisterMeetingsModel) -> ResponseBodyDTO<RegisterMeetingsResponseModel>? {
let mockData = RegisterMeetingsResponseModel(
Expand Down
54 changes: 54 additions & 0 deletions KkuMulKum/Network/TargetType/MeetingListTargetType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// MeetingListTargetType.swift
// KkuMulKum
//
// Created by 예삐 on 8/26/24.
//

import Foundation

import Moya

enum MeetingListTargetType {
case fetchLoginUser
case fetchMeetingList
}

extension MeetingListTargetType: TargetType {
var baseURL: URL {
guard let privacyInfo = Bundle.main.privacyInfo,
let urlString = privacyInfo["BASE_URL"] as? String,
let url = URL(string: urlString) else {
fatalError("Invalid BASE_URL in PrivacyInfo.plist")
}
return url
}

var path: String {
switch self {
case .fetchLoginUser:
return "/api/v1/users/me"
case .fetchMeetingList:
return "/api/v1/meetings"
}
}

var method: Moya.Method {
return .get
}

var task: Task {
return .requestPlain
}

var headers: [String : String]? {
guard let token = DefaultKeychainService.shared.accessToken else {
return ["Content-Type" : "application/json"]
}

return [
"Content-Type" : "application/json",
"Authorization" : "Bearer \(token)"
]
}
}
2 changes: 1 addition & 1 deletion KkuMulKum/Source/Core/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class MainTabBarController: UITabBarController {

let meetingListViewController = MeetingListViewController(
viewModel: MeetingListViewModel(
service: MeetingService()
service: MeetingListService()
)).then {
$0.tabBarItem.title = "내 모임"
$0.tabBarItem.image = .iconGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// MeetingListServiceProtocol.swift
// KkuMulKum
//
// Created by 예삐 on 8/26/24.
//

import Foundation

import Moya

protocol MeetingListServiceProtocol {
func fetchLoginUser() async throws -> ResponseBodyDTO<LoginUserModel>?
func fetchMeetingList() async throws -> ResponseBodyDTO<MeetingListModel>?
}

This file was deleted.

Loading

0 comments on commit ae05ccb

Please sign in to comment.