diff --git a/build.gradle b/build.gradle
index deca6ed..3e46775 100644
--- a/build.gradle
+++ b/build.gradle
@@ -35,6 +35,7 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+ implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
}
tasks.named('test') {
diff --git a/dami_ms_ss2/.idea/compiler.xml b/dami_ms_ss2/.idea/compiler.xml
new file mode 100644
index 0000000..6f2089d
--- /dev/null
+++ b/dami_ms_ss2/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dami_ms_ss2/.idea/gradle.xml b/dami_ms_ss2/.idea/gradle.xml
new file mode 100644
index 0000000..f35f741
--- /dev/null
+++ b/dami_ms_ss2/.idea/gradle.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dami_ms_ss2/.idea/misc.xml b/dami_ms_ss2/.idea/misc.xml
new file mode 100644
index 0000000..55222c3
--- /dev/null
+++ b/dami_ms_ss2/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dami_ms_ss2/.idea/modules.xml b/dami_ms_ss2/.idea/modules.xml
new file mode 100644
index 0000000..9fb9d01
--- /dev/null
+++ b/dami_ms_ss2/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dami_ms_ss2/.idea/workspace.xml b/dami_ms_ss2/.idea/workspace.xml
new file mode 100644
index 0000000..71cdc3b
--- /dev/null
+++ b/dami_ms_ss2/.idea/workspace.xml
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1775730248928
+
+
+ 1775730248928
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/.gitattributes b/dami_ms_ss2/SpringCRUDSession/.gitattributes
new file mode 100644
index 0000000..8af972c
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/.gitattributes
@@ -0,0 +1,3 @@
+/gradlew text eol=lf
+*.bat text eol=crlf
+*.jar binary
diff --git a/dami_ms_ss2/SpringCRUDSession/.gitignore b/dami_ms_ss2/SpringCRUDSession/.gitignore
new file mode 100644
index 0000000..6a87385
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/.gitignore
@@ -0,0 +1,40 @@
+application.yaml
+.env
+
+HELP.md
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
diff --git a/dami_ms_ss2/SpringCRUDSession/board/.gitignore b/dami_ms_ss2/SpringCRUDSession/board/.gitignore
new file mode 100644
index 0000000..1fac4d5
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/.gitignore
@@ -0,0 +1,43 @@
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+.kotlin
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/board/build.gradle b/dami_ms_ss2/SpringCRUDSession/board/build.gradle
new file mode 100644
index 0000000..973cc48
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/build.gradle
@@ -0,0 +1,20 @@
+plugins {
+ id 'java'
+}
+
+group = 'org.example'
+version = '1.0-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testImplementation platform('org.junit:junit-bom:5.10.0')
+ testImplementation 'org.junit.jupiter:junit-jupiter'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+}
+
+test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar b/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..249e583
Binary files /dev/null and b/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties b/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..e04915b
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Mar 25 13:04:36 KST 2026
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/dami_ms_ss2/SpringCRUDSession/board/gradlew b/dami_ms_ss2/SpringCRUDSession/board/gradlew
new file mode 100644
index 0000000..1b6c787
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/dami_ms_ss2/SpringCRUDSession/board/gradlew.bat b/dami_ms_ss2/SpringCRUDSession/board/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/dami_ms_ss2/SpringCRUDSession/board/settings.gradle b/dami_ms_ss2/SpringCRUDSession/board/settings.gradle
new file mode 100644
index 0000000..311f804
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'board'
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/board/src/main/java/org/example/Main.java b/dami_ms_ss2/SpringCRUDSession/board/src/main/java/org/example/Main.java
new file mode 100644
index 0000000..876719a
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/src/main/java/org/example/Main.java
@@ -0,0 +1,17 @@
+package org.example;
+
+//TIP 코드를 실행하려면 을(를) 누르거나
+// 에디터 여백에 있는 아이콘을 클릭하세요.
+public class Main {
+ public static void main(String[] args) {
+ //TIP 캐럿을 강조 표시된 텍스트에 놓고 을(를) 누르면
+ // IntelliJ IDEA이(가) 수정을 제안하는 것을 확인할 수 있습니다.
+ System.out.printf("Hello and welcome!");
+
+ for (int i = 1; i <= 5; i++) {
+ //TIP 을(를) 눌러 코드 디버그를 시작하세요. 1개의 중단점을 설정해 드렸습니다
+ // 언제든 을(를) 눌러 중단점을 더 추가할 수 있습니다.
+ System.out.println("i = " + i);
+ }
+ }
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/board/src/main/resources/application.yml b/dami_ms_ss2/SpringCRUDSession/board/src/main/resources/application.yml
new file mode 100644
index 0000000..4733b81
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/board/src/main/resources/application.yml
@@ -0,0 +1,28 @@
+server:
+ port: 8080
+
+spring:
+ application:
+ name: session
+
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/session?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
+ username: root
+ password: yebin1448!
+
+ jpa:
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+ jackson:
+ serialization:
+ fail-on-empty-beans: false
+
+logging:
+ level:
+ org.hibernate.SQL: debug
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/build.gradle b/dami_ms_ss2/SpringCRUDSession/build.gradle
new file mode 100644
index 0000000..e771751
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/build.gradle
@@ -0,0 +1,45 @@
+plugins {
+ id 'java'
+ id 'org.springframework.boot' version '4.0.4'
+ id 'io.spring.dependency-management' version '1.1.7'
+
+}
+
+group = 'com.likelion'
+version = '0.0.1-SNAPSHOT'
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(21)
+ }
+}
+
+configurations {
+ compileOnly {
+ extendsFrom annotationProcessor
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
+ implementation 'org.springframework.boot:spring-boot-starter-webmvc'
+ implementation 'org.springframework.boot:spring-boot-starter-validation'
+ implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
+
+ compileOnly 'org.projectlombok:lombok'
+ developmentOnly 'org.springframework.boot:spring-boot-devtools'
+ runtimeOnly 'com.mysql:mysql-connector-j'
+ annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
+ annotationProcessor 'org.projectlombok:lombok'
+ testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
+ testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
+}
diff --git a/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar b/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..d997cfc
Binary files /dev/null and b/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties b/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..dbc3ce4
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/dami_ms_ss2/SpringCRUDSession/gradlew b/dami_ms_ss2/SpringCRUDSession/gradlew
new file mode 100644
index 0000000..0262dcb
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/dami_ms_ss2/SpringCRUDSession/gradlew.bat b/dami_ms_ss2/SpringCRUDSession/gradlew.bat
new file mode 100644
index 0000000..c4bdd3a
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/gradlew.bat
@@ -0,0 +1,93 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%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
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/dami_ms_ss2/SpringCRUDSession/settings.gradle b/dami_ms_ss2/SpringCRUDSession/settings.gradle
new file mode 100644
index 0000000..ade3347
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'session'
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java
new file mode 100644
index 0000000..64dda82
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java
@@ -0,0 +1,13 @@
+package com.likelion.session;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication //Spring Boot 애플리케이션의 시작점이며 설정·컴포넌트 스캔을 한 번에 처리하는 핵심 어노테이션
+public class SessionApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SessionApplication.class, args);
+ }
+
+}
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java
new file mode 100644
index 0000000..084a1c2
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java
@@ -0,0 +1,91 @@
+package com.likelion.session.controller;
+
+import com.likelion.session.dto.BoardCreateRequest;
+import com.likelion.session.dto.BoardResponse;
+import com.likelion.session.dto.BoardUpdateRequest;
+import com.likelion.session.service.BoardService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController //요청 받으면 JSON 같은 데이터만 반환하는 클래스
+@RequestMapping("/boards") //Spring Framework에서 “요청 URL 경로를 매핑(연결)하는 설정.
+// /boards"로 들어오는 요청을 이 컨트롤러(또는 메서드)가 처리하겠다는 뜻
+@RequiredArgsConstructor //필수 필드만 파라미터로 받는 생성자를 자동 생성
+
+public class BoardController {
+
+ private final BoardService boardService;
+
+ /*
+ 게시글 생성
+
+ [요청 흐름]
+ Client
+ -> DispatcherServlet
+ -> HandlerMapping
+ -> BoardController의 create() 메서드 선택
+ -> Service 호출
+ -> Repository 호출
+ -> DB 저장
+ -> 결과 반환
+ -> JSON 응답
+ */
+ @Operation( //이 API가 뭔지 설명해주는 주석
+ summary = "게시글 생성",
+ description = "새로운 게시글을 생성합니다."
+ )
+ @PostMapping //POST 요청을 받아서 데이터를 생성/처리하는 API 연결 어노테이션
+ public ResponseEntity create(@RequestBody BoardCreateRequest request) {
+ BoardResponse response = boardService.create(request);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 전체 조회
+ @Operation( //이 API가 뭔지 설명해주는 주석
+ summary = "게시글 전체 조회",
+ description = "등록된 모든 게시글을 조회합니다."
+ )
+ @GetMapping //GET 요청을 받아서 데이터를 조회하는 API 연결 어노테이션
+ public ResponseEntity> findAll() {
+ List response = boardService.findAll();
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 단건 조회
+ @Operation( //이 API가 뭔지 설명해주는 주석
+ summary = "게시글 단건 조회",
+ description = "id로 특정 게시글을 조회합니다."
+ )
+ @GetMapping("/{id}") //URL 경로에 있는 id 값을 받아 해당 데이터를 조회하는 GET API 매핑
+ public ResponseEntity findById(@PathVariable Long id) {
+ BoardResponse response = boardService.findById(id);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 수정
+ @Operation( //이 API가 뭔지 설명해주는 주석
+ summary = "게시글 수정",
+ description = "id로 특정 게시글의 제목과 내용을 수정합니다."
+ )
+ @PutMapping("/{id}") //URL의 id에 해당하는 데이터를 수정하는 PUT API 매핑
+ public ResponseEntity update(@PathVariable Long id,
+ @RequestBody BoardUpdateRequest request) {
+ BoardResponse response = boardService.update(id, request);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 삭제
+ @Operation( //이 API가 뭔지 설명해주는 주석
+ summary = "게시글 삭제",
+ description = "id로 특정 게시글을 삭제합니다."
+ )
+ @DeleteMapping("/{id}") //URL의 id에 해당하는 데이터를 삭제하는 DELETE API 매핑
+ public ResponseEntity delete(@PathVariable Long id) {
+ boardService.delete(id);
+ return ResponseEntity.noContent().build();
+ }
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java
new file mode 100644
index 0000000..d1b15ed
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java
@@ -0,0 +1,66 @@
+package com.likelion.session.domain;
+
+import jakarta.persistence.*;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.AllArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Entity //자바 객체를 DB 테이블로 매핑하는 표시
+@Table(name = "boards") //이 엔티티가 어떤 DB 테이블 이름과 매핑되는지 지정하는 역할. 이 클래스는 DB의 "boards" 테이블과 연결된다.
+@NoArgsConstructor(access = AccessLevel.PROTECTED) //외부에서는 못 쓰고, 내부/상속/JPA만 쓸 수 있는 기본 생성자 생성
+@AllArgsConstructor //모든 필드를 한 번에 초기화하는 생성자 생성
+
+public class Board {
+
+ @Id //데이터베이스에서 해당 엔티티의 기본키를 지정하는 어노테이션
+ @GeneratedValue(strategy = GenerationType.IDENTITY) //기본키 값을 DB가 자동으로 증가해서 생성하도록 설정하는 어노테이션
+ private Long id;
+
+ // 게시글 제목
+ @Column(nullable = false, length = 100) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String title;
+
+ // 게시글 내용
+ @Column(nullable = false, columnDefinition = "TEXT") //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String content;
+
+ // 작성자
+ @Column(nullable = false, length = 30) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String writer;
+
+ // 생성 시간
+ @Column(nullable = false) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private LocalDateTime createdAt;
+
+ // 수정 시간
+ @Column(nullable = false) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private LocalDateTime updatedAt;
+
+
+ public Board(String title, String content, String writer) {
+ this.title = title;
+ this.content = content;
+ this.writer = writer;
+ }
+
+ @PrePersist //엔티티가 DB에 저장되기 전에 실행되는 메서드를 지정하는 어노테이션
+ public void prePersist() {
+ this.createdAt = LocalDateTime.now();
+ this.updatedAt = LocalDateTime.now();
+ }
+
+ @PreUpdate //엔티티가 DB에서 수정되기 전에 실행되는 메서드를 지정하는 어노테이션
+ public void preUpdate() {
+ this.updatedAt = LocalDateTime.now();
+ }
+
+
+ public void update(String title, String content) {
+ this.title = title;
+ this.content = content;
+ }
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
new file mode 100644
index 0000000..f871bbe
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
@@ -0,0 +1,17 @@
+package com.likelion.session.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+
+public class BoardCreateRequest {
+ private String title;
+ private String content;
+ private String writer;
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java
new file mode 100644
index 0000000..4e7fcd2
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java
@@ -0,0 +1,22 @@
+package com.likelion.session.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+import java.time.LocalDateTime;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+@Builder //객체를 빌더 패턴으로 생성할 수 있게 해주는 기능
+//빌더 패턴: 복잡한 객체를 단계적으로 생성하는 디자인 패턴
+
+public class BoardResponse {
+
+ private Long id;
+ private String title;
+ private String content;
+ private String writer;
+ private LocalDateTime createdAt;
+ private LocalDateTime updatedAt;
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
new file mode 100644
index 0000000..2fd7131
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
@@ -0,0 +1,21 @@
+package com.likelion.session.dto;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
+public class BoardUpdateRequest {
+ @NotBlank(message = "제목은 필수입니다.") //문자열이 null이 아니고 공백이 아닌 값이어야 함을 검증하는 어노테이션
+ @Size(max = 100, message = "제목은 100자 이하로 입력해주세요.") //문자열이나 컬렉션의 길이(크기)를 제한하는 검증 어노테이션
+ private String title;
+
+ @NotBlank(message = "내용은 필수입니다.")
+ private String content;
+}
+
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java
new file mode 100644
index 0000000..65a424d
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java
@@ -0,0 +1,7 @@
+package com.likelion.session.repository;
+
+import com.likelion.session.domain.Board;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface BoardRepository extends JpaRepository {
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java
new file mode 100644
index 0000000..77d8121
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java
@@ -0,0 +1,123 @@
+package com.likelion.session.service;
+
+import com.likelion.session.domain.Board;
+import com.likelion.session.dto.BoardCreateRequest;
+import com.likelion.session.dto.BoardResponse;
+import com.likelion.session.dto.BoardUpdateRequest;
+import com.likelion.session.repository.BoardRepository;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j //로그 출력을 위한 log 객체를 자동으로 생성해주는 어노테이션
+@Service //이 클래스가 비즈니스 로직을 처리하는 클래스임을 스프링에게 알려줌.
+@RequiredArgsConstructor //final이 붙은 필드(boardRepository)를 생성자로 자동 주입해줌
+@Transactional //DB 작업 도중 에러가 나면 모든 작업을 이전으로 롤백함
+
+public class BoardService {
+
+ private final BoardRepository boardRepository;
+
+ /*
+ 게시글 생성
+ - Controller가 넘겨준 요청 DTO를 받아서
+ - Entity로 바꾼 뒤
+ - Repository를 통해 DB에 저장
+ - 저장된 결과를 Response DTO로 변환해서 반환
+ */
+ public BoardResponse create(BoardCreateRequest request) {
+ Board board = new Board(
+ request.getTitle(),
+ request.getContent(),
+ request.getWriter()
+ );
+
+ Board savedBoard = boardRepository.save(board);
+
+ return BoardResponse.builder()
+ .id(savedBoard.getId())
+ .title(savedBoard.getTitle())
+ .content(savedBoard.getContent())
+ .writer(savedBoard.getWriter())
+ .createdAt(savedBoard.getCreatedAt())
+ .updatedAt(savedBoard.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 전체 조회
+ - DB에 있는 모든 게시글을 가져옴
+ - Entity 리스트를 Response DTO 리스트로 변환
+ */
+ @Transactional(readOnly = true)
+ public List findAll() {
+ return boardRepository.findAll()
+ .stream()
+ .map(board -> BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build())
+ .toList();
+ }
+
+ /*
+ 게시글 단건 조회
+ - id로 게시글 조회
+ - 없으면 예외 발생
+ */
+ @Transactional(readOnly = true)
+ public BoardResponse findById(Long id) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ return BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 수정
+ - 기존 게시글을 찾음
+ - 엔티티의 update 메서드로 값 변경
+ - JPA 변경 감지로 update 반영
+ */
+ public BoardResponse update(Long id, BoardUpdateRequest request) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ board.update(request.getTitle(), request.getContent());
+
+ return BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 삭제
+ - id로 게시글을 찾고
+ - 있으면 삭제
+ */
+ public void delete(Long id) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ boardRepository.delete(board);
+ }
+}
\ No newline at end of file
diff --git a/dami_ms_ss2/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java b/dami_ms_ss2/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java
new file mode 100644
index 0000000..f4185b3
--- /dev/null
+++ b/dami_ms_ss2/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java
@@ -0,0 +1,13 @@
+package com.likelion.session;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest //실제 서버처럼 스프링 환경을 다 켜고 테스트하는 것
+class SessionApplicationTests {
+
+ @Test //해당 메서드를 테스트 코드로 실행하도록 지정하는 어노테이션
+ void contextLoads() {
+ }
+
+}
diff --git a/ms_session/.idea/.gitignore b/ms_session/.idea/.gitignore
new file mode 100644
index 0000000..30cf57e
--- /dev/null
+++ b/ms_session/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/ms_session/.idea/misc.xml b/ms_session/.idea/misc.xml
new file mode 100644
index 0000000..b67a5b0
--- /dev/null
+++ b/ms_session/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ms_session/.idea/modules.xml b/ms_session/.idea/modules.xml
new file mode 100644
index 0000000..9fb9d01
--- /dev/null
+++ b/ms_session/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ms_session/.idea/ms_session.iml b/ms_session/.idea/ms_session.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/ms_session/.idea/ms_session.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ms_session/.idea/vcs.xml b/ms_session/.idea/vcs.xml
new file mode 100644
index 0000000..286b7ad
--- /dev/null
+++ b/ms_session/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/.gitattributes b/ms_session/SpringCRUDSession/.gitattributes
new file mode 100644
index 0000000..8af972c
--- /dev/null
+++ b/ms_session/SpringCRUDSession/.gitattributes
@@ -0,0 +1,3 @@
+/gradlew text eol=lf
+*.bat text eol=crlf
+*.jar binary
diff --git a/ms_session/SpringCRUDSession/.gitignore b/ms_session/SpringCRUDSession/.gitignore
new file mode 100644
index 0000000..6a87385
--- /dev/null
+++ b/ms_session/SpringCRUDSession/.gitignore
@@ -0,0 +1,40 @@
+application.yaml
+.env
+
+HELP.md
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
diff --git a/ms_session/SpringCRUDSession/board/.gitignore b/ms_session/SpringCRUDSession/board/.gitignore
new file mode 100644
index 0000000..1fac4d5
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/.gitignore
@@ -0,0 +1,43 @@
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+.kotlin
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/board/build.gradle b/ms_session/SpringCRUDSession/board/build.gradle
new file mode 100644
index 0000000..973cc48
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/build.gradle
@@ -0,0 +1,20 @@
+plugins {
+ id 'java'
+}
+
+group = 'org.example'
+version = '1.0-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testImplementation platform('org.junit:junit-bom:5.10.0')
+ testImplementation 'org.junit.jupiter:junit-jupiter'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+}
+
+test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar b/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..249e583
Binary files /dev/null and b/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties b/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..e04915b
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Mar 25 13:04:36 KST 2026
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/ms_session/SpringCRUDSession/board/gradlew b/ms_session/SpringCRUDSession/board/gradlew
new file mode 100644
index 0000000..1b6c787
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/ms_session/SpringCRUDSession/board/gradlew.bat b/ms_session/SpringCRUDSession/board/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ms_session/SpringCRUDSession/board/settings.gradle b/ms_session/SpringCRUDSession/board/settings.gradle
new file mode 100644
index 0000000..311f804
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'board'
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/board/src/main/java/org/example/Main.java b/ms_session/SpringCRUDSession/board/src/main/java/org/example/Main.java
new file mode 100644
index 0000000..876719a
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/src/main/java/org/example/Main.java
@@ -0,0 +1,17 @@
+package org.example;
+
+//TIP 코드를 실행하려면 을(를) 누르거나
+// 에디터 여백에 있는 아이콘을 클릭하세요.
+public class Main {
+ public static void main(String[] args) {
+ //TIP 캐럿을 강조 표시된 텍스트에 놓고 을(를) 누르면
+ // IntelliJ IDEA이(가) 수정을 제안하는 것을 확인할 수 있습니다.
+ System.out.printf("Hello and welcome!");
+
+ for (int i = 1; i <= 5; i++) {
+ //TIP 을(를) 눌러 코드 디버그를 시작하세요. 1개의 중단점을 설정해 드렸습니다
+ // 언제든 을(를) 눌러 중단점을 더 추가할 수 있습니다.
+ System.out.println("i = " + i);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/board/src/main/resources/application.yml b/ms_session/SpringCRUDSession/board/src/main/resources/application.yml
new file mode 100644
index 0000000..4733b81
--- /dev/null
+++ b/ms_session/SpringCRUDSession/board/src/main/resources/application.yml
@@ -0,0 +1,28 @@
+server:
+ port: 8080
+
+spring:
+ application:
+ name: session
+
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/session?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
+ username: root
+ password: yebin1448!
+
+ jpa:
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+ jackson:
+ serialization:
+ fail-on-empty-beans: false
+
+logging:
+ level:
+ org.hibernate.SQL: debug
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/build.gradle b/ms_session/SpringCRUDSession/build.gradle
new file mode 100644
index 0000000..915fb01
--- /dev/null
+++ b/ms_session/SpringCRUDSession/build.gradle
@@ -0,0 +1,44 @@
+plugins {
+ id 'java'
+ id 'org.springframework.boot' version '4.0.4'
+ id 'io.spring.dependency-management' version '1.1.7'
+}
+
+group = 'com.likelion'
+version = '0.0.1-SNAPSHOT'
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(21)
+ }
+}
+
+configurations {
+ compileOnly {
+ extendsFrom annotationProcessor
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
+ implementation 'org.springframework.boot:spring-boot-starter-webmvc'
+ implementation 'org.springframework.boot:spring-boot-starter-validation'
+ implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
+
+ compileOnly 'org.projectlombok:lombok'
+ developmentOnly 'org.springframework.boot:spring-boot-devtools'
+ runtimeOnly 'com.mysql:mysql-connector-j'
+ annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
+ annotationProcessor 'org.projectlombok:lombok'
+ testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
+ testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
+}
diff --git a/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar b/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..d997cfc
Binary files /dev/null and b/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties b/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..dbc3ce4
--- /dev/null
+++ b/ms_session/SpringCRUDSession/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/ms_session/SpringCRUDSession/gradlew b/ms_session/SpringCRUDSession/gradlew
new file mode 100644
index 0000000..0262dcb
--- /dev/null
+++ b/ms_session/SpringCRUDSession/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/ms_session/SpringCRUDSession/gradlew.bat b/ms_session/SpringCRUDSession/gradlew.bat
new file mode 100644
index 0000000..c4bdd3a
--- /dev/null
+++ b/ms_session/SpringCRUDSession/gradlew.bat
@@ -0,0 +1,93 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%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
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ms_session/SpringCRUDSession/settings.gradle b/ms_session/SpringCRUDSession/settings.gradle
new file mode 100644
index 0000000..ade3347
--- /dev/null
+++ b/ms_session/SpringCRUDSession/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'session'
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java
new file mode 100644
index 0000000..62fbda8
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/SessionApplication.java
@@ -0,0 +1,13 @@
+package com.likelion.session;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication //이 프로젝트를 실행하는 메인 설정 클래스라는 걸 알림.
+public class SessionApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SessionApplication.class, args);
+ }
+
+}
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java
new file mode 100644
index 0000000..f1ad74f
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/controller/BoardController.java
@@ -0,0 +1,90 @@
+package com.likelion.session.controller;
+
+import com.likelion.session.dto.BoardCreateRequest;
+import com.likelion.session.dto.BoardResponse;
+import com.likelion.session.dto.BoardUpdateRequest;
+import com.likelion.session.service.BoardService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController //요청 받으면 JSON 같은 데이터만 반환하는 클래스
+@RequestMapping("/boards") //Spring Framework에서 “요청 URL 경로를 매핑(연결)하는 설정.
+ // /boards"로 들어오는 요청을 이 컨트롤러(또는 메서드)가 처리하겠다는 뜻
+@RequiredArgsConstructor //필수 필드만 파라미터로 받는 생성자를 자동 생성
+public class BoardController {
+
+ private final BoardService boardService;
+
+ /*
+ 게시글 생성
+
+ [요청 흐름]
+ Client
+ -> DispatcherServlet
+ -> HandlerMapping
+ -> BoardController의 create() 메서드 선택
+ -> Service 호출
+ -> Repository 호출
+ -> DB 저장
+ -> 결과 반환
+ -> JSON 응답
+ */
+ @Operation( //API의 기능과 설명을 문서화하기 위한 어노테이션
+ summary = "게시글 생성",
+ description = "새로운 게시글을 생성합니다."
+ )
+ @PostMapping //POST 요청을 처리해 데이터를 생성/전송하는 API 매핑 어노테이션
+ public ResponseEntity create(@RequestBody BoardCreateRequest request) {
+ BoardResponse response = boardService.create(request);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 전체 조회
+ @Operation( //API의 기능과 설명을 문서화하기 위한 어노테이션
+ summary = "게시글 전체 조회",
+ description = "등록된 모든 게시글을 조회합니다."
+ )
+ @GetMapping //GET 요청을 처리해 데이터를 조회하는 API 매핑 어노테이션
+ public ResponseEntity> findAll() {
+ List response = boardService.findAll();
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 단건 조회
+ @Operation( //API의 기능과 설명을 문서화하기 위한 어노테이션
+ summary = "게시글 단건 조회",
+ description = "id로 특정 게시글을 조회합니다."
+ )
+ @GetMapping("/{id}") //URL의 id 값을 받아 해당 데이터를 조회하는 GET API 매핑
+ public ResponseEntity findById(@PathVariable Long id) {
+ BoardResponse response = boardService.findById(id);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 수정
+ @Operation( //API의 기능과 설명을 문서화하기 위한 어노테이션
+ summary = "게시글 수정",
+ description = "id로 특정 게시글의 제목과 내용을 수정합니다."
+ )
+ @PutMapping("/{id}") //URL의 id에 해당하는 데이터를 수정하는 PUT API 매핑
+ public ResponseEntity update(@PathVariable Long id,
+ @RequestBody BoardUpdateRequest request) {
+ BoardResponse response = boardService.update(id, request);
+ return ResponseEntity.ok(response);
+ }
+
+ // 게시글 삭제
+ @Operation( //API의 기능과 설명을 문서화하기 위한 어노테이션
+ summary = "게시글 삭제",
+ description = "id로 특정 게시글을 삭제합니다."
+ )
+ @DeleteMapping("/{id}") //URL의 id에 해당하는 데이터를 삭제하는 DELETE API 매핑
+ public ResponseEntity delete(@PathVariable Long id) {
+ boardService.delete(id);
+ return ResponseEntity.noContent().build();
+ }
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java
new file mode 100644
index 0000000..9ed1463
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/domain/Board.java
@@ -0,0 +1,65 @@
+package com.likelion.session.domain;
+
+import jakarta.persistence.*;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.AllArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Entity //자바 객체를 DB 테이블로 매핑하는 표시
+@Table(name = "boards") //이 엔티티가 어떤 DB 테이블 이름과 매핑되는지 지정하는 역할. 이 클래스는 DB의 "boards" 테이블과 연결된다.
+@NoArgsConstructor(access = AccessLevel.PROTECTED) //외부에서는 못 쓰고, 내부/상속/JPA만 쓸 수 있는 기본 생성자 생성
+@AllArgsConstructor //모든 필드를 한 번에 초기화하는 생성자 생성
+public class Board {
+
+ @Id //데이터베이스에서 해당 엔티티의 기본키를 지정하는 어노테이션
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ // 게시글 제목
+ @Column(nullable = false, length = 100) //컬럼을 NULL 불가로 하고 최대 길이를 100으로 제한하는 매핑 설정
+ private String title;
+
+ // 게시글 내용
+ @Column(nullable = false, columnDefinition = "TEXT") //컬럼을 NULL 불가로 하고 DB 타입을 TEXT로 지정하는 매핑 설정
+ private String content;
+
+ // 작성자
+ @Column(nullable = false, length = 30) //컬럼을 NULL 불가로 하고 최대 길이를 30으로 제한하는 매핑 설정
+ private String writer;
+
+ // 생성 시간
+ @Column(nullable = false) //컬럼을 NULL 불가로 하는 매핑 설정
+ private LocalDateTime createdAt;
+
+ // 수정 시간
+ @Column(nullable = false) //컬럼을 NULL 불가로 하는 매핑 설정
+ private LocalDateTime updatedAt;
+
+
+ public Board(String title, String content, String writer) {
+ this.title = title;
+ this.content = content;
+ this.writer = writer;
+ }
+
+ @PrePers //엔티티가 저장되기 직전에 실행되는 메서드를 지정하는 어노테이션ist
+ public void prePersist() {
+ this.createdAt = LocalDateTime.now();
+ this.updatedAt = LocalDateTime.now();
+ }
+
+ @PreUpdate //엔티티가 수정되기 직전에 실행되는 메서드를 지정하는 어노테이션
+ public void preUpdate() {
+ this.updatedAt = LocalDateTime.now();
+ }
+
+
+ public void update(String title, String content) {
+ this.title = title;
+ this.content = content;
+ }
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
new file mode 100644
index 0000000..a5c593a
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
@@ -0,0 +1,16 @@
+package com.likelion.session.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+public class BoardCreateRequest {
+ private String title;
+ private String content;
+ private String writer;
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java
new file mode 100644
index 0000000..cfcc606
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardResponse.java
@@ -0,0 +1,21 @@
+package com.likelion.session.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+import java.time.LocalDateTime;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+@Builder //객체를 빌더 패턴으로 생성할 수 있게 해주는 기능
+ //빌더 패턴: 복잡한 객체를 단계적으로 생성하는 디자인 패턴
+public class BoardResponse {
+
+ private Long id;
+ private String title;
+ private String content;
+ private String writer;
+ private LocalDateTime createdAt;
+ private LocalDateTime updatedAt;
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
new file mode 100644
index 0000000..8ccea30
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
@@ -0,0 +1,22 @@
+package com.likelion.session.dto;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
+
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
+public class BoardUpdateRequest {
+ @NotBlank(message = "제목은 필수입니다.") //값이 비어있거나 공백이면 제목은 필수입니다.라는 메시지로 검증 실패를 발생시키는 어노테이션
+ @Size(max = 100, message = "제목은 100자 이하로 입력해주세요.") //값의 길이를 100자 이하로 제한하고 초과 시 해당 메시지로 검증 실패를 발생시키는 어노테이션
+ private String title;
+
+ @NotBlank(message = "내용은 필수입니다.") //값이 비어있거나 공백이면 내용은 필수입니다.라는 메시지로 검증 실패를 발생시키는 어노테이션
+ private String content;
+}
+
+
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java
new file mode 100644
index 0000000..65a424d
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/repository/BoardRepository.java
@@ -0,0 +1,7 @@
+package com.likelion.session.repository;
+
+import com.likelion.session.domain.Board;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface BoardRepository extends JpaRepository {
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java
new file mode 100644
index 0000000..071d729
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/java/com/likelion/session/service/BoardService.java
@@ -0,0 +1,122 @@
+package com.likelion.session.service;
+
+import com.likelion.session.domain.Board;
+import com.likelion.session.dto.BoardCreateRequest;
+import com.likelion.session.dto.BoardResponse;
+import com.likelion.session.dto.BoardUpdateRequest;
+import com.likelion.session.repository.BoardRepository;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j //로그 출력을 위한 log 객체를 자동으로 생성해주는 어노테이션
+@Service //이 클래스가 비즈니스 로직을 처리하는 클래스임을 스프링에게 알려줌.
+@RequiredArgsConstructor //final이 붙은 필드(boardRepository)를 생성자로 자동 주입해줌
+@Transactional //DB 작업 도중 에러가 나면 모든 작업을 이전으로 롤백함
+public class BoardService {
+
+ private final BoardRepository boardRepository;
+
+ /*
+ 게시글 생성
+ - Controller가 넘겨준 요청 DTO를 받아서
+ - Entity로 바꾼 뒤
+ - Repository를 통해 DB에 저장
+ - 저장된 결과를 Response DTO로 변환해서 반환
+ */
+ public BoardResponse create(BoardCreateRequest request) {
+ Board board = new Board(
+ request.getTitle(),
+ request.getContent(),
+ request.getWriter()
+ );
+
+ Board savedBoard = boardRepository.save(board);
+
+ return BoardResponse.builder()
+ .id(savedBoard.getId())
+ .title(savedBoard.getTitle())
+ .content(savedBoard.getContent())
+ .writer(savedBoard.getWriter())
+ .createdAt(savedBoard.getCreatedAt())
+ .updatedAt(savedBoard.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 전체 조회
+ - DB에 있는 모든 게시글을 가져옴
+ - Entity 리스트를 Response DTO 리스트로 변환
+ */
+ @Transactional(readOnly = true) //조회만 한다는 뜻.
+ public List findAll() {
+ return boardRepository.findAll()
+ .stream()
+ .map(board -> BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build())
+ .toList();
+ }
+
+ /*
+ 게시글 단건 조회
+ - id로 게시글 조회
+ - 없으면 예외 발생
+ */
+ @Transactional(readOnly = true) //조회만 한다는 뜻.
+ public BoardResponse findById(Long id) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ return BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 수정
+ - 기존 게시글을 찾음
+ - 엔티티의 update 메서드로 값 변경
+ - JPA 변경 감지로 update 반영
+ */
+ public BoardResponse update(Long id, BoardUpdateRequest request) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ board.update(request.getTitle(), request.getContent());
+
+ return BoardResponse.builder()
+ .id(board.getId())
+ .title(board.getTitle())
+ .content(board.getContent())
+ .writer(board.getWriter())
+ .createdAt(board.getCreatedAt())
+ .updatedAt(board.getUpdatedAt())
+ .build();
+ }
+
+ /*
+ 게시글 삭제
+ - id로 게시글을 찾고
+ - 있으면 삭제
+ */
+ public void delete(Long id) {
+ Board board = boardRepository.findById(id)
+ .orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
+
+ boardRepository.delete(board);
+ }
+}
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/main/resources/application.yml b/ms_session/SpringCRUDSession/src/main/resources/application.yml
new file mode 100644
index 0000000..6255e3d
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/main/resources/application.yml
@@ -0,0 +1,28 @@
+server:
+ port: 8082
+
+spring:
+ application:
+ name: session
+
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/session?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
+ username: root
+ password: dami0819!
+
+ jpa:
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+ jackson:
+ serialization:
+ fail-on-empty-beans: false
+
+logging:
+ level:
+ org.hibernate.SQL: debug
\ No newline at end of file
diff --git a/ms_session/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java b/ms_session/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java
new file mode 100644
index 0000000..f4185b3
--- /dev/null
+++ b/ms_session/SpringCRUDSession/src/test/java/com/likelion/session/SessionApplicationTests.java
@@ -0,0 +1,13 @@
+package com.likelion.session;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest //실제 서버처럼 스프링 환경을 다 켜고 테스트하는 것
+class SessionApplicationTests {
+
+ @Test //해당 메서드를 테스트 코드로 실행하도록 지정하는 어노테이션
+ void contextLoads() {
+ }
+
+}
diff --git a/src/main/java/com/likelion/session/SessionApplication.java b/src/main/java/com/likelion/session/SessionApplication.java
index 658e562..64dda82 100644
--- a/src/main/java/com/likelion/session/SessionApplication.java
+++ b/src/main/java/com/likelion/session/SessionApplication.java
@@ -3,7 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-@SpringBootApplication
+@SpringBootApplication //Spring Boot 애플리케이션의 시작점이며 설정·컴포넌트 스캔을 한 번에 처리하는 핵심 어노테이션
public class SessionApplication {
public static void main(String[] args) {
diff --git a/src/main/java/com/likelion/session/controller/BoardController.java b/src/main/java/com/likelion/session/controller/BoardController.java
index 2af74e7..084a1c2 100644
--- a/src/main/java/com/likelion/session/controller/BoardController.java
+++ b/src/main/java/com/likelion/session/controller/BoardController.java
@@ -11,12 +11,14 @@
import java.util.List;
-@RestController
-@RequestMapping("/boards")
-@RequiredArgsConstructor
+@RestController //요청 받으면 JSON 같은 데이터만 반환하는 클래스
+@RequestMapping("/boards") //Spring Framework에서 “요청 URL 경로를 매핑(연결)하는 설정.
+// /boards"로 들어오는 요청을 이 컨트롤러(또는 메서드)가 처리하겠다는 뜻
+@RequiredArgsConstructor //필수 필드만 파라미터로 받는 생성자를 자동 생성
+
public class BoardController {
- private final ;
+ private final BoardService boardService;
/*
게시글 생성
@@ -32,44 +34,44 @@ public class BoardController {
-> 결과 반환
-> JSON 응답
*/
- @Operation(
+ @Operation( //이 API가 뭔지 설명해주는 주석
summary = "게시글 생성",
description = "새로운 게시글을 생성합니다."
)
- @
+ @PostMapping //POST 요청을 받아서 데이터를 생성/처리하는 API 연결 어노테이션
public ResponseEntity create(@RequestBody BoardCreateRequest request) {
BoardResponse response = boardService.create(request);
return ResponseEntity.ok(response);
}
// 게시글 전체 조회
- @Operation(
+ @Operation( //이 API가 뭔지 설명해주는 주석
summary = "게시글 전체 조회",
description = "등록된 모든 게시글을 조회합니다."
)
- @
+ @GetMapping //GET 요청을 받아서 데이터를 조회하는 API 연결 어노테이션
public ResponseEntity> findAll() {
List response = boardService.findAll();
return ResponseEntity.ok(response);
}
// 게시글 단건 조회
- @Operation(
+ @Operation( //이 API가 뭔지 설명해주는 주석
summary = "게시글 단건 조회",
description = "id로 특정 게시글을 조회합니다."
)
- @GetMapping("/{id}")
+ @GetMapping("/{id}") //URL 경로에 있는 id 값을 받아 해당 데이터를 조회하는 GET API 매핑
public ResponseEntity findById(@PathVariable Long id) {
BoardResponse response = boardService.findById(id);
return ResponseEntity.ok(response);
}
// 게시글 수정
- @Operation(
+ @Operation( //이 API가 뭔지 설명해주는 주석
summary = "게시글 수정",
description = "id로 특정 게시글의 제목과 내용을 수정합니다."
)
- @("/{id}")
+ @PutMapping("/{id}") //URL의 id에 해당하는 데이터를 수정하는 PUT API 매핑
public ResponseEntity update(@PathVariable Long id,
@RequestBody BoardUpdateRequest request) {
BoardResponse response = boardService.update(id, request);
@@ -77,11 +79,11 @@ public ResponseEntity update(@PathVariable Long id,
}
// 게시글 삭제
- @Operation(
+ @Operation( //이 API가 뭔지 설명해주는 주석
summary = "게시글 삭제",
description = "id로 특정 게시글을 삭제합니다."
)
- @("/{id}")
+ @DeleteMapping("/{id}") //URL의 id에 해당하는 데이터를 삭제하는 DELETE API 매핑
public ResponseEntity delete(@PathVariable Long id) {
boardService.delete(id);
return ResponseEntity.noContent().build();
diff --git a/src/main/java/com/likelion/session/domain/Board.java b/src/main/java/com/likelion/session/domain/Board.java
index cb873de..d1b15ed 100644
--- a/src/main/java/com/likelion/session/domain/Board.java
+++ b/src/main/java/com/likelion/session/domain/Board.java
@@ -8,36 +8,37 @@
import java.time.LocalDateTime;
-@Getter // getter 메서드 자동 생성
-@Entity // 해당 클래스 DB 테이블로 인식하고 관리
-@Table(name = "boards")
-@NoArgsConstructor(access = AccessLevel.PROTECTED)
-@AllArgsConstructor
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Entity //자바 객체를 DB 테이블로 매핑하는 표시
+@Table(name = "boards") //이 엔티티가 어떤 DB 테이블 이름과 매핑되는지 지정하는 역할. 이 클래스는 DB의 "boards" 테이블과 연결된다.
+@NoArgsConstructor(access = AccessLevel.PROTECTED) //외부에서는 못 쓰고, 내부/상속/JPA만 쓸 수 있는 기본 생성자 생성
+@AllArgsConstructor //모든 필드를 한 번에 초기화하는 생성자 생성
+
public class Board {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long ;
+ @Id //데이터베이스에서 해당 엔티티의 기본키를 지정하는 어노테이션
+ @GeneratedValue(strategy = GenerationType.IDENTITY) //기본키 값을 DB가 자동으로 증가해서 생성하도록 설정하는 어노테이션
+ private Long id;
// 게시글 제목
- @Column(nullable = false, length = 100)
- private String ;
+ @Column(nullable = false, length = 100) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String title;
// 게시글 내용
- @Column(nullable = false, columnDefinition = "TEXT")
- private String ;
+ @Column(nullable = false, columnDefinition = "TEXT") //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String content;
// 작성자
- @Column(nullable = false, length = 30)
- private String ;
+ @Column(nullable = false, length = 30) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private String writer;
// 생성 시간
- @Column(nullable = false)
- private LocalDateTime ;
+ @Column(nullable = false) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private LocalDateTime createdAt;
// 수정 시간
- @Column(nullable = false)
- private LocalDateTime ;
+ @Column(nullable = false) //엔티티 필드를 데이터베이스 컬럼과 매핑하는 어노테이션
+ private LocalDateTime updatedAt;
public Board(String title, String content, String writer) {
@@ -46,13 +47,13 @@ public Board(String title, String content, String writer) {
this.writer = writer;
}
- @PrePersist
+ @PrePersist //엔티티가 DB에 저장되기 전에 실행되는 메서드를 지정하는 어노테이션
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();
}
- @PreUpdate
+ @PreUpdate //엔티티가 DB에서 수정되기 전에 실행되는 메서드를 지정하는 어노테이션
public void preUpdate() {
this.updatedAt = LocalDateTime.now();
}
diff --git a/src/main/java/com/likelion/session/dto/BoardCreateRequest.java b/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
index 62b1821..f871bbe 100644
--- a/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
+++ b/src/main/java/com/likelion/session/dto/BoardCreateRequest.java
@@ -5,13 +5,13 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
-@Getter
-@Setter
-@NoArgsConstructor
-@AllArgsConstructor
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+
public class BoardCreateRequest {
- // 넘겨주고 싶은 정보: 제목(title), 내용(content), 작성자(writer)
- private String ;
- private String ;
- private String ;
+ private String title;
+ private String content;
+ private String writer;
}
\ No newline at end of file
diff --git a/src/main/java/com/likelion/session/dto/BoardResponse.java b/src/main/java/com/likelion/session/dto/BoardResponse.java
index dc6e74f..4e7fcd2 100644
--- a/src/main/java/com/likelion/session/dto/BoardResponse.java
+++ b/src/main/java/com/likelion/session/dto/BoardResponse.java
@@ -6,12 +6,13 @@
import java.time.LocalDateTime;
-@Getter
-@AllArgsConstructor
-@Builder
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@AllArgsConstructor //모든 필드를 매개변수로 받는 생성자를 자동으로 만들어줌
+@Builder //객체를 빌더 패턴으로 생성할 수 있게 해주는 기능
+//빌더 패턴: 복잡한 객체를 단계적으로 생성하는 디자인 패턴
+
public class BoardResponse {
- // 돌려주고 싶은 응답: id, title, content, writer, createdAt, updatedAt
private Long id;
private String title;
private String content;
diff --git a/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java b/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
index d1e98e4..14b5796 100644
--- a/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
+++ b/src/main/java/com/likelion/session/dto/BoardUpdateRequest.java
@@ -7,15 +7,15 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
-@Getter
-@Setter
-@NoArgsConstructor
+@Getter //필드 값을 읽는 getter 메서드를 자동으로 생성해줌
+@Setter //setter 메서드를 자동 생성해줌
+@NoArgsConstructor //매개변수가 없는 기본 생성자를 자동으로 만들어 줌
public class BoardUpdateRequest {
- @NotBlank(message = "제목은 필수입니다.")
- @Size(max = 100, message = "제목은 100자 이하로 입력해주세요.")
+ @NotBlank(message = "제목은 필수입니다.") //문자열이 null이 아니고 공백이 아닌 값이어야 함을 검증하는 어노테이션
+ @Size(max = 100, message = "제목은 100자 이하로 입력해주세요.") //문자열이나 컬렉션의 길이(크기)를 제한하는 검증 어노테이션
private String title;
- @NotBlank(message = "내용은 필수입니다.")
+ @NotBlank(message = "내용은 필수입니다.") //문자열이 null이 아니고 공백이 아닌 값이어야 함을 검증하는 어노테이션
private String content;
}
diff --git a/src/main/java/com/likelion/session/service/BoardService.java b/src/main/java/com/likelion/session/service/BoardService.java
index 1bc58af..6b79fc2 100644
--- a/src/main/java/com/likelion/session/service/BoardService.java
+++ b/src/main/java/com/likelion/session/service/BoardService.java
@@ -12,13 +12,14 @@
import java.util.List;
-@Slf4j
-@Service
-@RequiredArgsConstructor
-@Transactional
+@Slf4j //로그 출력을 위한 log 객체를 자동으로 생성해주는 어노테이션
+@Service //이 클래스가 비즈니스 로직을 처리하는 클래스임을 스프링에게 알려줌.
+@RequiredArgsConstructor //final이 붙은 필드(boardRepository)를 생성자로 자동 주입해줌
+@Transactional //DB 작업 도중 에러가 나면 모든 작업을 이전으로 롤백함
+
public class BoardService {
- private final ;
+ private final BoardRepository boardRepository;
/*
게시글 생성
@@ -51,7 +52,7 @@ public BoardResponse create(BoardCreateRequest request) {
- DB에 있는 모든 게시글을 가져옴
- Entity 리스트를 Response DTO 리스트로 변환
*/
- @Transactional(readOnly = true)
+ @Transactional(readOnly = true) //해당 메서드/클래스의 작업을 하나의 트랜잭션으로 묶어 모두 성공하거나 모두 롤백되도록 하는 어노테이션
public List findAll() {
return boardRepository.findAll()
.stream()
@@ -71,7 +72,7 @@ public List findAll() {
- id로 게시글 조회
- 없으면 예외 발생
*/
- @Transactional(readOnly = true)
+ @Transactional(readOnly = true) //해당 메서드/클래스의 작업을 하나의 트랜잭션으로 묶어 모두 성공하거나 모두 롤백되도록 하는 어노테이션
public BoardResponse findById(Long id) {
Board board = boardRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("해당 게시글이 없습니다. id=" + id));
diff --git a/src/test/java/com/likelion/session/SessionApplicationTests.java b/src/test/java/com/likelion/session/SessionApplicationTests.java
index b65f4a0..f4185b3 100644
--- a/src/test/java/com/likelion/session/SessionApplicationTests.java
+++ b/src/test/java/com/likelion/session/SessionApplicationTests.java
@@ -3,10 +3,10 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
-@SpringBootTest
+@SpringBootTest //실제 서버처럼 스프링 환경을 다 켜고 테스트하는 것
class SessionApplicationTests {
- @Test
+ @Test //해당 메서드를 테스트 코드로 실행하도록 지정하는 어노테이션
void contextLoads() {
}