diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/auth/AuthService.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/auth/AuthService.kt index 0c61335..fef3758 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/auth/AuthService.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/auth/AuthService.kt @@ -23,11 +23,11 @@ class AuthService( private val userRepository: UserRepository, private val schoolRepository: SchoolRepository, private val googleOAuth2Client: GoogleOAuth2Client, + private val googleOAuth2Helper: GoogleOAuth2Helper, private val appleOAuth2Client: AppleOAuth2Client, private val appleOAuth2Helper: AppleOAuth2Helper, - private val googleOAuth2Helper: GoogleOAuth2Helper, private val jwtClient: JwtClient, - private val sessionHolder: UserAuthenticationHolder + private val authenticationHolder: UserAuthenticationHolder ) { fun signIn(req: SignInReq): TokenRes { val email = when (req.platformType) { @@ -50,7 +50,7 @@ class AuthService( fun signUp(req: SignUpReq): TokenRes { val school = schoolRepository.getBy(req.schoolId) - val user = sessionHolder.current() + val user = authenticationHolder.current() if (user.isActive) { throw CustomException(HttpStatus.BAD_REQUEST, "User already sign in") diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/meal/MealService.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/meal/MealService.kt index 5112d8f..19a8738 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/meal/MealService.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/meal/MealService.kt @@ -3,8 +3,6 @@ package com.bestswlkh0310.graduating.graduatingserver.api.meal import com.bestswlkh0310.graduating.graduatingserver.api.meal.res.MealRes import com.bestswlkh0310.graduating.graduatingserver.core.global.safeSaveAll import com.bestswlkh0310.graduating.graduatingserver.core.meal.MealRepository -import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolRepository -import com.bestswlkh0310.graduating.graduatingserver.core.school.getBy import com.bestswlkh0310.graduating.graduatingserver.core.user.UserAuthenticationHolder import com.bestswlkh0310.graduating.graduatingserver.global.exception.CustomException import com.bestswlkh0310.graduating.graduatingserver.infra.neis.meal.NeisMealClient @@ -16,10 +14,10 @@ import java.time.LocalDate class MealService( private val mealRepository: MealRepository, private val neisMealClient: NeisMealClient, - private val sessionHolder: UserAuthenticationHolder + private val authenticationHolder: UserAuthenticationHolder ) { fun getMeals(): List { - val school = sessionHolder.current().school ?: throw CustomException(HttpStatus.NOT_FOUND, "Not found school") + val school = authenticationHolder.current().school ?: throw CustomException(HttpStatus.NOT_FOUND, "Not found school") val currentTime = LocalDate.now() val schools = mealRepository.findBySchoolIdAndMealDate(school.id, currentTime) diff --git a/Graduating-iOS/Graduating/Feature/Component/GoogleAdView.swift b/Graduating-iOS/Graduating/Feature/Component/GoogleAdView.swift new file mode 100644 index 0000000..a8ecccf --- /dev/null +++ b/Graduating-iOS/Graduating/Feature/Component/GoogleAdView.swift @@ -0,0 +1,44 @@ +import SwiftUI +import GoogleMobileAds + +public struct GoogleAdView: UIViewControllerRepresentable { + public func makeUIViewController(context: Context) -> UIViewController { + let viewController = UIViewController() + let bannerSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(UIScreen.main.bounds.width) + let banner = GADBannerView(adSize: bannerSize) + banner.rootViewController = viewController + viewController.view.addSubview(banner) + viewController.view.frame = CGRect(origin: .zero, size: bannerSize.size) +#if DEBUG + banner.adUnitID = "ca-app-pub-3940256099942544/2435281174" +#else + banner.adUnitID = "ca-app-pub-2589637472995872/3554240467" +#endif + banner.load(GADRequest()) + return viewController + } + + public func updateUIViewController(_ viewController: UIViewController, context: Context) {} +} + +public extension GoogleAdView { + struct BottomBannerPresenter: View { + public let banner: () -> Banner + public let label: () -> Label + + public init( + @ViewBuilder banner: @escaping () -> Banner, + @ViewBuilder label: @escaping () -> Label + ) { + self.banner = banner + self.label = label + } + + public var body: some View { + VStack(spacing: 0) { + banner() + label() + } + } + } +} diff --git a/Graduating-iOS/Graduating/GraduatingApp.swift b/Graduating-iOS/Graduating/GraduatingApp.swift index 94e5112..08e46d0 100644 --- a/Graduating-iOS/Graduating/GraduatingApp.swift +++ b/Graduating-iOS/Graduating/GraduatingApp.swift @@ -33,11 +33,16 @@ extension GraduatingApp { datePickerProvider: datePickerProvider, timePickerProvider: timePickerProvider ) { - NavigationStack(path: $router.path) { - if appState.shouldSignUp { - OnboardingCoordinator() - } else { - MainCoordinator() + GoogleAdView.BottomBannerPresenter { + GoogleAdView() + .frame(width: UIScreen.main.bounds.width, height: GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(UIScreen.main.bounds.width).size.height) + } label: { + NavigationStack(path: $router.path) { + if appState.shouldSignUp { + OnboardingCoordinator() + } else { + MainCoordinator() + } } } }