diff --git a/.gitignore b/.gitignore index a1c2a23..22d7005 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,43 @@ +week2/HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ +gradlew +gredlew.bat + +### 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/ + # Compiled class file *.class @@ -21,3 +61,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +.DS_Store \ No newline at end of file diff --git a/week1/.idea/.gitignore b/week1/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/week1/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/week1/.idea/jpa-buddy.xml b/week1/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/week1/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/week1/.idea/misc.xml b/week1/.idea/misc.xml new file mode 100644 index 0000000..59780fe --- /dev/null +++ b/week1/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/week1/.idea/modules.xml b/week1/.idea/modules.xml new file mode 100644 index 0000000..8e5aec5 --- /dev/null +++ b/week1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/week1/.idea/vcs.xml b/week1/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/week1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/week1/.idea/week1.iml b/week1/.idea/week1.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/week1/.idea/week1.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/week1/Seminar/week1_seminar/.gitignore b/week1/Seminar/week1_seminar/.gitignore new file mode 100644 index 0000000..fc2fa08 --- /dev/null +++ b/week1/Seminar/week1_seminar/.gitignore @@ -0,0 +1,39 @@ +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/ + +.DS_Store diff --git a/week1/Seminar/week1_seminar/build.gradle b/week1/Seminar/week1_seminar/build.gradle new file mode 100644 index 0000000..af23cf3 --- /dev/null +++ b/week1/Seminar/week1_seminar/build.gradle @@ -0,0 +1,22 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.10' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.jar b/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.jar differ diff --git a/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.properties b/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..774fae8 --- /dev/null +++ b/week1/Seminar/week1_seminar/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/week1/Seminar/week1_seminar/gradlew b/week1/Seminar/week1_seminar/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/week1/Seminar/week1_seminar/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/week1/Seminar/week1_seminar/gradlew.bat b/week1/Seminar/week1_seminar/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/week1/Seminar/week1_seminar/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/week1/Seminar/week1_seminar/settings.gradle b/week1/Seminar/week1_seminar/settings.gradle new file mode 100644 index 0000000..41af5fa --- /dev/null +++ b/week1/Seminar/week1_seminar/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'week1_seminar' diff --git a/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/Week1SeminarApplication.java b/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/Week1SeminarApplication.java new file mode 100644 index 0000000..21ed108 --- /dev/null +++ b/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/Week1SeminarApplication.java @@ -0,0 +1,13 @@ +package com.example.week1_seminar; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Week1SeminarApplication { + + public static void main(String[] args) { + SpringApplication.run(Week1SeminarApplication.class, args); + } + +} diff --git a/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/controller/TestController.java b/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/controller/TestController.java new file mode 100644 index 0000000..af2d247 --- /dev/null +++ b/week1/Seminar/week1_seminar/src/main/java/com/example/week1_seminar/controller/TestController.java @@ -0,0 +1,14 @@ +package com.example.week1_seminar.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + + @GetMapping("/test") + public String test() { + return "Welcome Spring!"; + } + +} diff --git a/week1/Seminar/week1_seminar/src/main/resources/application.properties b/week1/Seminar/week1_seminar/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/week1/Seminar/week1_seminar/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/week1/Seminar/week1_seminar/src/test/java/com/example/week1_seminar/Week1SeminarApplicationTests.java b/week1/Seminar/week1_seminar/src/test/java/com/example/week1_seminar/Week1SeminarApplicationTests.java new file mode 100644 index 0000000..0f139b8 --- /dev/null +++ b/week1/Seminar/week1_seminar/src/test/java/com/example/week1_seminar/Week1SeminarApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.week1_seminar; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Week1SeminarApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/week2/Basic/SecondSeminar/.gitignore b/week2/Basic/SecondSeminar/.gitignore new file mode 100644 index 0000000..fc2fa08 --- /dev/null +++ b/week2/Basic/SecondSeminar/.gitignore @@ -0,0 +1,39 @@ +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/ + +.DS_Store diff --git a/week2/Basic/SecondSeminar/build.gradle b/week2/Basic/SecondSeminar/build.gradle new file mode 100644 index 0000000..c7007f0 --- /dev/null +++ b/week2/Basic/SecondSeminar/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.10' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.jar b/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.jar differ diff --git a/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.properties b/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..774fae8 --- /dev/null +++ b/week2/Basic/SecondSeminar/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/week2/Basic/SecondSeminar/gradlew.bat b/week2/Basic/SecondSeminar/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/week2/Basic/SecondSeminar/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/week2/Basic/SecondSeminar/settings.gradle b/week2/Basic/SecondSeminar/settings.gradle new file mode 100644 index 0000000..b15c549 --- /dev/null +++ b/week2/Basic/SecondSeminar/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'SecondSeminar' diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/SecondSeminarApplication.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/SecondSeminarApplication.java new file mode 100644 index 0000000..508501c --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/SecondSeminarApplication.java @@ -0,0 +1,24 @@ +package com.example.SecondSeminar; + +import com.example.SecondSeminar.domain.Post; +import com.example.SecondSeminar.domain.User; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.util.ArrayList; + +@SpringBootApplication +public class SecondSeminarApplication { + + public static ArrayList userList; + public static ArrayList postList; + + public static void main(String[] args) { + SpringApplication.run(SecondSeminarApplication.class, args); + + userList = new ArrayList<>(); + postList = new ArrayList<>(); + + } + +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/PostController.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/PostController.java new file mode 100644 index 0000000..3b4d596 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/PostController.java @@ -0,0 +1,52 @@ +package com.example.SecondSeminar.controller.post; + +import com.example.SecondSeminar.controller.post.dto.request.PostRequestDto; +import com.example.SecondSeminar.domain.Post; +import com.example.SecondSeminar.service.PostService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Optional; + +import static com.example.SecondSeminar.SecondSeminarApplication.postList; +import static com.example.SecondSeminar.SecondSeminarApplication.userList; + +@RestController +@RequiredArgsConstructor +public class PostController { + + private final PostService postService; + + //* 게시물 생성 + @PostMapping("/post") + public String register(@RequestBody PostRequestDto request) { + Long postId = postService.register(request); + return postId + "번 게시물이 등록되었습니다!"; + } + + //* 게시물 조회 - 아이디로 조회 + @GetMapping("/post/{postId}") + public String getByPostId(@PathVariable final Long postId) { + try { + Post getPost = postService.findById(postId); + System.out.println(getPost.toString()); + + return "===========" + getPost.getId() + "번 게시물 조회 성공" + + "===========\n" + getPost.toString(); + + } catch (Exception e) { + return "해당 id 값의 게시물이 존재하지 않습니다."; + } + } + + //* 게시물 검색 - 해당 제목의 게시물 검색 + @GetMapping("/post/search") + public String getByPostTitle(@RequestParam final String title) { + Post getPost = postService.findByTitle(title); + if (getPost == null) { + return "해당 제목의 게시물이 존재하지 않습니다."; + } + return "=========== 제목 : " + getPost.getTitle() + " 게시물 조회 성공" + + "===========\n" + getPost.toString(); + } +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/dto/request/PostRequestDto.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/dto/request/PostRequestDto.java new file mode 100644 index 0000000..84f712a --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/post/dto/request/PostRequestDto.java @@ -0,0 +1,16 @@ +package com.example.SecondSeminar.controller.post.dto.request; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class PostRequestDto { + private String title; + private String content; + private String writer; + +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/UserController.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/UserController.java new file mode 100644 index 0000000..7a8c93b --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/UserController.java @@ -0,0 +1,50 @@ +package com.example.SecondSeminar.controller.user; + +import com.example.SecondSeminar.controller.user.dto.request.RegisterRequestDto; +import com.example.SecondSeminar.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import static com.example.SecondSeminar.SecondSeminarApplication.userList; + +@RestController +@RequiredArgsConstructor +public class UserController { + + private final UserService userService; + + @PostMapping("/user") + public String register(@RequestBody final RegisterRequestDto request) { + System.out.println("성별 = " + request.getGender()); + System.out.println("이름 = " + request.getName()); + System.out.println("전화번호 = " + request.getContact()); + System.out.println("나이 = " + request.getAge()); + + //서비스 계층에 유저를 등록하는 메서드를 호출 + return "유저 등록이 완료됐습니다."; + } + + @GetMapping("/user/{userId}") + public String getOne(@PathVariable final Long userId) { + System.out.println(userId + "번 유저 조회 성공"); + + return "유저 아이디로 조회 성공!"; + } + + @GetMapping("/user/search") + public String search(@RequestParam final String name) { + System.out.println("닉네임이 " + name + "인 유저 조회 성공"); + + return "유저 닉네임으로 검색 성공!"; + } + + @PostMapping("/user/allUser") + public String registerList(@RequestBody final RegisterRequestDto request) { + + //서비스 계층에 유저를 등록하는 메서드 호출 + Long userId = userService.register(request); + System.out.println(userList.get(userId.intValue() - 1).toString()); + + return userId + "번 유저가 등록되었습니다 !"; + } +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/dto/request/RegisterRequestDto.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/dto/request/RegisterRequestDto.java new file mode 100644 index 0000000..6588894 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/controller/user/dto/request/RegisterRequestDto.java @@ -0,0 +1,16 @@ +package com.example.SecondSeminar.controller.user.dto.request; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class RegisterRequestDto { + private String gender; + private String name; + private String contact; + private int age; +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/Post.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/Post.java new file mode 100644 index 0000000..c9f01ea --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/Post.java @@ -0,0 +1,25 @@ +package com.example.SecondSeminar.domain; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Getter @Setter +@ToString +public class Post { + private Long id; + private String title; + private String content; + private String writer; + private LocalDateTime currentDate; + + public Post(String title, String content, String writer, LocalDateTime currentDate) { + this.title = title; + this.content = content; + this.writer = writer; + this.currentDate = currentDate; + } + +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/User.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/User.java new file mode 100644 index 0000000..b50fb52 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/domain/User.java @@ -0,0 +1,30 @@ +package com.example.SecondSeminar.domain; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter @Setter //사실 Setter 열어놓는 것은 좋지 않음 +public class User { + private Long id; + private String gender; + private String name; + private int age; + private String contact; + + public User(String gender, String name, String contact, int age) { + this.gender = gender; + this.name = name; + this.age = age; + this.contact = contact; + } + + public String toString() { + return "id: " + this.id + "\n" + + "gender: " + this.gender + "\n" + + "name: " + this.name + "\n" + + "contact: " + this.contact + "\n" + + "age: " + this.age; + } + +} \ No newline at end of file diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/PostService.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/PostService.java new file mode 100644 index 0000000..9582b23 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/PostService.java @@ -0,0 +1,42 @@ +package com.example.SecondSeminar.service; + +import com.example.SecondSeminar.controller.post.dto.request.PostRequestDto; +import com.example.SecondSeminar.domain.Post; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; + +import static com.example.SecondSeminar.SecondSeminarApplication.postList; + +@Service +public class PostService { + public Long register(PostRequestDto request) { + + //Post 객체 생성 + Post newPost = new Post( + request.getTitle(), + request.getContent(), + request.getWriter(), + LocalDateTime.now() + ); + + //데이터 베이스에 저장 + postList.add(newPost); + newPost.setId((long) postList.size()); + + return newPost.getId(); + } + + public Post findById(Long id) { + return postList.get(id.intValue()-1); + } + + public Post findByTitle(String title) { + for (Post post : postList) { + if (post.getTitle().equals(title)) { + return post; + } + } + return null; + } +} diff --git a/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/UserService.java b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/UserService.java new file mode 100644 index 0000000..44518c0 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/java/com/example/SecondSeminar/service/UserService.java @@ -0,0 +1,28 @@ +package com.example.SecondSeminar.service; + +import com.example.SecondSeminar.controller.user.dto.request.RegisterRequestDto; +import com.example.SecondSeminar.domain.User; +import org.springframework.stereotype.Service; + +import static com.example.SecondSeminar.SecondSeminarApplication.userList; + +@Service +public class UserService { + public Long register(RegisterRequestDto request) { + + //받아온 request 데이터를 토대로 실제 User 객체 생성 + User newUser = new User( + request.getGender(), + request.getName(), + request.getContact(), + request.getAge() + ); + + //데이터 베이스에 저장 (일단 임시로 ArrayList에 저장) + userList.add(newUser); + newUser.setId((long) userList.size()); + + //저장한 유저 아이디 값 반환 + return newUser.getId(); + } +} diff --git a/week2/Basic/SecondSeminar/src/main/resources/application.properties b/week2/Basic/SecondSeminar/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/week2/Basic/SecondSeminar/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/week2/Basic/SecondSeminar/src/test/java/com/example/SecondSeminar/SecondSeminarApplicationTests.java b/week2/Basic/SecondSeminar/src/test/java/com/example/SecondSeminar/SecondSeminarApplicationTests.java new file mode 100644 index 0000000..83e5f7e --- /dev/null +++ b/week2/Basic/SecondSeminar/src/test/java/com/example/SecondSeminar/SecondSeminarApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.SecondSeminar; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SecondSeminarApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/week3/Advanced/ThirdAdvanced/.gitignore b/week3/Advanced/ThirdAdvanced/.gitignore new file mode 100644 index 0000000..6e5a248 --- /dev/null +++ b/week3/Advanced/ThirdAdvanced/.gitignore @@ -0,0 +1,39 @@ +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/ + +resources diff --git a/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Comment.java b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Comment.java new file mode 100644 index 0000000..4190efc --- /dev/null +++ b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Comment.java @@ -0,0 +1,2 @@ +package sopt.org.ThirdAdvanced.domain;public class Comment { +} diff --git a/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Post.java b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Post.java new file mode 100644 index 0000000..0c0ced6 --- /dev/null +++ b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/Post.java @@ -0,0 +1,2 @@ +package sopt.org.ThirdAdvanced.domain;public class Post { +} diff --git a/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/User.java b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/User.java new file mode 100644 index 0000000..410c407 --- /dev/null +++ b/week3/Advanced/ThirdAdvanced/src/main/java/sopt/org/ThirdAdvanced/domain/User.java @@ -0,0 +1,2 @@ +package sopt.org.ThirdAdvanced.domain;public class User { +} diff --git a/week3/Basic/ThirdSeminar/.gitignore b/week3/Basic/ThirdSeminar/.gitignore new file mode 100644 index 0000000..6e5a248 --- /dev/null +++ b/week3/Basic/ThirdSeminar/.gitignore @@ -0,0 +1,39 @@ +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/ + +resources diff --git a/week3/Basic/ThirdSeminar/build.gradle b/week3/Basic/ThirdSeminar/build.gradle new file mode 100644 index 0000000..cabf5f3 --- /dev/null +++ b/week3/Basic/ThirdSeminar/build.gradle @@ -0,0 +1,35 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.11' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + // mysql --version + implementation 'mysql:mysql-connector-java:8.0.32' + + implementation 'org.springframework.boot:spring-boot-starter-validation' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.jar b/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.jar differ diff --git a/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.properties b/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..774fae8 --- /dev/null +++ b/week3/Basic/ThirdSeminar/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/week3/Basic/ThirdSeminar/gradlew.bat b/week3/Basic/ThirdSeminar/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/week3/Basic/ThirdSeminar/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/week3/Basic/ThirdSeminar/settings.gradle b/week3/Basic/ThirdSeminar/settings.gradle new file mode 100644 index 0000000..397b799 --- /dev/null +++ b/week3/Basic/ThirdSeminar/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ThirdSeminar' diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/ThirdSeminarApplication.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/ThirdSeminarApplication.java new file mode 100644 index 0000000..1223b37 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/ThirdSeminarApplication.java @@ -0,0 +1,13 @@ +package com.example.ThirdSeminar; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ThirdSeminarApplication { + + public static void main(String[] args) { + SpringApplication.run(ThirdSeminarApplication.class, args); + } + +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/advice/ControllerExceptionAdvice.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/advice/ControllerExceptionAdvice.java new file mode 100644 index 0000000..a9b8915 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/advice/ControllerExceptionAdvice.java @@ -0,0 +1,22 @@ +package com.example.ThirdSeminar.common.advice; + +import com.example.ThirdSeminar.common.dto.ApiResponseDto; +import com.example.ThirdSeminar.exception.ErrorStatus; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ControllerExceptionAdvice { + + /* + * 400 BAD_REQUEST + */ + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(MethodArgumentNotValidException.class) + protected ApiResponseDto handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) { + return ApiResponseDto.error(ErrorStatus.VALIDATION_REQUEST_MISSING_EXCEPTION); + } +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/dto/ApiResponseDto.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/dto/ApiResponseDto.java new file mode 100644 index 0000000..e8a7de5 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/common/dto/ApiResponseDto.java @@ -0,0 +1,30 @@ +package com.example.ThirdSeminar.common.dto; + +import com.example.ThirdSeminar.exception.ErrorStatus; +import com.example.ThirdSeminar.exception.SuccessStatus; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class ApiResponseDto { + + private final int code; + private final String message; + private T data; + + public static ApiResponseDto success(SuccessStatus successStatus) { + return new ApiResponseDto<>(successStatus.getHttpStatus().value(), successStatus.getMessage()); + } + + public static ApiResponseDto success(SuccessStatus successStatus, T data) { + return new ApiResponseDto(successStatus.getHttpStatus().value(), successStatus.getMessage(), data); + } + + public static ApiResponseDto error(ErrorStatus errorStatus) { + return new ApiResponseDto<>(errorStatus.getHttpStatus().value(), errorStatus.getMessage()); + } +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/UserController.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/UserController.java new file mode 100644 index 0000000..7759f68 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/UserController.java @@ -0,0 +1,28 @@ +package com.example.ThirdSeminar.controller; + +import com.example.ThirdSeminar.common.dto.ApiResponseDto; +import com.example.ThirdSeminar.controller.dto.user.request.UserRequestDto; +import com.example.ThirdSeminar.controller.dto.user.response.UserResponseDto; +import com.example.ThirdSeminar.exception.SuccessStatus; +import com.example.ThirdSeminar.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +public class UserController { + private final UserService userService; + + @PostMapping("/user/signup") + @ResponseStatus(HttpStatus.CREATED) + public ApiResponseDto create(@RequestBody @Valid final UserRequestDto requestDto) { + return ApiResponseDto.success(SuccessStatus.SIGNUP_SUCCESS, userService.create(requestDto)); + } + +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/request/UserRequestDto.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/request/UserRequestDto.java new file mode 100644 index 0000000..b91baf4 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/request/UserRequestDto.java @@ -0,0 +1,30 @@ +package com.example.ThirdSeminar.controller.dto.user.request; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class UserRequestDto { + + @Email(message = "이메일 형식에 맞지 않습니다") + @NotNull + private String email; + + @NotBlank + @Pattern(regexp = "^[가-힣a-zA-Z]{2,10}$", message = "닉네임 형식에 맞지 않습니다.") + private String nickname; + + @NotBlank + @Pattern( + regexp="(?=.*[0-9])(?=.*[a-zA-Z])(?=.*\\W)(?=\\S+$).{8,20}", + message = "비밀번호는 영문 대,소문자와 숫자, 특수기호가 적어도 1개 이상씩 포함된 8자 ~ 20자의 비밀번호여야 합니다." + ) + private String password; +} \ No newline at end of file diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/response/UserResponseDto.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/response/UserResponseDto.java new file mode 100644 index 0000000..063f0d4 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/controller/dto/user/response/UserResponseDto.java @@ -0,0 +1,17 @@ +package com.example.ThirdSeminar.controller.dto.user.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class UserResponseDto { + + private Long userId; + private String nickname; + + public static UserResponseDto of(Long userId, String nickname) { + return new UserResponseDto(userId, nickname); + } +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/domain/User.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/domain/User.java new file mode 100644 index 0000000..b7b5c50 --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/domain/User.java @@ -0,0 +1,32 @@ +package com.example.ThirdSeminar.domain; + +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private String nickname; + @Column(nullable = false) + private String email; + @Column(nullable = false) + private String password; + + @Builder + private User(String nickname, String email, String password) { + this.nickname = nickname; + this.email = email; + this.password = password; + } +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/ErrorStatus.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/ErrorStatus.java new file mode 100644 index 0000000..3da7d9e --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/ErrorStatus.java @@ -0,0 +1,35 @@ +package com.example.ThirdSeminar.exception; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum ErrorStatus { + + /* + BAD_REQUEST + */ + VALIDATION_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."), + VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "요청값이 입력되지 않았습니다."), + + /* + CONFLICT + */ + CONFLICT_EMAIL_EXCEPTION(HttpStatus.CONFLICT, "이미 등록된 이메일입니다."), + CONFLICT_NICKNAME_EXCEPTION(HttpStatus.CONFLICT, "이미 등록된 닉네임입니다."), + + /* + SERVER_ERROR + */ + INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "예상치 못한 서버 에러가 발생했습니다."), + BAD_GATEWAY_EXCEPTION(HttpStatus.BAD_GATEWAY, "일시적인 에러가 발생하였습니다.\n잠시 후 다시 시도해주세요!"), + SERVICE_UNAVAILABLE_EXCEPTION(HttpStatus.SERVICE_UNAVAILABLE, "현재 점검 중입니다.\n잠시 후 다시 시도해주세요!"), + ; + + private final HttpStatus httpStatus; + private final String message; +} + diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/SuccessStatus.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/SuccessStatus.java new file mode 100644 index 0000000..5937c1b --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/exception/SuccessStatus.java @@ -0,0 +1,21 @@ +package com.example.ThirdSeminar.exception; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum SuccessStatus { + + /* + user + */ + SIGNUP_SUCCESS(HttpStatus.CREATED, "회원가입이 완료되었습니다."), + ; + + private final HttpStatus httpStatus; + private final String message; +} + diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/infrastructure/UserRepository.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/infrastructure/UserRepository.java new file mode 100644 index 0000000..cca1bff --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/infrastructure/UserRepository.java @@ -0,0 +1,8 @@ +package com.example.ThirdSeminar.infrastructure; + +import com.example.ThirdSeminar.domain.User; +import org.springframework.data.repository.Repository; + +public interface UserRepository extends Repository { + void save(User user); +} diff --git a/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/service/UserService.java b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/service/UserService.java new file mode 100644 index 0000000..dea18aa --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/main/java/com/example/ThirdSeminar/service/UserService.java @@ -0,0 +1,27 @@ +package com.example.ThirdSeminar.service; + +import com.example.ThirdSeminar.controller.dto.user.request.UserRequestDto; +import com.example.ThirdSeminar.controller.dto.user.response.UserResponseDto; +import com.example.ThirdSeminar.domain.User; +import com.example.ThirdSeminar.infrastructure.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class UserService { + private final UserRepository userRepository; + + @Transactional + public UserResponseDto create(UserRequestDto requestDto) { + User user = User.builder() + .email(requestDto.getEmail()) + .nickname(requestDto.getNickname()) + .password(requestDto.getPassword()) + .build(); + + userRepository.save(user); + return UserResponseDto.of(user.getId(), user.getNickname()); + } +} diff --git a/week3/Basic/ThirdSeminar/src/test/java/com/example/ThirdSeminar/ThirdSeminarApplicationTests.java b/week3/Basic/ThirdSeminar/src/test/java/com/example/ThirdSeminar/ThirdSeminarApplicationTests.java new file mode 100644 index 0000000..3b3acdf --- /dev/null +++ b/week3/Basic/ThirdSeminar/src/test/java/com/example/ThirdSeminar/ThirdSeminarApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.ThirdSeminar; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ThirdSeminarApplicationTests { + + @Test + void contextLoads() { + } + +}