Skip to content

Commit

Permalink
Merge pull request #367 from School-of-Company/366-schooldomain-setting
Browse files Browse the repository at this point in the history
🔀 :: [#366] SchoolDomain 세팅
  • Loading branch information
uuuunseo authored Jul 18, 2024
2 parents d47e391 + d2a3ac6 commit fe12f4e
Show file tree
Hide file tree
Showing 35 changed files with 414 additions and 101 deletions.
16 changes: 16 additions & 0 deletions App/Sources/Application/DI/School/AppComponent+School.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@ public extension AppComponent {
var fetchSchoolListUseCase: any FetchSchoolListUseCase {
FetchSchoolListUseCaseImpl(schoolRepository: schoolRepository)
}

var fetchAllSchoolNameUseCase: any FetchAllSchoolNameUseCase {
FetchAllSchoolNameUseCaseImpl(schoolRepository: schoolRepository)
}

var createdSchoolUseCase: any CreatedSchoolUseCase {
CreatedSchoolUseCaseImpl(schoolRepository: schoolRepository)
}

var modifySchoolUseCase: any ModifySchoolUseCase {
ModifySchoolUseCaseImpl(schoolRepository: schoolRepository)
}

var deleteSchoolUseCase: any DeleteSchoolUseCase {
DeleteSchoolUseCaseImpl(schoolRepository: schoolRepository)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ final class ClubDetailViewModel: BaseViewModel {
@Published var studentID: String = ""

// MARK: ClubInfo

var clubID: Int = 0
@Published var clubName: String = ""
@Published var schoolName: String = ""
@Published var students: [ClubDetailEntity.MemberInfoEntity] = []
@Published var teacher: ClubDetailEntity.TeacherInfoEntity?

// MARK: UseCase

private let loadUserAuthorityUseCase: any LoadUserAuthorityUseCase
private let fetchClubDetailUseCase: any FetchClubDetailUseCase
private let fetchStudentListByClubUseCase: any FetchStudentListByClubUseCase
Expand Down Expand Up @@ -65,11 +67,11 @@ final class ClubDetailViewModel: BaseViewModel {
}

func updateClubDetail(clubInfo: ClubDetailEntity) {
self.clubID = clubInfo.clubID
self.clubName = clubInfo.clubName
self.schoolName = clubInfo.schoolName
self.students = clubInfo.students
self.teacher = clubInfo.teacher
clubID = clubInfo.clubID
clubName = clubInfo.clubName
schoolName = clubInfo.schoolName
students = clubInfo.students
teacher = clubInfo.teacher
}

func updateIsPresentedStudentInfoView(isPresented: Bool) {
Expand Down
5 changes: 2 additions & 3 deletions App/Sources/Feature/ClubListFeature/Source/ClubListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ struct ClubListView: View {
ZStack {
ScrollView {
LazyVStack(spacing: 40) {
ForEach(viewModel.schoolClubList, id: \.id) { school in
ForEach(viewModel.schoolList, id: \.schoolID) { school in
SchoolClubsView(
schoolName: school.schoolName,
clubList: school.clubs
clubList: school.clubs.map { .init(clubID: $0.clubID, clubName: $0.clubName) }
) { clubID in
viewModel.updateClubID(clubID: clubID)
viewModel.updateIsPresentedClubDetailView(isPresented: true)
Expand All @@ -43,7 +43,6 @@ struct ClubListView: View {
}

SchoolListPopup(
schoolList: viewModel.schoolList,
selectedSchool: viewModel.selectedSchool
) { school in
viewModel.selectedSchool = school
Expand Down
22 changes: 16 additions & 6 deletions App/Sources/Feature/ClubListFeature/Source/ClubListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import Service
final class ClubListViewModel: BaseViewModel {
@Published var selectedSchool: HighSchoolType?
@Published var isShowingLoginAlert: Bool = false
@Published var schoolClubList: [SchoolListEntity] = []
@Published var clubList: [ClubEntity] = []
@Published var schoolList: [SchoolListEntity] = []
@Published var clubList: [ClubListModel] = []
@Published var clubID: Int = 0
@Published var isPresentedSelectedSchoolPopup: Bool = false
@Published var isPresentedClubDetailView: Bool = false
var schoolList: [HighSchoolType] = HighSchoolType.allCases
var authority: UserAuthorityType = .user

private let fetchClubListUseCase: any FetchClubListUseCase
Expand Down Expand Up @@ -38,6 +37,10 @@ final class ClubListViewModel: BaseViewModel {
isPresentedClubDetailView = isPresented
}

func updateClubList(clubList: [ClubListModel]) {
self.clubList = clubList
}

@MainActor
func onAppear() {
authority = loadUserAuthorityUseCase()
Expand All @@ -58,9 +61,9 @@ final class ClubListViewModel: BaseViewModel {
func fetchSchoolList() {
Task {
do {
schoolClubList = try await fetchSchoolListUseCase()
schoolList = try await fetchSchoolListUseCase()
} catch {
print(error.localizedDescription)
print(String(describing: error))
}
}
}
Expand All @@ -71,7 +74,14 @@ final class ClubListViewModel: BaseViewModel {
do {
guard let selectedSchool else { return }

clubList = try await fetchClubListUseCase(highSchool: selectedSchool.rawValue)
let response = try await fetchClubListUseCase(highSchool: selectedSchool.rawValue)

updateClubList(clubList: response.map {
.init(
clubID: $0.id,
clubName: $0.name
)
})
} catch {
errorMessage = error.clubDomainErrorMessage()
isErrorOccurred = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

public struct SchoolClubsView: View {
let schoolName: String
let clubList: [ClubEntity]
let clubList: [ClubListModel]
let selectedClub: (_ clubID: Int) -> Void

public var body: some View {
Expand All @@ -22,10 +22,10 @@ public struct SchoolClubsView: View {
.padding(.top, 12)

LazyVStack(spacing: 0) {
ForEach(clubList, id: \.id) { club in
ClubListRow(clubName: club.name)
ForEach(clubList, id: \.clubID) { club in
ClubListRow(clubName: club.clubName)
.onTapGesture {
selectedClub(club.id)
selectedClub(club.clubID)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Service
import SwiftUI

struct SchoolListPopup: View {
let schoolList: [HighSchoolType]
let schoolList: [HighSchoolType] = HighSchoolType.allCases
let selectedSchool: HighSchoolType?
let onSchoolSelect: (HighSchoolType) -> Void
let cancel: (Bool) -> Void
Expand Down Expand Up @@ -54,7 +54,7 @@ struct SchoolListPopup: View {
@ViewBuilder
func schoolListRow(
school: HighSchoolType,
selectedSchool: HighSchoolType?,
selectedSchool _: HighSchoolType?,
onSchoolSelect: @escaping (HighSchoolType) -> Void
) -> some View {
VStack(alignment: .leading) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public struct ClubListModel: Equatable {
let clubID: Int
let clubName: String
}
2 changes: 1 addition & 1 deletion Service/Sources/Base/BitgouelAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public enum BitgouelDomain: String {

extension BitgouelDomain {
var asURLString: String {
"/\(self.rawValue)"
"/\(rawValue)"
}
}

Expand Down
90 changes: 45 additions & 45 deletions Service/Sources/Base/Enum/CareerClubType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,92 @@ public enum CareerClubType {
case 전자어벤져스 = "전자 어벤져스"
case 전자히어로스 = "전자 히어로스"
case Civil마스터 = "Civil 마스터"
case 건축연구소 = "건축연구소"
case 건축연구소
}

public enum KumpaTechnicalHighSchool: String, CaseIterable, Decodable, Encodable {
case 레프리 = "레프리"
case 블라썸 = "블라썸"
case 유선통신 = "유선통신"
case 전기꿈나무 = "전기꿈나무"
case 어썸 = "어썸"
case 다이나믹 = "다이나믹"
case 레프리
case 블라썸
case 유선통신
case 전기꿈나무
case 어썸
case 다이나믹
case 금호로80베이커리 = "금호로80 베이커리"
}

// swiftlint: disable redundant_string_enum_value
public enum JeonnamTechnicalHighSchool: String, CaseIterable, Decodable, Encodable {
case 진짜기계 = "진짜기계"
case 핫앤쿨 = "핫앤쿨"
case 에너지지키미 = "에너지지키미"
case 라온하제 = "라온하제"
case 스카이드론 = "스카이드론"
case 그린라이트 = "그린라이트"
case 진짜기계
case 핫앤쿨
case 에너지지키미
case 라온하제
case 스카이드론
case 그린라이트
}

public enum GwangjeGirlsCommercialHighSchool: String, CaseIterable, Decodable, Encodable {
case 금융실무 = "금융실무"
case 소개팅 = "소개팅"
case 취사모 = "취사모"
case 금융실무
case 소개팅
case 취사모
}

public enum JeonnamGirlsCommercialHighSchool: String, CaseIterable, Decodable, Encodable {
case 없음 = "없음"
case 없음
}

public enum GwangjuNaturalScienceHighSchool: String, CaseIterable, Decodable, Encodable {
case DCT = "DCT"
case 뉴쿡 = "뉴쿡"
case DCT
case 뉴쿡
case 베이커리카페CEO = "베이커리 카페 CEO"
case 우아행 = "우아행"
case 우아행
}

public enum GwangjuElectronicTechnicalHighSchool: String, CaseIterable, Decodable, Encodable {
case 감성기계 = "감성기계"
case 감성기계
case 열정그자체 = "열정 그 자체"
case ACT = "ACT"
case ECT = "ECT"
case Tesla = "Tesla"
case 발자국 = "발자국"
case ACT
case ECT
case Tesla
case 발자국
case 메이커연구소 = "M lab"
}

// swiftlint: disable type_name
public enum DongilHighSchoolOfFutureScienceHighSchool: String, CaseIterable, Decodable, Encodable {
case 놀고잡고 = "놀고잡고"
case 믿고잡고 = "믿고잡고"
case 따고잡고 = "따고잡고"
case 쓰고잡고 = "쓰고잡고"
case 하고잡고 = "하고잡고"
case 놀고잡고
case 믿고잡고
case 따고잡고
case 쓰고잡고
case 하고잡고
}

public enum SeojinGirlsHighSchool: String, CaseIterable, Decodable, Encodable {
case 없음 = "없음"
case 없음
}

public enum SunguiScienceTechnologyHighSchool: String, CaseIterable, Decodable, Encodable {
case 서전트스나이퍼 = "서전트스나이퍼"
case 서전트스나이퍼
case 카페인팅 = "카-페인팅"
case 드림온 = "드림온"
case 드림온
case 볼트와암페어 = "볼트와 암페어"
case 크로스핏마스터 = "크로스핏마스터"
case 비상 = "비상"
case 캐치어드론 = "캐치어드론"
case 내빵네빵 = "내빵네빵"
case 카페바리 = "카페바리"
case 쿠킹마스터즈 = "쿠킹마스터즈"
case 크로스핏마스터
case 비상
case 캐치어드론
case 내빵네빵
case 카페바리
case 쿠킹마스터즈
}

public enum SongwonGirlsCommercialHighSchool: String, CaseIterable, Decodable, Encodable {
case 건강지킴이 = "건강지킴이"
case 미용서비스 = "미용서비스"
case 뷰티아트 = "뷰티아트"
case 클로즈업 = "클로즈업"
case 건강지킴이
case 미용서비스
case 뷰티아트
case 클로즈업
}

public enum GwangjuAutomaticEquipmentTechnicalHighSchool: String, CaseIterable, Decodable, Encodable {
case HMI동아리 = "HMI동아리"
case 마취제 = "마취제"
case HMI동아리
case 마취제
case 빛go = "빛go job go"
case 취업진로동아리 = "취업진로 동아리"
}
Expand Down
21 changes: 21 additions & 0 deletions Service/Sources/Base/Enum/FieldType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation

public enum FieldType: String, Codable {
case futuristicTransportationEquipment = "FUTURISTIC_TRANSPORTATION_EQUIPMENT"
case energy = "ENERGY"
case medicalHealthcare = "MEDICAL_HEALTHCARE"
case aiConvergence = "AI_CONVERGENCE"
case culture = "CULTURE"
}

public extension FieldType {
func display() -> String {
switch self {
case .futuristicTransportationEquipment: return "미래형 운송기기"
case .energy: return "에너지 산업"
case .medicalHealthcare: return "의료 헬스케어"
case .aiConvergence: return "AI 융복합"
case .culture: return "문화산업"
}
}
}
19 changes: 19 additions & 0 deletions Service/Sources/Base/Enum/LineType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

public enum LineType: String, Codable {
case industry = "INDUSTRY"
case commerce = "COMMERCE"
case agriculturalLifeHealthCare = "AGRICULTURAL_LIFE_HEALTH_CARE"
case customizedIndustrialDemand = "CUSTOMIZED_INDUSTRIAL_DEMAND"
}

public extension LineType {
func display() -> String {
switch self {
case .industry: return "공업계열"
case .commerce: return "상업계열"
case .agriculturalLifeHealthCare: return "농업생명/보건의료계열"
case .customizedIndustrialDemand: return "산업수요 맞춤형계열"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ public final class RemoteSchoolDataSourceImpl: BaseRemoteDataSource<SchoolAPI>,
public func fetchSchoolList() async throws -> [SchoolListEntity] {
try await request(.fetchSchoolList, dto: FetchSchoolListResponseDTO.self).toDomain()
}

public func fetchAllSchoolName() async throws -> [String] {
try await request(.fetchAllSchoolName, dto: FetchSchoolNameResponseDTO.self).toDomain()
}

public func createdSchool(req: CreatedSchoolRequestDTO) async throws {
try await request(.createdSchool(req: req))
}

public func modifySchool(schoolID: String, req: ModifySchoolRequestDTO) async throws {
try await request(.modifySchool(schoolID: schoolID, req: req))
}

public func deleteSchool(schoolID: String) async throws {
try await request(.deleteSchool(schoolID: schoolID))
}
}
Loading

0 comments on commit fe12f4e

Please sign in to comment.