diff --git a/Projects/App/Sources/Domain/Organization/VerifingCodeUseCase.swift b/Projects/App/Sources/Domain/Organization/VerifingCodeUseCase.swift index 09a23db0..b4150aa1 100644 --- a/Projects/App/Sources/Domain/Organization/VerifingCodeUseCase.swift +++ b/Projects/App/Sources/Domain/Organization/VerifingCodeUseCase.swift @@ -40,7 +40,7 @@ final class VerifingCodeUseCase { func postSignUp(email: String, orgnization: Organization) { guard let authorization = KeyChainManager.read(key: .authToken) else { return } - let userDTO = SignUpUserDTO(id: orgnization.id, email: email, organizationName: orgnization.name) + let userDTO = SignUpUserDTO(email: email, organizationName: orgnization.name) UserAPI.postSignUp(authorization: authorization, userDTO: userDTO) .sink { [weak self] error in diff --git a/Projects/App/Sources/Domain/Place/AddPlace/AddPlaceUseCase.swift b/Projects/App/Sources/Domain/Place/AddPlace/AddPlaceUseCase.swift index 7d6fa2cc..cc06990d 100644 --- a/Projects/App/Sources/Domain/Place/AddPlace/AddPlaceUseCase.swift +++ b/Projects/App/Sources/Domain/Place/AddPlace/AddPlaceUseCase.swift @@ -12,7 +12,6 @@ import Network protocol AddPlaceUseCaseType { func searchKakaoPlaces(with name: String) -> AnyPublisher<[KakaoPlace], Error> -// func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher func fetchCategories() -> AnyPublisher<[Category], Error> func addNewPlace(with place: KakaoPlace, category: Int) -> AnyPublisher @@ -29,7 +28,7 @@ final class AddPlaceUseCase: AddPlaceUseCaseType { func addNewPlace(with place: KakaoPlace, category: Int) -> AnyPublisher { let user = UserInfoManager.userInfo?.userID ?? 64 - let org = UserInfoManager.userInfo?.userOrganization ?? 400 + let org = UserInfoManager.userInfo?.userOrganization[0] ?? 400 let placeDTO = PlacePostDTO(address: place.address, name: place.placeName, latitude: place.lat, @@ -91,7 +90,9 @@ final class AddPlaceUseCase: AddPlaceUseCaseType { */ func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher { - PlaceAPI.checkRegisterdPlace(kakaoPlaceId: kakaoPlaceId) + guard let orgId = UserInfoManager.userInfo?.userOrganization else { return Fail(error: AddPlaceError.none).eraseToAnyPublisher() } + + return PlaceAPI.checkRegisterdPlace(kakaoPlaceId: kakaoPlaceId, orgId: orgId[0]) .mapError { _ -> AddPlaceError in return .none }.eraseToAnyPublisher() diff --git a/Projects/App/Sources/Domain/Place/PlaceSearch/PlaceSearchUseCase.swift b/Projects/App/Sources/Domain/Place/PlaceSearch/PlaceSearchUseCase.swift index 5a42c3d1..4c6f9a92 100644 --- a/Projects/App/Sources/Domain/Place/PlaceSearch/PlaceSearchUseCase.swift +++ b/Projects/App/Sources/Domain/Place/PlaceSearch/PlaceSearchUseCase.swift @@ -21,8 +21,7 @@ final class PlaceSearchUseCase: PlaceSearchUseCaseType { func searchPlaces(with placeName: String) -> AnyPublisher<[Place], Error> { -// TODO: ORG-ID 넣고 교체 필요 - let orgId = UserInfoManager.userInfo?.userOrganization ?? 400 + let orgId = UserInfoManager.userInfo?.userOrganization[0] ?? 400 PlaceAPI.fetchSearchPlaceResults(orgId: orgId, placeName: placeName) .sink { error in diff --git a/Projects/App/Sources/Domain/Place/PlaceUseCase.swift b/Projects/App/Sources/Domain/Place/PlaceUseCase.swift index 5c30d10b..b4a9bb02 100644 --- a/Projects/App/Sources/Domain/Place/PlaceUseCase.swift +++ b/Projects/App/Sources/Domain/Place/PlaceUseCase.swift @@ -15,11 +15,13 @@ final class PlaceListUseCase { func fetchPlaceList(with page: Int, type: PlaceType) -> AnyPublisher<[Place], NetworkError> { let api: AnyPublisher + guard let authorization = KeyChainManager.read(key: .authToken) else { return Fail(error: NetworkError.unauthorized("권한이 없습니다")).eraseToAnyPublisher() } + switch type { case .whole: - api = PlaceAPI.fetchPlaceList(with: page) + api = PlaceAPI.fetchPlaceList(with: page, authorization: authorization) case .hot: - api = PlaceAPI.fetchHotPlaceList(with: page) + api = PlaceAPI.fetchHotPlaceList(with: page, authorization: authorization) } return api diff --git a/Projects/App/Sources/Domain/User/UserInfoManager.swift b/Projects/App/Sources/Domain/User/UserInfoManager.swift index c6955484..0913fd3e 100644 --- a/Projects/App/Sources/Domain/User/UserInfoManager.swift +++ b/Projects/App/Sources/Domain/User/UserInfoManager.swift @@ -19,7 +19,7 @@ final class UserInfoManager { struct UserInfo: Codable { - init(userNickname: String? = nil, userID: Int? = nil, userOrganization: Int? = nil, userOrgName: String? = nil ) { + init(userNickname: String? = nil, userID: Int? = nil, userOrganization: [Int] = [], userOrgName: String? = nil ) { UserInfoManager.userInfo?.userNickname = userNickname UserInfoManager.userInfo?.userID = userID UserInfoManager.userInfo?.userOrganization = userOrganization @@ -48,10 +48,10 @@ final class UserInfoManager { UserDefaults.standard.set(newValue, forKey: UserInfoKeys.userID.rawValue) } } - var userOrganization: Int? { + var userOrganization: [Int] { get { - guard let userOrganization = UserDefaults.standard.value(forKey: UserInfoKeys.userOrganization.rawValue) as? Int else { - return nil + guard let userOrganization = UserDefaults.standard.value(forKey: UserInfoKeys.userOrganization.rawValue) as? [Int] else { + return [] } return userOrganization } @@ -93,7 +93,7 @@ final class UserInfoManager { UserInfoManager.userInfo = UserInfo() } - static func initialUserInfo(userNickname: String?, userID: Int?, userOrganization: Int?, userOrgName: String?) { + static func initialUserInfo(userNickname: String?, userID: Int?, userOrganization: [Int], userOrgName: String?) { UserInfoManager.userInfo = UserInfo() UserInfoManager.userInfo?.userNickname = userNickname UserInfoManager.userInfo?.userID = userID diff --git a/Projects/App/Sources/UI/Organization/DomainSetting/View/DomainSettingViewController.swift b/Projects/App/Sources/UI/Organization/DomainSetting/View/DomainSettingViewController.swift index 89c3a74a..ddcf7ac1 100644 --- a/Projects/App/Sources/UI/Organization/DomainSetting/View/DomainSettingViewController.swift +++ b/Projects/App/Sources/UI/Organization/DomainSetting/View/DomainSettingViewController.swift @@ -77,7 +77,7 @@ final class DomainSettingViewController: UIViewController { let orgID = viewModel.organization.id let orgName = viewModel.organization.name UserInfoManager.userInfo?.userOrgName = orgName - UserInfoManager.userInfo?.userOrganization = orgID + UserInfoManager.userInfo?.userOrganization = [orgID] navigationController?.pushViewController(DomainSettingCompleteViewController(), animated: true) } } diff --git a/Projects/App/Sources/UI/Organization/OrgDetail/View/OrgDetailViewController.swift b/Projects/App/Sources/UI/Organization/OrgDetail/View/OrgDetailViewController.swift index e89fbae5..d29e3159 100644 --- a/Projects/App/Sources/UI/Organization/OrgDetail/View/OrgDetailViewController.swift +++ b/Projects/App/Sources/UI/Organization/OrgDetail/View/OrgDetailViewController.swift @@ -25,7 +25,7 @@ final class OrgDetailViewController: UIViewController { private let orgInformationStackView3 = UIStackView() private let orgInfoImageView1 = UIImageView() private let orgInfoImageView2 = UIImageView() - private let orgInfoImageView3 = UIImageView() +// private let orgInfoImageView3 = UIImageView() private let orgInviteButton = FullWidthBlackButton() private var orgDetailInformationView1 = OrgDetailInformationView() @@ -121,7 +121,7 @@ extension OrgDetailViewController { orgDetailInformationView2 = OrgDetailInformationView() orgDetailInformationView3 = OrgDetailInformationView() - orgNameLabel.text = "애플 디벨로퍼 아카데미" + orgNameLabel.text = UserInfoManager.userInfo?.userOrgName ?? "(인증대학없음)" orgNameLabel.textColor = .black orgNameLabel.font = UIFont.systemFont(ofSize: CGFloat(26), weight: .bold) orgNameLabel.textAlignment = .center @@ -158,11 +158,12 @@ extension OrgDetailViewController { orgDetailInformationView2.informationLabel.text = "등록된 맛집" orgDetailInformationView2.numberLabel.text = "0곳" - orgInfoImageView3.image = UIImage(.img_reviewfriends_photo) - orgInfoImageView3.contentMode = .scaleAspectFit - orgInfoImageView3.layer.applyFigmaShadow(color: .black, opacity: 0.1, xCoord: 0, yCoord: 0, blur: 5, spread: 0) - orgDetailInformationView3.informationLabel.text = "업로드된 사진" - orgDetailInformationView3.numberLabel.text = "0개" + // TODO: - 백엔드 작업 완료 후 복구 +// orgInfoImageView3.image = UIImage(.img_reviewfriends_photo) +// orgInfoImageView3.contentMode = .scaleAspectFit +// orgInfoImageView3.layer.applyFigmaShadow(color: .black, opacity: 0.1, xCoord: 0, yCoord: 0, blur: 5, spread: 0) +// orgDetailInformationView3.informationLabel.text = "업로드된 사진" +// orgDetailInformationView3.numberLabel.text = "0개" orgInviteButton.setTitle("우리학교 사람들 초대하기", for: .normal) orgInviteButton.addTarget(self, action: #selector(shareAppStoreLink), for: .touchUpInside) @@ -173,7 +174,7 @@ extension OrgDetailViewController { orgInformationSuperStackView.addArrangedSubviews([orgInformationStackView1, orgInformationStackView2, orgInformationStackView3]) orgInformationStackView1.addArrangedSubviews([orgInfoImageView1, orgDetailInformationView1]) orgInformationStackView2.addArrangedSubviews([orgInfoImageView2, orgDetailInformationView2]) - orgInformationStackView3.addArrangedSubviews([orgInfoImageView3, orgDetailInformationView3]) +// orgInformationStackView3.addArrangedSubviews([orgInfoImageView3, orgDetailInformationView3]) orgNameLabel.snp.makeConstraints { make in make.top.equalTo(view.safeAreaLayoutGuide).inset(30) @@ -206,9 +207,9 @@ extension OrgDetailViewController { make.width.height.equalTo(60) } - orgInfoImageView3.snp.makeConstraints { make in - make.width.height.equalTo(60) - } +// orgInfoImageView3.snp.makeConstraints { make in +// make.width.height.equalTo(60) +// } orgInviteButton.snp.makeConstraints { make in make.horizontalEdges.bottom.equalTo(view.safeAreaLayoutGuide).inset(20) diff --git a/Projects/App/Sources/UI/Organization/VerifyCode/ViewModel/VerifingCodeViewModel.swift b/Projects/App/Sources/UI/Organization/VerifyCode/ViewModel/VerifingCodeViewModel.swift index 4d8dcc51..3d4a31fd 100644 --- a/Projects/App/Sources/UI/Organization/VerifyCode/ViewModel/VerifingCodeViewModel.swift +++ b/Projects/App/Sources/UI/Organization/VerifyCode/ViewModel/VerifingCodeViewModel.swift @@ -68,7 +68,7 @@ extension VerifingCodeViewModel { let orgID = self.organization.id let orgName = self.organization.name UserInfoManager.userInfo?.userOrgName = orgName - UserInfoManager.userInfo?.userOrganization = orgID + UserInfoManager.userInfo?.userOrganization = (UserInfoManager.userInfo?.userOrganization ?? []) + [orgID] } self.isEmailOverlapedSubject.send(isEmailOverlaped) } diff --git a/Projects/App/Sources/UI/Place/PlaceList/View/PlaceListViewController.swift b/Projects/App/Sources/UI/Place/PlaceList/View/PlaceListViewController.swift index f3878835..9452de9e 100644 --- a/Projects/App/Sources/UI/Place/PlaceList/View/PlaceListViewController.swift +++ b/Projects/App/Sources/UI/Place/PlaceList/View/PlaceListViewController.swift @@ -138,9 +138,21 @@ extension PlaceListViewController: QuestionButtonTapDelegate, UIAdaptivePresenta func addPlaceButtonTapped() { navigationController?.pushViewController(AddPlaceSearchViewController(viewModel: AddPlaceSearchViewModel()), animated: true) } - - @objc func orgDetailButtonTapped() { - navigationController?.pushViewController(OrgDetailViewController(viewModel: OrgDetailViewModel(orgId: UserInfoManager.userInfo?.userOrganization ?? 400)), animated: true) + + @objc func orgDetailButtonTapped() throws { + + if let orgId = UserInfoManager.userInfo?.userOrganization.first { + navigationController?.pushViewController(OrgDetailViewController(viewModel: OrgDetailViewModel(orgId: orgId)), + animated: true) + } else { + let alert = UIAlertController(title: "인증대학없음", + message: "등록되어 있는 대학 정보가 없습니다", + preferredStyle: .alert) + let okAction = UIAlertAction(title: "닫기", style: .default) + alert.addAction(okAction) + self.present(alert, animated: false) + } + FirebaseAnalytics.Analytics.logEvent(AnalyticsEventSelectItem, parameters: [ AnalyticsParameterItemListName: "org_detail_button" ]) @@ -241,7 +253,7 @@ extension PlaceListViewController { let placeTitle = UILabel() let tapGesture = UITapGestureRecognizer(target: self, action: #selector(orgDetailButtonTapped)) - placeTitle.text = "애플디벨로퍼아카데미" + placeTitle.text = UserInfoManager.userInfo?.userOrgName ?? "(인증대학없음)" placeTitle.font = .systemFont(ofSize: 17, weight: .bold) placeTitle.isUserInteractionEnabled = true placeTitle.addGestureRecognizer(tapGesture) diff --git a/Projects/App/Sources/UI/Place/PlaceList/View/Views/ExplanationPopOverViewController.swift b/Projects/App/Sources/UI/Place/PlaceList/View/Views/ExplanationPopOverViewController.swift index b1d8af6c..b2b0a9fd 100644 --- a/Projects/App/Sources/UI/Place/PlaceList/View/Views/ExplanationPopOverViewController.swift +++ b/Projects/App/Sources/UI/Place/PlaceList/View/Views/ExplanationPopOverViewController.swift @@ -15,7 +15,6 @@ final class ExplanationPopOverViewController: UIViewController { // MARK: - Properties private var explanationLabel = UILabel() - // MARK: - LifeCycle override func viewDidLoad() { diff --git a/Projects/Network/Sources/API/PlaceAPI.swift b/Projects/Network/Sources/API/PlaceAPI.swift index 2e774748..1bfe4da5 100644 --- a/Projects/Network/Sources/API/PlaceAPI.swift +++ b/Projects/Network/Sources/API/PlaceAPI.swift @@ -13,16 +13,16 @@ public struct PlaceAPI { static let networkService = NetworkService() - public static func fetchPlaceList(with page: Int) -> AnyPublisher { - let header = ["Content-Type": "application/json"] + public static func fetchPlaceList(with page: Int, authorization: String) -> AnyPublisher { + let header = ["Content-Type": "application/json", "Authorization": "\(authorization)"] let query = ["cursor": "\(page)"] let endpoint = Endpoint(path: "/api/places", queryParams: query, headers: header) return networkService.request(with: endpoint, responseType: PlaceListDTO.self) } - public static func fetchHotPlaceList(with page: Int) -> AnyPublisher { - let header = ["Content-Type": "application/json"] + public static func fetchHotPlaceList(with page: Int, authorization: String) -> AnyPublisher { + let header = ["Content-Type": "application/json", "Authorization": "\(authorization)"] let query = ["cursor": "\(page)"] let endpoint = Endpoint(path: "/api/places/goods", queryParams: query, headers: header) @@ -37,10 +37,11 @@ public struct PlaceAPI { return networkService.request(with: endpoint, responseType: KakaoPlaceListDTO.self) } - public static func checkRegisterdPlace(kakaoPlaceId: Int) -> AnyPublisher { + public static func checkRegisterdPlace(kakaoPlaceId: Int, orgId: Int) -> AnyPublisher { let header = ["Content-Type": "application/json"] - let endpoint = Endpoint(path: "/api/places/kakaoPlace/\(kakaoPlaceId)/registered", headers: header) + let query = ["organizationId": "\(orgId)"] + let endpoint = Endpoint(path: "/api/places/kakaoPlace/\(kakaoPlaceId)/registered", queryParams: query, headers: header) return networkService.request(with: endpoint, responseType: Bool.self) } diff --git a/Projects/Network/Sources/API/UserAPI.swift b/Projects/Network/Sources/API/UserAPI.swift index b3605c5b..e65686a1 100644 --- a/Projects/Network/Sources/API/UserAPI.swift +++ b/Projects/Network/Sources/API/UserAPI.swift @@ -17,7 +17,6 @@ public struct UserAPI { let header = ["Content-Type": "application/json", "Authorization": "\(authorization)"] let user = ["email": userDTO.email, "organizationName": userDTO.organizationName] let endpoint = Endpoint(path: "/api/users", method: .post, bodyParams: user, headers: header) - return networkService.request(with: endpoint) } @@ -77,7 +76,6 @@ public struct UserAPI { public static func postSendCode(email: String) -> AnyPublisher { let header = ["Content-Type": "application/json"] let endpoint = Endpoint(path: "/api/users/send/verifyCode", method: .post, bodyParams: ["email": email], headers: header) - return networkService.request(with: endpoint) } diff --git a/Projects/Network/Sources/DTO/RequestDTO/SignUpUserDTO.swift b/Projects/Network/Sources/DTO/RequestDTO/SignUpUserDTO.swift index 124159c9..3838c039 100644 --- a/Projects/Network/Sources/DTO/RequestDTO/SignUpUserDTO.swift +++ b/Projects/Network/Sources/DTO/RequestDTO/SignUpUserDTO.swift @@ -9,12 +9,10 @@ import Foundation public struct SignUpUserDTO: Encodable { - public let id: Int public let email: String public let organizationName: String - public init(id: Int, email: String, organizationName: String) { - self.id = id + public init(email: String, organizationName: String) { self.email = email self.organizationName = organizationName } diff --git a/Projects/Network/Sources/DTO/ResponseDTO/User/UserProfileDTO.swift b/Projects/Network/Sources/DTO/ResponseDTO/User/UserProfileDTO.swift index 59a23575..3dcaec58 100644 --- a/Projects/Network/Sources/DTO/ResponseDTO/User/UserProfileDTO.swift +++ b/Projects/Network/Sources/DTO/ResponseDTO/User/UserProfileDTO.swift @@ -13,7 +13,7 @@ public struct UserProfileDTO: Decodable { public let nickname: String? public let email: String? public let social: String - public let organization: Int? + public let organization: [Int] public let deletedAt: String? public let createdAt: String public let updatedAt: String diff --git a/Projects/Network/Sources/Service/NetworkService.swift b/Projects/Network/Sources/Service/NetworkService.swift index 22785701..069f2057 100644 --- a/Projects/Network/Sources/Service/NetworkService.swift +++ b/Projects/Network/Sources/Service/NetworkService.swift @@ -54,7 +54,7 @@ extension NetworkService { -> AnyPublisher { do { let request = try endpoint.urlRequest() - + return session.dataTaskPublisher(for: request) .tryMap({ (data, response) in if let error = self.checkError(data: data, response: response) {