diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..c1dd12f
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..b74bf7f
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..788e30a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+# 2022 땅울림 써머코딩 백엔드
+
+> 자바기반 백엔드 스터디 (스프링, 기본개념 등)
+
+
+
diff --git a/build.gradle b/build.gradle
index 6492e7e..e5e6d3b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,31 +1,39 @@
plugins {
- id 'org.springframework.boot' version '2.7.2'
- id 'io.spring.dependency-management' version '1.0.12.RELEASE'
- id 'java'
+ id 'org.springframework.boot' version '2.6.9'
+ id 'io.spring.dependency-management' version '1.0.11.RELEASE'
+ id 'java'
}
-group = 'com.landvibe.summer'
+group = 'com.landvibe'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
- compileOnly {
- extendsFrom annotationProcessor
- }
+ compileOnly {
+ extendsFrom annotationProcessor
+ }
}
repositories {
- mavenCentral()
+ mavenCentral()
}
dependencies {
- implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
- implementation 'org.springframework.boot:spring-boot-starter-web'
- compileOnly 'org.projectlombok:lombok'
- annotationProcessor 'org.projectlombok:lombok'
- testImplementation 'org.springframework.boot:spring-boot-starter-test'
+ implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
+ implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
+ implementation 'org.springframework.boot:spring-boot-starter-web'
+ implementation 'org.springframework.boot:spring-boot-starter-security'
+ compileOnly 'org.projectlombok:lombok'
+ runtimeOnly 'com.h2database:h2'
+ runtimeOnly 'mysql:mysql-connector-java'
+ annotationProcessor 'org.projectlombok:lombok'
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
+
+ implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5'
+ runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5'
+ runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5'
}
tasks.named('test') {
- useJUnitPlatform()
+ useJUnitPlatform()
}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 249e583..41d9927 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 8049c68..00e33ed 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index a69d9cb..1b6c787 100755
--- a/gradlew
+++ b/gradlew
@@ -205,12 +205,6 @@ set -- \
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.
diff --git a/gradlew.bat b/gradlew.bat
index f127cfd..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000..8a8fb22
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,316 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /usr/local/etc/mavenrc ] ; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ 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
+ else
+ JAVACMD="`\\unset -f command; \\command -v java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ else
+ jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ fi
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ if $cygwin; then
+ wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ fi
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ else
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl -o "$wrapperJarPath" "$jarUrl" -f
+ else
+ curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ fi
+
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaClass=`cygpath --path --windows "$javaClass"`
+ fi
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..1d8ab01
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,188 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. 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,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..1498c4a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.3
+
+
+ com.example
+ landvibe
+ 0.0.1-SNAPSHOT
+ landvibe
+ landvibe
+
+ 11
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
diff --git a/settings.gradle b/settings.gradle
index abf7253..fc92777 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-rootProject.name = 'reservation'
+rootProject.name = 'summerCoding'
diff --git a/src/main/java/com/landvibe/summer/reservation/ReservationApplication.java b/src/main/java/com/landvibe/summer/reservation/LandvibeApplication.java
similarity index 69%
rename from src/main/java/com/landvibe/summer/reservation/ReservationApplication.java
rename to src/main/java/com/landvibe/summer/reservation/LandvibeApplication.java
index 38e612a..8c8ee17 100644
--- a/src/main/java/com/landvibe/summer/reservation/ReservationApplication.java
+++ b/src/main/java/com/landvibe/summer/reservation/LandvibeApplication.java
@@ -4,10 +4,10 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-public class ReservationApplication {
+public class LandvibeApplication {
public static void main(String[] args) {
- SpringApplication.run(ReservationApplication.class, args);
+ SpringApplication.run(LandvibeApplication.class, args);
}
}
diff --git a/src/main/java/com/landvibe/summer/reservation/config/SecurityConfig.java b/src/main/java/com/landvibe/summer/reservation/config/SecurityConfig.java
new file mode 100644
index 0000000..b2fe265
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/config/SecurityConfig.java
@@ -0,0 +1,50 @@
+package com.landvibe.summer.reservation.config;
+
+import com.landvibe.summer.reservation.exception.JwtAccessDeniedHandler;
+import com.landvibe.summer.reservation.exception.JwtAuthenticationEntryPoint;
+import com.landvibe.summer.reservation.jwt.JwtSecurityConfig;
+import com.landvibe.summer.reservation.jwt.TokenProvider;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
+
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+@RequiredArgsConstructor
+public class SecurityConfig {
+ private final TokenProvider tokenProvider;
+ private final JwtAccessDeniedHandler accessDeniedHandler;
+ private final JwtAuthenticationEntryPoint authenticationEntryPoint;
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+ http
+ .csrf().disable()
+ .exceptionHandling()
+ .authenticationEntryPoint(authenticationEntryPoint)
+ .accessDeniedHandler(accessDeniedHandler)
+ .and()
+ .sessionManagement()
+ .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
+ .and()
+ .authorizeRequests()
+ .antMatchers("/api/signup", "/api/login").permitAll() //해당 URL로 들어오는 경우 필터 없이 허용
+ .anyRequest().authenticated() // 나머지 URL에 대해서는 인증을 진행
+ .and()
+ .apply(new JwtSecurityConfig(tokenProvider));
+
+
+ return http.build();
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/controller/AuthController.java b/src/main/java/com/landvibe/summer/reservation/controller/AuthController.java
new file mode 100644
index 0000000..9900605
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/controller/AuthController.java
@@ -0,0 +1,30 @@
+package com.landvibe.summer.reservation.controller;
+
+import com.landvibe.summer.reservation.dto.request.LoginRequest;
+import com.landvibe.summer.reservation.dto.response.TokenResponse;
+import com.landvibe.summer.reservation.service.AuthService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/api")
+@RequiredArgsConstructor
+public class AuthController {
+
+ private final AuthService authService;
+
+ @PostMapping("/login")
+ public ResponseEntity login(@RequestBody LoginRequest request) {
+ String jwt = authService.login(request);
+ return new ResponseEntity<>(new TokenResponse(jwt), generateHeader(jwt), HttpStatus.OK);
+ }
+
+ private HttpHeaders generateHeader(String jwt) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.add("x-access-token", jwt);
+ return httpHeaders;
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/controller/CategoryController.java b/src/main/java/com/landvibe/summer/reservation/controller/CategoryController.java
index 6780cc8..fdd3086 100644
--- a/src/main/java/com/landvibe/summer/reservation/controller/CategoryController.java
+++ b/src/main/java/com/landvibe/summer/reservation/controller/CategoryController.java
@@ -1,16 +1,15 @@
package com.landvibe.summer.reservation.controller;
import com.landvibe.summer.reservation.dto.request.CategoryRequest;
-import com.landvibe.summer.reservation.dto.request.ProductRequest;
+
import com.landvibe.summer.reservation.dto.response.*;
-import com.landvibe.summer.reservation.entity.Product;
+import com.landvibe.summer.reservation.dto.response.CategoryDetail;
import com.landvibe.summer.reservation.service.CategoryService;
-import com.landvibe.summer.reservation.service.ProductService;
import lombok.RequiredArgsConstructor;
-import com.landvibe.summer.reservation.entity.Category;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
-import java.util.ArrayList;
+
import java.util.List;
@RestController
@@ -19,20 +18,19 @@
public class CategoryController {
private final CategoryService categoryService;
-
- @ResponseBody
- @PostMapping(value = "category")
+ @PostMapping(value = "/category")
+ @PreAuthorize("hasAnyRole('ADMIN')")
public CategoryResponse create(@RequestBody CategoryRequest request) {
- Long categoryId = categoryService.join(request);
- if (categoryId == -1) {
- return new CategoryResponse(-1);
- }
+ Long categoryId = categoryService.create(request);
return new CategoryResponse(0, new Result(categoryId));
}
- @GetMapping(value = "categories")
- public CategoriesResponse lookUp() {
- List categories = categoryService.lookUp();
- return new CategoriesResponse(categories.size(), (ArrayList) categories);
+
+ @GetMapping(value = "/categories")
+ @PreAuthorize("hasAnyRole('USER')")
+ public CategoriesResponse getCategories() {
+ List categories = categoryService.getCategories();
+ return new CategoriesResponse(categories.size(), categories);
}
+
}
diff --git a/src/main/java/com/landvibe/summer/reservation/controller/GlobalCatcher.java b/src/main/java/com/landvibe/summer/reservation/controller/GlobalCatcher.java
new file mode 100644
index 0000000..bc0ce85
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/controller/GlobalCatcher.java
@@ -0,0 +1,16 @@
+package com.landvibe.summer.reservation.controller;
+
+import com.landvibe.summer.reservation.dto.response.ErrorResult;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+@ControllerAdvice
+public class GlobalCatcher {
+ @ExceptionHandler(IllegalStateException.class)
+ public ResponseEntity handleException(Exception e) {
+ ErrorResult errorResult = new ErrorResult("-1", e.getMessage());
+ return new ResponseEntity<>(errorResult, HttpStatus.BAD_REQUEST);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/controller/ProductController.java b/src/main/java/com/landvibe/summer/reservation/controller/ProductController.java
index 3479164..cb2c2d6 100644
--- a/src/main/java/com/landvibe/summer/reservation/controller/ProductController.java
+++ b/src/main/java/com/landvibe/summer/reservation/controller/ProductController.java
@@ -2,52 +2,37 @@
import com.landvibe.summer.reservation.dto.request.ProductRequest;
import com.landvibe.summer.reservation.dto.response.*;
-import com.landvibe.summer.reservation.entity.*;
-import com.landvibe.summer.reservation.service.CategoryService;
import com.landvibe.summer.reservation.service.ProductService;
import lombok.RequiredArgsConstructor;
-import org.apache.logging.log4j.message.Message;
-import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
+import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api")
public class ProductController {
private final ProductService productService;
- private final CategoryService categoryService;
@PostMapping(value = "/product")
- @ResponseBody
+ @PreAuthorize("hasAnyRole('USER')")
public ProductResponse create(@RequestBody ProductRequest request) {
- Long productId = productService.join(request);
- if (productId == -1) {
- return new ProductResponse(-1);
- }
+ Long productId = productService.create(request);
return new ProductResponse(0, new Result(productId));
}
- @GetMapping(value = "products")
- public ProductsResponse lookUp() {
- ArrayList products = productService.lookUp();
+ @GetMapping(value = "/products")
+ @PreAuthorize("hasAnyRole('USER')")
+ public ProductsResponse getProducts() {
+ List products = productService.getProductsRes();
return new ProductsResponse(products.size(), products);
}
@GetMapping("/product/{productId}")
+ @PreAuthorize("hasAnyRole('USER')")
public ProductDetailResponse findById(@PathVariable("productId") Long id) {
- Product product = productService.findById(id);
- Category category = categoryService.findById(product.getCategoryId());
- ProductDetail productDetail = ProductDetail.builder()
- .categoryId(category.getCateId())
- .categoryName(category.getCateName())
- .name(product.getName())
- .description(product.getDescription())
- .id(product.getId())
- .createdAt(product.getCreatedAt())
- .build();
+ ProductDetail productDetail = productService.productDetail(id);
return new ProductDetailResponse(productDetail);
}
}
diff --git a/src/main/java/com/landvibe/summer/reservation/controller/UserController.java b/src/main/java/com/landvibe/summer/reservation/controller/UserController.java
new file mode 100644
index 0000000..1375aec
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/controller/UserController.java
@@ -0,0 +1,46 @@
+package com.landvibe.summer.reservation.controller;
+
+import com.landvibe.summer.reservation.dto.request.UserRequest;
+import com.landvibe.summer.reservation.dto.response.Products;
+import com.landvibe.summer.reservation.dto.response.ProductsResponse;
+import com.landvibe.summer.reservation.dto.response.UserResponse;
+import com.landvibe.summer.reservation.service.ProductService;
+import com.landvibe.summer.reservation.service.UserService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/api")
+public class UserController {
+ private final UserService userService;
+ private final ProductService productService;
+
+ @PostMapping("/signup")
+ public UserResponse create(@RequestBody UserRequest request) {
+ return userService.join(request);
+ }
+
+ @GetMapping("/user/{name}")
+ @PreAuthorize("hasAnyRole('ADMIN')")//권한이 있을때만 볼수있게
+ public UserResponse findUserByName(@PathVariable(value = "name") String name) {
+ return userService.getUserByName(name);
+ }
+
+ @GetMapping("/myinfo")
+ @PreAuthorize("hasAnyRole('USER')")
+ public UserResponse findMyInfo() {
+ return userService.getMyInfo();
+ }
+
+ @GetMapping(value = "/myproducts")
+ @PreAuthorize("hasAnyRole('USER')")
+ public ProductsResponse getMyProducts() {
+ List products = productService.myProducts();
+ return new ProductsResponse(products.size(), products);
+ }
+
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/request/LoginRequest.java b/src/main/java/com/landvibe/summer/reservation/dto/request/LoginRequest.java
new file mode 100644
index 0000000..9dbeef2
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/request/LoginRequest.java
@@ -0,0 +1,13 @@
+package com.landvibe.summer.reservation.dto.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+@AllArgsConstructor
+public class LoginRequest {
+ private String name;
+ private String password;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/request/ProductRequest.java b/src/main/java/com/landvibe/summer/reservation/dto/request/ProductRequest.java
index bceac4b..d575c22 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/request/ProductRequest.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/request/ProductRequest.java
@@ -4,7 +4,6 @@
import lombok.Getter;
import lombok.Setter;
-import java.time.LocalDateTime;
@Getter
@Setter
@@ -13,5 +12,4 @@ public class ProductRequest {
private Long categoryId;
private String name;
private String description;
- private Long id;
}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/request/UserRequest.java b/src/main/java/com/landvibe/summer/reservation/dto/request/UserRequest.java
new file mode 100644
index 0000000..df48bee
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/request/UserRequest.java
@@ -0,0 +1,13 @@
+package com.landvibe.summer.reservation.dto.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+@AllArgsConstructor
+public class UserRequest {
+ private String name;
+ private String password;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/CategoriesResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoriesResponse.java
index dd405ca..05cde21 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/response/CategoriesResponse.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoriesResponse.java
@@ -1,16 +1,15 @@
package com.landvibe.summer.reservation.dto.response;
-import com.landvibe.summer.reservation.entity.Category;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-import java.util.ArrayList;
+import java.util.List;
@Getter
@Setter
@AllArgsConstructor
public class CategoriesResponse {
private Integer size;
- private ArrayList categories;
+ private List categories;
}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryDetail.java b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryDetail.java
new file mode 100644
index 0000000..55926de
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryDetail.java
@@ -0,0 +1,14 @@
+package com.landvibe.summer.reservation.dto.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+@Builder
+public class CategoryDetail {
+ Long id;
+ String name;
+ Integer count;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryResponse.java
index fc9619d..d717b4b 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryResponse.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/CategoryResponse.java
@@ -1,21 +1,14 @@
package com.landvibe.summer.reservation.dto.response;
-import com.landvibe.summer.reservation.entity.Category;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-import java.util.ArrayList;
-
@Getter
@Setter
@AllArgsConstructor
public class CategoryResponse {
private Integer code;
private Result result;
-
- public CategoryResponse(Integer code) {
- this.code = code;
- }
}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/ErrorResult.java b/src/main/java/com/landvibe/summer/reservation/dto/response/ErrorResult.java
new file mode 100644
index 0000000..a47522c
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/ErrorResult.java
@@ -0,0 +1,11 @@
+package com.landvibe.summer.reservation.dto.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class ErrorResult {
+ private String code;
+ private String message;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/entity/ProductDetail.java b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetail.java
similarity index 82%
rename from src/main/java/com/landvibe/summer/reservation/entity/ProductDetail.java
rename to src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetail.java
index 03dedf5..34e3d10 100644
--- a/src/main/java/com/landvibe/summer/reservation/entity/ProductDetail.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetail.java
@@ -1,14 +1,12 @@
-package com.landvibe.summer.reservation.entity;
+package com.landvibe.summer.reservation.dto.response;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
-import lombok.Setter;
import java.time.LocalDateTime;
@Getter
-@Setter
@AllArgsConstructor
@Builder
public class ProductDetail {
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.java
index d340de0..c2a068b 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.java
@@ -1,7 +1,5 @@
package com.landvibe.summer.reservation.dto.response;
-import com.landvibe.summer.reservation.entity.Product;
-import com.landvibe.summer.reservation.entity.ProductDetail;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductResponse.java
index 6154acc..a89d067 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductResponse.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductResponse.java
@@ -10,9 +10,5 @@
public class ProductResponse {
private Integer code;
private Result result;
-
- public ProductResponse(Integer code) {
- this.code = code;
- }
}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/Products.java b/src/main/java/com/landvibe/summer/reservation/dto/response/Products.java
new file mode 100644
index 0000000..14db092
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/Products.java
@@ -0,0 +1,17 @@
+package com.landvibe.summer.reservation.dto.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+import java.time.LocalDateTime;
+
+@Getter
+@AllArgsConstructor
+@Builder
+public class Products {
+ Long id;
+ Long categoryId;
+ String name;
+ LocalDateTime createdAt;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductsResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductsResponse.java
index 4e90063..9ff898b 100644
--- a/src/main/java/com/landvibe/summer/reservation/dto/response/ProductsResponse.java
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/ProductsResponse.java
@@ -1,17 +1,15 @@
package com.landvibe.summer.reservation.dto.response;
-import com.landvibe.summer.reservation.entity.Product;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
+import java.util.List;
@Getter
@Setter
@AllArgsConstructor
public class ProductsResponse {
private Integer size;
- private ArrayList products;
+ private List products;
}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/TokenResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/TokenResponse.java
new file mode 100644
index 0000000..da003b9
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/TokenResponse.java
@@ -0,0 +1,12 @@
+package com.landvibe.summer.reservation.dto.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+
+@AllArgsConstructor
+@Builder
+@Data
+public class TokenResponse {
+ private String token;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/dto/response/UserResponse.java b/src/main/java/com/landvibe/summer/reservation/dto/response/UserResponse.java
new file mode 100644
index 0000000..b5db455
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/dto/response/UserResponse.java
@@ -0,0 +1,14 @@
+package com.landvibe.summer.reservation.dto.response;
+
+import com.landvibe.summer.reservation.entity.User;
+import lombok.*;
+
+@AllArgsConstructor
+@Builder
+@Data
+@Getter
+@Setter
+public class UserResponse {
+ private String name;
+ private Long id;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/entity/Authority.java b/src/main/java/com/landvibe/summer/reservation/entity/Authority.java
new file mode 100644
index 0000000..17bd942
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/entity/Authority.java
@@ -0,0 +1,23 @@
+package com.landvibe.summer.reservation.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Getter
+@AllArgsConstructor
+@Builder
+@Entity
+@NoArgsConstructor
+@Table(name = "authority")
+public class Authority {
+ @Id
+ @Column(name = "authority_name", length = 50)
+ private String authorityName;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/entity/Category.java b/src/main/java/com/landvibe/summer/reservation/entity/Category.java
index 5619260..db07a8b 100644
--- a/src/main/java/com/landvibe/summer/reservation/entity/Category.java
+++ b/src/main/java/com/landvibe/summer/reservation/entity/Category.java
@@ -1,14 +1,25 @@
package com.landvibe.summer.reservation.entity;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.*;
+
+import javax.persistence.*;
+import java.util.List;
@Getter
-@Setter
@AllArgsConstructor
+@Builder
+@Entity
+@NoArgsConstructor
+@Table(name = "category")
public class Category {
private String cateName;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)//PK값 자동 증가
private Long cateId;
- private Integer count;
+ @OneToMany(mappedBy = "category")
+ private List products;
+
+ public int size() {
+ return products.size();
+ }
}
diff --git a/src/main/java/com/landvibe/summer/reservation/entity/Product.java b/src/main/java/com/landvibe/summer/reservation/entity/Product.java
index ddaaba5..79df18e 100644
--- a/src/main/java/com/landvibe/summer/reservation/entity/Product.java
+++ b/src/main/java/com/landvibe/summer/reservation/entity/Product.java
@@ -1,21 +1,26 @@
package com.landvibe.summer.reservation.entity;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.*;
+import javax.persistence.*;
import java.time.LocalDateTime;
@Getter
-@Setter
@AllArgsConstructor
-@Builder()
+@Builder
+@Entity
+@NoArgsConstructor
+@Table(name = "product")
public class Product {
- private Long categoryId;
+ @ManyToOne
+ @JoinColumn(name = "category_id")
+ private Category category;
private String name;
private String description;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)//PK값 자동 증가
private Long id;
private LocalDateTime createdAt;
+ private String register;
}
diff --git a/src/main/java/com/landvibe/summer/reservation/entity/User.java b/src/main/java/com/landvibe/summer/reservation/entity/User.java
new file mode 100644
index 0000000..23a6e5b
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/entity/User.java
@@ -0,0 +1,31 @@
+package com.landvibe.summer.reservation.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+import java.util.Set;
+
+@Getter
+@AllArgsConstructor
+@Builder
+@Entity
+@NoArgsConstructor
+@Table(name = "name")
+public class User {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)//PK값 자동 증가
+ @Column(name = "user_id")
+ private Long id;
+ private String password;
+ private String name;
+ @ManyToMany
+ @JoinTable(
+ name = "user_authority",
+ joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")},
+ inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "authority_name")}
+ )
+ private Set authorities;
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/exception/JwtAccessDeniedHandler.java b/src/main/java/com/landvibe/summer/reservation/exception/JwtAccessDeniedHandler.java
new file mode 100644
index 0000000..acca9cf
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/exception/JwtAccessDeniedHandler.java
@@ -0,0 +1,20 @@
+package com.landvibe.summer.reservation.exception;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.security.web.access.AccessDeniedHandler;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+public class JwtAccessDeniedHandler implements AccessDeniedHandler {
+
+ @Override
+ public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/exception/JwtAuthenticationEntryPoint.java b/src/main/java/com/landvibe/summer/reservation/exception/JwtAuthenticationEntryPoint.java
new file mode 100644
index 0000000..faf874e
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/exception/JwtAuthenticationEntryPoint.java
@@ -0,0 +1,19 @@
+package com.landvibe.summer.reservation.exception;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
+ @Override
+ public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/jwt/JwtFilter.java b/src/main/java/com/landvibe/summer/reservation/jwt/JwtFilter.java
new file mode 100644
index 0000000..3c345b1
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/jwt/JwtFilter.java
@@ -0,0 +1,39 @@
+package com.landvibe.summer.reservation.jwt;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+public class JwtFilter extends GenericFilter {
+ public static String AUTHORIZATION_HEADER = "x-access-token";
+ private final TokenProvider tokenProvider;
+
+ public JwtFilter(TokenProvider tokenProvider) {
+ this.tokenProvider = tokenProvider;
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+ String jwt = extractToken(httpServletRequest);
+
+ if (tokenProvider.validateToken(jwt)) {
+ Authentication authentication = tokenProvider.getAuthentication(jwt);
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ }
+
+ chain.doFilter(request, response);//다음 필터로 나머지 요청을 위임
+ }
+
+ private String extractToken(HttpServletRequest request) {
+ String token = request.getHeader(AUTHORIZATION_HEADER);
+ if (StringUtils.hasText(token)) {
+ return token;
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/jwt/JwtSecurityConfig.java b/src/main/java/com/landvibe/summer/reservation/jwt/JwtSecurityConfig.java
new file mode 100644
index 0000000..558aa99
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/jwt/JwtSecurityConfig.java
@@ -0,0 +1,21 @@
+package com.landvibe.summer.reservation.jwt;
+
+
+import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.web.DefaultSecurityFilterChain;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+public class JwtSecurityConfig extends SecurityConfigurerAdapter {
+ private TokenProvider tokenProvider;
+
+ public JwtSecurityConfig(TokenProvider tokenProvider) {
+ this.tokenProvider = tokenProvider;
+ }
+
+ @Override
+ public void configure(HttpSecurity builder) throws Exception {
+ JwtFilter jwtFilter = new JwtFilter(tokenProvider);
+ builder.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/jwt/TokenProvider.java b/src/main/java/com/landvibe/summer/reservation/jwt/TokenProvider.java
new file mode 100644
index 0000000..b3e25cc
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/jwt/TokenProvider.java
@@ -0,0 +1,85 @@
+package com.landvibe.summer.reservation.jwt;
+
+import io.jsonwebtoken.*;
+import io.jsonwebtoken.io.Decoders;
+import io.jsonwebtoken.security.Keys;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.stereotype.Service;
+
+import java.security.Key;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.stream.Collectors;
+
+@Service
+public class TokenProvider implements InitializingBean {
+ private static final String AUTHORITY_KEY = "auth";
+ private final String secret;
+ private final Long tokenValidityInSeconds;
+ private Key key;
+
+ public TokenProvider(@Value("${jwt.secrete}") String secret,
+ @Value("${jwt.token-validity-in-seconds}") Long tokenValidityInSeconds) {
+ this.secret = secret;
+ this.tokenValidityInSeconds = tokenValidityInSeconds;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ byte[] keyBytes = Decoders.BASE64.decode(secret);
+ this.key = Keys.hmacShaKeyFor(keyBytes);
+ }
+
+ public String createToken(Authentication authentication) {
+ String authories = authentication.getAuthorities().stream()
+ .map(GrantedAuthority::getAuthority)
+ .collect(Collectors.joining(","));
+ long now = new Date().getTime();
+ Date validity = new Date(now + this.tokenValidityInSeconds);
+
+ return Jwts.builder()
+ .setSubject(authentication.getName())//principal
+ .claim(AUTHORITY_KEY, authories)
+ .signWith(key, SignatureAlgorithm.HS512)
+ .setExpiration(validity)
+ .compact();
+ }
+
+ public boolean validateToken(String token) {
+ try {
+ Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token);
+ return true;
+ } catch (SecurityException | MalformedJwtException e) {
+
+ } catch (ExpiredJwtException e) {
+
+ } catch (UnsupportedJwtException e) {
+
+ } catch (IllegalArgumentException e) {
+
+ }
+ return false;
+ }
+
+ public Authentication getAuthentication(String token) {
+ Claims claims = Jwts.parserBuilder()
+ .setSigningKey(key)
+ .build()
+ .parseClaimsJws(token)
+ .getBody();
+
+ Collection extends GrantedAuthority> authorities =
+ Arrays.stream(claims.get(AUTHORITY_KEY).toString().split(","))
+ .map(SimpleGrantedAuthority::new)
+ .collect(Collectors.toList());
+ User principle = new User(claims.getSubject(), "", authorities);
+ return new UsernamePasswordAuthenticationToken(principle, token, authorities);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/repository/CategoryRepository.java b/src/main/java/com/landvibe/summer/reservation/repository/CategoryRepository.java
index ecada48..9d0190a 100644
--- a/src/main/java/com/landvibe/summer/reservation/repository/CategoryRepository.java
+++ b/src/main/java/com/landvibe/summer/reservation/repository/CategoryRepository.java
@@ -1,24 +1,12 @@
package com.landvibe.summer.reservation.repository;
import com.landvibe.summer.reservation.entity.Category;
-import com.landvibe.summer.reservation.entity.Product;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
-import java.util.ArrayList;
import java.util.Optional;
-@Repository
-public interface CategoryRepository {
- Category save(Category category);
-
- ArrayList lookUp();
-
- Optional findByName(String name);
-
- Optional findById(Long id);
-
- void clearDb();
-
- void plusCategoryCount(Long cateId);
-
+public interface CategoryRepository extends JpaRepository {
+ @Query(value = "select c from Category c where c.cateId = :categoryId")
+ Optional getCategory(Long categoryId);
}
diff --git a/src/main/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepository.java b/src/main/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepository.java
deleted file mode 100644
index b11870e..0000000
--- a/src/main/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepository.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.landvibe.summer.reservation.repository;
-
-import com.landvibe.summer.reservation.entity.Category;
-import com.landvibe.summer.reservation.entity.Product;
-import org.springframework.stereotype.Repository;
-
-import java.util.*;
-
-@Repository
-public class MemoryCategoryRepository implements CategoryRepository {
- private static List db = new ArrayList();
- private static Long sequence = 0L;
-
- @Override
- public Category save(Category category) {
- category.setCateId(++sequence);
- db.add(category);
- return category;
- }
-
- @Override
- public ArrayList lookUp() {
- return (ArrayList) db;
- }
-
- @Override
- public Optional findByName(String name) {
- return db.stream()
- .filter(product -> name.equals(product.getCateName()))
- .findAny();
- }
-
- @Override
- public Optional findById(Long id) {
- return db.stream()
- .filter(product -> id.equals(product.getCateId()))
- .findAny();
- }
-
- @Override
- public void clearDb() {
- db.clear();
- }
-
- @Override
- public void plusCategoryCount(Long cateId) {
- for (Category category : db) {
- if (category.getCateId().equals(cateId)) {
- category.setCount(category.getCount() + 1);
- }
- }
- }
-}
diff --git a/src/main/java/com/landvibe/summer/reservation/repository/MemoryProductRepository.java b/src/main/java/com/landvibe/summer/reservation/repository/MemoryProductRepository.java
deleted file mode 100644
index d894ec8..0000000
--- a/src/main/java/com/landvibe/summer/reservation/repository/MemoryProductRepository.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.landvibe.summer.reservation.repository;
-
-import com.landvibe.summer.reservation.entity.Product;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Repository;
-
-import java.util.*;
-
-@Repository
-public class MemoryProductRepository implements ProductRepository {
- private static Map db = new HashMap<>();
- private static Long sequence = 0L;
-
- @Override
- public Product save(Product product) {
- product.setId(++sequence);
- db.put(product.getId(), product);
- return product;
- }
-
- @Override
- public Optional findById(Long id) {
- return Optional.ofNullable(db.get(id));
- }
-
- @Override
- public Optional findByName(String name) {
- return db.values().stream()
- .filter(product -> name.equals(product.getName()))
- .findAny();
- }
-
- @Override
- public ArrayList lookUp() {
- List productList = new ArrayList<>(db.values());
- return (ArrayList) productList;
- }
-
- @Override
- public void clearDb() {
- db.clear();
- }
-}
diff --git a/src/main/java/com/landvibe/summer/reservation/repository/ProductRepository.java b/src/main/java/com/landvibe/summer/reservation/repository/ProductRepository.java
index c5a4a4d..b869ad7 100644
--- a/src/main/java/com/landvibe/summer/reservation/repository/ProductRepository.java
+++ b/src/main/java/com/landvibe/summer/reservation/repository/ProductRepository.java
@@ -1,22 +1,7 @@
package com.landvibe.summer.reservation.repository;
import com.landvibe.summer.reservation.entity.Product;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Repository;
-
-import java.util.ArrayList;
-import java.util.Optional;
-
-@Repository
-public interface ProductRepository {
- Product save(Product product);
-
- Optional findById(Long id);
-
- Optional findByName(String name);
-
- ArrayList lookUp();
-
- void clearDb();
+import org.springframework.data.jpa.repository.JpaRepository;
+public interface ProductRepository extends JpaRepository {
}
diff --git a/src/main/java/com/landvibe/summer/reservation/repository/UserRepository.java b/src/main/java/com/landvibe/summer/reservation/repository/UserRepository.java
new file mode 100644
index 0000000..de21b8c
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/repository/UserRepository.java
@@ -0,0 +1,16 @@
+package com.landvibe.summer.reservation.repository;
+
+import com.landvibe.summer.reservation.entity.User;
+import org.springframework.data.jpa.repository.EntityGraph;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.Optional;
+
+@Repository
+public interface UserRepository extends JpaRepository {
+ Optional findByName(String name);
+
+ @EntityGraph(attributePaths = "authorities")
+ Optional findOneWithAuthoritiesByName(String name);
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/service/AuthService.java b/src/main/java/com/landvibe/summer/reservation/service/AuthService.java
new file mode 100644
index 0000000..cbd0d49
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/service/AuthService.java
@@ -0,0 +1,27 @@
+package com.landvibe.summer.reservation.service;
+
+import com.landvibe.summer.reservation.dto.request.LoginRequest;
+import com.landvibe.summer.reservation.jwt.TokenProvider;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class AuthService {
+ private final TokenProvider tokenProvider;
+ private final AuthenticationManagerBuilder authenticationManagerBuilder;
+
+ public String login(LoginRequest request) {
+ UsernamePasswordAuthenticationToken authenticationToken =
+ new UsernamePasswordAuthenticationToken(request.getName(), request.getPassword());
+
+ Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+
+ return tokenProvider.createToken(authentication);
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/service/CategoryService.java b/src/main/java/com/landvibe/summer/reservation/service/CategoryService.java
index bb3a135..06a0dad 100644
--- a/src/main/java/com/landvibe/summer/reservation/service/CategoryService.java
+++ b/src/main/java/com/landvibe/summer/reservation/service/CategoryService.java
@@ -2,50 +2,55 @@
import com.landvibe.summer.reservation.dto.request.CategoryRequest;
import com.landvibe.summer.reservation.entity.Category;
-import com.landvibe.summer.reservation.entity.Product;
+import com.landvibe.summer.reservation.dto.response.CategoryDetail;
import com.landvibe.summer.reservation.repository.CategoryRepository;
import lombok.RequiredArgsConstructor;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
-import org.springframework.web.bind.annotation.ExceptionHandler;
+import javax.transaction.Transactional;
import java.util.ArrayList;
+import java.util.List;
@Service
@RequiredArgsConstructor
public class CategoryService {
private final CategoryRepository categoryRepository;
- public Long join(CategoryRequest request) {
- if (!validateProduct(request)) {
- return -1L;
- }
- Category newCategory = new Category(request.getName(), null, 0);
- categoryRepository.save(newCategory);
- return newCategory.getCateId();
- }
-
- public boolean validateProduct(CategoryRequest request) {
- ArrayList categories = categoryRepository.lookUp();
- for (Category category : categories) {
- if (category.getCateName().equals(request.getName())) {
- return false;
- }
- }
- return true;
+ @Transactional
+ public void save(Category request) {
+ categoryRepository.save(request);
}
- public Category findByName(String name) {
- return categoryRepository.findByName(name)
- .orElseThrow(() -> new IllegalStateException("존재하지 않는 카테고리입니다."));
+ public Long create(CategoryRequest request) {
+ Category category = Category.builder()
+ .cateName(request.getName())
+ .build();
+ validate(category);
+ save(category);
+ return category.getCateId();
}
- public Category findById(Long id) {
- return categoryRepository.findById(id)
- .orElseThrow(() -> new IllegalStateException("존재하지 않는 카테고리입니다."));
+ public List getCategories() {
+ List categories = categoryRepository.findAll();
+ List cateDetails = new ArrayList<>();
+ for (int i = 0; i < categories.size(); i++) {
+ Category category = categories.get(i);
+ CategoryDetail categoryDetail = CategoryDetail.builder()
+ .id(category.getCateId())
+ .name(category.getCateName())
+ .count(category.size())
+ .build();
+ cateDetails.add(categoryDetail);
+ }
+ return cateDetails;
}
- public ArrayList lookUp() {
- return categoryRepository.lookUp();
+ public void validate(Category category) throws IllegalStateException {
+ List categories = categoryRepository.findAll();
+ for (int i = 0; i < categories.size(); i++) {
+ if (categories.get(i).getCateName().equals(category.getCateName())) {
+ throw new IllegalStateException("이미 존재하는 카테고리입니다.");
+ }
+ }
}
}
diff --git a/src/main/java/com/landvibe/summer/reservation/service/CustomUserDetailService.java b/src/main/java/com/landvibe/summer/reservation/service/CustomUserDetailService.java
new file mode 100644
index 0000000..ff87d63
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/service/CustomUserDetailService.java
@@ -0,0 +1,40 @@
+package com.landvibe.summer.reservation.service;
+
+import com.landvibe.summer.reservation.repository.UserRepository;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@RequiredArgsConstructor
+public class CustomUserDetailService implements UserDetailsService {
+
+ private final UserRepository userRepository;
+
+
+ @Override
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+ return userRepository.findOneWithAuthoritiesByName(username)
+ .map(user -> createUser(username, user))
+ .orElseThrow(() -> new IllegalStateException("user not found"));
+ }
+
+ private User createUser(String name, com.landvibe.summer.reservation.entity.User user) {
+ List grantedAuthorityList = user.getAuthorities().stream()
+ .map(authority -> new SimpleGrantedAuthority(authority.getAuthorityName()))
+ .collect(Collectors.toList());
+ return new User(
+ user.getName(),
+ user.getPassword(),
+ grantedAuthorityList
+ );
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/service/ProductService.java b/src/main/java/com/landvibe/summer/reservation/service/ProductService.java
index cc46e43..eb84ef8 100644
--- a/src/main/java/com/landvibe/summer/reservation/service/ProductService.java
+++ b/src/main/java/com/landvibe/summer/reservation/service/ProductService.java
@@ -2,56 +2,105 @@
import com.landvibe.summer.reservation.dto.request.ProductRequest;
import com.landvibe.summer.reservation.entity.Product;
+import com.landvibe.summer.reservation.dto.response.ProductDetail;
+import com.landvibe.summer.reservation.dto.response.Products;
+import com.landvibe.summer.reservation.entity.User;
import com.landvibe.summer.reservation.repository.CategoryRepository;
import com.landvibe.summer.reservation.repository.ProductRepository;
+import com.landvibe.summer.reservation.repository.UserRepository;
+import com.landvibe.summer.reservation.util.SecurityUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
+import java.util.List;
+
@Service
@RequiredArgsConstructor
public class ProductService {
private final ProductRepository productRepository;
private final CategoryRepository categoryRepository;
+ private final UserRepository userRepository;
- public Long join(ProductRequest request) {
- if (!validateProduct(request)) {
- return -1L;
- }
- Product newProduct = Product.builder()
- .categoryId(request.getCategoryId())
+ @Transactional
+ public void save(Product product) {
+ productRepository.save(product);
+ }
+
+ public Long create(ProductRequest request) {
+ String name = SecurityUtil.getCurrentUsername().orElseThrow(() -> new IllegalStateException("user not found"));
+ User user = userRepository.findByName(name).orElseThrow(() -> new IllegalStateException("user not found"));
+ Product product = Product.builder()
+ .category(categoryRepository.getCategory(request.getCategoryId()).orElse(null))
.name(request.getName())
.description(request.getDescription())
.createdAt(LocalDateTime.now())
+ .register(user.getName())
.build();
- productRepository.save(newProduct);
- categoryRepository.plusCategoryCount(request.getCategoryId());
- return newProduct.getId();
+ validate(product, request.getCategoryId());
+ save(product);
+ return product.getId();
}
- public boolean validateProduct(ProductRequest request) {
- ArrayList products = productRepository.lookUp();
- for (Product product : products) {
- if (product.getName().equals(request.getName())) {
- return false;
- }
+ public List getProductsRes() {
+ List product = productRepository.findAll();
+ List products = new ArrayList<>();
+ for (int i = 0; i < product.size(); i++) {
+ Product nowPro = product.get(i);
+ Products nowPros = Products.builder()
+ .id(nowPro.getId())
+ .categoryId(nowPro.getCategory().getCateId())
+ .name(nowPro.getName())
+ .createdAt(nowPro.getCreatedAt())
+ .build();
+ products.add(nowPros);
}
- return true;
+ return products;
}
- public Product findByName(String name) {
- return productRepository.findByName(name)
- .orElseThrow(() -> new IllegalStateException("존재하지 않는 회원입니다."));
+ public ProductDetail productDetail(Long productId) {
+ Product product = productRepository.getById(productId);
+ ProductDetail productDetail = ProductDetail.builder()
+ .categoryId(product.getCategory().getCateId())
+ .categoryName(product.getCategory().getCateName())
+ .name(product.getName())
+ .description(product.getDescription())
+ .id(product.getId())
+ .createdAt(product.getCreatedAt())
+ .build();
+ return productDetail;
}
- public Product findById(Long id) {
- return productRepository.findById(id)
- .orElseThrow(() -> new IllegalStateException("존재하지 않는 회원입니다."));
+ public List myProducts() {
+ String name = SecurityUtil.getCurrentUsername().orElseThrow(() -> new IllegalStateException("user not found"));
+ User user = userRepository.findByName(name).orElseThrow(() -> new IllegalStateException("user not found"));
+ List product = productRepository.findAll();
+ List products = new ArrayList<>();
+ for (Product p : product) {
+ if (p.getRegister().equals(user.getName())) {
+ Products nowPros = Products.builder()
+ .id(p.getId())
+ .categoryId(p.getCategory().getCateId())
+ .name(p.getName())
+ .createdAt(p.getCreatedAt())
+ .build();
+ products.add(nowPros);
+ }
+ }
+ return products;
}
- public ArrayList lookUp() {
- return productRepository.lookUp();
+ public void validate(Product product, Long categoryId) throws IllegalStateException {
+ List products = productRepository.findAll();
+ for (int i = 0; i < products.size(); i++) {
+ if (products.get(i).getName().equals(product.getName())) {
+ throw new IllegalStateException("이미 존재하는 상품입니다.");
+ } else if (categoryRepository.findById(categoryId).orElse(null) == null) {
+ throw new IllegalStateException("해당 카테고리가 존재하지 않습니다");
+ }
+ }
}
}
diff --git a/src/main/java/com/landvibe/summer/reservation/service/UserService.java b/src/main/java/com/landvibe/summer/reservation/service/UserService.java
new file mode 100644
index 0000000..2f85e07
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/service/UserService.java
@@ -0,0 +1,62 @@
+package com.landvibe.summer.reservation.service;
+
+import com.landvibe.summer.reservation.dto.request.UserRequest;
+import com.landvibe.summer.reservation.dto.response.UserResponse;
+import com.landvibe.summer.reservation.entity.Authority;
+import com.landvibe.summer.reservation.entity.User;
+import com.landvibe.summer.reservation.repository.UserRepository;
+import com.landvibe.summer.reservation.util.SecurityUtil;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collections;
+
+@Service
+@RequiredArgsConstructor
+public class UserService {
+ private final UserRepository userRepository;
+ private final PasswordEncoder passwordEncoder;
+
+ @Transactional
+ public UserResponse join(UserRequest request) {
+
+ Authority authority = Authority.builder()
+ .authorityName("ROLE_USER")
+ .build();
+ User user = User.builder()
+ .name(request.getName())
+ .password(passwordEncoder.encode(request.getPassword()))
+ .authorities(Collections.singleton(authority))
+ .build();
+
+ user = userRepository.save(user);
+
+ return UserResponse.builder()
+ .id(user.getId())
+ .name(user.getName())
+ .build();
+ }
+
+ @Transactional
+ public UserResponse getUserByName(String name) {
+ User user = userRepository.findByName(name).orElseThrow(() -> new IllegalStateException("User not found"));
+
+ return UserResponse.builder()
+ .id(user.getId())
+ .name(user.getName())
+ .build();
+ }
+
+ @Transactional
+ public UserResponse getMyInfo() {
+ String name = SecurityUtil.getCurrentUsername().orElseThrow(() -> new IllegalStateException("user not found"));
+ User user = userRepository.findByName(name).orElseThrow(() -> new IllegalStateException("user not found"));
+
+ return UserResponse.builder()
+ .id(user.getId())
+ .name(user.getName())
+ .build();
+ }
+}
diff --git a/src/main/java/com/landvibe/summer/reservation/util/SecurityUtil.java b/src/main/java/com/landvibe/summer/reservation/util/SecurityUtil.java
new file mode 100644
index 0000000..e91905d
--- /dev/null
+++ b/src/main/java/com/landvibe/summer/reservation/util/SecurityUtil.java
@@ -0,0 +1,24 @@
+package com.landvibe.summer.reservation.util;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.Optional;
+
+public class SecurityUtil { //authentication에서 유저이름을 받아오는 유틸성 클래스
+ public static Optional getCurrentUsername() {
+ final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ if (authentication == null) {
+ return Optional.empty();
+ }
+ String username = null;
+ if (authentication.getPrincipal() instanceof UserDetails) {
+ UserDetails user = (UserDetails) authentication.getPrincipal();
+ username = user.getUsername();
+ } else if (authentication.getPrincipal() instanceof String) {
+ username = (String) authentication.getPrincipal();
+ }
+ return Optional.ofNullable(username);
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
deleted file mode 100644
index 0e18a6f..0000000
--- a/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-server.servlet.encoding.charset=UTF-8
-server.servlet.encoding.force=true
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..04cf52d
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,20 @@
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ url: jdbc:mysql://localhost:3306/2022_SummerCoding?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&serverTimezone=Asia/Seoul
+ password: tlacksgml12
+ jpa:
+ database-platform: org.hibernate.dialect.MySQL8Dialect
+ show-sql: 'true'
+ hibernate:
+ ddl-auto: update
+server:
+ servlet:
+ encoding:
+ force: 'true'
+ charset: UTF-8
+jwt:
+ header: x-access-token
+ secrete: 5f90fa5a3ba78d8f89bf8c3b7e391592ef060330c83cfbd283d21b2225562c37e4f01786695f5bd055f4e5af10d56397d01e17e3ab408fbb99d7413a719d4c21
+ token-validity-in-seconds: 86400
diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html
deleted file mode 100644
index 28b36dc..0000000
--- a/src/main/resources/templates/home.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- Title
-
-
- sadasd
-
-
\ No newline at end of file
diff --git a/src/test/java/com/landvibe/summer/reservation/ReservationApplicationTests.java b/src/test/java/com/landvibe/summer/reservation/LandvibeApplicationTests.java
similarity index 84%
rename from src/test/java/com/landvibe/summer/reservation/ReservationApplicationTests.java
rename to src/test/java/com/landvibe/summer/reservation/LandvibeApplicationTests.java
index b4ecc9d..75b71ee 100644
--- a/src/test/java/com/landvibe/summer/reservation/ReservationApplicationTests.java
+++ b/src/test/java/com/landvibe/summer/reservation/LandvibeApplicationTests.java
@@ -4,10 +4,10 @@
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
-class ReservationApplicationTests {
+class LandvibeApplicationTests {
@Test
void contextLoads() {
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepositoryTest.java b/src/test/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepositoryTest.java
deleted file mode 100644
index 846ca9c..0000000
--- a/src/test/java/com/landvibe/summer/reservation/repository/MemoryCategoryRepositoryTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.landvibe.summer.reservation.repository;
-
-import com.landvibe.summer.reservation.entity.Category;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.time.LocalDateTime;
-import java.util.Optional;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-class MemoryCategoryRepositoryTest {
- CategoryRepository repository = new MemoryCategoryRepository();
-
- @Test
- void save() {
- //given
- Category category = new Category("카테고리1", 1L, 1);
- //when
- repository.save(category);
- Optional savedCategory = repository.findByName(category.getCateName());
-
- //then
- Assertions.assertThat(savedCategory.get()).isEqualTo(savedCategory.get());
- }
-
-
-}
\ No newline at end of file
diff --git a/src/test/java/com/landvibe/summer/reservation/repository/MemoryProductRepositoryTest.java b/src/test/java/com/landvibe/summer/reservation/repository/MemoryProductRepositoryTest.java
deleted file mode 100644
index 48968a1..0000000
--- a/src/test/java/com/landvibe/summer/reservation/repository/MemoryProductRepositoryTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.landvibe.summer.reservation.repository;
-
-import com.landvibe.summer.reservation.entity.Product;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-public class MemoryProductRepositoryTest {
- ProductRepository repository = new MemoryProductRepository();
-
- // @Test
-// public void save() {
-// //given
-// Product product = new Product(1L,"고양이","고양이공연",1L, LocalDateTime.now());
-// //when
-// repository.save(product);
-// Product savedProduct = repository.findById(product.getId()).get();
-//
-// //then
-// Assertions.assertThat(product.getName()).isEqualTo(savedProduct.getName());
-// }
- @Test
- public void lookUp() {
- //given
- Product product1 = new Product(1L, "고양이1", "고양이공연", 1L, LocalDateTime.now());
- Product product2 = new Product(1L, "고양이2", "고양이공연", 2L, LocalDateTime.now());
- Product product3 = new Product(1L, "고양이3", "고양이공연", 3L, LocalDateTime.now());
- //when
- repository.save(product1);
- repository.save(product2);
- repository.save(product3);
- List saveProducts = new ArrayList<>();
- saveProducts.add(product1);
- saveProducts.add(product2);
- saveProducts.add(product3);
- ArrayList products = repository.lookUp();
- //then
- Assertions.assertThat(saveProducts.equals(products));
-
- }
-}
diff --git a/src/test/java/com/landvibe/summer/reservation/service/ProductServiceTest.java b/src/test/java/com/landvibe/summer/reservation/service/ProductServiceTest.java
deleted file mode 100644
index 30a84cf..0000000
--- a/src/test/java/com/landvibe/summer/reservation/service/ProductServiceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.landvibe.summer.reservation.service;
-
-import com.landvibe.summer.reservation.dto.request.ProductRequest;
-import com.landvibe.summer.reservation.entity.Product;
-import com.landvibe.summer.reservation.repository.CategoryRepository;
-import com.landvibe.summer.reservation.repository.MemoryProductRepository;
-import com.landvibe.summer.reservation.repository.ProductRepository;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-class ProductServiceTest {
- ProductService service;
- ProductRepository repository;
- CategoryRepository categoryRepository;
-
- @BeforeEach
- public void beforEach() {
- this.repository = new MemoryProductRepository();
- this.service = new ProductService(repository, categoryRepository);
- }
-
- @AfterEach
- public void afterEach() {
- repository.clearDb();
- }
-
- @Test
- void join() {
- //given
- ProductRequest request = new ProductRequest(null, "심찬희", "찬희입니다", null);
- //when
- Long id = service.join(request);
- //then
- Product product = service.findByName("심찬희");
-
- Assertions.assertThat(product.getName()).isEqualTo(request.getName());
-
- }
-
- @Test
- public void 중복작품_예외() {
- //given
- ProductRequest request1 = new ProductRequest(null, "함석원", "함석원입니다", null);
- ProductRequest request2 = new ProductRequest(null, "함석원", "함입니다", null);
- //when
- service.join(request1);
- //then
- assertThrows(IllegalStateException.class, () -> {
- service.join(request2);
- });
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/landvibe/summer/reservation/service/categoryServiceTest.java b/src/test/java/com/landvibe/summer/reservation/service/categoryServiceTest.java
deleted file mode 100644
index f13e1e8..0000000
--- a/src/test/java/com/landvibe/summer/reservation/service/categoryServiceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.landvibe.summer.reservation.service;
-
-import com.landvibe.summer.reservation.dto.request.CategoryRequest;
-import com.landvibe.summer.reservation.dto.request.ProductRequest;
-import com.landvibe.summer.reservation.entity.Category;
-import com.landvibe.summer.reservation.entity.Product;
-import com.landvibe.summer.reservation.repository.CategoryRepository;
-import com.landvibe.summer.reservation.repository.MemoryCategoryRepository;
-import com.landvibe.summer.reservation.repository.MemoryProductRepository;
-import com.landvibe.summer.reservation.repository.ProductRepository;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-class categoryServiceTest {
-
- CategoryService service;
- CategoryRepository repository;
-
- @BeforeEach
- public void beforEach() {
- this.repository = new MemoryCategoryRepository();
- this.service = new CategoryService(repository);
- }
-
- @AfterEach
- public void afterEach() {
- repository.clearDb();
- }
-
- @Test
- void 카테고리등록() {
- //given
- CategoryRequest request = new CategoryRequest(-1, "1번 카테고리", -1);
- //when
- Long id = service.join(request);
- //then
-
- Category category = service.findByName(request.getName());
-
- Assertions.assertThat(category.getCateName()).isEqualTo(request.getName());
- }
-}
\ No newline at end of file
diff --git a/target/classes/application.properties b/target/classes/application.properties
new file mode 100644
index 0000000..3f48ddf
--- /dev/null
+++ b/target/classes/application.properties
@@ -0,0 +1,10 @@
+server.servlet.encoding.charset=UTF-8
+server.servlet.encoding.force=true
+spring.datasource.url=jdbc:mysql://localhost:3306/2022_SummerCoding?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
+spring.datasource.username=root
+spring.datasource.password=tlacksgml12
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+
+spring.jpa.show-sql=true
+spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
+spring.jpa.hibernate.ddl-auto=update
diff --git a/target/classes/com/landvibe/summer/reservation/LandvibeApplication.class b/target/classes/com/landvibe/summer/reservation/LandvibeApplication.class
new file mode 100644
index 0000000..cfe5616
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/LandvibeApplication.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/controller/CategoryController.class b/target/classes/com/landvibe/summer/reservation/controller/CategoryController.class
new file mode 100644
index 0000000..ff1cf2d
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/controller/CategoryController.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/controller/GlobalCatcher.class b/target/classes/com/landvibe/summer/reservation/controller/GlobalCatcher.class
new file mode 100644
index 0000000..a16dfb6
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/controller/GlobalCatcher.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/controller/ProductController.class b/target/classes/com/landvibe/summer/reservation/controller/ProductController.class
new file mode 100644
index 0000000..da22920
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/controller/ProductController.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/request/CategoryRequest.class b/target/classes/com/landvibe/summer/reservation/dto/request/CategoryRequest.class
new file mode 100644
index 0000000..da245bf
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/request/CategoryRequest.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/request/ProductRequest.class b/target/classes/com/landvibe/summer/reservation/dto/request/ProductRequest.class
new file mode 100644
index 0000000..4ed1e9c
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/request/ProductRequest.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/CategoriesResponse.class b/target/classes/com/landvibe/summer/reservation/dto/response/CategoriesResponse.class
new file mode 100644
index 0000000..1e9a812
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/CategoriesResponse.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail$CategoryDetailBuilder.class b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail$CategoryDetailBuilder.class
new file mode 100644
index 0000000..6110b26
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail$CategoryDetailBuilder.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail.class b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail.class
new file mode 100644
index 0000000..2e8a019
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryDetail.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/CategoryResponse.class b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryResponse.class
new file mode 100644
index 0000000..a9c4b31
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/CategoryResponse.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ErrorResult.class b/target/classes/com/landvibe/summer/reservation/dto/response/ErrorResult.class
new file mode 100644
index 0000000..9bc4d3a
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ErrorResult.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail$ProductDetailBuilder.class b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail$ProductDetailBuilder.class
new file mode 100644
index 0000000..6d8d0e2
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail$ProductDetailBuilder.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail.class b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail.class
new file mode 100644
index 0000000..3337cd8
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetail.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.class b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.class
new file mode 100644
index 0000000..41eb622
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ProductDetailResponse.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ProductResponse.class b/target/classes/com/landvibe/summer/reservation/dto/response/ProductResponse.class
new file mode 100644
index 0000000..10189fd
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ProductResponse.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/Products$ProductsBuilder.class b/target/classes/com/landvibe/summer/reservation/dto/response/Products$ProductsBuilder.class
new file mode 100644
index 0000000..168de26
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/Products$ProductsBuilder.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/Products.class b/target/classes/com/landvibe/summer/reservation/dto/response/Products.class
new file mode 100644
index 0000000..2355382
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/Products.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/ProductsResponse.class b/target/classes/com/landvibe/summer/reservation/dto/response/ProductsResponse.class
new file mode 100644
index 0000000..4d7b8ea
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/ProductsResponse.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/dto/response/Result.class b/target/classes/com/landvibe/summer/reservation/dto/response/Result.class
new file mode 100644
index 0000000..c9da1b0
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/dto/response/Result.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/entity/Category$CategoryBuilder.class b/target/classes/com/landvibe/summer/reservation/entity/Category$CategoryBuilder.class
new file mode 100644
index 0000000..1a6c488
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/entity/Category$CategoryBuilder.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/entity/Category.class b/target/classes/com/landvibe/summer/reservation/entity/Category.class
new file mode 100644
index 0000000..3adfaae
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/entity/Category.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/entity/Product$ProductBuilder.class b/target/classes/com/landvibe/summer/reservation/entity/Product$ProductBuilder.class
new file mode 100644
index 0000000..5583874
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/entity/Product$ProductBuilder.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/entity/Product.class b/target/classes/com/landvibe/summer/reservation/entity/Product.class
new file mode 100644
index 0000000..f8b96d3
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/entity/Product.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/repository/CategoryRepository.class b/target/classes/com/landvibe/summer/reservation/repository/CategoryRepository.class
new file mode 100644
index 0000000..682415d
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/repository/CategoryRepository.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/repository/ProductRepository.class b/target/classes/com/landvibe/summer/reservation/repository/ProductRepository.class
new file mode 100644
index 0000000..b3dbf16
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/repository/ProductRepository.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/service/CategoryService.class b/target/classes/com/landvibe/summer/reservation/service/CategoryService.class
new file mode 100644
index 0000000..09cbd55
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/service/CategoryService.class differ
diff --git a/target/classes/com/landvibe/summer/reservation/service/ProductService.class b/target/classes/com/landvibe/summer/reservation/service/ProductService.class
new file mode 100644
index 0000000..2f0c12f
Binary files /dev/null and b/target/classes/com/landvibe/summer/reservation/service/ProductService.class differ
diff --git a/target/test-classes/com/landvibe/summer/reservation/LandvibeApplicationTests.class b/target/test-classes/com/landvibe/summer/reservation/LandvibeApplicationTests.class
new file mode 100644
index 0000000..8c91193
Binary files /dev/null and b/target/test-classes/com/landvibe/summer/reservation/LandvibeApplicationTests.class differ
diff --git a/week3.zip b/week3.zip
new file mode 100644
index 0000000..67a77a9
Binary files /dev/null and b/week3.zip differ