Skip to content

Commit

Permalink
[Merge] #159 - 컨플릭트 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
0inn committed Apr 20, 2023
2 parents a01c3c5 + 3578d6b commit e0e4302
Show file tree
Hide file tree
Showing 38 changed files with 379 additions and 175 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public extension Project {
"App Transport Security Settings": ["Allow Arbitrary Loads": true],
"NSAppTransportSecurity": ["NSAllowsArbitraryLoads": true],
"ITSAppUsesNonExemptEncryption": false,
"UIUserInterfaceStyle": "Light",
"UIUserInterfaceStyle": "Dark",
"NSPhotoLibraryUsageDescription": "미션과 관련된 사진을 업로드하기 위해 갤러리 권한이 필요합니다.",
"CFBundleURLTypes": [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension SettingsDictionary {

static let baseSettings: Self = [
"OTHER_LDFLAGS" : [
"-Xlinker -interposable"
"$(inherited)"
]
]

Expand Down
19 changes: 14 additions & 5 deletions SOPT-iOS/Projects/Core/Sources/Enum/AttendanceStateType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@

import Foundation

public enum AttendanceStateType: String, CaseIterable {
case all = "전체"
case attendance = "출석"
case tardy = "지각"
case absent = "결석"
public enum AttendanceStateType: String {
case attendance
case tardy
case absent
case participate

public var korean: String {
switch self {
case .attendance: return "출석"
case .tardy: return "지각"
case .absent: return "결석"
case .participate: return "참여"
}
}
}
11 changes: 7 additions & 4 deletions SOPT-iOS/Projects/Core/Sources/Enum/UserType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import Foundation

public enum UserType {
case visitor // 비회원
case active // 활동 회원
case inactive // 비활동 회원
public enum UserType: String {
case visitor = "UNAUTHENTICATED" // 비회원
case active = "ACTIVE" // 활동 회원
case inactive = "INACTIVE" // 비활동 회원
case unregisteredInactive = "UNREGISTERED" // 비활동 회원 + 플그 프로필 미등록

public func makeDescription(recentHistory: Int) -> String {
switch self {
Expand All @@ -21,6 +22,8 @@ public enum UserType {
return "\(recentHistory)\(I18N.Main.active)"
case .inactive:
return "\(recentHistory)\(I18N.Main.inactive)"
case .unregisteredInactive:
return I18N.Main.inactiveMember
}
}
}
4 changes: 4 additions & 0 deletions SOPT-iOS/Projects/Core/Sources/Literals/ExternalURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public struct ExternalURL {
public static let findEmail = "https://forms.gle/XkVFMUPsWWV1DXU38"
}

public struct SOPT {
public static let project = "https://sopt.org/project"
}

public struct Playground {
#if DEV || PROD
public static let main = "https://playground.sopt.org"
Expand Down
2 changes: 2 additions & 0 deletions SOPT-iOS/Projects/Core/Sources/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public struct I18N {
public static let encourage = "안녕하세요, \nSOPT의 열정이 되어주세요!"
public static let hello = "안녕하세요"
public static let welcome = "안녕하세요, \nSOPT에 오신 것을 환영합니다!"
public static let failedToGetUserInfo = "활동 정보를 가져올 수 없어요."
public static let needToRegisterPlayground = "플레이그라운드에서 프로필을 업데이트하면\n 서비스를 원활하게 사용할 수 있어요."

public static func userHistory(name: String, months: String) -> String {
return "\(name) 님은 \nSOPT와 \(months)개월째"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,36 @@ public class ShowAttendanceRepository {
extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface {
public func fetchAttendanceScheduleModel() -> AnyPublisher<AttendanceScheduleModel, Error> {
// return Future<AttendanceScheduleModel, Error> { promise in
//// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
//// location: "단국대학교 혜당관",
//// name: "3차 세미나",
//// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
//// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
//// TodayAttendanceModel(status: "ABSENT", attendedAt:
//// "2023-04-13T14:10:04")])))
//
// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
// location: "한국대학교 혜당관",
// name: "2차 행사",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00",
// message: "행사도 참여하고, 출석점수도 받고, 일석이조!",
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")])))
//
//// promise(.success(AttendanceScheduleModel(type: "NO_SESSION",
//// location: "",
//// name: "",
//// startDate: "", endDate: "", message: "",
//// attendances: [TodayAttendanceModel(status: "", attendedAt: ""),
//// TodayAttendanceModel(status: "", attendedAt: "")])))
// }
// .eraseToAnyPublisher()
// location: "솝트대학교 IT 창업관",
// name: "3차 세미나",
// startDate: "2023-04-29T14:00:00", endDate: "2023-04-29T18:00:00",
// message: "",
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-29T14:00:00"),
// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-29T14:02:00")])))
// }.eraseToAnyPublisher()

return self.attendanceService.fetchAttendanceSchedule()
.compactMap { $0.data?.toDomain() }
.eraseToAnyPublisher()
.compactMap { $0.data?.toDomain() }
.eraseToAnyPublisher()
}

public func fetchAttendanceScoreModel() -> AnyPublisher<Domain.AttendanceScoreModel, Error> {
// return Future<AttendanceScoreModel, Error> { promise in
// promise(.success(AttendanceScoreModel.init(part: "iOS",
// generation: 31,
// name: "윤수빈",
// score: 2.0,
// total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1),
// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"),
// AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")])))
// promise(.success(AttendanceScoreModel.init(part: "디자인",
// generation: 32,
// name: "김솝트",
// score: 1.0,
// total: TotalScoreModel(attendance: 2, absent: 1, tardy: 1, participate: 1),
// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "PARTICIPATE", date: "4월 22일"),
// AttendanceModel(attribute: "ETC", name: "1차 행사", status: "ATTENDANCE", date: "4월 15일"),
// AttendanceModel(attribute: "SEMINAR", name: "2차 세미나", status: "ATTENDANCE", date: "4월 08일"),
// AttendanceModel(attribute: "SEMINAR", name: "1차 세미나", status: "ABSENT", date: "4월 01일"),
// AttendanceModel(attribute: "ETC", name: "OT", status: "TARDY", date: "3월 25일")])))
// }.eraseToAnyPublisher()

return self.attendanceService.fetchAttendanceScore()
.compactMap{ $0.data?.toDomain() }
.eraseToAnyPublisher()
.compactMap{ $0.data?.toDomain() }
.eraseToAnyPublisher()
}
}
16 changes: 11 additions & 5 deletions SOPT-iOS/Projects/Data/Sources/Repository/SignInRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ public class SignInRepository {
}

extension SignInRepository: SignInRepositoryInterface {

public func requestSignIn(token: String) -> AnyPublisher<Bool, Never> {
public func requestSignIn(token: String) -> AnyPublisher<Bool, Error> {
authService.signIn(token: token)
.catch({ _ in
return self.userService.reissuance()
.catch ({ error in
guard
let error = error as? SOPTAPPError,
case .network(let statusCode) = error,
statusCode == 400
else {
return self.userService.reissuance()
}

return Fail(error: error).eraseToAnyPublisher()
})
.map { entity in
UserDefaultKeyList.Auth.appAccessToken = entity.accessToken
Expand All @@ -43,7 +50,6 @@ extension SignInRepository: SignInRepositoryInterface {
: false
return true
}
.replaceError(with: false)
.withUnretained(self)
.flatMap { owner, isSuccessed in
guard isSuccessed else {
Expand Down
15 changes: 15 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/Model/UserMainInfoModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import Foundation

import Core

public struct UserMainInfoModel {
public let status, name: String
public let profileImage: String?
Expand All @@ -17,6 +19,19 @@ public struct UserMainInfoModel {
public let responseMessage: String?
public var withError: Bool = false

public var userType: UserType {
switch status {
case "": // 플그 미등록인 경우
return .unregisteredInactive
case UserType.active.rawValue:
return .active
case UserType.inactive.rawValue:
return .inactive
default:
return .visitor
}
}

public init(status: String, name: String, profileImage: String?, historyList: [Int], attendanceScore: Float?, announcement: String?, responseMessage: String?) {
self.status = status
self.name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import Combine
// TODO: - User 유형 설정 방식 생각하기

public protocol SignInRepositoryInterface {
func requestSignIn(token: String) -> AnyPublisher<Bool, Never>
func requestSignIn(token: String) -> AnyPublisher<Bool, Error>
}
12 changes: 12 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/MainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extension DefaultMainUseCase: MainUseCase {
.sink { event in
print("MainUseCase: \(event)")
} receiveValue: { [weak self] userMainInfoModel in
self?.setUserType(with: userMainInfoModel?.userType)
self?.userMainInfo.send(userMainInfoModel)
}.store(in: self.cancelBag)
}
Expand All @@ -49,4 +50,15 @@ extension DefaultMainUseCase: MainUseCase {
self?.serviceState.send(serviceStateModel)
}.store(in: self.cancelBag)
}

private func setUserType(with userType: UserType?) {
switch userType {
case .none, .unregisteredInactive, .inactive: // nil인 경우도 플그 미등록 유저로 취급
UserDefaultKeyList.Auth.isActiveUser = false
case .active:
UserDefaultKeyList.Auth.isActiveUser = true
default:
UserDefaultKeyList.Auth.isActiveUser = false
}
}
}
25 changes: 20 additions & 5 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/SignInUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ import Combine

import Core

// NOTE: unregistered 없어지면 당장 삭제할거임
public enum SiginInHandleableType {
case loginSuccess
case loginFailure
case unregistedProfile
}

public protocol SignInUseCase {
func requestSignIn(token: String)
var signInSuccess: CurrentValueSubject<Bool, Error> { get set }
var signInSuccess: CurrentValueSubject<SiginInHandleableType, Error> { get set }
}

public class DefaultSignInUseCase {

private let repository: SignInRepositoryInterface
private var cancelBag = CancelBag()
public var signInSuccess = CurrentValueSubject<Bool, Error>(false)
public var signInSuccess = CurrentValueSubject<SiginInHandleableType, Error>(.loginFailure)

public init(repository: SignInRepositoryInterface) {
self.repository = repository
Expand All @@ -29,11 +36,19 @@ public class DefaultSignInUseCase {
extension DefaultSignInUseCase: SignInUseCase {
public func requestSignIn(token: String) {
repository.requestSignIn(token: token)
.replaceError(with: false)
.sink { event in
print("SignInUseCase: \(event)")
switch event {
case .failure(let error):
// NOTE: signin에서 400이 날아오는 경우는 현재 기준 한가지 경우.
// 4월 19일 기준으로 대응됨. 만약 다르게 날아오거나 에러스펙을 새로 정의하는 경우 다시 리팩토링 해야 함.
// @승호. 2023 04 19

self.signInSuccess.send(.unregistedProfile)
case .finished:
print("SignInUseCase: \(event)")
}
} receiveValue: { isSuccessed in
self.signInSuccess.send(isSuccessed)
self.signInSuccess.send(isSuccessed ? .loginSuccess : .loginFailure)
}.store(in: self.cancelBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ public final class AppMyPageVC: UIViewController, AppMyPageViewControllable {
frame: self.view.frame
)

// MARK: For UnregisteredInActive

private lazy var etcForUnregisteredInActiveSectionGroup = MypageSectionGroupView(
headerTitle: I18N.MyPage.etcSectionGroupTitle,
subviews: [
self.logoutListItem,
self.withDrawalListItem
],
frame: self.view.frame
)

public init(
userType: UserType,
viewModel: AppMyPageViewModel,
Expand Down Expand Up @@ -187,6 +198,12 @@ extension AppMyPageVC {
self.servicePolicySectionGroup,
self.etcForVisitorsSectionGroup
)

case .unregisteredInactive:
self.contentStackView.addArrangedSubviews(
self.servicePolicySectionGroup,
self.etcForUnregisteredInActiveSectionGroup
)
}
}

Expand Down Expand Up @@ -264,7 +281,9 @@ extension AppMyPageVC {
}

self.withDrawalListItem.addTapGestureRecognizer {
let viewController = self.factory.makeWithdrawalVC().viewController
let viewController = self.factory.makeWithdrawalVC(
userType: self.userType
).viewController
self.navigationController?.pushViewController(viewController, animated: true)
}

Expand Down
Loading

0 comments on commit e0e4302

Please sign in to comment.