Skip to content

Commit 4fb63ad

Browse files
authored
Merge pull request #106 from YAPP-Github/TNT-302-TraineeMypage
[TNT-32] νŠΈλ ˆμ΄λ‹ˆ λ§ˆμ΄νŽ˜μ΄μ§€ 정보 μˆ˜μ • ν™”λ©΄ κ΅¬ν˜„ μ™„λ£Œ
2 parents 163684b + 50a805e commit 4fb63ad

File tree

16 files changed

+1140
-33
lines changed

16 files changed

+1140
-33
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@ Signing/
7777
master.key
7878

7979
# PList
80-
GoogleService-Info.plist
80+
GoogleService-Info.plist
81+
82+
# CLAUDE
83+
CLAUDE.md

β€ŽTnT/Projects/Data/Sources/Network/Service/User/UserRepositoryImpl.swiftβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,15 @@ public struct UserRepositoryImpl: UserRepository {
5555
public func getMyPageInfo() async throws -> GetMyPageInfoResDTO {
5656
return try await networkService.request(UserTargetType.getMyPageInfo, decodingType: GetMyPageInfoResDTO.self)
5757
}
58+
59+
/// νšŒμ› 정보 μˆ˜μ • μš”μ²­μ„ μˆ˜ν–‰
60+
public func putUpdateUserInfo(_ reqDTO: UpdateUserInfoRequestDTO, profileImage: Data?) async throws -> EmptyResponse {
61+
return try await networkService.request(
62+
UserTargetType.putUpdateUserInfo(
63+
reqDTO: reqDTO,
64+
imgData: profileImage
65+
),
66+
decodingType: EmptyResponse.self
67+
)
68+
}
5869
}

β€ŽTnT/Projects/Data/Sources/Network/Service/User/UserTargetType.swiftβ€Ž

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public enum UserTargetType {
2424
case postWithdrawal
2525
/// λ§ˆμ΄νŽ˜μ΄μ§€ 정보 μš”μ²­
2626
case getMyPageInfo
27+
/// νšŒμ› 정보 μˆ˜μ • μš”μ²­
28+
case putUpdateUserInfo(reqDTO: UpdateUserInfoRequestDTO, imgData: Data?)
2729
}
2830

2931
extension UserTargetType: TargetType {
@@ -35,20 +37,20 @@ extension UserTargetType: TargetType {
3537
switch self {
3638
case .getSessionCheck:
3739
return "/check-session"
38-
40+
3941
case .postSocialLogin:
4042
return "/login"
41-
43+
4244
case .postSignUp:
4345
return "/members/sign-up"
44-
46+
4547
case .postLogout:
4648
return "/logout"
47-
49+
4850
case .postWithdrawal:
4951
return "/members/withdraw"
50-
51-
case .getMyPageInfo:
52+
53+
case .getMyPageInfo, .putUpdateUserInfo:
5254
return "/members"
5355
}
5456
}
@@ -57,28 +59,41 @@ extension UserTargetType: TargetType {
5759
switch self {
5860
case .getSessionCheck, .getMyPageInfo:
5961
return .get
60-
62+
6163
case .postSocialLogin, .postSignUp, .postLogout, .postWithdrawal:
6264
return .post
65+
66+
case .putUpdateUserInfo:
67+
return .put
6368
}
6469
}
6570

6671
var task: RequestTask {
6772
switch self {
6873
case .getSessionCheck, .postLogout, .postWithdrawal, .getMyPageInfo:
6974
return .requestPlain
70-
75+
7176
case .postSocialLogin(let reqDto):
7277
return .requestJSONEncodable(encodable: reqDto)
73-
78+
7479
case let .postSignUp(reqDto, imgData):
7580
let jsons: [MultipartJSON] = [.init(jsonName: "request", json: reqDto)]
76-
81+
82+
// ν”„λ‘œν•„ 이미지가 μžˆμ„ 경우 λ©€ν‹°νŒŒνŠΈ μ—…λ‘œλ“œ 처리
83+
let files: [MultipartFile] = imgData.map {
84+
[.init(fieldName: "profileImage", fileName: "profile.png", mimeType: "image/png", data: $0)]
85+
} ?? []
86+
87+
return .uploadMultipart(jsons: jsons, files: files, additionalFields: [:])
88+
89+
case let .putUpdateUserInfo(reqDto, imgData):
90+
let jsons: [MultipartJSON] = [.init(jsonName: "request", json: reqDto)]
91+
7792
// ν”„λ‘œν•„ 이미지가 μžˆμ„ 경우 λ©€ν‹°νŒŒνŠΈ μ—…λ‘œλ“œ 처리
7893
let files: [MultipartFile] = imgData.map {
7994
[.init(fieldName: "profileImage", fileName: "profile.png", mimeType: "image/png", data: $0)]
8095
} ?? []
81-
96+
8297
return .uploadMultipart(jsons: jsons, files: files, additionalFields: [:])
8398
}
8499
}
@@ -87,21 +102,18 @@ extension UserTargetType: TargetType {
87102
switch self {
88103
case .getSessionCheck, .postLogout, .postWithdrawal, .getMyPageInfo:
89104
return nil
90-
105+
91106
case .postSocialLogin:
92107
return ["Content-Type": "application/json"]
93-
94-
case .postSignUp:
95-
return [
96-
"Content-Type": "multipart/form-data",
97-
"Authorization": "SESSION-ID 1111"
98-
]
108+
109+
case .postSignUp, .putUpdateUserInfo:
110+
return ["Content-Type": "multipart/form-data"]
99111
}
100112
}
101113

102114
var interceptors: [any Interceptor] {
103115
switch self {
104-
case .getSessionCheck, .postLogout, .postWithdrawal, .getMyPageInfo:
116+
case .getSessionCheck, .postLogout, .postWithdrawal, .getMyPageInfo, .putUpdateUserInfo:
105117
return [
106118
LoggingInterceptor(),
107119
AuthTokenInterceptor(),

β€ŽTnT/Projects/Domain/Sources/DTO/User/UserRequestDTO.swiftβ€Ž

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,43 @@ public struct PostSignUpReqDTO: Encodable {
9595
self.goalContents = goalContents
9696
}
9797
}
98+
99+
/// νšŒμ› 정보 μˆ˜μ • μš”μ²­ DTO
100+
public struct UpdateUserInfoRequestDTO: Encodable, Equatable {
101+
/// 이미지 μ‚­μ œ μ—¬λΆ€
102+
public let removeImage: Bool
103+
/// νšŒμ› νƒ€μž… (TRAINER, TRAINEE)
104+
public let memberType: String
105+
/// νšŒμ› 이름
106+
public let name: String
107+
/// 생년월일 (yyyy-MM-dd)
108+
public let birthday: String?
109+
/// ν‚€ (cm)
110+
public let height: Double?
111+
/// λͺΈλ¬΄κ²Œ (kg)
112+
public let weight: Double?
113+
/// μ£Όμ˜μ‚¬ν•­
114+
public let cautionNote: String?
115+
/// PT λͺ©μ  (ν•œκΈ€ λ¬Έμžμ—΄ λ°°μ—΄)
116+
public let ptGoals: [String]?
117+
118+
public init(
119+
removeImage: Bool,
120+
memberType: String,
121+
name: String,
122+
birthday: String?,
123+
height: Double?,
124+
weight: Double?,
125+
cautionNote: String?,
126+
ptGoals: [String]?
127+
) {
128+
self.removeImage = removeImage
129+
self.memberType = memberType
130+
self.name = name
131+
self.birthday = birthday
132+
self.height = height
133+
self.weight = weight
134+
self.cautionNote = cautionNote
135+
self.ptGoals = ptGoals
136+
}
137+
}

β€ŽTnT/Projects/Domain/Sources/Entity/MyPageEntity.swiftβ€Ž

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,56 @@ public struct TraineeMyPageEntity: Equatable, Sendable {
1717
public let profileImageUrl: String
1818
/// μ†Œμ…œ νƒ€μž…
1919
public let socialType: String
20+
21+
/// 생년월일
22+
public let birthday: String?
23+
/// λ‚˜μ΄
24+
public let age: Int?
25+
/// ν‚€ (cm)
26+
public let height: Double?
27+
/// λͺΈλ¬΄κ²Œ (kg)
28+
public let weight: Double?
29+
/// μ£Όμ˜μ‚¬ν•­
30+
public let cautionNote: String?
31+
/// PT λͺ©ν‘œ
32+
public let ptGoals: [String]
33+
34+
public init(
35+
isConnected: Bool,
36+
name: String,
37+
profileImageUrl: String,
38+
socialType: String,
39+
birthday: String?,
40+
age: Int?,
41+
height: Double?,
42+
weight: Double?,
43+
cautionNote: String?,
44+
ptGoals: [String]
45+
) {
46+
self.isConnected = isConnected
47+
self.name = name
48+
self.profileImageUrl = profileImageUrl
49+
self.socialType = socialType
50+
self.birthday = birthday
51+
self.age = age
52+
self.height = height
53+
self.weight = weight
54+
self.cautionNote = cautionNote
55+
self.ptGoals = ptGoals
56+
}
57+
58+
public init() {
59+
self.isConnected = false
60+
self.name = ""
61+
self.profileImageUrl = ""
62+
self.socialType = ""
63+
self.birthday = ""
64+
self.age = 0
65+
self.height = 0
66+
self.weight = 0
67+
self.cautionNote = ""
68+
self.ptGoals = []
69+
}
2070
}
2171

2272
public struct TrainerMyPageEntity: Equatable, Sendable {

β€ŽTnT/Projects/Domain/Sources/Entity/TrainingPurpose.swiftβ€Ž

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,24 @@ public extension TrainingPurpose {
4242
return "μžμ„Έ ꡐ정"
4343
}
4444
}
45+
46+
/// ν•œκΈ€ μ΄λ¦„μœΌλ‘œλΆ€ν„° TrainingPurposeλ₯Ό 생성
47+
init?(koreanName: String) {
48+
switch koreanName {
49+
case "체쀑 κ°λŸ‰":
50+
self = .loseWeight
51+
case "κ·Όλ ₯ ν–₯상":
52+
self = .gainMuscle
53+
case "건강 관리":
54+
self = .healthWellness
55+
case "μœ μ—°μ„± ν–₯상":
56+
self = .flexibilityImprovement
57+
case "λ°”λ””ν”„λ‘œν•„":
58+
self = .bodyProfile
59+
case "μžμ„Έ ꡐ정":
60+
self = .postureCorrection
61+
default:
62+
return nil
63+
}
64+
}
4565
}

β€ŽTnT/Projects/Domain/Sources/Mapper/UserMapper.swiftβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ public extension GetMyPageInfoResDTO {
1414
isConnected: self.trainee?.isConnected ?? false,
1515
name: self.name,
1616
profileImageUrl: self.profileImageUrl,
17-
socialType: self.socialType
17+
socialType: self.socialType,
18+
birthday: self.trainee?.birthday,
19+
age: self.trainee?.age,
20+
height: self.trainee?.height,
21+
weight: self.trainee?.weight,
22+
cautionNote: self.trainee?.cautionNote,
23+
ptGoals: self.trainee?.ptGoals ?? []
1824
)
1925
}
2026

β€ŽTnT/Projects/Domain/Sources/Policy/AppStorage.swiftβ€Ž

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// Copyright Β© 2025 yapp25thTeamTnT. All rights reserved.
77
//
88

9-
import Foundation
10-
119
public enum AppStorage {
1210
public static let hideHomePopupUntil: String = "hideHomePopupUntil"
1311
public static let isConnected: String = "isConnected"

β€ŽTnT/Projects/Domain/Sources/Repository/UserRepository.swiftβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ public protocol UserRepository {
4444
/// - Returns: λ§ˆμ΄νŽ˜μ΄μ§€ ν‘œμ‹œμ— ν•„μš”ν•œ 응닡 DTO (`GetMyPageInfoResDTO`)
4545
/// - Throws: λ„€νŠΈμ›Œν¬ 였λ₯˜ λ˜λŠ” μ„œλ²„μ—μ„œ λ°˜ν™˜ν•œ 였λ₯˜λ₯Ό λ°œμƒμ‹œν‚¬ 수 있음
4646
func getMyPageInfo() async throws -> GetMyPageInfoResDTO
47+
48+
/// νšŒμ› 정보 μˆ˜μ • μš”μ²­
49+
/// - Parameters:
50+
/// - reqDTO: νšŒμ› 정보 μˆ˜μ • μš”μ²­μ— ν•„μš”ν•œ 데이터
51+
/// - profileImage: μ‚¬μš©μžκ°€ μ—…λ‘œλ“œν•œ ν”„λ‘œν•„ 이미지 (μ˜΅μ…˜)
52+
/// - Returns: νšŒμ› 정보 μˆ˜μ • 성곡 μ‹œ 빈 응닡
53+
/// - Throws: λ„€νŠΈμ›Œν¬ 였λ₯˜ λ˜λŠ” μ„œλ²„μ—μ„œ λ°˜ν™˜ν•œ 였λ₯˜λ₯Ό λ°œμƒμ‹œν‚¬ 수 있음
54+
func putUpdateUserInfo(_ reqDTO: UpdateUserInfoRequestDTO, profileImage: Data?) async throws -> EmptyResponse
4755
}

β€ŽTnT/Projects/Domain/Sources/UseCase/UserUseCase.swiftβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,8 @@ extension DefaultUserUseCase: UserRepository {
9191
public func getMyPageInfo() async throws -> GetMyPageInfoResDTO {
9292
return try await userRepostiory.getMyPageInfo()
9393
}
94+
95+
public func putUpdateUserInfo(_ reqDTO: UpdateUserInfoRequestDTO, profileImage: Data?) async throws -> EmptyResponse {
96+
return try await userRepostiory.putUpdateUserInfo(reqDTO, profileImage: profileImage)
97+
}
9498
}

0 commit comments

Comments
Β (0)