Skip to content

Commit

Permalink
[Network/#95] 학교 검색 API 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Nya128 committed Jan 22, 2025
1 parent 0a0c6cb commit ff3d948
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// GetSchoolSearchResponseDTO.swift
// Gongbaek_iOS
//
// Created by 김나연 on 1/23/25.
//

import Foundation

struct GetSchoolSearchResponseDTO: Codable {
let schoolNames: [String]
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ extension SchoolMajorSearchView {
private func getSearchResultList() {
switch state {
case .school:
viewModel.searchResultList = SchoolNameListModel.mockData().schoolNames
viewModel.getSchoolSearchResults() { response in

}
case .major:
viewModel.searchResultList = MajorNameListModel.mockData().schoolMajors
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ final class SignupViewModel: ObservableObject {

extension SignupViewModel {

/// 닉네임 검증 API
func postNicknameValidation(completion: @escaping (Bool) -> ()) {
Providers.SignupProvider.request(
target: .postNicknameValidation(nickname: nickname),
Expand All @@ -127,4 +128,18 @@ extension SignupViewModel {
}
}
}

/// 학교 검색 API
func getSchoolSearchResults(completion: @escaping (Bool) -> ()) {
Providers.SignupProvider.request(
target: .getSchoolSearchResults(schoolName: searchWord),
instance: BaseResponse<GetSchoolSearchResponseDTO>.self
) { response in
print(response)
if response.success {
guard let data = response.data else { return }
self.searchResultList = data.schoolNames
}
}
}
}

0 comments on commit ff3d948

Please sign in to comment.