diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..2f9fea60c --- /dev/null +++ b/.gitignore @@ -0,0 +1,324 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/swift,swiftpackagemanager,xcode,gradle,intellij,macos,windows,java +# Edit at https://www.toptal.com/developers/gitignore?templates=swift,swiftpackagemanager,xcode,gradle,intellij,macos,windows,java + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# Pods/ +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### SwiftPackageManager ### +Packages +xcuserdata +*.xcodeproj + + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Xcode ### + +## Xcode 8 and earlier + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno +**/xcshareddata/WorkspaceSettings.xcsettings + +### Gradle ### +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/swift,swiftpackagemanager,xcode,gradle,intellij,macos,windows,java \ No newline at end of file diff --git a/BE/.gitignore b/BE/.gitignore new file mode 100644 index 000000000..c2065bc26 --- /dev/null +++ b/BE/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/BE/build.gradle b/BE/build.gradle new file mode 100644 index 000000000..00af28afd --- /dev/null +++ b/BE/build.gradle @@ -0,0 +1,68 @@ +plugins { + id 'org.springframework.boot' version '2.7.0' + id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'java' +} + +group = 'louie.dong' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'mysql:mysql-connector-java' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'io.rest-assured:rest-assured' + testImplementation 'org.springframework.restdocs:spring-restdocs-restassured' +} + +ext { + snippetsDir = file('build/generated-snippets') +} + +test { + useJUnitPlatform() + outputs.dir snippetsDir +} + +asciidoctor { + dependsOn test + inputs.dir snippetsDir +} + +asciidoctor.doFirst { + delete file('src/main/resources/static/docs') +} + +bootJar { + dependsOn asciidoctor + copy { + from "${asciidoctor.outputDir}" + into 'src/main/resources/static/docs' + } +} + +task copyDocument(type: Copy) { + dependsOn asciidoctor + from file("build/docs/asciidoc") + into file("src/main/resources/static/docs") +} + +build { + dependsOn copyDocument +} diff --git a/BE/gradle/wrapper/gradle-wrapper.jar b/BE/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..41d9927a4 Binary files /dev/null and b/BE/gradle/wrapper/gradle-wrapper.jar differ diff --git a/BE/gradle/wrapper/gradle-wrapper.properties b/BE/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..00e33edef --- /dev/null +++ b/BE/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/BE/gradlew b/BE/gradlew new file mode 100644 index 000000000..1b6c78733 --- /dev/null +++ b/BE/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/BE/gradlew.bat b/BE/gradlew.bat new file mode 100644 index 000000000..107acd32c --- /dev/null +++ b/BE/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/BE/settings.gradle b/BE/settings.gradle new file mode 100644 index 000000000..aab815121 --- /dev/null +++ b/BE/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'airbnb' diff --git a/BE/src/docs/asciidoc/index.adoc b/BE/src/docs/asciidoc/index.adoc new file mode 100644 index 000000000..53b318274 --- /dev/null +++ b/BE/src/docs/asciidoc/index.adoc @@ -0,0 +1,29 @@ +ifndef::snippets[] +:snippets: ./build/generated-snippets +endif::[] + += Airbnb API + +== 메인 히어로 이미지 조회 + +=== Request +include::{snippets}/get-hero-image/http-request.adoc[] + +=== Response +include::{snippets}/get-hero-image/http-response.adoc[] + +== 인기 여행지 조회 + +=== Request +include::{snippets}/get-popular-destination/http-request.adoc[] + +=== Response +include::{snippets}/get-popular-destination/http-response.adoc[] + +== 숙소 지역 검색 + +=== Request +include::{snippets}/get-search-country/http-request.adoc[] + +=== Response +include::{snippets}/get-search-country/http-response.adoc[] diff --git a/BE/src/main/java/louie/dong/airbnb/AirbnbApplication.java b/BE/src/main/java/louie/dong/airbnb/AirbnbApplication.java new file mode 100644 index 000000000..73a02a508 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/AirbnbApplication.java @@ -0,0 +1,13 @@ +package louie.dong.airbnb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AirbnbApplication { + + public static void main(String[] args) { + SpringApplication.run(AirbnbApplication.class, args); + } + +} diff --git a/BE/src/main/java/louie/dong/airbnb/controller/AccommodationController.java b/BE/src/main/java/louie/dong/airbnb/controller/AccommodationController.java new file mode 100644 index 000000000..d3b8e3d07 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/controller/AccommodationController.java @@ -0,0 +1,20 @@ +package louie.dong.airbnb.controller; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import louie.dong.airbnb.dto.SearchCountryResponse; +import louie.dong.airbnb.service.MockAccommodationService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class AccommodationController { + + private final MockAccommodationService mockAccommodationService; + + @GetMapping("/accommodations") + public List getSearchCountries(String country) { + return mockAccommodationService.findByCountryLike(country); + } +} diff --git a/BE/src/main/java/louie/dong/airbnb/controller/MainController.java b/BE/src/main/java/louie/dong/airbnb/controller/MainController.java new file mode 100644 index 000000000..2f6592efa --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/controller/MainController.java @@ -0,0 +1,17 @@ +package louie.dong.airbnb.controller; + +import java.util.Collections; +import java.util.Map; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class MainController { + + private static final String MAIN_IMAGE_URL = "https://user-images.githubusercontent.com/92966772/169965428-e12f898a-1f72-4510-8ddb-8086519366c0.PNG"; + + @GetMapping("/main") + public Map getMainImage() { + return Collections.singletonMap("imageUrl", MAIN_IMAGE_URL); + } +} diff --git a/BE/src/main/java/louie/dong/airbnb/controller/PopularDestinationController.java b/BE/src/main/java/louie/dong/airbnb/controller/PopularDestinationController.java new file mode 100644 index 000000000..d3ce4a69c --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/controller/PopularDestinationController.java @@ -0,0 +1,20 @@ +package louie.dong.airbnb.controller; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import louie.dong.airbnb.dto.PopularDestinationResponse; +import louie.dong.airbnb.service.MockPopularDestinationService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class PopularDestinationController { + + private final MockPopularDestinationService mockPopularDestinationService; + + @GetMapping("/popular-destinations") + public List getPopularDestinations() { + return mockPopularDestinationService.findAll(); + } +} diff --git a/BE/src/main/java/louie/dong/airbnb/dto/PopularDestinationResponse.java b/BE/src/main/java/louie/dong/airbnb/dto/PopularDestinationResponse.java new file mode 100644 index 000000000..593a70434 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/dto/PopularDestinationResponse.java @@ -0,0 +1,13 @@ +package louie.dong.airbnb.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class PopularDestinationResponse { + + private String name; + private String imageUrl; + private String distance; +} diff --git a/BE/src/main/java/louie/dong/airbnb/dto/SearchCountryResponse.java b/BE/src/main/java/louie/dong/airbnb/dto/SearchCountryResponse.java new file mode 100644 index 000000000..b9d66a625 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/dto/SearchCountryResponse.java @@ -0,0 +1,12 @@ +package louie.dong.airbnb.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SearchCountryResponse { + + private String country; + private String imageUrl; +} diff --git a/BE/src/main/java/louie/dong/airbnb/service/MockAccommodationService.java b/BE/src/main/java/louie/dong/airbnb/service/MockAccommodationService.java new file mode 100644 index 000000000..ac1beb797 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/service/MockAccommodationService.java @@ -0,0 +1,18 @@ +package louie.dong.airbnb.service; + +import java.util.List; +import louie.dong.airbnb.dto.SearchCountryResponse; +import org.springframework.stereotype.Service; + +@Service +public class MockAccommodationService { + + public List findByCountryLike(String country) { + return List.of( + new SearchCountryResponse("양재동, 서초구, 서울특별시", ""), + new SearchCountryResponse("양재역 사거리, 양재1동", ""), + new SearchCountryResponse("서울특별시 양재2동 시민의숲앞", ""), + new SearchCountryResponse("서울특별시 양재2동 양재IC", "") + ); + } +} diff --git a/BE/src/main/java/louie/dong/airbnb/service/MockPopularDestinationService.java b/BE/src/main/java/louie/dong/airbnb/service/MockPopularDestinationService.java new file mode 100644 index 000000000..083c75d24 --- /dev/null +++ b/BE/src/main/java/louie/dong/airbnb/service/MockPopularDestinationService.java @@ -0,0 +1,22 @@ +package louie.dong.airbnb.service; + +import java.util.List; +import louie.dong.airbnb.dto.PopularDestinationResponse; +import org.springframework.stereotype.Service; + +@Service +public class MockPopularDestinationService { + + public List findAll() { + return List.of( + new PopularDestinationResponse("서울", "", "차로 30분 거리"), + new PopularDestinationResponse("광주", "", "차로 4시간 거리"), + new PopularDestinationResponse("의정부시", "", "차로 30분 거리"), + new PopularDestinationResponse("수원시", "", "차로 45분 거리"), + new PopularDestinationResponse("대구", "", "차로 3.5시간 거리"), + new PopularDestinationResponse("울산", "", "차로 4.5시간 거리"), + new PopularDestinationResponse("대전", "", "차로 2시간 거리"), + new PopularDestinationResponse("부천시", "", "차로 30분 거리") + ); + } +} diff --git a/BE/src/main/resources/application.yml b/BE/src/main/resources/application.yml new file mode 100644 index 000000000..e70c7b8be --- /dev/null +++ b/BE/src/main/resources/application.yml @@ -0,0 +1,6 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/airbnb + username: loudong + password: '0524' diff --git a/BE/src/main/resources/static/docs/index.html b/BE/src/main/resources/static/docs/index.html new file mode 100644 index 000000000..0a8968942 --- /dev/null +++ b/BE/src/main/resources/static/docs/index.html @@ -0,0 +1,594 @@ + + + + + + + +Airbnb API + + + + + +
+
+

메인 히어로 이미지 조회

+
+
+

Request

+
+
+
GET /main HTTP/1.1
+Accept: application/json
+Host: localhost:56509
+
+
+
+
+

Response

+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json
+Transfer-Encoding: chunked
+Date: Tue, 24 May 2022 08:59:14 GMT
+Keep-Alive: timeout=60
+Connection: keep-alive
+Content-Length: 124
+
+{
+  "imageUrl" : "https://user-images.githubusercontent.com/92966772/169965428-e12f898a-1f72-4510-8ddb-8086519366c0.PNG"
+}
+
+
+
+
+
+
+

인기 여행지 조회

+
+
+

Request

+
+
+
GET /popular-destinations HTTP/1.1
+Accept: application/json
+Host: localhost:56509
+
+
+
+
+

Response

+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json
+Transfer-Encoding: chunked
+Date: Tue, 24 May 2022 08:59:14 GMT
+Keep-Alive: timeout=60
+Connection: keep-alive
+Content-Length: 714
+
+[ {
+  "name" : "서울",
+  "imageUrl" : "",
+  "distance" : "차로 30분 거리"
+}, {
+  "name" : "광주",
+  "imageUrl" : "",
+  "distance" : "차로 4시간 거리"
+}, {
+  "name" : "의정부시",
+  "imageUrl" : "",
+  "distance" : "차로 30분 거리"
+}, {
+  "name" : "수원시",
+  "imageUrl" : "",
+  "distance" : "차로 45분 거리"
+}, {
+  "name" : "대구",
+  "imageUrl" : "",
+  "distance" : "차로 3.5시간 거리"
+}, {
+  "name" : "울산",
+  "imageUrl" : "",
+  "distance" : "차로 4.5시간 거리"
+}, {
+  "name" : "대전",
+  "imageUrl" : "",
+  "distance" : "차로 2시간 거리"
+}, {
+  "name" : "부천시",
+  "imageUrl" : "",
+  "distance" : "차로 30분 거리"
+} ]
+
+
+
+
+
+
+

숙소 지역 검색

+
+
+

Request

+
+
+
GET /accommodations?country=%EC%96%91%EC%9E%AC%EB%8F%99 HTTP/1.1
+Accept: application/json
+Host: localhost:56509
+
+
+
+
+

Response

+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json
+Transfer-Encoding: chunked
+Date: Tue, 24 May 2022 08:59:13 GMT
+Keep-Alive: timeout=60
+Connection: keep-alive
+Content-Length: 323
+
+[ {
+  "country" : "양재동, 서초구, 서울특별시",
+  "imageUrl" : ""
+}, {
+  "country" : "양재역 사거리, 양재1동",
+  "imageUrl" : ""
+}, {
+  "country" : "서울특별시 양재2동 시민의숲앞",
+  "imageUrl" : ""
+}, {
+  "country" : "서울특별시 양재2동 양재IC",
+  "imageUrl" : ""
+} ]
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/BE/src/test/java/louie/dong/airbnb/AirbnbApplicationTests.java b/BE/src/test/java/louie/dong/airbnb/AirbnbApplicationTests.java new file mode 100644 index 000000000..35beaee99 --- /dev/null +++ b/BE/src/test/java/louie/dong/airbnb/AirbnbApplicationTests.java @@ -0,0 +1,13 @@ +package louie.dong.airbnb; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class AirbnbApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/BE/src/test/java/louie/dong/airbnb/integration/AccommodationIntegrationTest.java b/BE/src/test/java/louie/dong/airbnb/integration/AccommodationIntegrationTest.java new file mode 100644 index 000000000..3db705aa9 --- /dev/null +++ b/BE/src/test/java/louie/dong/airbnb/integration/AccommodationIntegrationTest.java @@ -0,0 +1,65 @@ +package louie.dong.airbnb.integration; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration; + +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.specification.RequestSpecification; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.restdocs.RestDocumentationContextProvider; +import org.springframework.restdocs.RestDocumentationExtension; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.filter.CharacterEncodingFilter; + +@ExtendWith({RestDocumentationExtension.class}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Transactional +class AccommodationIntegrationTest { + + @LocalServerPort + int port; + + RequestSpecification documentationSpec; + + @BeforeEach + void setup(RestDocumentationContextProvider restDocumentation) { + RestAssured.port = port; + documentationSpec = new RequestSpecBuilder() + .addFilter(documentationConfiguration(restDocumentation)) + .build(); + } + + @Test + void 숙소_지역_검색() { + given(documentationSpec) + .urlEncodingEnabled(false) + .accept(MediaType.APPLICATION_JSON_VALUE) + .filter(document("get-search-country", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) + + .when() + .get("/accommodations?country=양재동") + + .then() + .statusCode(HttpStatus.OK.value()) + .assertThat() + .body("", hasSize(4)) + .body("[0].country", equalTo("양재동, 서초구, 서울특별시")) + .body("[0].imageUrl", equalTo("")) + .body("[1].country", equalTo("양재역 사거리, 양재1동")) + .body("[1].imageUrl", equalTo("")); + } +} diff --git a/BE/src/test/java/louie/dong/airbnb/integration/MainIntegrationTest.java b/BE/src/test/java/louie/dong/airbnb/integration/MainIntegrationTest.java new file mode 100644 index 000000000..d4bc64d00 --- /dev/null +++ b/BE/src/test/java/louie/dong/airbnb/integration/MainIntegrationTest.java @@ -0,0 +1,58 @@ +package louie.dong.airbnb.integration; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration; + +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.specification.RequestSpecification; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.restdocs.RestDocumentationContextProvider; +import org.springframework.restdocs.RestDocumentationExtension; +import org.springframework.transaction.annotation.Transactional; + +@ExtendWith({RestDocumentationExtension.class}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Transactional +class MainIntegrationTest { + + @LocalServerPort + int port; + + RequestSpecification documentationSpec; + + @BeforeEach + void setup(RestDocumentationContextProvider restDocumentation) { + RestAssured.port = port; + documentationSpec = new RequestSpecBuilder() + .addFilter(documentationConfiguration(restDocumentation)) + .build(); + } + + @Test + void 메인_히어로_이미지_조회() { + given(documentationSpec) + .accept(MediaType.APPLICATION_JSON_VALUE) + .filter(document("get-hero-image", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) + + .when() + .get("/main") + + .then() + .statusCode(HttpStatus.OK.value()) + .assertThat() + .body("imageUrl", equalTo( + "https://user-images.githubusercontent.com/92966772/169965428-e12f898a-1f72-4510-8ddb-8086519366c0.PNG")); + } +} diff --git a/BE/src/test/java/louie/dong/airbnb/integration/PopularDestinationIntegrationTest.java b/BE/src/test/java/louie/dong/airbnb/integration/PopularDestinationIntegrationTest.java new file mode 100644 index 000000000..555f97a1f --- /dev/null +++ b/BE/src/test/java/louie/dong/airbnb/integration/PopularDestinationIntegrationTest.java @@ -0,0 +1,64 @@ +package louie.dong.airbnb.integration; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration; + +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.specification.RequestSpecification; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.restdocs.RestDocumentationContextProvider; +import org.springframework.restdocs.RestDocumentationExtension; +import org.springframework.transaction.annotation.Transactional; + +@ExtendWith({RestDocumentationExtension.class}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Transactional +class PopularDestinationIntegrationTest { + + @LocalServerPort + int port; + + RequestSpecification documentationSpec; + + @BeforeEach + void setup(RestDocumentationContextProvider restDocumentation) { + RestAssured.port = port; + documentationSpec = new RequestSpecBuilder() + .addFilter(documentationConfiguration(restDocumentation)) + .build(); + } + + @Test + void 인기_여행지_조회() { + given(documentationSpec) + .accept(MediaType.APPLICATION_JSON_VALUE) + .filter(document("get-popular-destination", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) + + .when() + .get("/popular-destinations") + + .then() + .statusCode(HttpStatus.OK.value()) + .assertThat() + .body("", hasSize(8)) + .body("[0].name", equalTo("서울")) + .body("[0].imageUrl", equalTo("")) + .body("[0].distance", equalTo("차로 30분 거리")) + .body("[1].name", equalTo("광주")) + .body("[1].imageUrl", equalTo("")) + .body("[1].distance", equalTo("차로 4시간 거리")); + } +} diff --git a/README.md b/README.md index 8ec09bd21..e8c809504 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # airbnb -그룹 프로젝트 #4 +> 12조 + +## 팀원 + +|iOS|BE| +|---|---| +|[sally](https://github.com/sally4405)|[루이](https://github.com/Louie-03)| +|[bibi](https://github.com/bibi6666667)|[동기](https://github.com/donggi-lee-bit)| + +--- + +## Document +- [Ground Rule](https://github.com/sally4405/airbnb/wiki/Ground-Rule) +- [기획서](https://www.figma.com/proto/inTClwuq2Hr7E33JPIMKza/%EB%AA%A8%EB%B0%94%EC%9D%BC_%EC%88%99%EC%86%8C%EC%98%88%EC%95%BD%EC%84%9C%EB%B9%84%EC%8A%A4?page-id=56%3A1424&node-id=56%3A1972&viewport=25%2C336%2C0.03&scaling=contain) +- [디자인 가이드](https://www.figma.com/file/inTClwuq2Hr7E33JPIMKza/%EB%AA%A8%EB%B0%94%EC%9D%BC_%EC%88%99%EC%86%8C%EC%98%88%EC%95%BD%EC%84%9C%EB%B9%84%EC%8A%A4?node-id=56%3A2206) \ No newline at end of file