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

[Feat] #167 - 출석 점수 조회하기 서버 수정 #172

Merged
merged 4 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,50 @@ public class ShowAttendanceRepository {

extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface {
public func fetchAttendanceScheduleModel() -> AnyPublisher<AttendanceScheduleModel, Error> {
return Future<AttendanceScheduleModel, Error> { promise in
// return Future<AttendanceScheduleModel, Error> { promise in
//// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
//// location: "단국대학교 혜당관",
//// name: "3차 세미나",
//// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
//// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
//// TodayAttendanceModel(status: "ABSENT", attendedAt:
//// "2023-04-13T14:10:04")])))
//
// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
// location: "단국대학교 혜당관",
// name: "3차 세미나",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
// location: "한국대학교 혜당관",
// name: "2차 행사",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00",
// message: "행사도 참여하고, 출석점수도 받고, 일석이조!",
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
// TodayAttendanceModel(status: "ABSENT", attendedAt:
// "2023-04-13T14:10:04")])))

promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
location: "한국대학교 혜당관",
name: "2차 행사",
startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00",
message: "행사도 참여하고, 출석점수도 받고, 일석이조!",
attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")])))

// promise(.success(AttendanceScheduleModel(type: "NO_SESSION",
// location: "",
// name: "",
// startDate: "", endDate: "", message: "",
// attendances: [TodayAttendanceModel(status: "", attendedAt: ""),
// TodayAttendanceModel(status: "", attendedAt: "")])))
}
.eraseToAnyPublisher()
// return self.attendanceService.fetchAttendanceSchedule()
// .map { $0.toDomain() }
// .eraseToAnyPublisher()
// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")])))
//
//// promise(.success(AttendanceScheduleModel(type: "NO_SESSION",
//// location: "",
//// name: "",
//// startDate: "", endDate: "", message: "",
//// attendances: [TodayAttendanceModel(status: "", attendedAt: ""),
//// TodayAttendanceModel(status: "", attendedAt: "")])))
// }
// .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: "iOS",
generation: 31,
name: "윤수빈",
score: 2.0,
total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1),
attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"),
AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"),
AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"),
AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")])))
}.eraseToAnyPublisher()
// return self.attendanceService.fetchAttendanceScore()
// .map { $0.toDomain() }
// .eraseToAnyPublisher()
// return Future<AttendanceScoreModel, Error> { promise in
// promise(.success(AttendanceScoreModel.init(part: "iOS",
// generation: 31,
// name: "윤수빈",
// score: 2.0,
// total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1),
// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"),
// AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")])))
// }.eraseToAnyPublisher()
return self.attendanceService.fetchAttendanceScore()
.compactMap{ $0.data?.toDomain() }
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension DefaultShowAttendanceUseCase: ShowAttendanceUseCase {
public func fetchAttendanceSchedule() {
self.repository.fetchAttendanceScheduleModel()
.sink(receiveCompletion: { event in
print("completion: \(event)")
print("completion: fetchAttendanceSchedule \(event)")
}, receiveValue: { model in
self.attendanceScheduleFetched.send(model)
})
Expand All @@ -43,7 +43,7 @@ extension DefaultShowAttendanceUseCase: ShowAttendanceUseCase {
public func fetchAttendanceScore() {
self.repository.fetchAttendanceScoreModel()
.sink(receiveCompletion: { event in
print("completion: \(event)")
print("completion: fetchAttendanceScore \(event)")
}, receiveValue: { model in
self.attendanceScoreFetched.send(model)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ extension ShowAttendanceVC {

containerScrollView.snp.makeConstraints {
$0.top.equalTo(navibar.snp.bottom)
$0.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide)
$0.leading.trailing.equalTo(view.safeAreaLayoutGuide)
$0.bottom.equalToSuperview()
}

contentView.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property 1=Done.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property 1=Done@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property 1=Done@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property 1=Late.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property 1=Late@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property 1=Late@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property 1=No.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property 1=No@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property 1=No@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property 1=Yes.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property 1=Yes@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property 1=Yes@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BaseEntity.swift
// Network
//
// Created by 김영인 on 2023/04/16.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import Foundation

public struct BaseEntity<T: Decodable>: Decodable {
let success: Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구들은 public 필요 없을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

필요할 것 같아요 . .!
추후에 수정해두겠습니다 !

let message: String
public let data: T?
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import Moya
public typealias DefaultAttendanceService = BaseService<AttendanceAPI>

public protocol AttendanceService {
func fetchAttendanceSchedule() -> AnyPublisher<AttendanceScheduleEntity, Error>
func fetchAttendanceScore() -> AnyPublisher<AttendanceScoreEntity, Error>
func fetchAttendanceSchedule() -> AnyPublisher<BaseEntity<AttendanceScheduleEntity>, Error>
func fetchAttendanceScore() -> AnyPublisher<BaseEntity<AttendanceScoreEntity>, Error>
}

extension DefaultAttendanceService: AttendanceService {

public func fetchAttendanceSchedule() -> AnyPublisher<AttendanceScheduleEntity, Error> {
requestObjectInCombine(AttendanceAPI.score)
public func fetchAttendanceSchedule() -> AnyPublisher<BaseEntity<AttendanceScheduleEntity>, Error> {
requestObjectInCombine(AttendanceAPI.lecture)
}

public func fetchAttendanceScore() -> AnyPublisher<AttendanceScoreEntity, Error> {
requestObjectInCombine(AttendanceAPI.lecture)
public func fetchAttendanceScore() -> AnyPublisher<BaseEntity<AttendanceScoreEntity>, Error> {
requestObjectInCombine(AttendanceAPI.total)
}
}