Skip to content

Commit

Permalink
Merge pull request #62 from YAPP-Github/TNT-213-TrainerTraineeList
Browse files Browse the repository at this point in the history
[TNT-213] ํŠธ๋ ˆ์ด๋„ˆ ํšŒ์›๋ชฉ๋ก ํŽ˜์ด์ง€ ์ž‘์„ฑ
  • Loading branch information
FpRaArNkK authored Feb 10, 2025
2 parents f75cf83 + b04683d commit 78b0919
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 1 deletion.
9 changes: 9 additions & 0 deletions TnT/Projects/DIContainer/Sources/DIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ private enum SocialUseCaseKey: DependencyKey {
static let liveValue: SocialLoginUseCase = SocialLoginUseCase(socialLoginRepository: SocialLogInRepositoryImpl(loginManager: SNSLoginManager()))
}

private enum TrainerUseCaseRepoKey: DependencyKey {
static let liveValue: TrainerRepository = DefaultTrainerUseCase(trainerRepository: TrainerRepositoryImpl())
}

private enum KeyChainManagerKey: DependencyKey {
static let liveValue: KeyChainManager = keyChainManager
}
Expand Down Expand Up @@ -60,4 +64,9 @@ public extension DependencyValues {
get { self[SocialUseCaseKey.self] }
set { self[SocialUseCaseKey.self] = newValue }
}

var trainerRepoUseCase: TrainerRepository {
get { self[TrainerUseCaseRepoKey.self] }
set { self[TrainerUseCaseRepoKey.self] = newValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ public struct TrainerRepositoryImpl: TrainerRepository {
decodingType: GetDateSessionListDTO.self
)
}

public func getMembersList() async throws -> GetMembersListDTO {
return try await networkService.request(
TrainerTargetType.getMemebersList,
decodingType: GetMembersListDTO.self
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public enum TrainerTargetType {
case getDateLessionList(date: String)
/// ํŠธ๋ ˆ์ด๋„ˆ ์ดˆ๋Œ€์ฝ”๋“œ ์žฌ๋ฐœ๊ธ‰
case getReissuanceInvitationCode
/// ํšŒ์› ์กฐํฌ
case getMemebersList
}

extension TrainerTargetType: TargetType {
Expand All @@ -38,6 +40,8 @@ extension TrainerTargetType: TargetType {
return "/lessions/\(date)"
case .getReissuanceInvitationCode:
return "/invitation-code/reissue"
case .getMemebersList:
return "/members"
}
}

Expand All @@ -51,6 +55,8 @@ extension TrainerTargetType: TargetType {
return .get
case .getReissuanceInvitationCode:
return .put
case .getMemebersList:
return .get
}
}

Expand All @@ -64,6 +70,8 @@ extension TrainerTargetType: TargetType {
return .requestPlain
case .getReissuanceInvitationCode:
return .requestPlain
case .getMemebersList:
return .requestPlain
}
}

Expand All @@ -77,6 +85,8 @@ extension TrainerTargetType: TargetType {
return ["Content-Type": "application/json"]
case .getReissuanceInvitationCode:
return ["Content-Type": "application/json"]
case .getMemebersList:
return ["Content-Type": "application/json"]
}
}

Expand Down
22 changes: 21 additions & 1 deletion TnT/Projects/DesignSystem/Sources/Navigation/TNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public struct TNavigation: View {
Rectangle()
.fill(Color.clear)
.frame(width: 32, height: 32)

case .LTextRButtonTitle(let leftTitle, let pointText, _):
HStack(spacing: 6){
Text(leftTitle)
.typographyStyle(.heading2, with: .neutral900)
if let pointText = pointText {
Text(pointText)
.typographyStyle(.heading2, with: .red500)
} else { EmptyView() }
}
}
}

Expand All @@ -78,7 +88,7 @@ public struct TNavigation: View {
Text(centerTitle)
.typographyStyle(.heading4, with: .neutral900)
.frame(maxWidth: .infinity, alignment: .center)
case .LButton:
case .LButton, .LTextRButtonTitle(_, _, _):
EmptyView()
}
}
Expand All @@ -105,6 +115,14 @@ public struct TNavigation: View {
Rectangle()
.fill(Color.clear)
.frame(width: 32, height: 32)

case .LTextRButtonTitle(_, _, let rightButton):
TButton(
title: rightButton,
config: .small,
state: .disable(.gray(isEnabled: true))) {
rightAction?()
}
}
}
}
Expand Down Expand Up @@ -143,4 +161,6 @@ public enum TNavigationCase {
case Title(centerTitle: String)
/// ์™ผ์ชฝ ์ด๋ฏธ์ง€
case LButton(leftImage: ImageResource)
/// ์™ผ์ชฝ ํ…์ŠคํŠธ, ์˜ค๋ฅธ์ชฝ ๋ฒ„ํŠผ
case LTextRButtonTitle(leftTitle: String, pointText: String?, rightButton: String)
}
59 changes: 59 additions & 0 deletions TnT/Projects/Domain/Sources/DTO/Trainer/GetMembersListDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// GetMembersListDTO.swift
// Domain
//
// Created by ๋ฐ•์„œ์—ฐ on 2/8/25.
// Copyright ยฉ 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// ํŠธ๋ ˆ์ด๋„ˆ ํšŒ์› ์กฐํšŒ DTO
public struct GetMembersListDTO: Decodable {
/// ์ด๋ฆ„
public let name: String
/// ์ด๋ฉ”์ผ
public let email: String
/// ํ”„๋กœํ•„ ์‚ฌ์ง„
public let profileImageUrl: String
/// ์ƒ๋…„์›”์ผ
public let birthday: String?
/// ์œ ์ € ํƒ€์ž… (ํŠธ๋ ˆ์ด๋„ˆ/ํŠธ๋ ˆ์ด๋‹ˆ)
public let memberType: String
/// ์†Œ์…œ ๋กœ๊ทธ์ธ ํƒ€์ž…
public let socialType: String
/// ๊ด€๋ฆฌ์ค‘์ธ ํšŒ์›์˜ ์ˆ˜
public let managementMember: Int
/// ํ•จ๊ป˜ํ–ˆ๋˜ ํšŒ์›์˜ ์ˆ˜
public let fellowMember: Int
/// ํŠธ๋ ˆ์ด๋„ˆ ID
public let trainerId: String
/// ํŠธ๋ ˆ์ด๋‹ˆ ํ‚ค
public let height: Double?
/// ํŠธ๋ ˆ์ด๋‹ˆ ๋ฌด๊ฒŒ
public let weight: Double?
/// ์ฃผ์˜์‚ฌํ•ญ
public let cautionNote: String?
/// PT ๋ชฉํ‘œ
public let goalContents: [String]
}

public extension GetMembersListDTO {
public static func toEntity(resEntity: GetMembersListDTO) -> GetMembersListEntity {
return GetMembersListEntity(
name: resEntity.name,
email: resEntity.email,
profileImageUrl: resEntity.profileImageUrl,
birthday: resEntity.birthday ?? "",
memberType: resEntity.memberType,
socialType: resEntity.socialType,
managementMember: resEntity.managementMember,
fellowMember: resEntity.fellowMember,
trainerId: resEntity.trainerId,
height: resEntity.height ?? 0.0,
weight: resEntity.weight ?? 0.0,
cautionNote: resEntity.cautionNote ?? "",
goalContents: resEntity.goalContents
)
}
}
92 changes: 92 additions & 0 deletions TnT/Projects/Domain/Sources/Entity/GetMembersListEntity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// GetMembersListEntity.swift
// Domain
//
// Created by ๋ฐ•์„œ์—ฐ on 2/8/25.
// Copyright ยฉ 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// ํŠธ๋ ˆ์ด๋„ˆ ํšŒ์› ์กฐํšŒ DTO
public struct GetMembersListEntity: Encodable, Equatable {
/// ID ๊ฐ’ ํ™œ์šฉ์„ ์œ„ํ•œ ์ถ”๊ฐ€
public let id: String
/// ์ด๋ฆ„
public let name: String
/// ์ด๋ฉ”์ผ
public let email: String
/// ํ”„๋กœํ•„ ์‚ฌ์ง„
public let profileImageUrl: String
/// ์ƒ๋…„์›”์ผ
public let birthday: String?
/// ์œ ์ € ํƒ€์ž… (ํŠธ๋ ˆ์ด๋„ˆ/ํŠธ๋ ˆ์ด๋‹ˆ)
public let memberType: String
/// ์†Œ์…œ ๋กœ๊ทธ์ธ ํƒ€์ž…
public let socialType: String
/// ๊ด€๋ฆฌ์ค‘์ธ ํšŒ์›์˜ ์ˆ˜
public let managementMember: Int
/// ํ•จ๊ป˜ํ–ˆ๋˜ ํšŒ์›์˜ ์ˆ˜
public let fellowMember: Int
/// ํŠธ๋ ˆ์ด๋„ˆ ID
public let trainerId: String
/// ํŠธ๋ ˆ์ด๋‹ˆ ํ‚ค
public let height: Double?
/// ํŠธ๋ ˆ์ด๋‹ˆ ๋ฌด๊ฒŒ
public let weight: Double?
/// ์ฃผ์˜์‚ฌํ•ญ
public let cautionNote: String?
/// PT ๋ชฉํ‘œ
public let goalContents: [String]

public init(
id: String = UUID().uuidString,
name: String,
email: String,
profileImageUrl: String,
birthday: String?,
memberType: String,
socialType: String,
managementMember: Int,
fellowMember: Int,
trainerId: String,
height: Double?,
weight: Double?,
cautionNote: String?,
goalContents: [String]
) {
self.id = id
self.name = name
self.email = email
self.profileImageUrl = profileImageUrl
self.birthday = birthday
self.memberType = memberType
self.socialType = socialType
self.managementMember = managementMember
self.fellowMember = fellowMember
self.trainerId = trainerId
self.height = height
self.weight = weight
self.cautionNote = cautionNote
self.goalContents = goalContents
}
}

extension GetMembersListEntity {
static func toDTO(entity: GetMembersListEntity) -> GetMembersListDTO {
return GetMembersListDTO(
name: entity.name,
email: entity.email,
profileImageUrl: entity.profileImageUrl,
birthday: entity.birthday ?? "",
memberType: entity.memberType,
socialType: entity.socialType,
managementMember: entity.managementMember,
fellowMember: entity.fellowMember,
trainerId: entity.trainerId,
height: entity.height ?? 0.0,
weight: entity.weight ?? 0.0,
cautionNote: entity.cautionNote ?? "",
goalContents: entity.goalContents)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ public protocol TrainerRepository {

/// ํŠธ๋ ˆ์ด๋„ˆ ์บ˜๋ฆฐ๋”์— ํŠน์ • ๋‚ ์งœ์˜ ์ˆ˜์—… ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ
func getDateSessionList(date: String) async throws -> GetDateSessionListDTO

/// ํšŒ์› ์กฐํฌ
func getMembersList() async throws -> GetMembersListDTO
}
39 changes: 39 additions & 0 deletions TnT/Projects/Domain/Sources/UseCase/TrainerUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// TrainerUseCase.swift
// Domain
//
// Created by ๋ฐ•์„œ์—ฐ on 2/8/25.
// Copyright ยฉ 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

// MARK: - TrainerUseCase Default ๊ตฌํ˜„์ฒด
public struct DefaultTrainerUseCase: TrainerRepository {

private let trainerRepository: TrainerRepository

public init (trainerRepository: TrainerRepository) {
self.trainerRepository = trainerRepository
}

public func getVerifyInvitationCode(code: String) async throws -> GetVerifyInvitationCodeResDTO {
return try await trainerRepository.getVerifyInvitationCode(code: code)
}

public func getTheFirstInvitationCode() async throws -> GetTheFirstInvitationCodeDTO {
return try await trainerRepository.getTheFirstInvitationCode()
}

public func getReissuanceInvitationCode() async throws -> GetReissuanceInvitationCodeDTO {
return try await trainerRepository.getReissuanceInvitationCode()
}

public func getDateSessionList(date: String) async throws -> GetDateSessionListDTO {
return try await trainerRepository.getDateSessionList(date: date)
}

public func getMembersList() async throws -> GetMembersListDTO {
return try await trainerRepository.getMembersList()
}
}
Loading

0 comments on commit 78b0919

Please sign in to comment.