diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/Good-Night-Hackathon-SpringBoot.iml b/.idea/Good-Night-Hackathon-SpringBoot.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/Good-Night-Hackathon-SpringBoot.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..639900d1
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..44e3fc6d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hackathon/.gitignore b/Hackathon/.gitignore
new file mode 100644
index 00000000..c2065bc2
--- /dev/null
+++ b/Hackathon/.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/Hackathon/build.gradle b/Hackathon/build.gradle
new file mode 100644
index 00000000..b3d778b3
--- /dev/null
+++ b/Hackathon/build.gradle
@@ -0,0 +1,36 @@
+plugins {
+ id 'java'
+ id 'org.springframework.boot' version '2.7.9'
+ id 'io.spring.dependency-management' version '1.0.15.RELEASE'
+}
+
+group = 'com.example'
+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-security'
+ implementation 'org.springframework.boot:spring-boot-starter-web'
+ implementation 'org.springframework.boot:spring-boot-starter-validation'
+ compileOnly 'org.projectlombok:lombok'
+ developmentOnly 'org.springframework.boot:spring-boot-devtools'
+ runtimeOnly 'com.mysql:mysql-connector-j'
+ annotationProcessor 'org.projectlombok:lombok'
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
+ testImplementation 'org.springframework.security:spring-security-test'
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
+}
diff --git a/Hackathon/gradle/wrapper/gradle-wrapper.jar b/Hackathon/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..249e5832
Binary files /dev/null and b/Hackathon/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/Hackathon/gradle/wrapper/gradle-wrapper.properties b/Hackathon/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..070cb702
--- /dev/null
+++ b/Hackathon/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/Hackathon/gradlew b/Hackathon/gradlew
new file mode 100644
index 00000000..a69d9cb6
--- /dev/null
+++ b/Hackathon/gradlew
@@ -0,0 +1,240 @@
+#!/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 \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# 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/Hackathon/gradlew.bat b/Hackathon/gradlew.bat
new file mode 100644
index 00000000..f127cfd4
--- /dev/null
+++ b/Hackathon/gradlew.bat
@@ -0,0 +1,91 @@
+@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% equ 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% equ 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!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/Hackathon/settings.gradle b/Hackathon/settings.gradle
new file mode 100644
index 00000000..aa8e53e1
--- /dev/null
+++ b/Hackathon/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'Hackathon'
diff --git a/Hackathon/src/main/java/com/example/hackathon/HackathonApplication.java b/Hackathon/src/main/java/com/example/hackathon/HackathonApplication.java
new file mode 100644
index 00000000..515e7ba4
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/HackathonApplication.java
@@ -0,0 +1,13 @@
+package com.example.hackathon;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HackathonApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(HackathonApplication.class, args);
+ }
+
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/config/JpaAuditingConfig.java b/Hackathon/src/main/java/com/example/hackathon/global/config/JpaAuditingConfig.java
new file mode 100644
index 00000000..e7980124
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/config/JpaAuditingConfig.java
@@ -0,0 +1,8 @@
+package com.example.hackathon.global.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+
+@EnableJpaAuditing
+@Configuration
+public class JpaAuditingConfig {}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/dto/ErrorResponse.java b/Hackathon/src/main/java/com/example/hackathon/global/dto/ErrorResponse.java
new file mode 100644
index 00000000..3b9117eb
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/dto/ErrorResponse.java
@@ -0,0 +1,15 @@
+package com.example.hackathon.global.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+@Builder
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class ErrorResponse {
+ private String businessCode;
+ private String errorMessage;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/dto/ResultResponse.java b/Hackathon/src/main/java/com/example/hackathon/global/dto/ResultResponse.java
new file mode 100644
index 00000000..c057ecf9
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/dto/ResultResponse.java
@@ -0,0 +1,25 @@
+package com.example.hackathon.global.dto;
+
+import com.example.hackathon.global.dto.code.ResultCode;
+import lombok.Getter;
+
+@Getter
+public class ResultResponse {
+ private String code;
+ private String message;
+ private Object data;
+
+ public ResultResponse(ResultCode resultCode, Object data){
+ this.code = resultCode.getCode();
+ this.message = resultCode.getMessage();
+ this.data = data;
+ }
+
+ public static ResultResponse of(ResultCode resultCode, Object data){
+ return new ResultResponse(resultCode,data);
+ }
+
+ public static ResultResponse of(ResultCode resultCode){
+ return new ResultResponse(resultCode,"");
+ }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ErrorCode.java b/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ErrorCode.java
new file mode 100644
index 00000000..cc69cade
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ErrorCode.java
@@ -0,0 +1,19 @@
+package com.example.hackathon.global.dto.code;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ErrorCode {
+ // 전체
+ INTERNAL_SERVER_ERROR(500, "G001", "서버 오류"),
+ INPUT_INVALID_VALUE(409, "G002", "잘못된 입력"),
+
+ // 레스토랑
+ RESTAURANT_DUPLICATION_ERROR(409, "ROO1", "레스토랑 이름이 중복됩니다.");
+
+ private final int status;
+ private final String code;
+ private final String messege;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ResultCode.java b/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ResultCode.java
new file mode 100644
index 00000000..99aad22d
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/dto/code/ResultCode.java
@@ -0,0 +1,29 @@
+package com.example.hackathon.global.dto.code;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ResultCode {
+
+ // 레스토랑
+ EXAMPLE_RESULT_CODE("EXAM1", "예시용"),
+ RESTAURANT_CREATE_SUCCESS("R001", "레스토랑 생성 성공"),
+ RESTAURANT_CATEGORY_CHANGE_SUCCESS("R002","카테고리 변경 성공"),
+ GET_RESTAURANT_BY_CATEGORY_SUCCESS("R003", "특정 카테고리 레스토랑 조회 성공"),
+ DELETE_RESTAURANT_SUCCESS("R004", "레스토랑 삭제 성공"),
+ GET_FIND_BY_ID_RESTAURANT("R005", "레스토랑 조회 성공"),
+
+ // 리뷰
+ CREATE_REVIEW_SUCCESS("V001", "리뷰 생성 성공"),
+ UPDATE_REVIEW_SUCCESS("VOO2","리뷰 수정 성공"),
+ GET_REVIEW_SUCCESS("VOO3","리뷰 조회 성공"),
+ DELETE_REVIEW_SUCCESS("V004", "리뷰 삭제 성공"),
+ GET_ALL_REVIEW_SUCCESS("V005", "리뷰 페이징 조회 성공");
+
+
+
+ private final String code;
+ private final String message;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/global/entity/BaseTimeEntity.java b/Hackathon/src/main/java/com/example/hackathon/global/entity/BaseTimeEntity.java
new file mode 100644
index 00000000..27425296
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/global/entity/BaseTimeEntity.java
@@ -0,0 +1,26 @@
+package com.example.hackathon.global.entity;
+
+import lombok.Getter;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.Column;
+import javax.persistence.EntityListeners;
+import javax.persistence.MappedSuperclass;
+import java.time.LocalDateTime;
+
+@Getter
+@EntityListeners(value = {AuditingEntityListener.class})
+@MappedSuperclass
+public abstract class BaseTimeEntity {
+ @CreatedDate private LocalDateTime createdDate;
+
+ @LastModifiedDate private LocalDateTime updatedDate;
+
+ @Getter
+ @Column(name = "is_active", nullable = false)
+ protected boolean isActive;
+
+ public void activeOff() { this.isActive = false; }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/RestaurantMapper.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/RestaurantMapper.java
new file mode 100644
index 00000000..8ea67449
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/RestaurantMapper.java
@@ -0,0 +1,32 @@
+package com.example.hackathon.restaurant;
+
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import com.example.hackathon.restaurant.dto.RestaurantCreateDTO;
+import com.example.hackathon.restaurant.dto.RestaurantResponse;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+public class RestaurantMapper {
+ public Restaurant toEntity (RestaurantCreateDTO request) {
+ return Restaurant.builder()
+ .category(request.getCategory())
+ .name(request.getName())
+ .build();
+ }
+
+ public RestaurantResponse toDto(Restaurant restaurant) {
+ return RestaurantResponse.builder()
+ .name(restaurant.getName())
+ .category(restaurant.getCategory().name())
+ .createdAt(restaurant.getCreatedDate())
+ .build();
+ }
+
+ public List toDtoList (List list) {
+ // 스트림내 요소들에 대해 함수가 적용된 결과의 새로운 요소로 매핑해준다.
+ return list.stream().map(this::toDto).collect(Collectors.toList());
+ }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/controller/RestaurantController.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/controller/RestaurantController.java
new file mode 100644
index 00000000..6285e4f6
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/controller/RestaurantController.java
@@ -0,0 +1,48 @@
+package com.example.hackathon.restaurant.controller;
+
+import com.example.hackathon.global.dto.ResultResponse;
+import com.example.hackathon.global.dto.code.ResultCode;
+import com.example.hackathon.restaurant.dto.RestaurantChange;
+import com.example.hackathon.restaurant.dto.RestaurantCreateDTO;
+import com.example.hackathon.restaurant.service.RestaurantService;
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("api/v1/restaurant")
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public class RestaurantController {
+ private final RestaurantService restaurantService;
+
+ @PostMapping
+ public ResponseEntity registerRestaurant(@RequestBody RestaurantCreateDTO request) {
+ restaurantService.createRestaurant(request);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.RESTAURANT_CREATE_SUCCESS));
+ }
+
+ @PatchMapping
+ public ResponseEntity changeRestaurantCategory (@RequestBody RestaurantChange request){
+ restaurantService.changeRestaurantCategory(request);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.RESTAURANT_CATEGORY_CHANGE_SUCCESS));
+ }
+
+ @GetMapping("/all")
+ public ResponseEntity getAllRestaurantByCategory(@RequestBody String categories) {
+ restaurantService.getRestaurantResponse(categories);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.GET_RESTAURANT_BY_CATEGORY_SUCCESS));
+ }
+
+ @PatchMapping("/{id}")
+ public ResponseEntity deleteRestaurant(@PathVariable Long id){
+ restaurantService.deleteRestaurant(id);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.DELETE_RESTAURANT_SUCCESS));
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity getRestaurant(@PathVariable Long id) {
+ restaurantService.getRestaurant(id);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.GET_FIND_BY_ID_RESTAURANT));
+ }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Category.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Category.java
new file mode 100644
index 00000000..a0e1161a
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Category.java
@@ -0,0 +1,34 @@
+package com.example.hackathon.restaurant.domain.entity;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor
+public enum Category {
+ KOREAN_RESTAURANT("한식"),
+ CHINESE_RESTAURANT("중식"),
+ JAPANESE_RESTAURANT("일식");
+
+ private final String category;
+
+ // 카테고리가 있는지 판별
+ public static boolean isVaildCategory(String category) {
+ for(Category cat: Category.values()) {
+ System.out.println(cat.getCategory());
+ if(cat.toString().equals(category)) return true;
+ }
+ return false;
+ }
+
+ // 카테고리 이름 가져오기
+ public static Category getCategory(String category) {
+ for(Category cat: Category.values()) {
+ System.out.println(cat.getCategory());
+ if(cat.toString().equals(category)) return cat;
+ }
+ return null;
+ }
+
+
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Restaurant.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Restaurant.java
new file mode 100644
index 00000000..980bf21c
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/entity/Restaurant.java
@@ -0,0 +1,49 @@
+package com.example.hackathon.restaurant.domain.entity;
+
+import com.example.hackathon.global.entity.BaseTimeEntity;
+import com.example.hackathon.review.domain.entity.Review;
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.DynamicInsert;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Getter
+@Table(name = "restaurant")
+@DynamicInsert
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
+@EntityListeners(AuditingEntityListener.class)
+public class Restaurant extends BaseTimeEntity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "restaurant_id" , nullable = false)
+ private Long id;
+
+ @Column(nullable = false, length = 30)
+ private String name;
+
+ @Column(name = "category", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private Category category;
+
+ // Review 와 1:n 관계
+ // cascade = 엔티티 상태가 변화했을 때 관계가 있는 엔티티에게도 상태 변화 전파
+ // orphanRemoval = 부모와 관계가 끊어진 자식을 자동으로 제거해주는 옵션
+ @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL, orphanRemoval = true)
+ private List reviews = new ArrayList<>();
+
+ @Builder
+ public Restaurant(String name, Category category) {
+ this.name = name;
+ this.category = category;
+ this.isActive = true;
+ }
+
+ public void deleteRestaurant() { this.activeOff();}
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/repository/RestaurantRepository.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/repository/RestaurantRepository.java
new file mode 100644
index 00000000..52044a77
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/domain/repository/RestaurantRepository.java
@@ -0,0 +1,37 @@
+package com.example.hackathon.restaurant.domain.repository;
+
+import com.example.hackathon.restaurant.domain.entity.Category;
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface RestaurantRepository extends JpaRepository {
+ boolean existsByName(String name);
+
+ // 레스토랑 수정
+ @Modifying // insert, update , delete 등 db에 변화가 발생하는 작업에는 필수
+ @Transactional // 이 과정 중 다른 연산이 끼어들 수 없게 하는 어노테이션
+ @Query("update Restaurant r set r.category = :category where r.id = :id")
+ void updateCategory(@Param("id") Long id ,@Param("category") Category category);
+
+ //레스토랑 카테고리에 따른 레스토랑 목록 조회
+ @Query("select r from Restaurant r where r.category In :categories")
+ List findByCategory(@Param("categories")List categories);
+
+ // 레스토랑 삭제
+ @Modifying
+ @Transactional
+ @Query("update Restaurant r set r.isActive = false where r.id = :id")
+ void softDeleteById(Long id);
+
+ // 레스토랑 이름으로 조회
+ Optional findByName(String restaurantName);
+
+
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantChange.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantChange.java
new file mode 100644
index 00000000..e5ce22f5
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantChange.java
@@ -0,0 +1,15 @@
+package com.example.hackathon.restaurant.dto;
+
+import com.example.hackathon.restaurant.domain.entity.Category;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class RestaurantChange {
+ private Long id;
+ private Category category;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantCreateDTO.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantCreateDTO.java
new file mode 100644
index 00000000..173e4128
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantCreateDTO.java
@@ -0,0 +1,19 @@
+package com.example.hackathon.restaurant.dto;
+
+import com.example.hackathon.restaurant.domain.entity.Category;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+import javax.validation.constraints.NotBlank;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class RestaurantCreateDTO {
+
+ @NotBlank(message = "유효한 카테고리로 요청하기 바랍니다.")
+ private Category category;
+ private String name;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantResponse.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantResponse.java
new file mode 100644
index 00000000..f7fd7606
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/dto/RestaurantResponse.java
@@ -0,0 +1,18 @@
+package com.example.hackathon.restaurant.dto;
+
+import com.example.hackathon.restaurant.domain.entity.Category;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+import java.time.LocalDateTime;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class RestaurantResponse {
+ String name;
+ String category;
+ LocalDateTime createdAt;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/restaurant/service/RestaurantService.java b/Hackathon/src/main/java/com/example/hackathon/restaurant/service/RestaurantService.java
new file mode 100644
index 00000000..1d5ca2f3
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/restaurant/service/RestaurantService.java
@@ -0,0 +1,52 @@
+package com.example.hackathon.restaurant.service;
+
+import com.example.hackathon.restaurant.RestaurantMapper;
+import com.example.hackathon.restaurant.domain.entity.Category;
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import com.example.hackathon.restaurant.domain.repository.RestaurantRepository;
+import com.example.hackathon.restaurant.dto.RestaurantChange;
+import com.example.hackathon.restaurant.dto.RestaurantCreateDTO;
+import com.example.hackathon.restaurant.dto.RestaurantResponse;
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public class RestaurantService {
+ private final RestaurantRepository restaurantRepository;
+ private final RestaurantMapper restaurantMapper;
+
+ public void createRestaurant(RestaurantCreateDTO restaurantCreateDTO) {
+ restaurantRepository.save(restaurantMapper.toEntity(restaurantCreateDTO));
+ }
+
+ public void changeRestaurantCategory(RestaurantChange request) {
+ restaurantRepository.updateCategory(request.getId(), request.getCategory());
+ }
+
+ public List getRestaurantResponse(String categories) {
+ String[] categoryArray = categories.split(",");
+ List categoryList = new ArrayList<>();
+ for(String category : categoryArray) {
+ if(Category.isVaildCategory(category)) {
+ categoryList.add(Category.getCategory(category));
+ }
+ }
+ List restaurants = restaurantRepository.findByCategory(categoryList);
+ return restaurantMapper.toDtoList(restaurants);
+ }
+
+ public void deleteRestaurant(Long id){
+ restaurantRepository.softDeleteById(id);
+ }
+
+ public void getRestaurant(Long id) {
+ restaurantRepository.findById(id);
+ }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/ReviewMapper.java b/Hackathon/src/main/java/com/example/hackathon/review/ReviewMapper.java
new file mode 100644
index 00000000..9fe24044
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/ReviewMapper.java
@@ -0,0 +1,44 @@
+package com.example.hackathon.review;
+
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import com.example.hackathon.review.domain.entity.Review;
+import com.example.hackathon.review.dto.ReviewChange;
+import com.example.hackathon.review.dto.ReviewCreateDTO;
+import com.example.hackathon.review.dto.ReviewInfo;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+@Component
+public class ReviewMapper {
+ public Review toEntity (ReviewCreateDTO request, Restaurant restaurant) {
+ return Review.builder()
+ .restaurant(restaurant)
+ .title(request.getTitle())
+ .content(request.getContent())
+ .build();
+ }
+
+ public Review toEntity (ReviewChange request, Restaurant restaurant) {
+ return Review.builder()
+ .restaurant(restaurant)
+ .title(request.getTitle())
+ .content(request.getContent())
+ .build();
+ }
+
+ public ReviewInfo toDto(Review review) {
+ return ReviewInfo.builder()
+ .RestaurantName(review.getRestaurant().getName())
+ .title(review.getTitle())
+ .content(review.getContent())
+ .build();
+ }
+
+ public List toDtoList(List list){
+ return list.stream().map(this::toDto).collect(Collectors.toList());
+ }
+
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/controller/ReviewController.java b/Hackathon/src/main/java/com/example/hackathon/review/controller/ReviewController.java
new file mode 100644
index 00000000..2ce97141
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/controller/ReviewController.java
@@ -0,0 +1,57 @@
+package com.example.hackathon.review.controller;
+
+import com.example.hackathon.global.dto.ResultResponse;
+import com.example.hackathon.global.dto.code.ResultCode;
+import com.example.hackathon.review.dto.ReviewChange;
+import com.example.hackathon.review.dto.ReviewCreateDTO;
+import com.example.hackathon.review.dto.ReviewInfo;
+import com.example.hackathon.review.service.ReviewService;
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("api/v1/review")
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public class ReviewController {
+ private final ReviewService reviewService;
+
+ @PostMapping
+ public ResponseEntity createReview(@RequestBody ReviewCreateDTO request) {
+ reviewService.createReview(request);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.CREATE_REVIEW_SUCCESS));
+ }
+
+ @PatchMapping("/{id}")
+ public ResponseEntity updateReview(@RequestBody ReviewChange request) {
+ reviewService.updateReview(request);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.UPDATE_REVIEW_SUCCESS));
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity getReview(@PathVariable Long id) {
+ reviewService.getReview(id);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.GET_REVIEW_SUCCESS, reviewService.getReview(id)));
+ }
+
+ @DeleteMapping("/{id}")
+ public ResponseEntity deleteReview(@PathVariable Long id) {
+ reviewService.deleteReview(id);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.DELETE_REVIEW_SUCCESS));
+ }
+
+ // https://ws-pace.tistory.com/223 pagenation 관련 글
+ @GetMapping("/all/{page}")
+ public ResponseEntity getReviews(@PathVariable Integer page
+ , @RequestParam(defaultValue = "10") Integer size){
+ PageRequest pageRequest = PageRequest.of(page,size);
+ List reviews = reviewService.getReviews(pageRequest);
+ return ResponseEntity.ok(ResultResponse.of(ResultCode.GET_ALL_REVIEW_SUCCESS, reviews));
+ }
+
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/domain/entity/Review.java b/Hackathon/src/main/java/com/example/hackathon/review/domain/entity/Review.java
new file mode 100644
index 00000000..41bb6468
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/domain/entity/Review.java
@@ -0,0 +1,43 @@
+package com.example.hackathon.review.domain.entity;
+
+import com.example.hackathon.global.entity.BaseTimeEntity;
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Entity
+@Getter
+@Table(name = "review")
+@NoArgsConstructor
+public class Review extends BaseTimeEntity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "REVIEW_ID")
+ private Long id;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "restaurant_id" , nullable = false)
+ private Restaurant restaurant;
+ // 제목
+ @Column(name = "title",nullable = false, length = 100)
+ private String title;
+
+ // 내용
+ @Lob
+ @Column(name = "content")
+ private String content;
+
+ @Builder
+ public Review (Restaurant restaurant, String title, String content) {
+ this.restaurant = restaurant;
+ this.title = title;
+ this.content = content;
+ }
+
+ public void updateContent(String content) {
+ this.content = content;
+ }
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/domain/repository/ReviewRepository.java b/Hackathon/src/main/java/com/example/hackathon/review/domain/repository/ReviewRepository.java
new file mode 100644
index 00000000..a147c337
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/domain/repository/ReviewRepository.java
@@ -0,0 +1,22 @@
+package com.example.hackathon.review.domain.repository;
+
+import com.example.hackathon.review.domain.entity.Review;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Optional;
+
+
+public interface ReviewRepository extends JpaRepository {
+
+ Optional findById(Long id);
+
+ // 리뷰 수정
+ @Modifying // insert, update , delete 등 db에 변화가 발생하는 작업에는 필수
+ @Transactional // 이 과정 중 다른 연산이 끼어들 수 없게 하는 어노테이션
+ @Query("update Review v set v.title = :title ,v.content = :content where v.id = :id")
+ void updateReview(@Param("id") Long id , @Param("title") String title, @Param("content") String content);
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewChange.java b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewChange.java
new file mode 100644
index 00000000..6eaf5bbd
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewChange.java
@@ -0,0 +1,15 @@
+package com.example.hackathon.review.dto;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class ReviewChange {
+ private Long id;
+ private String title;
+ private String content;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewCreateDTO.java b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewCreateDTO.java
new file mode 100644
index 00000000..73df2612
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewCreateDTO.java
@@ -0,0 +1,13 @@
+package com.example.hackathon.review.dto;
+
+import lombok.*;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class ReviewCreateDTO {
+ private String restaurantName;
+ private String title;
+ private String content;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewInfo.java b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewInfo.java
new file mode 100644
index 00000000..1bc70d65
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/dto/ReviewInfo.java
@@ -0,0 +1,13 @@
+package com.example.hackathon.review.dto;
+
+import lombok.*;
+
+@Getter
+@Builder
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class ReviewInfo {
+ private String RestaurantName;
+ private String title;
+ private String content;
+}
diff --git a/Hackathon/src/main/java/com/example/hackathon/review/service/ReviewService.java b/Hackathon/src/main/java/com/example/hackathon/review/service/ReviewService.java
new file mode 100644
index 00000000..53e55a4a
--- /dev/null
+++ b/Hackathon/src/main/java/com/example/hackathon/review/service/ReviewService.java
@@ -0,0 +1,57 @@
+package com.example.hackathon.review.service;
+
+import com.example.hackathon.restaurant.domain.entity.Restaurant;
+import com.example.hackathon.restaurant.domain.repository.RestaurantRepository;
+import com.example.hackathon.review.ReviewMapper;
+import com.example.hackathon.review.domain.entity.Review;
+import com.example.hackathon.review.domain.repository.ReviewRepository;
+import com.example.hackathon.review.dto.ReviewChange;
+import com.example.hackathon.review.dto.ReviewCreateDTO;
+import com.example.hackathon.review.dto.ReviewInfo;
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public class ReviewService {
+ private final RestaurantRepository restaurantRepository;
+ private final ReviewRepository reviewRepository;
+ private final ReviewMapper reviewMapper;
+
+ // https://stir.tistory.com/140 -> optional 관련
+ public void createReview(ReviewCreateDTO request) {
+ Restaurant restaurant = restaurantRepository.findByName(request.getRestaurantName()).orElseThrow(
+ () -> new IllegalArgumentException("해당 레스토랑이 존재하지 않습니다."));
+ reviewRepository.save(reviewMapper.toEntity(request, restaurant));
+ } // -> 똑같은 가게이름이 2개 이상 존재할 경우 에러 발생
+
+ public void updateReview(ReviewChange request) {
+ Review findReview = reviewRepository.findById(request.getId()).orElseThrow(
+ () -> new IllegalArgumentException("해당 리뷰가 존재하지 않습니다."));
+ Review review = reviewMapper.toEntity(request, findReview.getRestaurant());
+ reviewRepository.updateReview(findReview.getId(), review.getTitle(), review.getContent());
+ }
+
+ public ReviewInfo getReview(Long id) {
+ Review review = reviewRepository.findById(id).orElseThrow(
+ () -> new IllegalArgumentException("해당 리뷰가 존재하지 않습니다."));
+ return reviewMapper.toDto(review);
+ }
+
+ public void deleteReview(Long id) {
+ reviewRepository.findById(id).orElseThrow(
+ () -> new IllegalArgumentException("해당 리뷰가 존재하지 않습니다."));
+ reviewRepository.deleteById(id);
+ }
+
+ public List getReviews(PageRequest pageRequest){
+ List reviews = reviewRepository.findAll(pageRequest).getContent();
+ return reviewMapper.toDtoList(reviews);
+ }
+}
diff --git a/Hackathon/src/main/resources/application.yml b/Hackathon/src/main/resources/application.yml
new file mode 100644
index 00000000..7e192621
--- /dev/null
+++ b/Hackathon/src/main/resources/application.yml
@@ -0,0 +1,30 @@
+server:
+ port: 8080
+ servlet:
+ context-path: /
+ encoding:
+ charset: UTF-8
+ enabled: true
+ force: true
+
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/hackaton?serverTimezone=Asia/Seoul
+ username: sunghyun
+ password: vix0000
+
+ jpa:
+ open-in-view: true
+ hibernate:
+ ddl-auto: update
+ naming:
+ physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
+ use-new-id-generator-mappings: false
+ show-sql: true
+ properties:
+ hibernate.format_sql: true
+
+ jackson:
+ serialization:
+ fail-on-empty-beans: false
\ No newline at end of file
diff --git a/Hackathon/src/test/java/com/example/hackathon/HackathonApplicationTests.java b/Hackathon/src/test/java/com/example/hackathon/HackathonApplicationTests.java
new file mode 100644
index 00000000..86bc607b
--- /dev/null
+++ b/Hackathon/src/test/java/com/example/hackathon/HackathonApplicationTests.java
@@ -0,0 +1,13 @@
+package com.example.hackathon;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class HackathonApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}