Skip to content

Commit 6c3a9e3

Browse files
authored
Merge pull request #123 from DeveloperAcademy-POSTECH/hofix/auth/ZES-175
[Hotfix] ์„œ๋ฒ„API ๋ณ€๋™์— ๋”ฐ๋ฅธ ์˜ค๋ฅ˜ ์ˆ˜์ •
2 parents 498acc6 + 1767bcc commit 6c3a9e3

File tree

15 files changed

+55
-44
lines changed

15 files changed

+55
-44
lines changed

โ€ŽProjects/App/Sources/Domain/Organization/VerifingCodeUseCase.swiftโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class VerifingCodeUseCase {
4040
func postSignUp(email: String, orgnization: Organization) {
4141
guard let authorization = KeyChainManager.read(key: .authToken) else { return }
4242

43-
let userDTO = SignUpUserDTO(id: orgnization.id, email: email, organizationName: orgnization.name)
43+
let userDTO = SignUpUserDTO(email: email, organizationName: orgnization.name)
4444

4545
UserAPI.postSignUp(authorization: authorization, userDTO: userDTO)
4646
.sink { [weak self] error in

โ€ŽProjects/App/Sources/Domain/Place/AddPlace/AddPlaceUseCase.swiftโ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Network
1212

1313
protocol AddPlaceUseCaseType {
1414
func searchKakaoPlaces(with name: String) -> AnyPublisher<[KakaoPlace], Error>
15-
// func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher<Bool, Error>
1615
func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher<Bool, AddPlaceError>
1716
func fetchCategories() -> AnyPublisher<[Category], Error>
1817
func addNewPlace(with place: KakaoPlace, category: Int) -> AnyPublisher<PlaceResult, Error>
@@ -29,7 +28,7 @@ final class AddPlaceUseCase: AddPlaceUseCaseType {
2928
func addNewPlace(with place: KakaoPlace, category: Int) -> AnyPublisher<PlaceResult, Error> {
3029

3130
let user = UserInfoManager.userInfo?.userID ?? 64
32-
let org = UserInfoManager.userInfo?.userOrganization ?? 400
31+
let org = UserInfoManager.userInfo?.userOrganization[0] ?? 400
3332
let placeDTO = PlacePostDTO(address: place.address,
3433
name: place.placeName,
3534
latitude: place.lat,
@@ -91,7 +90,9 @@ final class AddPlaceUseCase: AddPlaceUseCaseType {
9190
*/
9291

9392
func checkRegisterdPlace(with kakaoPlaceId: Int) -> AnyPublisher<Bool, AddPlaceError> {
94-
PlaceAPI.checkRegisterdPlace(kakaoPlaceId: kakaoPlaceId)
93+
guard let orgId = UserInfoManager.userInfo?.userOrganization else { return Fail(error: AddPlaceError.none).eraseToAnyPublisher() }
94+
95+
return PlaceAPI.checkRegisterdPlace(kakaoPlaceId: kakaoPlaceId, orgId: orgId[0])
9596
.mapError { _ -> AddPlaceError in
9697
return .none
9798
}.eraseToAnyPublisher()

โ€ŽProjects/App/Sources/Domain/Place/PlaceSearch/PlaceSearchUseCase.swiftโ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ final class PlaceSearchUseCase: PlaceSearchUseCaseType {
2121

2222
func searchPlaces(with placeName: String) -> AnyPublisher<[Place], Error> {
2323

24-
// TODO: ORG-ID ๋„ฃ๊ณ  ๊ต์ฒด ํ•„์š”
25-
let orgId = UserInfoManager.userInfo?.userOrganization ?? 400
24+
let orgId = UserInfoManager.userInfo?.userOrganization[0] ?? 400
2625

2726
PlaceAPI.fetchSearchPlaceResults(orgId: orgId, placeName: placeName)
2827
.sink { error in

โ€ŽProjects/App/Sources/Domain/Place/PlaceUseCase.swiftโ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ final class PlaceListUseCase {
1515
func fetchPlaceList(with page: Int, type: PlaceType) -> AnyPublisher<[Place], NetworkError> {
1616
let api: AnyPublisher<PlaceListDTO, NetworkError>
1717

18+
guard let authorization = KeyChainManager.read(key: .authToken) else { return Fail(error: NetworkError.unauthorized("๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค")).eraseToAnyPublisher() }
19+
1820
switch type {
1921
case .whole:
20-
api = PlaceAPI.fetchPlaceList(with: page)
22+
api = PlaceAPI.fetchPlaceList(with: page, authorization: authorization)
2123
case .hot:
22-
api = PlaceAPI.fetchHotPlaceList(with: page)
24+
api = PlaceAPI.fetchHotPlaceList(with: page, authorization: authorization)
2325
}
2426

2527
return api

โ€ŽProjects/App/Sources/Domain/User/UserInfoManager.swiftโ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class UserInfoManager {
1919

2020
struct UserInfo: Codable {
2121

22-
init(userNickname: String? = nil, userID: Int? = nil, userOrganization: Int? = nil, userOrgName: String? = nil ) {
22+
init(userNickname: String? = nil, userID: Int? = nil, userOrganization: [Int] = [], userOrgName: String? = nil ) {
2323
UserInfoManager.userInfo?.userNickname = userNickname
2424
UserInfoManager.userInfo?.userID = userID
2525
UserInfoManager.userInfo?.userOrganization = userOrganization
@@ -48,10 +48,10 @@ final class UserInfoManager {
4848
UserDefaults.standard.set(newValue, forKey: UserInfoKeys.userID.rawValue)
4949
}
5050
}
51-
var userOrganization: Int? {
51+
var userOrganization: [Int] {
5252
get {
53-
guard let userOrganization = UserDefaults.standard.value(forKey: UserInfoKeys.userOrganization.rawValue) as? Int else {
54-
return nil
53+
guard let userOrganization = UserDefaults.standard.value(forKey: UserInfoKeys.userOrganization.rawValue) as? [Int] else {
54+
return []
5555
}
5656
return userOrganization
5757
}
@@ -93,7 +93,7 @@ final class UserInfoManager {
9393
UserInfoManager.userInfo = UserInfo()
9494
}
9595

96-
static func initialUserInfo(userNickname: String?, userID: Int?, userOrganization: Int?, userOrgName: String?) {
96+
static func initialUserInfo(userNickname: String?, userID: Int?, userOrganization: [Int], userOrgName: String?) {
9797
UserInfoManager.userInfo = UserInfo()
9898
UserInfoManager.userInfo?.userNickname = userNickname
9999
UserInfoManager.userInfo?.userID = userID

โ€ŽProjects/App/Sources/UI/Organization/DomainSetting/View/DomainSettingViewController.swiftโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ final class DomainSettingViewController: UIViewController {
7777
let orgID = viewModel.organization.id
7878
let orgName = viewModel.organization.name
7979
UserInfoManager.userInfo?.userOrgName = orgName
80-
UserInfoManager.userInfo?.userOrganization = orgID
80+
UserInfoManager.userInfo?.userOrganization = [orgID]
8181
navigationController?.pushViewController(DomainSettingCompleteViewController(), animated: true)
8282
}
8383
}

โ€ŽProjects/App/Sources/UI/Organization/OrgDetail/View/OrgDetailViewController.swiftโ€Ž

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class OrgDetailViewController: UIViewController {
2525
private let orgInformationStackView3 = UIStackView()
2626
private let orgInfoImageView1 = UIImageView()
2727
private let orgInfoImageView2 = UIImageView()
28-
private let orgInfoImageView3 = UIImageView()
28+
// private let orgInfoImageView3 = UIImageView()
2929
private let orgInviteButton = FullWidthBlackButton()
3030

3131
private var orgDetailInformationView1 = OrgDetailInformationView()
@@ -121,7 +121,7 @@ extension OrgDetailViewController {
121121
orgDetailInformationView2 = OrgDetailInformationView()
122122
orgDetailInformationView3 = OrgDetailInformationView()
123123

124-
orgNameLabel.text = "์• ํ”Œ ๋””๋ฒจ๋กœํผ ์•„์นด๋ฐ๋ฏธ"
124+
orgNameLabel.text = UserInfoManager.userInfo?.userOrgName ?? "(์ธ์ฆ๋Œ€ํ•™์—†์Œ)"
125125
orgNameLabel.textColor = .black
126126
orgNameLabel.font = UIFont.systemFont(ofSize: CGFloat(26), weight: .bold)
127127
orgNameLabel.textAlignment = .center
@@ -158,11 +158,12 @@ extension OrgDetailViewController {
158158
orgDetailInformationView2.informationLabel.text = "๋“ฑ๋ก๋œ ๋ง›์ง‘"
159159
orgDetailInformationView2.numberLabel.text = "0๊ณณ"
160160

161-
orgInfoImageView3.image = UIImage(.img_reviewfriends_photo)
162-
orgInfoImageView3.contentMode = .scaleAspectFit
163-
orgInfoImageView3.layer.applyFigmaShadow(color: .black, opacity: 0.1, xCoord: 0, yCoord: 0, blur: 5, spread: 0)
164-
orgDetailInformationView3.informationLabel.text = "์—…๋กœ๋“œ๋œ ์‚ฌ์ง„"
165-
orgDetailInformationView3.numberLabel.text = "0๊ฐœ"
161+
// TODO: - ๋ฐฑ์—”๋“œ ์ž‘์—… ์™„๋ฃŒ ํ›„ ๋ณต๊ตฌ
162+
// orgInfoImageView3.image = UIImage(.img_reviewfriends_photo)
163+
// orgInfoImageView3.contentMode = .scaleAspectFit
164+
// orgInfoImageView3.layer.applyFigmaShadow(color: .black, opacity: 0.1, xCoord: 0, yCoord: 0, blur: 5, spread: 0)
165+
// orgDetailInformationView3.informationLabel.text = "์—…๋กœ๋“œ๋œ ์‚ฌ์ง„"
166+
// orgDetailInformationView3.numberLabel.text = "0๊ฐœ"
166167

167168
orgInviteButton.setTitle("์šฐ๋ฆฌํ•™๊ต ์‚ฌ๋žŒ๋“ค ์ดˆ๋Œ€ํ•˜๊ธฐ", for: .normal)
168169
orgInviteButton.addTarget(self, action: #selector(shareAppStoreLink), for: .touchUpInside)
@@ -173,7 +174,7 @@ extension OrgDetailViewController {
173174
orgInformationSuperStackView.addArrangedSubviews([orgInformationStackView1, orgInformationStackView2, orgInformationStackView3])
174175
orgInformationStackView1.addArrangedSubviews([orgInfoImageView1, orgDetailInformationView1])
175176
orgInformationStackView2.addArrangedSubviews([orgInfoImageView2, orgDetailInformationView2])
176-
orgInformationStackView3.addArrangedSubviews([orgInfoImageView3, orgDetailInformationView3])
177+
// orgInformationStackView3.addArrangedSubviews([orgInfoImageView3, orgDetailInformationView3])
177178

178179
orgNameLabel.snp.makeConstraints { make in
179180
make.top.equalTo(view.safeAreaLayoutGuide).inset(30)
@@ -206,9 +207,9 @@ extension OrgDetailViewController {
206207
make.width.height.equalTo(60)
207208
}
208209

209-
orgInfoImageView3.snp.makeConstraints { make in
210-
make.width.height.equalTo(60)
211-
}
210+
// orgInfoImageView3.snp.makeConstraints { make in
211+
// make.width.height.equalTo(60)
212+
// }
212213

213214
orgInviteButton.snp.makeConstraints { make in
214215
make.horizontalEdges.bottom.equalTo(view.safeAreaLayoutGuide).inset(20)

โ€ŽProjects/App/Sources/UI/Organization/VerifyCode/ViewModel/VerifingCodeViewModel.swiftโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extension VerifingCodeViewModel {
6868
let orgID = self.organization.id
6969
let orgName = self.organization.name
7070
UserInfoManager.userInfo?.userOrgName = orgName
71-
UserInfoManager.userInfo?.userOrganization = orgID
71+
UserInfoManager.userInfo?.userOrganization = (UserInfoManager.userInfo?.userOrganization ?? []) + [orgID]
7272
}
7373
self.isEmailOverlapedSubject.send(isEmailOverlaped)
7474
}

โ€ŽProjects/App/Sources/UI/Place/PlaceList/View/PlaceListViewController.swiftโ€Ž

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,21 @@ extension PlaceListViewController: QuestionButtonTapDelegate, UIAdaptivePresenta
138138
func addPlaceButtonTapped() {
139139
navigationController?.pushViewController(AddPlaceSearchViewController(viewModel: AddPlaceSearchViewModel()), animated: true)
140140
}
141-
142-
@objc func orgDetailButtonTapped() {
143-
navigationController?.pushViewController(OrgDetailViewController(viewModel: OrgDetailViewModel(orgId: UserInfoManager.userInfo?.userOrganization ?? 400)), animated: true)
141+
142+
@objc func orgDetailButtonTapped() throws {
143+
144+
if let orgId = UserInfoManager.userInfo?.userOrganization.first {
145+
navigationController?.pushViewController(OrgDetailViewController(viewModel: OrgDetailViewModel(orgId: orgId)),
146+
animated: true)
147+
} else {
148+
let alert = UIAlertController(title: "์ธ์ฆ๋Œ€ํ•™์—†์Œ",
149+
message: "๋“ฑ๋ก๋˜์–ด ์žˆ๋Š” ๋Œ€ํ•™ ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค",
150+
preferredStyle: .alert)
151+
let okAction = UIAlertAction(title: "๋‹ซ๊ธฐ", style: .default)
152+
alert.addAction(okAction)
153+
self.present(alert, animated: false)
154+
}
155+
144156
FirebaseAnalytics.Analytics.logEvent(AnalyticsEventSelectItem, parameters: [
145157
AnalyticsParameterItemListName: "org_detail_button"
146158
])
@@ -241,7 +253,7 @@ extension PlaceListViewController {
241253
let placeTitle = UILabel()
242254
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(orgDetailButtonTapped))
243255

244-
placeTitle.text = "์• ํ”Œ๋””๋ฒจ๋กœํผ์•„์นด๋ฐ๋ฏธ"
256+
placeTitle.text = UserInfoManager.userInfo?.userOrgName ?? "(์ธ์ฆ๋Œ€ํ•™์—†์Œ)"
245257
placeTitle.font = .systemFont(ofSize: 17, weight: .bold)
246258
placeTitle.isUserInteractionEnabled = true
247259
placeTitle.addGestureRecognizer(tapGesture)

โ€ŽProjects/App/Sources/UI/Place/PlaceList/View/Views/ExplanationPopOverViewController.swiftโ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ final class ExplanationPopOverViewController: UIViewController {
1515
// MARK: - Properties
1616
private var explanationLabel = UILabel()
1717

18-
1918
// MARK: - LifeCycle
2019

2120
override func viewDidLoad() {

0 commit comments

Comments
ย (0)