Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-221] 기존 User API 최신화, OnboardingFlow 중 회원가입 연결 #63

Merged
merged 9 commits into from
Feb 10, 2025
8 changes: 0 additions & 8 deletions TnT/Projects/Domain/Sources/DTO/User/UserRequestDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,18 @@ public struct PostSocialLoginReqDTO: Encodable {
let fcmToken: String
/// 소셜 액세스 토큰
let socialAccessToken: String?
/// 애플 인가 코드 (Apple 로그인 시 필요)
let authorizationCode: String?
/// 애플 ID 토큰 (Apple 로그인 시 필요)
let idToken: String?

public init(
socialType: String,
fcmToken: String,
socialAccessToken: String?,
authorizationCode: String?,
idToken: String?
) {
self.socialType = socialType
self.fcmToken = fcmToken
self.socialAccessToken = socialAccessToken
self.authorizationCode = authorizationCode
self.idToken = idToken
}
}
Expand All @@ -54,8 +50,6 @@ public struct PostSignUpReqDTO: Encodable {
let collectionAgreement: Bool
/// 광고성 알림 수신 동의 여부
let advertisementAgreement: Bool
/// 푸시 알림 수신 동의 여부
let pushAgreement: Bool
/// 회원 이름
let name: String
/// 생년월일 (yyyy-MM-dd)
Expand All @@ -78,7 +72,6 @@ public struct PostSignUpReqDTO: Encodable {
serviceAgreement: Bool,
collectionAgreement: Bool,
advertisementAgreement: Bool,
pushAgreement: Bool,
name: String,
birthday: String?,
height: Double?,
Expand All @@ -94,7 +87,6 @@ public struct PostSignUpReqDTO: Encodable {
self.serviceAgreement = serviceAgreement
self.collectionAgreement = collectionAgreement
self.advertisementAgreement = advertisementAgreement
self.pushAgreement = pushAgreement
self.name = name
self.birthday = birthday
self.height = height
Expand Down
24 changes: 20 additions & 4 deletions TnT/Projects/Domain/Sources/DTO/User/UserResponseDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,29 @@ public struct PostSocialLoginResDTO: Decodable {
/// 세션 ID
public let sessionId: String?
/// 소셜 로그인 ID
public let socialId: String
public let socialId: String?
/// 소셜 이메일
public let socialEmail: String
public let socialEmail: String?
/// 소셜 로그인 타입 (KAKAO, APPLE)
public let socialType: String
public let socialType: String?
/// 가입 여부 (`true`: 이미 가입됨, `false`: 미가입)
public let isSignUp: Bool
/// 회원 타입 (TRAINER, TRAINEE, UNREGISTERED)
public let memberType: MemberTypeResDTO
}

/// Trainer, Trainee, Unregistered로 구분되는 MemberTypeDTO
public enum MemberTypeResDTO: String, Decodable {
case trainer = "TRAINER"
case trainee = "TRAINEE"
case unregistered = "UNREGISTERED"
case unknown = ""

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let rawValue = try container.decode(String.self)
self = MemberTypeResDTO(rawValue: rawValue) ?? .unknown
}
}

/// 회원 정보 응답 DTO
Expand All @@ -31,5 +47,5 @@ public struct PostSignUpResDTO: Decodable {
/// 회원 이름
let name: String
/// 프로필 이미지 URL
let profileImageUrl: String
let profileImageUrl: String?
}
89 changes: 89 additions & 0 deletions TnT/Projects/Domain/Sources/Entity/SignUpEntity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// SignUpEntity.swift
// Domain
//
// Created by 박민서 on 2/8/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// 회원가입 요청 DTO
public struct PostSignUpEntity: Equatable {
/// FCM 토큰
public var fcmToken: String?
/// 회원 타입 (trainer, trainee)
public var memberType: UserType?
/// 소셜 로그인 타입 (KAKAO, APPLE)
public var socialType: SocialType?
/// 소셜 로그인 ID
public var socialId: String?
/// 소셜 로그인 이메일
public var socialEmail: String?
/// 서비스 이용 약관 동의 여부
public var serviceAgreement: Bool
/// 개인정보 수집 동의 여부
public var collectionAgreement: Bool
/// 광고성 알림 수신 동의 여부
public var advertisementAgreement: Bool
/// 회원 이름
public var name: String?
/// 프로필 이미지 데이터
public var imageData: Data?
/// 생년월일 (yyyy-MM-dd)
public var birthday: String?
/// 키 (cm)
public var height: Double?
/// 몸무게 (kg, 소수점 1자리까지 가능)
public var weight: Double?
/// 트레이너에게 전달할 주의사항
public var cautionNote: String?
/// PT 목적 (체중 감량, 근력 향상 등)
public var goalContents: [String]?

public init(
fcmToken: String? = nil,
memberType: UserType? = nil,
socialType: SocialType? = nil,
socialId: String? = nil,
socialEmail: String? = nil,
serviceAgreement: Bool = false,
collectionAgreement: Bool = false,
advertisementAgreement: Bool = false,
name: String? = nil,
imageData: Data? = nil,
birthday: String? = nil,
height: Double? = nil,
weight: Double? = nil,
cautionNote: String? = nil,
goalContents: [String]? = nil
) {
self.fcmToken = fcmToken
self.memberType = memberType
self.socialType = socialType
self.socialId = socialId
self.socialEmail = socialEmail
self.serviceAgreement = serviceAgreement
self.collectionAgreement = collectionAgreement
self.advertisementAgreement = advertisementAgreement
self.name = name
self.imageData = imageData
self.birthday = birthday
self.height = height
self.weight = weight
self.cautionNote = cautionNote
self.goalContents = goalContents
}
}

/// 회원가입 응답 DTO
public struct PostSignUpResEntity: Equatable, Sendable {
/// 회원 타입 (trainer, trainee)
public let memberType: String
/// 세션 id
public let sessionId: String
/// 회원 이름
public let name: String
/// 프로필 이미지 URL
public let profileImageUrl: String?
}
95 changes: 14 additions & 81 deletions TnT/Projects/Domain/Sources/Entity/SocailLoginEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@

import Foundation

public enum SocialType: String {
case kakao = "KAKAO"
case apple = "APPLE"
}

/// 소셜 로그인 요청 DTO
public struct PostSocailEntity: Equatable {
public struct PostSocialEntity: Equatable {
/// 소셜 로그인 타입 (KAKAO, APPLE)
let socialType: String
let socialType: SocialType
/// FCM 토큰
let fcmToken: String
/// 소셜 액세스 토큰
let socialAccessToken: String?
/// 애플 인가 코드 (Apple 로그인 시 필요)
let authorizationCode: String?
/// 애플 ID 토큰 (Apple 로그인 시 필요)
/// 애플 ID 토큰 (Apple z로그인 시 필요)
let idToken: String?

public init(
socialType: String,
socialType: SocialType,
fcmToken: String,
socialAccessToken: String?,
authorizationCode: String?,
idToken: String?
socialAccessToken: String? = nil,
idToken: String? = nil
) {
self.socialType = socialType
self.fcmToken = fcmToken
self.socialAccessToken = socialAccessToken
self.authorizationCode = authorizationCode
self.idToken = idToken
}
}
Expand All @@ -41,79 +42,11 @@ public struct PostSocialLoginResEntity: Equatable {
/// 세션 ID
public let sessionId: String?
/// 소셜 로그인 ID
public let socialId: String
public let socialId: String?
/// 소셜 이메일
public let socialEmail: String
public let socialEmail: String?
/// 소셜 로그인 타입 (KAKAO, APPLE)
public let socialType: String
public let socialType: String?
/// 가입 여부 (`true`: 이미 가입됨, `false`: 미가입)
public let isSignUp: Bool
}

/// 회원가입 요청 DTO
public struct PostSignUpReqEntity {
/// FCM 토큰
let fcmToken: String
/// 회원 타입 (trainer, trainee)
let memberType: String
/// 소셜 로그인 타입 (KAKAO, APPLE)
let socialType: String
/// 소셜 로그인 ID
let socialId: String
/// 소셜 로그인 이메일
let socialEmail: String
/// 서비스 이용 약관 동의 여부
let serviceAgreement: Bool
/// 개인정보 수집 동의 여부
let collectionAgreement: Bool
/// 광고성 알림 수신 동의 여부
let advertisementAgreement: Bool
/// 푸시 알림 수신 동의 여부
let pushAgreement: Bool
/// 회원 이름
let name: String
/// 생년월일 (yyyy-MM-dd)
let birthday: String?
/// 키 (cm)
let height: Double?
/// 몸무게 (kg, 소수점 1자리까지 가능)
let weight: Double?
/// 트레이너에게 전달할 주의사항
let cautionNote: String?
/// PT 목적 (체중 감량, 근력 향상 등)
let goalContents: [String]?

public init(
fcmToken: String,
memberType: String,
socialType: String,
socialId: String,
socialEmail: String,
serviceAgreement: Bool,
collectionAgreement: Bool,
advertisementAgreement: Bool,
pushAgreement: Bool,
name: String,
birthday: String?,
height: Double?,
weight: Double?,
cautionNote: String?,
goalContents: [String]?
) {
self.fcmToken = fcmToken
self.memberType = memberType
self.socialType = socialType
self.socialId = socialId
self.socialEmail = socialEmail
self.serviceAgreement = serviceAgreement
self.collectionAgreement = collectionAgreement
self.advertisementAgreement = advertisementAgreement
self.pushAgreement = pushAgreement
self.name = name
self.birthday = birthday
self.height = height
self.weight = weight
self.cautionNote = cautionNote
self.goalContents = goalContents
}
}
9 changes: 9 additions & 0 deletions TnT/Projects/Domain/Sources/Entity/UserType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ public extension UserType {
return "트레이니"
}
}

var englishName: String {
switch self {
case .trainer:
return "trainer"
case .trainee:
return "trainee"
}
}
}
Loading