Skip to content

Commit

Permalink
[Feat] sopt-makers#199 - N차 출석정보 조회 Entity, Model 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
0inn committed Apr 22, 2023
1 parent 810e179 commit f9ce877
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,21 @@ 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: "솝트대학교 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()
}

public func fetchAttendanceScoreModel() -> AnyPublisher<Domain.AttendanceScoreModel, Error> {
// return Future<AttendanceScoreModel, Error> { promise in
// 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()
}

public func fetchLectureRound(lectureId: Int) -> AnyPublisher<AttendanceRoundModel?, Error> {
return self.attendanceService
.fetchAttendanceRound(lectureId: lectureId)
.compactMap { $0.data?.toDomain() }
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AttendanceLectureRoundTransform.swift
// Data
//
// Created by 김영인 on 2023/04/22.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import Foundation

import Domain
import Network

extension AttendanceRoundEntity {
public func toDomain() -> AttendanceRoundModel {
return AttendanceRoundModel.init(
subLectureId: self.id,
round: self.round
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension AttendanceScheduleEntity {

public func toDomain() -> AttendanceScheduleModel {
return .init(type: self.type,
id: self.id,
location: self.location,
name: self.name,
startDate: self.startDate,
Expand Down
21 changes: 21 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/Model/AttendanceRoundModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AttendanceRoundModel.swift
// Domain
//
// Created by 김영인 on 2023/04/22.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import Foundation

public struct AttendanceRoundModel {
public let subLectureId: Int
public let round: Int

public init(subLectureId: Int, round: Int) {
self.subLectureId = subLectureId
self.round = round
}

public static let EMPTY: Self = .init(subLectureId: 0, round: 0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import Foundation

public struct AttendanceScheduleModel {
public let type: String
public let id: Int
public let location, name, startDate, endDate: String
public let message: String
public let attendances: [TodayAttendanceModel]

public init(type: String, location: String, name: String, startDate: String, endDate: String, message: String, attendances: [TodayAttendanceModel]) {
public init(type: String, id: Int, location: String, name: String, startDate: String, endDate: String, message: String, attendances: [TodayAttendanceModel]) {
self.type = type
self.id = id
self.location = location
self.name = name
self.startDate = startDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

import Combine

import Core

public protocol ShowAttendanceRepositoryInterface {
func fetchAttendanceScheduleModel() -> AnyPublisher<AttendanceScheduleModel, Error>
func fetchAttendanceScoreModel() -> AnyPublisher<AttendanceScoreModel, Error>
func fetchLectureRound(lectureId: Int) -> AnyPublisher<AttendanceRoundModel?, Error>
}

0 comments on commit f9ce877

Please sign in to comment.