Skip to content

Commit

Permalink
[Edit] enum DrinkJsonType case별로 맞지 않은 return 값을 갖고 있어 수정 #161
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrsky2010 committed Mar 18, 2024
1 parent bc329d3 commit 174b461
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 86 deletions.
40 changes: 28 additions & 12 deletions JUDA_iOS/JUDA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
09F869B72B6A47C700A56A4C /* AlarmStoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F869B62B6A47C700A56A4C /* AlarmStoreView.swift */; };
09F869BB2B6A4A9C00A56A4C /* LikedDrinkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F869BA2B6A4A9C00A56A4C /* LikedDrinkList.swift */; };
09F869BD2B6A4AAE00A56A4C /* LikedPostGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F869BC2B6A4AAE00A56A4C /* LikedPostGrid.swift */; };
09FD4F152BA5CAC300959672 /* DrinkLoading.json in Resources */ = {isa = PBXBuildFile; fileRef = 09FD4F142BA5CAC300959672 /* DrinkLoading.json */; };
09FD4F182BA5CAD400959672 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 09FD4F162BA5CAD300959672 /* GoogleService-Info.plist */; };
09FD4F192BA5CAD400959672 /* APIKEYS.plist in Resources */ = {isa = PBXBuildFile; fileRef = 09FD4F172BA5CAD300959672 /* APIKEYS.plist */; };
2C2044E82B63B9D600773266 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2044E72B63B9D600773266 /* ContentView.swift */; };
2C2AD4FD2B68891C00C681F4 /* SearchTagView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2AD4FC2B68891C00C681F4 /* SearchTagView.swift */; };
2C2AD5012B689CA500C681F4 /* SelectedPhotoHorizontalScroll.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2AD5002B689CA500C681F4 /* SelectedPhotoHorizontalScroll.swift */; };
Expand All @@ -93,6 +90,13 @@
7B0A8BC52B8C163E00740E61 /* Report.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A8BC42B8C163E00740E61 /* Report.swift */; };
7B0A8BCD2B8CA7E900740E61 /* PostSearchList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A8BCC2B8CA7E900740E61 /* PostSearchList.swift */; };
7B0A8BCF2B8CA8C300740E61 /* PostSearchListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A8BCE2B8CA8C300740E61 /* PostSearchListCell.swift */; };
7B17CF0B2BA80B8000A9C080 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF092BA80B8000A9C080 /* GoogleService-Info.plist */; };
7B17CF0C2BA80B8000A9C080 /* APIKEYS.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF0A2BA80B8000A9C080 /* APIKEYS.plist */; };
7B17CF0E2BA80B9400A9C080 /* DrinkLoading.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF0D2BA80B9400A9C080 /* DrinkLoading.json */; };
7B17CF132BA80BAA00A9C080 /* WineTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF0F2BA80BAA00A9C080 /* WineTest.json */; };
7B17CF142BA80BAA00A9C080 /* WhiskeyTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF102BA80BAA00A9C080 /* WhiskeyTest.json */; };
7B17CF152BA80BAA00A9C080 /* BeerTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF112BA80BAA00A9C080 /* BeerTest.json */; };
7B17CF162BA80BAA00A9C080 /* TraditionalTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B17CF122BA80BAA00A9C080 /* TraditionalTest.json */; };
7B5174922B69EAB300915793 /* NavigationPostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5174912B69EAB300915793 /* NavigationPostsView.swift */; };
7B56AE172BA66C8200C47F3C /* FirebaseFunctions in Frameworks */ = {isa = PBXBuildFile; productRef = 7B56AE162BA66C8200C47F3C /* FirebaseFunctions */; };
7B6D76A72B677A8F00601B55 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D76A62B677A8F00601B55 /* Button.swift */; };
Expand Down Expand Up @@ -241,9 +245,6 @@
09F869B62B6A47C700A56A4C /* AlarmStoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmStoreView.swift; sourceTree = "<group>"; };
09F869BA2B6A4A9C00A56A4C /* LikedDrinkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikedDrinkList.swift; sourceTree = "<group>"; };
09F869BC2B6A4AAE00A56A4C /* LikedPostGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikedPostGrid.swift; sourceTree = "<group>"; };
09FD4F142BA5CAC300959672 /* DrinkLoading.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = DrinkLoading.json; path = "../../../../../흐르미/Lottie/DrinkLoading.json"; sourceTree = "<group>"; };
09FD4F162BA5CAD300959672 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../흐르미/GoogleService-Info.plist"; sourceTree = "<group>"; };
09FD4F172BA5CAD300959672 /* APIKEYS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = APIKEYS.plist; path = "../../../흐르미/APIKEYS.plist"; sourceTree = "<group>"; };
2C2044E72B63B9D600773266 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
2C2AD4FC2B68891C00C681F4 /* SearchTagView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTagView.swift; sourceTree = "<group>"; };
2C2AD5002B689CA500C681F4 /* SelectedPhotoHorizontalScroll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedPhotoHorizontalScroll.swift; sourceTree = "<group>"; };
Expand All @@ -262,6 +263,13 @@
7B0A8BC42B8C163E00740E61 /* Report.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Report.swift; sourceTree = "<group>"; };
7B0A8BCC2B8CA7E900740E61 /* PostSearchList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostSearchList.swift; sourceTree = "<group>"; };
7B0A8BCE2B8CA8C300740E61 /* PostSearchListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostSearchListCell.swift; sourceTree = "<group>"; };
7B17CF092BA80B8000A9C080 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../../../JUDA_file/GoogleService-Info.plist"; sourceTree = "<group>"; };
7B17CF0A2BA80B8000A9C080 /* APIKEYS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = APIKEYS.plist; path = ../../../../../../JUDA_file/APIKEYS.plist; sourceTree = "<group>"; };
7B17CF0D2BA80B9400A9C080 /* DrinkLoading.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = DrinkLoading.json; path = ../../../../../../../../JUDA_file/Lottie/DrinkLoading.json; sourceTree = "<group>"; };
7B17CF0F2BA80BAA00A9C080 /* WineTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = WineTest.json; path = ../../../../../../../../JUDA_file/TestJsonData/WineTest.json; sourceTree = "<group>"; };
7B17CF102BA80BAA00A9C080 /* WhiskeyTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = WhiskeyTest.json; path = ../../../../../../../../JUDA_file/TestJsonData/WhiskeyTest.json; sourceTree = "<group>"; };
7B17CF112BA80BAA00A9C080 /* BeerTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = BeerTest.json; path = ../../../../../../../../JUDA_file/TestJsonData/BeerTest.json; sourceTree = "<group>"; };
7B17CF122BA80BAA00A9C080 /* TraditionalTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = TraditionalTest.json; path = ../../../../../../../../JUDA_file/TestJsonData/TraditionalTest.json; sourceTree = "<group>"; };
7B5174912B69EAB300915793 /* NavigationPostsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationPostsView.swift; sourceTree = "<group>"; };
7B6D76A62B677A8F00601B55 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
7B6D76AA2B67CE3D00601B55 /* PostDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostDetailView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -410,6 +418,10 @@
isa = PBXGroup;
children = (
7BE14B962B84767000C1F6C3 /* DrinkUploadViewModel.swift */,
7B17CF112BA80BAA00A9C080 /* BeerTest.json */,
7B17CF122BA80BAA00A9C080 /* TraditionalTest.json */,
7B17CF102BA80BAA00A9C080 /* WhiskeyTest.json */,
7B17CF0F2BA80BAA00A9C080 /* WineTest.json */,
);
path = JsonUploadFiles;
sourceTree = "<group>";
Expand Down Expand Up @@ -443,7 +455,7 @@
09BCC1492B7C7E2900FF4D1B /* Loading.json */,
09BCC14C2B7C7E2900FF4D1B /* Rain.json */,
09BCC14D2B7C7E2900FF4D1B /* Snow.json */,
09FD4F142BA5CAC300959672 /* DrinkLoading.json */,
7B17CF0D2BA80B9400A9C080 /* DrinkLoading.json */,
09BCC14B2B7C7E2900FF4D1B /* Sun.json */,
09BCC14A2B7C7E2900FF4D1B /* Thunder.json */,
);
Expand Down Expand Up @@ -580,8 +592,8 @@
B1B8FE802B5EA9DA00921BBE /* Assets.xcassets */,
B1B8FE8C2B5EAAAB00921BBE /* Colors.xcassets */,
B121A56F2B5F8DA100667D42 /* Info.plist */,
09FD4F172BA5CAD300959672 /* APIKEYS.plist */,
09FD4F162BA5CAD300959672 /* GoogleService-Info.plist */,
7B17CF0A2BA80B8000A9C080 /* APIKEYS.plist */,
7B17CF092BA80B8000A9C080 /* GoogleService-Info.plist */,
B1B8FE822B5EA9DA00921BBE /* Preview Content */,
);
path = JUDA;
Expand Down Expand Up @@ -887,7 +899,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7B17CF142BA80BAA00A9C080 /* WhiskeyTest.json in Resources */,
09BCC1512B7C7E2900FF4D1B /* Sun.json in Resources */,
7B17CF0E2BA80B9400A9C080 /* DrinkLoading.json in Resources */,
7B17CF162BA80BAA00A9C080 /* TraditionalTest.json in Resources */,
7B17CF152BA80BAA00A9C080 /* BeerTest.json in Resources */,
09BCC1502B7C7E2900FF4D1B /* Thunder.json in Resources */,
B1B8FE8D2B5EAAAB00921BBE /* Colors.xcassets in Resources */,
B121A5732B5F910900667D42 /* Pretendard-Bold.otf in Resources */,
Expand All @@ -897,14 +913,14 @@
B121A5772B5F911900667D42 /* Pretendard-SemiBold.otf in Resources */,
09BCC1532B7C7E2900FF4D1B /* Snow.json in Resources */,
09BCC1542B7C7E2900FF4D1B /* Clouds.json in Resources */,
7B17CF132BA80BAA00A9C080 /* WineTest.json in Resources */,
B121A5742B5F910B00667D42 /* Pretendard-Light.otf in Resources */,
7B17CF0B2BA80B8000A9C080 /* GoogleService-Info.plist in Resources */,
09BCC1522B7C7E2900FF4D1B /* Rain.json in Resources */,
09FD4F182BA5CAD400959672 /* GoogleService-Info.plist in Resources */,
7B17CF0C2BA80B8000A9C080 /* APIKEYS.plist in Resources */,
B121A5762B5F911700667D42 /* Pretendard-Regular.otf in Resources */,
B1B8FE812B5EA9DA00921BBE /* Assets.xcassets in Resources */,
B121A5752B5F911500667D42 /* Pretendard-Medium.otf in Resources */,
09FD4F152BA5CAC300959672 /* DrinkLoading.json in Resources */,
09FD4F192BA5CAD400959672 /* APIKEYS.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
13 changes: 10 additions & 3 deletions JUDA_iOS/JUDA.xcodeproj/xcshareddata/xcschemes/JUDA.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,23 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Users/minjaekim/Library/Developer/Xcode/DerivedData/JUDA-gzjyaxsluhlruncajghxttycvogn/Build/Products/Debug-iphonesimulator/JUDA.app">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B1B8FE782B5EA9D900921BBE"
BuildableName = "JUDA"
BlueprintName = "JUDA"
ReferencedContainer = "container:JUDA.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</MacroExpansion>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
</LocationScenarioReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion JUDA_iOS/JUDA/ViewModel/Auth/AuthViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ extension AuthViewModel {
userData: UserField(
name: name, age: age, gender: gender,
fcmToken: "", notificationAllowed: notification,
profileImageURL: (currentUser?.userField.profileImageURL)!,
profileImageURL: currentUser?.userField.profileImageURL,
authProviders: try getProviderOptionString()),
uid: uid)
} catch {
Expand Down
43 changes: 24 additions & 19 deletions JUDA_iOS/JUDA/ViewModel/Drink/FirestoreDrinkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,30 @@ final class FirestoreDrinkService {

// MARK: Firestore Fetch Data
extension FirestoreDrinkService {
// Drink 리스트를 가져오는 함수
// Drink 를 단일로 가져오는 firestoreDrinkViewModel 의 fetchDrinkDocument 을 사용.
func fetchDrinkCollection(collection: CollectionReference) async throws -> [Drink] {
do {
var result = [Drink]()
// Drink 가져오는 코드 - FirestoreDrinkViewModel
let snapshot = try await collection.getDocuments()
for document in snapshot.documents {
let id = document.documentID
let documentRef = collection.document(id)
let drinkData = try await fetchDrinkDocument(document: documentRef)
result.append(drinkData)
}
return result
} catch let error {
print("error :: fetchDrinkCollection", error.localizedDescription)
throw DrinkError.fetchDrinkCollection
}
}
// Drink 리스트를 가져오는 함수
// Drink 를 단일로 가져오는 firestoreDrinkViewModel 의 fetchDrinkDocument 을 사용.
func fetchDrinkCollection(collection: CollectionReference, query: Query? = nil) async throws -> [Drink] {
do {
var result = [Drink]()
var snapshot: QuerySnapshot
// Drink 가져오는 코드 - FirestoreDrinkViewModel
if let query = query {
snapshot = try await query.getDocuments()
} else {
snapshot = try await collection.getDocuments()
}
for document in snapshot.documents {
let id = document.documentID
let documentRef = collection.document(id)
let drinkData = try await fetchDrinkDocument(document: documentRef)
result.append(drinkData)
}
return result
} catch let error {
print("error :: fetchDrinkCollection", error.localizedDescription)
throw DrinkError.fetchDrinkCollection
}
}

// drinks collection의 document data 불러오는 메서드
// 불러오지 못 할 경우 error를 throw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ final class DrinkUploadViewModel: ObservableObject {
drinks.append(contentsOf: drinkData)
}
}
print(drinks.filter { $0.category == "위스키" }.count)
print(drinks.filter { $0.category == "우리술" }.count)
print(drinks.filter { $0.category == "맥주" }.count)
print(drinks.filter { $0.category == "와인" }.count)
drinkDataUpload(drinkData: drinks)
}

Expand Down Expand Up @@ -118,10 +122,10 @@ final class DrinkUploadViewModel: ObservableObject {
group.addTask {
do {
if let fileName = Formatter.getImageName(category: category, detailedCategory: drink.type) {
let url = try await self.fireStorageService.fetchImageURL(folder: .drink, fileName: "")
let url = try await self.fireStorageService.fetchImageURL(folder: .drink, fileName: fileName)
return (index, url)
} else {
print("error :: getImageName")
print("error :: getImageName", drink.category, drink.type)
return (index, nil)
}
} catch {
Expand Down Expand Up @@ -233,11 +237,11 @@ extension DrinkUploadViewModel {
switch self {
case .beer:
return "BeerTest"
case .wine:
return "TraditionalTest"
case .traditional:
return "WhiskeyTest"
return "TraditionalTest"
case .whiskey:
return "WhiskeyTest"
case .wine:
return "WineTest"
}
}
Expand Down
50 changes: 25 additions & 25 deletions JUDA_iOS/JUDA/ViewModel/Main/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,31 @@ final class MainViewModel: ObservableObject {

// MARK: - Fetch
extension MainViewModel {
// 인기 있는 drink 가져오기
func getHottestDrinks() async {
do {
let hottestDrinksRef = firestore.collection(drinkCollection)
.order(by: "rating", descending: true).limit(to: 3)
// Drink 가져오는 함수 사용 - FirestoreDrinkService
let hottestDrinks = try await firestoreDrinkService.fetchDrinkCollection(collection: hottestDrinksRef as! CollectionReference)
drinks = hottestDrinks
} catch {
print("error :: getHottestDrinks", error.localizedDescription)
}
}
// 인기 있는 post 가져오기
func getHottestPosts() async {
do {
let hottestPostsRef = firestore.collection(postCollection)
.order(by: "likedCount", descending: true).limit(to: 3)
// Post 가져오는 함수 사용 - FirestorePostService
let hottestPosts = try await firestorePostService.fetchPostCollection(collection: hottestPostsRef as! CollectionReference)
posts = hottestPosts
} catch {
print("error :: getHottestPosts", error.localizedDescription)
}
}
// 인기 있는 drink 가져오기
func getHottestDrinks() async {
do {
let collectionRef = firestore.collection(drinkCollection)
let hottestDrinksRef = collectionRef.order(by: "rating", descending: true).limit(to: 3)
// Drink 가져오는 함수 사용 - FirestoreDrinkService
let hottestDrinks = try await firestoreDrinkService.fetchDrinkCollection(collection: collectionRef, query: hottestDrinksRef)
drinks = hottestDrinks
} catch {
print("error :: getHottestDrinks", error.localizedDescription)
}
}
// 인기 있는 post 가져오기
func getHottestPosts() async {
do {
let collectionRef = firestore.collection(postCollection)
let hottestPostsRef = collectionRef.order(by: "likedCount", descending: true).limit(to: 3)
// Post 가져오는 함수 사용 - FirestorePostService
let hottestPosts = try await firestorePostService.fetchPostCollection(collection: collectionRef, query: hottestPostsRef)
posts = hottestPosts
} catch {
print("error :: getHottestPosts", error.localizedDescription)
}
}

// 날씨 & 음식 + 술 받아오기
func getWeatherAndAIResponse(location: CLLocation) async {
Expand Down
Loading

0 comments on commit 174b461

Please sign in to comment.