Skip to content

Commit

Permalink
✨ :: [#398] LectureDomain / 강의 이수중인 학생 상세조회 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuunseo committed Aug 7, 2024
1 parent 273c22c commit 6d7551d
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 1 deletion.
6 changes: 6 additions & 0 deletions App/Sources/Application/DI/Lecture/AppComponent+Lecture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ public extension AppComponent {
ModifyLectureUseCaseImpl(lectureRepository: lectureRepository)
}
}

var fetchAppliedLectureStudentDetailUseCase: any FetchAppliedLectureStudentDetailUseCase {
shared {
FetchAppliedLectureStudentDetailUseCaseImpl(lectureRepository: lectureRepository)
}
}
}
1 change: 1 addition & 0 deletions App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ extension AppComponent: Registration {
localTable["setLectureCompletionUseCase-any SetLectureCompletionUseCase"] = { [unowned self] in self.setLectureCompletionUseCase as Any }
localTable["deleteLectureUseCase-any DeleteLectureUseCase"] = { [unowned self] in self.deleteLectureUseCase as Any }
localTable["modifyLectureUseCase-any ModifyLectureUseCase"] = { [unowned self] in self.modifyLectureUseCase as Any }
localTable["fetchAppliedLectureStudentDetailUseCase-any FetchAppliedLectureStudentDetailUseCase"] = { [unowned self] in self.fetchAppliedLectureStudentDetailUseCase as Any }
localTable["remoteClubDataSource-any RemoteClubDataSource"] = { [unowned self] in self.remoteClubDataSource as Any }
localTable["clubRepository-any ClubRepository"] = { [unowned self] in self.clubRepository as Any }
localTable["fetchClubListUseCase-any FetchClubListUseCase"] = { [unowned self] in self.fetchClubListUseCase as Any }
Expand Down
19 changes: 19 additions & 0 deletions Service/Sources/Base/Enum/CompleteStatusType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

public enum CompleteStatusType: String, Decodable {
case notCompletedYet = "NOT_COMPLETED_YET"
case completedIn3RD = "COMPLETED_IN_3RD"
case completedIn2RD = "COMPLETED_IN_2RD"
case completedIn1RD = "COMPLETED_IN_1RD"
}

extension CompleteStatusType {
func display() -> String {
switch self {
case .notCompletedYet: return "아직 이수하지 않음"
case .completedIn3RD: return "이수 완료(3학년)"
case .completedIn2RD: return "이수 완료(2학년)"
case .completedIn1RD: return "이수 완료(1학년)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public final class RemoteLectureDataSourceImpl: BaseRemoteDataSource<LectureAPI>
public func modifyLecture(lectureID: String, req: InputLectureRequestDTO) async throws {
try await request(.modifyLecture(lectureID: lectureID, req: req))
}

public func fetchAppliedLectureStudentDetail(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity {
try await request(.fetchAppliedLectureStudentDetail(lectureID: lectureID, studentID: studentID), dto: AppliedLectureStudentDetailResponseDTO.self).toDomain()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ public struct LectureRepositoryImpl: LectureRepository {
public func modifyLecture(lectureID: String, req: InputLectureRequestDTO) async throws {
try await remoteLectureDataSource.modifyLecture(lectureID: lectureID, req: req)
}

public func fetchAppliedLectureStudentDetail(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity {
try await remoteLectureDataSource.fetchAppliedLectureStudentDetail(lectureID: lectureID, studentID: studentID)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

public struct FetchAppliedLectureStudentDetailUseCaseImpl: FetchAppliedLectureStudentDetailUseCase {
private let lectureRepository: any LectureRepository

public init(lectureRepository: any LectureRepository) {
self.lectureRepository = lectureRepository
}

public func callAsFunction(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity {
try await lectureRepository.fetchAppliedLectureStudentDetail(lectureID: lectureID, studentID: studentID)
}
}
7 changes: 6 additions & 1 deletion Service/Sources/Domain/LectureDomain/API/LectureAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum LectureAPI {
case setLectureCompletion(lectureID: String, students: [String])
case deleteLecture(lectureID: String)
case modifyLecture(lectureID: String, req: InputLectureRequestDTO)
case fetchAppliedLectureStudentDetail(lectureID: String, studentID: String)
}

extension LectureAPI: BitgouelAPI {
Expand Down Expand Up @@ -60,6 +61,9 @@ extension LectureAPI: BitgouelAPI {

case let .deleteLecture(lectureID):
return "/\(lectureID)/soft"

case let .fetchAppliedLectureStudentDetail(lectureID, studentID):
return "/student/\(lectureID)/\(studentID)"
}
}

Expand All @@ -76,7 +80,8 @@ extension LectureAPI: BitgouelAPI {
.searchDepartment,
.searchDivision,
.fetchAppliedLectureList,
.fetchApplicantList:
.fetchApplicantList,
.fetchAppliedLectureStudentDetail:
return .get

case .cancelLectureApplication,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Foundation

struct AppliedLectureStudentDetailResponseDTO: Decodable {
public let email: String
public let name: String
public let grade: Int
public let classNumber: Int
public let number: Int
public let phoneNumber: String
public let school: String
public let clubName: String
public let cohort: Int
public let currentCompletedDate: Date
public let completeStatus: CompleteStatusType
}

extension AppliedLectureStudentDetailResponseDTO {
func toDomain() -> AppliedLectureStudentDetailEntity {
AppliedLectureStudentDetailEntity(
email: email,
name: name,
grade: grade,
classNumber: classNumber,
number: number,
phoneNumber: phoneNumber,
school: school,
clubName: clubName,
cohort: cohort,
currentCompletedDate: currentCompletedDate,
completeStatus: completeStatus
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public protocol RemoteLectureDataSource: BaseRemoteDataSource<LectureAPI> {
func setLectureCompletion(lectureID: String, students: [String]) async throws
func deleteLecture(lectureID: String) async throws
func modifyLecture(lectureID: String, req: InputLectureRequestDTO) async throws
func fetchAppliedLectureStudentDetail(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Foundation

public struct AppliedLectureStudentDetailEntity: Equatable {
public let email: String
public let name: String
public let grade: Int
public let classNumber: Int
public let number: Int
public let phoneNumber: String
public let school: String
public let clubName: String
public let cohort: Int
public let currentCompletedDate: Date
public let completeStatus: CompleteStatusType

public init(
email: String,
name: String,
grade: Int,
classNumber: Int,
number: Int,
phoneNumber: String,
school: String,
clubName: String,
cohort: Int,
currentCompletedDate: Date,
completeStatus: CompleteStatusType
) {
self.email = email
self.name = name
self.grade = grade
self.classNumber = classNumber
self.number = number
self.phoneNumber = phoneNumber
self.school = school
self.clubName = clubName
self.cohort = cohort
self.currentCompletedDate = currentCompletedDate
self.completeStatus = completeStatus
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public protocol LectureRepository {
func setLectureCompletion(lectureID: String, students: [String]) async throws
func deleteLecture(lectureID: String) async throws
func modifyLecture(lectureID: String, req: InputLectureRequestDTO) async throws
func fetchAppliedLectureStudentDetail(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

public protocol FetchAppliedLectureStudentDetailUseCase {
func callAsFunction(lectureID: String, studentID: String) async throws -> AppliedLectureStudentDetailEntity
}

0 comments on commit 6d7551d

Please sign in to comment.