diff --git a/Eunji/.DS_Store b/Eunji/.DS_Store index 6608c75..0b52679 100644 Binary files a/Eunji/.DS_Store and b/Eunji/.DS_Store differ diff --git a/Eunji/week5/.DS_Store b/Eunji/week5/.DS_Store new file mode 100644 index 0000000..13037f2 Binary files /dev/null and b/Eunji/week5/.DS_Store differ diff --git a/Eunji/week5/jpa-mapping b/Eunji/week5/jpa-mapping new file mode 160000 index 0000000..45213e4 --- /dev/null +++ b/Eunji/week5/jpa-mapping @@ -0,0 +1 @@ +Subproject commit 45213e407ce9db36d1b857875d5539fce79f0bed diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.DS_Store" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.DS_Store" new file mode 100644 index 0000000..8b36376 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.DS_Store" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/.DS_Store" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/.DS_Store" new file mode 100644 index 0000000..9859b61 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/.DS_Store" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/checksums.lock" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/checksums.lock" new file mode 100644 index 0000000..dc57e76 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/checksums.lock" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/sha1-checksums.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/sha1-checksums.bin" new file mode 100644 index 0000000..f86ad5a Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/checksums/sha1-checksums.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.bin" new file mode 100644 index 0000000..6c65d44 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.lock" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.lock" new file mode 100644 index 0000000..cc1af83 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/executionHistory/executionHistory.lock" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileChanges/last-build.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileChanges/last-build.bin" new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileChanges/last-build.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.bin" new file mode 100644 index 0000000..be9387e Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.lock" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.lock" new file mode 100644 index 0000000..3f9befc Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/fileHashes.lock" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/resourceHashesCache.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/resourceHashesCache.bin" new file mode 100644 index 0000000..bde39ce Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/fileHashes/resourceHashesCache.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/gc.properties" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/8.13/gc.properties" new file mode 100644 index 0000000..e69de29 diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/buildOutputCleanup.lock" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/buildOutputCleanup.lock" new file mode 100644 index 0000000..4cd54f1 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/buildOutputCleanup.lock" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/cache.properties" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/cache.properties" new file mode 100644 index 0000000..c307166 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/cache.properties" @@ -0,0 +1,2 @@ +#Thu May 08 13:58:17 KST 2025 +gradle.version=8.13 diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/outputFiles.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/outputFiles.bin" new file mode 100644 index 0000000..d5cbda7 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/buildOutputCleanup/outputFiles.bin" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/file-system.probe" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/file-system.probe" new file mode 100644 index 0000000..cfacdd5 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/file-system.probe" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/vcs-1/gc.properties" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.gradle/vcs-1/gc.properties" new file mode 100644 index 0000000..e69de29 diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.gitignore" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.gitignore" new file mode 100644 index 0000000..7bc07ec --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.gitignore" @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Environment-dependent path to Maven home directory +/mavenHomeManager.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.name" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.name" new file mode 100644 index 0000000..efd261b --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/.name" @@ -0,0 +1 @@ +demo \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/compiler.xml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/compiler.xml" new file mode 100644 index 0000000..94d193a --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/compiler.xml" @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/gradle.xml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/gradle.xml" new file mode 100644 index 0000000..6cef087 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/gradle.xml" @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/misc.xml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/misc.xml" new file mode 100644 index 0000000..ed6ca53 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/misc.xml" @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules.xml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules.xml" new file mode 100644 index 0000000..2fdc91e --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules.xml" @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1231885029/demo.main.iml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1231885029/demo.main.iml" new file mode 100644 index 0000000..2ab1d78 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1231885029/demo.main.iml" @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1804026255/demo.main.iml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1804026255/demo.main.iml" new file mode 100644 index 0000000..7381848 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/-1804026255/demo.main.iml" @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/344824075/demo.main.iml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/344824075/demo.main.iml" new file mode 100644 index 0000000..caa5658 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/modules/344824075/demo.main.iml" @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/springboot-base-project-main.iml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/springboot-base-project-main.iml" new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/springboot-base-project-main.iml" @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/vcs.xml" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/vcs.xml" new file mode 100644 index 0000000..ba43f69 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/.idea/vcs.xml" @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/.DS_Store" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/.DS_Store" new file mode 100644 index 0000000..6370f6d Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/.DS_Store" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/DemoApplication.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/DemoApplication.class" new file mode 100644 index 0000000..cf55156 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/DemoApplication.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post$PostBuilder.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post$PostBuilder.class" new file mode 100644 index 0000000..dfe9ce5 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post$PostBuilder.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post.class" new file mode 100644 index 0000000..a688be4 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/Post.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/PostState.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/PostState.class" new file mode 100644 index 0000000..d28c6df Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/entity/PostState.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/InvalidPasswordException.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/InvalidPasswordException.class" new file mode 100644 index 0000000..6a777a8 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/InvalidPasswordException.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostErrorCode.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostErrorCode.class" new file mode 100644 index 0000000..f3b4667 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostErrorCode.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostNotFoundException.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostNotFoundException.class" new file mode 100644 index 0000000..57ed316 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/exception/PostNotFoundException.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/repository/PostRepository.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/repository/PostRepository.class" new file mode 100644 index 0000000..a371995 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/repository/PostRepository.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostService.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostService.class" new file mode 100644 index 0000000..3426418 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostService.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostServiceImpl.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostServiceImpl.class" new file mode 100644 index 0000000..444a1f6 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/service/PostServiceImpl.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/controller/PostController.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/controller/PostController.class" new file mode 100644 index 0000000..7f41cf9 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/controller/PostController.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostReq.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostReq.class" new file mode 100644 index 0000000..2949b72 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostReq.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostRes.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostRes.class" new file mode 100644 index 0000000..5b61a2e Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/CreatePostRes.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/DeletePostReq.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/DeletePostReq.class" new file mode 100644 index 0000000..528cfe1 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/DeletePostReq.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/ModifyPostReq.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/ModifyPostReq.class" new file mode 100644 index 0000000..dd4d709 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/ModifyPostReq.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostDetailRes.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostDetailRes.class" new file mode 100644 index 0000000..9bc5d22 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostDetailRes.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes$PostSummary.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes$PostSummary.class" new file mode 100644 index 0000000..ac626ad Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes$PostSummary.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes.class" new file mode 100644 index 0000000..1b15898 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/domain/post/web/dto/PostSummaryRes.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/config/WebConfig.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/config/WebConfig.class" new file mode 100644 index 0000000..2f50b0b Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/config/WebConfig.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/constant/StaticValue.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/constant/StaticValue.class" new file mode 100644 index 0000000..a82a60b Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/constant/StaticValue.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/entity/BaseEntity.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/entity/BaseEntity.class" new file mode 100644 index 0000000..78c93cc Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/entity/BaseEntity.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/BaseException.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/BaseException.class" new file mode 100644 index 0000000..cfb1aea Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/BaseException.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/GlobalExceptionHandler.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/GlobalExceptionHandler.class" new file mode 100644 index 0000000..36361e6 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/exception/GlobalExceptionHandler.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/BaseResponse.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/BaseResponse.class" new file mode 100644 index 0000000..d21dd98 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/BaseResponse.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse$ErrorResponseBuilder.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse$ErrorResponseBuilder.class" new file mode 100644 index 0000000..3ec2eca Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse$ErrorResponseBuilder.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse.class" new file mode 100644 index 0000000..960660b Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/ErrorResponse.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse$SuccessResponseBuilder.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse$SuccessResponseBuilder.class" new file mode 100644 index 0000000..72ce247 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse$SuccessResponseBuilder.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse.class" new file mode 100644 index 0000000..e428904 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/SuccessResponse.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/BaseResponseCode.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/BaseResponseCode.class" new file mode 100644 index 0000000..646c23a Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/BaseResponseCode.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalErrorCode.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalErrorCode.class" new file mode 100644 index 0000000..734aae1 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalErrorCode.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalSuccessCode.class" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalSuccessCode.class" new file mode 100644 index 0000000..ce8d0f5 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/classes/java/main/com/likelion/demo/global/response/code/GlobalSuccessCode.class" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/reports/problems/problems-report.html" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/reports/problems/problems-report.html" new file mode 100644 index 0000000..2fb8513 --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/reports/problems/problems-report.html" @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/resources/main/application.properties" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/resources/main/application.properties" new file mode 100644 index 0000000..81a9a0e --- /dev/null +++ "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/resources/main/application.properties" @@ -0,0 +1,25 @@ +spring.application.name=demo +server.servlet.context-path=/api + +# application-secret.properties +spring.config.import=optional:application-secret.properties + +# Datasource +#spring.datasource.url=${DATABASE_URL} +#spring.datasource.username=${DATABASE_USERNAME} +#spring.datasource.password=${DATABASE_PASSWORD} + +# not used secret config file +spring.datasource.url=jdbc:h2:tcp://localhost/~/test +spring.datasource.username=sa +spring.datasource.password= + +# JPA +spring.jpa.hibernate.ddl-auto=update +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true + +# H2 +spring.datasource.driver-class-name=org.h2.Driver +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/compileTransaction/stash-dir/PostServiceImpl.class.uniqueId0" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/compileTransaction/stash-dir/PostServiceImpl.class.uniqueId0" new file mode 100644 index 0000000..61ac2f3 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/compileTransaction/stash-dir/PostServiceImpl.class.uniqueId0" differ diff --git "a/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/previous-compilation-data.bin" "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/previous-compilation-data.bin" new file mode 100644 index 0000000..4044078 Binary files /dev/null and "b/Eunji/week6/springboot-base-project-main-\353\205\271\352\260\225\354\213\234\354\236\221/build/tmp/compileJava/previous-compilation-data.bin" differ diff --git a/Eunji/week7/.DS_Store b/Eunji/week7/.DS_Store new file mode 100644 index 0000000..482062f Binary files /dev/null and b/Eunji/week7/.DS_Store differ diff --git a/Eunji/week7/springboot-base-project-main-final/.gitattributes b/Eunji/week7/springboot-base-project-main-final/.gitattributes new file mode 100644 index 0000000..8af972c --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/Eunji/week7/springboot-base-project-main-final/.gitignore b/Eunji/week7/springboot-base-project-main-final/.gitignore new file mode 100644 index 0000000..25d1871 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/.gitignore @@ -0,0 +1,84 @@ +# Allow gradle-wrapper.jar +!gradle/wrapper/gradle-wrapper.jar + +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + + +# Spring secret config +application-secret.yml +application-*.secret.yml +application-secret.properties +application-*.secret.properties + +# Build artifacts +*.jar +*.war +*.ear + +### 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/ + +### .env ### +.env.* +.env + +# macOS system file +.DS_Store + +# Windows system file +Thumbs.db +ehthumbs.db +Desktop.ini + +# Linux system file +*.swp +*~ + +# JetBrains 계열 IDE 추가 설정 파일 +.idea_modules/ +modules.xml +workspace.xml +tasks.xml + +# log file +*.log + +# test report +/test-output/ + +# Local configuration files +*.local +*.bak \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/build.gradle b/Eunji/week7/springboot-base-project-main-final/build.gradle new file mode 100644 index 0000000..9ad3467 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/build.gradle @@ -0,0 +1,39 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.4.5' + 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-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/Eunji/week7/springboot-base-project-main-final/gradle/wrapper/gradle-wrapper.properties b/Eunji/week7/springboot-base-project-main-final/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37f853b --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Eunji/week7/springboot-base-project-main-final/gradlew b/Eunji/week7/springboot-base-project-main-final/gradlew new file mode 100755 index 0000000..faf9300 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/gradlew @@ -0,0 +1,251 @@ +#!/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. +# +# 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/HEAD/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 + +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 + 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" ) + 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 + + +# 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" \ + -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/Eunji/week7/springboot-base-project-main-final/gradlew.bat b/Eunji/week7/springboot-base-project-main-final/gradlew.bat new file mode 100644 index 0000000..9d21a21 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/gradlew.bat @@ -0,0 +1,94 @@ +@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 + +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/Eunji/week7/springboot-base-project-main-final/settings.gradle b/Eunji/week7/springboot-base-project-main-final/settings.gradle new file mode 100644 index 0000000..0a383dd --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'demo' diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/DemoApplication.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/DemoApplication.java new file mode 100644 index 0000000..af56730 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/DemoApplication.java @@ -0,0 +1,30 @@ +package com.likelion.demo; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@EnableJpaAuditing +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + + @Bean + public CommandLineRunner dbConnectionCheck( + @Value("${spring.datasource.url}") String dbUrl, + @Value("${spring.datasource.username}") String dbUsername + ) { + return args -> { + System.out.println("=== Database Connection Info ==="); + System.out.println("URL: " + dbUrl); + System.out.println("Username: " + dbUsername); + System.out.println("================================"); + }; + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/entity/Comment.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/entity/Comment.java new file mode 100644 index 0000000..9caedfa --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/entity/Comment.java @@ -0,0 +1,34 @@ +package com.likelion.demo.domain.comment.entity; + +import com.likelion.demo.domain.post.entity.Post; +import com.likelion.demo.global.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class Comment extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String content; + + private String username; + + private String password; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="post_id", nullable = false) + private Post post; + + //댓글 수정 + public void modify(String content) { + this.content = content; + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentErrorCode.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentErrorCode.java new file mode 100644 index 0000000..1a07869 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentErrorCode.java @@ -0,0 +1,19 @@ +package com.likelion.demo.domain.comment.exception; + +import com.likelion.demo.global.response.code.BaseResponseCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +public enum CommentErrorCode implements BaseResponseCode { + COMMENT_NOT_FOUND_404("COMMENT_NOTFOUND_404", "댓글을 찾을 수 없습니다.", 404), + COMMENT_PASSWORD_INVALID_403("COMMENT_PASSWORD_INVALID_403", "비밀번호가 올바르지 않습니다.", 403); + + + private final String code; + private final String message; + private final int httpStatus; + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentInvalidPassword.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentInvalidPassword.java new file mode 100644 index 0000000..933c37d --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentInvalidPassword.java @@ -0,0 +1,9 @@ +package com.likelion.demo.domain.comment.exception; + +import com.likelion.demo.global.exception.BaseException; + +public class CommentInvalidPassword extends BaseException { + public CommentInvalidPassword() { + super(CommentErrorCode.COMMENT_PASSWORD_INVALID_403); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentNotFoundException.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentNotFoundException.java new file mode 100644 index 0000000..a2bfd11 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/exception/CommentNotFoundException.java @@ -0,0 +1,9 @@ +package com.likelion.demo.domain.comment.exception; + +import com.likelion.demo.global.exception.BaseException; + +public class CommentNotFoundException extends BaseException { + public CommentNotFoundException() { + super(CommentErrorCode.COMMENT_NOT_FOUND_404); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/repository/CommentRepository.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/repository/CommentRepository.java new file mode 100644 index 0000000..7f57f79 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/repository/CommentRepository.java @@ -0,0 +1,13 @@ +package com.likelion.demo.domain.comment.repository; + +import com.likelion.demo.domain.comment.entity.Comment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Collection; +import java.util.List; + +@Repository +public interface CommentRepository extends JpaRepository { + List findAllByPostId(Long postId); +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentService.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentService.java new file mode 100644 index 0000000..d48d101 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentService.java @@ -0,0 +1,18 @@ +package com.likelion.demo.domain.comment.service; + + +import com.likelion.demo.domain.comment.web.dto.*; + +public interface CommentService { + CreateCommentRes create(Long postId, CreateCommentReq createCommentReq); + + CommentSummaryRes getAllComment(Long postId); + + CommentDetailRes getComment(Long postId, Long commentId); + + // 댓글수정 + CommentDetailRes modifyComment(Long postId, Long commentId, ModifyCommentReq modifyCommentReq); + + // 댓글삭제 + void deleteComment(Long postId, Long commentId, DeleteCommentReq deleteCommentReq); +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentServiceImpl.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentServiceImpl.java new file mode 100644 index 0000000..7c2864b --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/service/CommentServiceImpl.java @@ -0,0 +1,113 @@ +package com.likelion.demo.domain.comment.service; + +import com.likelion.demo.domain.comment.entity.Comment; +import com.likelion.demo.domain.comment.exception.CommentInvalidPassword; +import com.likelion.demo.domain.comment.exception.CommentNotFoundException; +import com.likelion.demo.domain.comment.repository.CommentRepository; +import com.likelion.demo.domain.comment.web.dto.*; +import com.likelion.demo.domain.post.entity.Post; +import com.likelion.demo.domain.post.exception.PostNotFoundException; +import com.likelion.demo.domain.post.repository.PostRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class CommentServiceImpl implements CommentService { + + private final PostRepository postRepository; + private final CommentRepository commentRepository; + + @Override + public CreateCommentRes create(Long postId, CreateCommentReq createCommentReq) { + Post post = postRepository.findById(postId).orElseThrow(PostNotFoundException::new); + + Comment comment = Comment.builder() + .post(post) + .content(createCommentReq.getContent()) + .username(createCommentReq.getUsername()) + .password(createCommentReq.getPassword()) + .build(); + + Comment res = commentRepository.save(comment); + return new CreateCommentRes(res.getId()); + } + + @Override + public CommentSummaryRes getAllComment(Long postId) { + Post post = postRepository.findById(postId).orElseThrow(PostNotFoundException::new); + + return new CommentSummaryRes( + commentRepository.findAllByPostId(postId).stream() + .map(c -> new CommentSummaryRes.CommentSummary( + c.getId(), + c.getContent(), + c.getUsername(), + c.getPassword(), + c.getCreatedAt() + )) + .collect(Collectors.toList()) + ); + } + + @Override + public CommentDetailRes getComment(Long postId, Long commentId) { + Comment comment = commentRepository.findById(commentId).orElseThrow(CommentNotFoundException::new); + + if(!comment.getPost().getId().equals(postId)) { + throw new CommentNotFoundException(); + } + + return new CommentDetailRes( + comment.getId(), + comment.getPost().getId(), + comment.getContent(), + comment.getUsername(), + comment.getCreatedAt(), + comment.getUpdatedAt() + ); + } + + @Override + public CommentDetailRes modifyComment(Long postId, Long commentId, ModifyCommentReq modifyCommentReq) { + + // comment 찾기 + Comment comment = commentRepository.findById(commentId).orElseThrow(CommentNotFoundException::new); + + // 비밀번호 일치 확인 + if(!comment.getPassword().equals(modifyCommentReq.getPassword())) { + throw new CommentInvalidPassword(); + } + + // 반환 + return new CommentDetailRes( + comment.getId(), + comment.getPost().getId(), + comment.getContent(), + comment.getUsername(), + comment.getCreatedAt(), + comment.getUpdatedAt() + ); + } + + @Override + public void deleteComment(Long postId, Long commentId, DeleteCommentReq deleteCommentReq) { + + // 댓글 찾기 + Comment comment = commentRepository.findById(commentId).orElseThrow(CommentNotFoundException::new); + + // 게시글에 댓글이 속해있는지 확인 + if(!comment.getPost().getId().equals(postId)) { + throw new CommentNotFoundException(); + } + + // 비밀번호 일치 확인 + if(!comment.getPassword().equals(deleteCommentReq.getPassword())) { + throw new CommentInvalidPassword(); + } + + commentRepository.delete(comment); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/controller/CommentController.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/controller/CommentController.java new file mode 100644 index 0000000..2c173e2 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/controller/CommentController.java @@ -0,0 +1,56 @@ +package com.likelion.demo.domain.comment.web.controller; + +import com.likelion.demo.domain.comment.entity.Comment; +import com.likelion.demo.domain.comment.service.CommentService; +import com.likelion.demo.domain.comment.web.dto.*; +import com.likelion.demo.global.response.SuccessResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/post/{postId}/comment") +public class CommentController { + + private final CommentService commentService; + + @PostMapping + public ResponseEntity> createComment(@PathVariable Long postId, @RequestBody @Valid CreateCommentReq createCommentReq) + { + CreateCommentRes res = commentService.create(postId, createCommentReq); + + return ResponseEntity.status(HttpStatus.CREATED).body(SuccessResponse.created(res)); + } + + @GetMapping() + public ResponseEntity> getAllComments(@PathVariable Long postId) { + CommentSummaryRes res = commentService.getAllComment(postId); + + return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.ok(res)); + } + + @GetMapping("/{commentId}") + public ResponseEntity> getComment(@PathVariable Long postId, @PathVariable Long commentId) { + CommentDetailRes res = commentService.getComment(postId, commentId); + return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.ok(res)); + + } + + @PutMapping("/{commentId}") + public ResponseEntity> modifyComment(@PathVariable Long postId, @PathVariable Long commentId, @RequestBody @Valid ModifyCommentReq modifyCommentReq) { + CommentDetailRes commentDetailRes = commentService.modifyComment(postId, commentId, modifyCommentReq); + + return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.ok(commentDetailRes)); + } + + @DeleteMapping("/{commentId}") + public ResponseEntity> deleteComment(@PathVariable Long postId, @PathVariable Long commentId, @RequestBody @Valid DeleteCommentReq deleteCommentReq) { + commentService.deleteComment(postId, commentId, deleteCommentReq); + + return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.empty()); + } + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentDetailRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentDetailRes.java new file mode 100644 index 0000000..409be88 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentDetailRes.java @@ -0,0 +1,14 @@ +package com.likelion.demo.domain.comment.web.dto; + +import java.time.LocalDateTime; + +public record CommentDetailRes( + Long commentId, + Long postId, + String content, + String username, + LocalDateTime createAt, + LocalDateTime updateAt + +) { +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentSummaryRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentSummaryRes.java new file mode 100644 index 0000000..f005a96 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CommentSummaryRes.java @@ -0,0 +1,17 @@ +package com.likelion.demo.domain.comment.web.dto; + +import com.likelion.demo.domain.comment.entity.Comment; + +import java.time.LocalDateTime; +import java.util.List; + +public record CommentSummaryRes(List comments) { + public record CommentSummary( + Long commentId, + String content, + String username, + String password, + LocalDateTime createAt + + ) {} +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentReq.java new file mode 100644 index 0000000..c49b302 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentReq.java @@ -0,0 +1,18 @@ +package com.likelion.demo.domain.comment.web.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CreateCommentReq { + @NotBlank(message = "내용은 필수값입니다.") + private String content; + + @NotBlank(message = "이름은 필수값입니다.") + private String username; + + @NotBlank(message = "비번은 필수값입니다.") + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentRes.java new file mode 100644 index 0000000..2986a4c --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/CreateCommentRes.java @@ -0,0 +1,5 @@ +package com.likelion.demo.domain.comment.web.dto; + + +public record CreateCommentRes(Long commentId) { +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/DeleteCommentReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/DeleteCommentReq.java new file mode 100644 index 0000000..180b892 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/DeleteCommentReq.java @@ -0,0 +1,12 @@ +package com.likelion.demo.domain.comment.web.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DeleteCommentReq { + @NotBlank(message = "비밀번호는 필수값입니다.") + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/ModifyCommentReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/ModifyCommentReq.java new file mode 100644 index 0000000..7c0eac2 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/comment/web/dto/ModifyCommentReq.java @@ -0,0 +1,19 @@ +package com.likelion.demo.domain.comment.web.dto; + + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ModifyCommentReq { + @NotBlank(message = "이름은 필수값입니다.") + private String username; + + @NotBlank(message = "내용은 필수값입니다.") + private String content; + + @NotBlank(message = "비밀번호는 필수값입니다.") + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/Post.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/Post.java new file mode 100644 index 0000000..bb6aa86 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/Post.java @@ -0,0 +1,38 @@ +package com.likelion.demo.domain.post.entity; + +import com.likelion.demo.domain.comment.entity.Comment; +import com.likelion.demo.global.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@Builder +@AllArgsConstructor +public class Post extends BaseEntity { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String title; + private String content; + private String username; + private String password; + // 작성일시, 수정일시 + + @OneToMany(mappedBy = "post") + private List comments = new ArrayList<>(); + + @Enumerated(EnumType.STRING) + private PostState state; + + // 게시글 수정(제목, 내용) + public void modify(String title, String content) { + this.title = title; + this.content = content; + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/PostState.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/PostState.java new file mode 100644 index 0000000..a9e077c --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/entity/PostState.java @@ -0,0 +1,5 @@ +package com.likelion.demo.domain.post.entity; + +public enum PostState { + PROGRESS, DONE +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/InvalidPasswordException.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/InvalidPasswordException.java new file mode 100644 index 0000000..f2eef66 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/InvalidPasswordException.java @@ -0,0 +1,9 @@ +package com.likelion.demo.domain.post.exception; + +import com.likelion.demo.global.exception.BaseException; + +public class InvalidPasswordException extends BaseException { + public InvalidPasswordException() { + super(PostErrorCode.POST_PASSWORD_INVALID_403); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostErrorCode.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostErrorCode.java new file mode 100644 index 0000000..945b086 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostErrorCode.java @@ -0,0 +1,16 @@ +package com.likelion.demo.domain.post.exception; + +import com.likelion.demo.global.response.code.BaseResponseCode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum PostErrorCode implements BaseResponseCode { + // 404 게시글 존재하지 않음 + POST_NOT_FOUND_404("POSST_NOT_FOUND_404", 404, "해당 게시글이 존재하지 않습니다"), + POST_PASSWORD_INVALID_403("POST_PASSWORD_INVALID_403", 403,"비밀번호가 일치하지 않습니다." ); + private final String code; + private final int httpStatus; + private final String message; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostNotFoundException.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostNotFoundException.java new file mode 100644 index 0000000..494bf5f --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/exception/PostNotFoundException.java @@ -0,0 +1,9 @@ +package com.likelion.demo.domain.post.exception; + +import com.likelion.demo.global.exception.BaseException; + +public class PostNotFoundException extends BaseException { + public PostNotFoundException() { + super(PostErrorCode.POST_NOT_FOUND_404); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/repository/PostRepository.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/repository/PostRepository.java new file mode 100644 index 0000000..c356e50 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/repository/PostRepository.java @@ -0,0 +1,9 @@ +package com.likelion.demo.domain.post.repository; + +import com.likelion.demo.domain.post.entity.Post; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PostRepository extends JpaRepository { +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostService.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostService.java new file mode 100644 index 0000000..4c87a70 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostService.java @@ -0,0 +1,20 @@ +package com.likelion.demo.domain.post.service; + +import com.likelion.demo.domain.post.web.dto.*; + +public interface PostService { + // 게시글 작성 + CreatePostRes createOne(CreatePostReq createPostReq); + + // 게시글 단건 조회 + PostDetailRes getById(Long postId); + + // 게시글 전체 조회 + PostSummaryRes getAll(); + + // 게시글 수정 + PostDetailRes modifyOne(Long postId, ModifyPostReq modifyPostReq); + + // 게시글 삭제 + void deleteOne(Long postId, DeletePostReq deletePostReq); +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostServiceImpl.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostServiceImpl.java new file mode 100644 index 0000000..0045fdf --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/service/PostServiceImpl.java @@ -0,0 +1,134 @@ +package com.likelion.demo.domain.post.service; + +import com.likelion.demo.domain.post.entity.Post; +import com.likelion.demo.domain.post.entity.PostState; +import com.likelion.demo.domain.post.exception.InvalidPasswordException; +import com.likelion.demo.domain.post.exception.PostNotFoundException; +import com.likelion.demo.domain.post.repository.PostRepository; +import com.likelion.demo.domain.post.web.dto.*; +import com.likelion.demo.domain.post.web.dto.PostSummaryRes.PostSummary; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class PostServiceImpl implements PostService { + private final PostRepository postRepository; + + // 게시글 작성 + @Override + public CreatePostRes createOne(CreatePostReq createPostReq) { + // 1. createPostReq가지고 Post Entity 생성 + Post post = Post.builder() + .title(createPostReq.getTitle()) + .content(createPostReq.getContent()) + .username((createPostReq.getUsername())) + .password(createPostReq.getPassword()) + .state(PostState.PROGRESS) + .build(); + + // 2. repository Post 저장 (postRepository 사용) + Post savedPost = postRepository.save(post); + + // 3. 반환 CreatePostRes + return new CreatePostRes(savedPost.getId()); + } + + // 게시글 단건 조회 + @Override + public PostDetailRes getById(Long postId) { + + // 1. postId가지고 Post 엔티티 찾기 + // 404: 게시글 없음 + Post post = postRepository.findById(postId) + .orElseThrow(PostNotFoundException::new); + + // 2. Post를 가지고 PostDetailRes 반환 + return new PostDetailRes( + post.getId(), + post.getTitle(), + post.getContent(), + post.getUsername(), + post.getPassword(), + post.getState(), + post.getCreatedAt(), + post.getUpdatedAt() + ); + } + + // 게시글 전체 조회 + @Override + public PostSummaryRes getAll() { + // 1. DB 에서 모든 Post 조회 + List posts = postRepository.findAll(); + // 게시글 리스트 + List postSummaryList= new ArrayList(); + + for (Post post : posts) { + PostSummary postSummary = new PostSummary( + post.getId(), + post.getTitle(), + post.getUsername(), + post.getCreatedAt() + ); + postSummaryList.add(postSummary); + } + // 2. PostSummaryRes 반환 + return new PostSummaryRes(postSummaryList); + } + + // 게시글 수정 + @Transactional + @Override + public PostDetailRes modifyOne(Long postId, ModifyPostReq modifyPostReq) { + // 1. DB 에서 postId로 Post 찾기 + Post foundPost = postRepository.findById(postId) + // 404 - 게시글 없음 + .orElseThrow(PostNotFoundException::new); + + // 2. 비밀번호 검증 + // 403 - 비밀번호 불일치 + if (!foundPost.getPassword().equals(modifyPostReq.getPassword())) { + throw new InvalidPasswordException(); + } + + // 3. post 수정 + foundPost.modify(modifyPostReq.getTitle(), modifyPostReq.getContent()); + + // PostDetailRes 반환 + return new PostDetailRes( + foundPost.getId(), + foundPost.getTitle(), + foundPost.getContent(), + foundPost.getUsername(), + foundPost.getPassword(), + foundPost.getState(), + foundPost.getCreatedAt(), + foundPost.getUpdatedAt() + ); + } + + // 게시글 삭제 + @Transactional + @Override + public void deleteOne(Long postId, DeletePostReq deletePostReq) { + // 1. 게시글 존재 확인 + // 404 - 게시글 존재하지 않음 + Post post = postRepository.findById(postId) + .orElseThrow(PostNotFoundException::new); + + // 2. 비밀번호 검증 + if (!post.getPassword().equals(deletePostReq.getPassword())) { + // 403 - 비밀번호 불일치 + throw new InvalidPasswordException(); + } + + // 3. 삭제 + postRepository.delete(post); + } + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/controller/PostController.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/controller/PostController.java new file mode 100644 index 0000000..c29fdb5 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/controller/PostController.java @@ -0,0 +1,83 @@ +package com.likelion.demo.domain.post.web.controller; + +import com.likelion.demo.domain.post.service.PostService; +import com.likelion.demo.domain.post.web.dto.*; +import com.likelion.demo.global.response.SuccessResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + + +@RestController +@RequestMapping("/post") +@RequiredArgsConstructor +public class PostController { + // 의존성부여 + private final PostService postService; + + // 게시글 작성 + @PostMapping + public ResponseEntity> CreatePost(@RequestBody @Valid CreatePostReq createPostReq) { + // 서비스 계층 위임 + CreatePostRes createPostRes = postService.createOne(createPostReq); + + // 반환 + return ResponseEntity + .status(HttpStatus.CREATED) + .body(SuccessResponse.created(createPostRes)); + } + + // 게시글 단건 조회 + @GetMapping("/{postId}") + public ResponseEntity> getPostById(@PathVariable Long postId) { + // 서비스 로직 + PostDetailRes postDetailRes = postService.getById(postId); + + // 반환 + return ResponseEntity + .status(HttpStatus.OK) //200 + .body(SuccessResponse.ok(postDetailRes)); + } + + // 게시글 전체 조회 + @GetMapping() + public ResponseEntity> getAllPosts() { + // 서비스 로직 + PostSummaryRes postSummaryRes = postService.getAll(); + + // 반환 + return ResponseEntity + .status(HttpStatus.OK) + .body(SuccessResponse.ok(postSummaryRes)); + } + + // 게시글 수정 + @PutMapping("/{postId}") + public ResponseEntity> modifyPost( + @PathVariable Long postId, + @RequestBody ModifyPostReq modifyPostReq + ) { + // 서비스 + PostDetailRes postDetailRes = postService.modifyOne(postId, modifyPostReq); + + // 반환 + return ResponseEntity + .status(HttpStatus.OK) + .body(SuccessResponse.ok(postDetailRes)); + } + + // 게시글 삭제 + @DeleteMapping("/{postId}") + public ResponseEntity> deletePost( + @PathVariable Long postId, + @RequestBody DeletePostReq deletePostReq) { + // 서비스 로직 + postService.deleteOne(postId, deletePostReq); + // 반환 + return ResponseEntity + .status(HttpStatus.OK) + .body(SuccessResponse.empty()); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostReq.java new file mode 100644 index 0000000..4c683e2 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostReq.java @@ -0,0 +1,16 @@ +package com.likelion.demo.domain.post.web.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class CreatePostReq { + @NotBlank(message = "게시글 제목은 비어있을 수 없습니다.") + private String title; + + private String content; + private String username; + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostRes.java new file mode 100644 index 0000000..fb674a3 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/CreatePostRes.java @@ -0,0 +1,4 @@ +package com.likelion.demo.domain.post.web.dto; + +public record CreatePostRes(Long postId) { +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeleteCommentReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeleteCommentReq.java new file mode 100644 index 0000000..d83812b --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeleteCommentReq.java @@ -0,0 +1,4 @@ +package com.likelion.demo.domain.post.web.dto; + +public class DeleteCommentReq { +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeletePostReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeletePostReq.java new file mode 100644 index 0000000..b1a75f1 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/DeletePostReq.java @@ -0,0 +1,10 @@ +package com.likelion.demo.domain.post.web.dto; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class DeletePostReq { + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/ModifyPostReq.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/ModifyPostReq.java new file mode 100644 index 0000000..5346c31 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/ModifyPostReq.java @@ -0,0 +1,12 @@ +package com.likelion.demo.domain.post.web.dto; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class ModifyPostReq { + private String title; + private String content; + private String password; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostDetailRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostDetailRes.java new file mode 100644 index 0000000..6982bed --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostDetailRes.java @@ -0,0 +1,8 @@ +package com.likelion.demo.domain.post.web.dto; + +import com.likelion.demo.domain.post.entity.PostState; + +import java.time.LocalDateTime; + +public record PostDetailRes(Long id, String title, String content, String username, String password, PostState state, LocalDateTime createdAt, LocalDateTime updatedAt) { +} \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostSummaryRes.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostSummaryRes.java new file mode 100644 index 0000000..a2ed1f9 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/domain/post/web/dto/PostSummaryRes.java @@ -0,0 +1,15 @@ +package com.likelion.demo.domain.post.web.dto; + +import java.time.LocalDateTime; +import java.util.List; + +public record PostSummaryRes( + List postSummaryList +) { + public record PostSummary( + Long id, + String title, + String username, + LocalDateTime createdAt + ){} +} \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/config/WebConfig.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/config/WebConfig.java new file mode 100644 index 0000000..f038af0 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/config/WebConfig.java @@ -0,0 +1,16 @@ +package com.likelion.demo.global.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("http://localhost:3000") // 실제 프론트 주소 명시 + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowCredentials(true); + } +} \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/constant/StaticValue.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/constant/StaticValue.java new file mode 100644 index 0000000..65603a9 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/constant/StaticValue.java @@ -0,0 +1,19 @@ +package com.likelion.demo.global.constant; + +public class StaticValue { + + // Success Code + public static final int OK = 200; + public static final int CREATED = 201; + public static final int NO_CONTENT = 204; + + // Error Code + public static final int BAD_REQUEST = 400; + public static final int UNAUTHORIZED = 401; + public static final int FORBIDDEN = 403; + public static final int NOT_FOUND = 404; + public static final int METHOD_NOT_ALLOWED = 405; + public static final int CONFLICT = 409; + public static final int INTERNAL_SERVER_ERROR = 500; + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/entity/BaseEntity.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/entity/BaseEntity.java new file mode 100644 index 0000000..15d5598 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/entity/BaseEntity.java @@ -0,0 +1,24 @@ +package com.likelion.demo.global.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + @CreatedDate + @Column(name = "created_at") + private LocalDateTime createdAt; + + @LastModifiedDate + @Column(name = "updated_at") + private LocalDateTime updatedAt; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/BaseException.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/BaseException.java new file mode 100644 index 0000000..630f5ca --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/BaseException.java @@ -0,0 +1,11 @@ +package com.likelion.demo.global.exception; + +import com.likelion.demo.global.response.code.BaseResponseCode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class BaseException extends RuntimeException { + private final BaseResponseCode errorCode; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/GlobalExceptionHandler.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..e4d1c54 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/exception/GlobalExceptionHandler.java @@ -0,0 +1,82 @@ +package com.likelion.demo.global.exception; + +import com.likelion.demo.global.response.ErrorResponse; +import com.likelion.demo.global.response.code.GlobalErrorCode; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.BindException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; + +@RestControllerAdvice +@Slf4j +public class GlobalExceptionHandler { + + /* + javax.validation.Valid or @Validated 으로 binding error 발생시 발생 + 주로 @RequestBody, @RequestPart 어노테이션에서 발생 + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + private ResponseEntity handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { + log.error("MethodArgumentNotValidException Error", e); + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.INVALID_HTTP_MESSAGE_BODY, + e.getFieldError().getDefaultMessage()); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + /* binding error 발생시 BindException 발생 */ + @ExceptionHandler(BindException.class) + private ResponseEntity handleBindException(BindException e) { + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.INVALID_HTTP_MESSAGE_BODY); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + /* enum type 일치하지 않아 binding 못할 경우 발생 */ + @ExceptionHandler(MethodArgumentTypeMismatchException.class) + private ResponseEntity handleMethodArgumentTypeMismatchException( + MethodArgumentTypeMismatchException e) { + log.error("MethodArgumentTypeMismatchException Error", e); + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.INVALID_HTTP_MESSAGE_BODY); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + /* 지원하지 않은 HTTP method 호출 할 경우 발생 */ + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + private ResponseEntity handleHttpRequestMethodNotSupportedException( + HttpRequestMethodNotSupportedException e) { + log.error("HttpRequestMethodNotSupportedException Error", e); + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.UNSUPPORTED_HTTP_METHOD); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + /* request 값을 읽을 수 없을 때 발생 */ + @ExceptionHandler(HttpMessageNotReadableException.class) + protected ResponseEntity handleHttpMessageNotReadableException(HttpMessageNotReadableException e) { + log.error("HttpMessageNotReadableException error", e); + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.BAD_REQUEST_ERROR); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + /* 비지니스 로직 에러 */ + @ExceptionHandler(BaseException.class) + private ResponseEntity handleBusinessException(BaseException e) { + log.error("BusinessError "); + log.error(e.getErrorCode().getMessage()); + ErrorResponse error = ErrorResponse.of(e.getErrorCode()); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + + + /* 나머지 예외 처리 */ + @ExceptionHandler(Exception.class) + private ResponseEntity handleException(Exception e) { + log.error("Exception Error ", e); + ErrorResponse error = ErrorResponse.of(GlobalErrorCode.SERVER_ERROR); + return ResponseEntity.status(error.getHttpStatus()).body(error); + } + +} \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/BaseResponse.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/BaseResponse.java new file mode 100644 index 0000000..1a239e1 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/BaseResponse.java @@ -0,0 +1,35 @@ +package com.likelion.demo.global.response; + +import com.likelion.demo.global.response.code.BaseResponseCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +@Getter +@ToString +@RequiredArgsConstructor +public class BaseResponse { + private final Boolean isSuccess; + + private final String code; + + private final String message; + + private final String timeStamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + + public static BaseResponse of(Boolean isSuccess, BaseResponseCode baseCode) { + return new BaseResponse(isSuccess, baseCode.getCode(), baseCode.getMessage()); + } + + public static BaseResponse of(Boolean isSuccess, BaseResponseCode baseCode, String message) { + return new BaseResponse(isSuccess, baseCode.getCode(), message); + } + + public static BaseResponse of(Boolean isSuccess, String code, String message) { + return new BaseResponse(isSuccess, code, message); + } + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/ErrorResponse.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/ErrorResponse.java new file mode 100644 index 0000000..cc9b6e1 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/ErrorResponse.java @@ -0,0 +1,50 @@ +package com.likelion.demo.global.response; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.likelion.demo.global.response.code.BaseResponseCode; +import lombok.Builder; +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +@JsonPropertyOrder({"isSuccess", "timestamp", "code", "httpStatus", "message", "data"}) +public class ErrorResponse extends BaseResponse { + private final int httpStatus; + private final T data; + + @Builder + public ErrorResponse(T data, String code, String message, int httpStatus) { + super(false, code, message); + this.data = data; + this.httpStatus = httpStatus; + } + + // 기본 메시지를 그대로 사용할 떄 + public static ErrorResponse of(BaseResponseCode baseCode) { + return ErrorResponse.builder() + .code(baseCode.getCode()) + .message(baseCode.getMessage()) + .httpStatus(baseCode.getHttpStatus()) + .data(null) + .build(); + } + + public static ErrorResponse of(BaseResponseCode baseCode, String message) { + return ErrorResponse.builder() + .code(baseCode.getCode()) + .httpStatus(baseCode.getHttpStatus()) + .message(message) + .data(null) + .build(); + } + + public static ErrorResponse of(BaseResponseCode baseCode, String message, T data) { + return ErrorResponse.builder() + .code(baseCode.getCode()) + .httpStatus(baseCode.getHttpStatus()) + .message(message) + .data(data) + .build(); + } +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/SuccessResponse.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/SuccessResponse.java new file mode 100644 index 0000000..5f8b6b0 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/SuccessResponse.java @@ -0,0 +1,43 @@ +package com.likelion.demo.global.response; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.likelion.demo.global.response.code.BaseResponseCode; +import com.likelion.demo.global.response.code.GlobalSuccessCode; +import lombok.Builder; +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +@JsonPropertyOrder({"isSuccess", "timestamp", "code", "httpStatus", "message", "data"}) +public class SuccessResponse extends BaseResponse{ + private final int httpStatus; + private final T data; + + @Builder + public SuccessResponse(T data, BaseResponseCode baseResponseCode) { + super(true, baseResponseCode.getCode(), baseResponseCode.getMessage()); + this.data = data; + this.httpStatus = baseResponseCode.getHttpStatus(); + } + + // 200 OK 응답 + public static SuccessResponse ok(T data) { + return new SuccessResponse<>(data, GlobalSuccessCode.SUCCESS_OK); + } + + // 201 Created 응답 + public static SuccessResponse created(T data) { + return new SuccessResponse<>(data, GlobalSuccessCode.SUCCESS_CREATED); + } + + // 200 OK 응답 (data가 null) + public static SuccessResponse empty() { + return new SuccessResponse<>(null, GlobalSuccessCode.SUCCESS_OK); + } + + public static SuccessResponse of(T data, BaseResponseCode baseResponseCode) { + return new SuccessResponse<>(data, baseResponseCode); + } + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/BaseResponseCode.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/BaseResponseCode.java new file mode 100644 index 0000000..d5221da --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/BaseResponseCode.java @@ -0,0 +1,7 @@ +package com.likelion.demo.global.response.code; + +public interface BaseResponseCode { + String getCode(); + String getMessage(); + int getHttpStatus(); +} \ No newline at end of file diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalErrorCode.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalErrorCode.java new file mode 100644 index 0000000..bdf8232 --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalErrorCode.java @@ -0,0 +1,21 @@ +package com.likelion.demo.global.response.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import static com.likelion.demo.global.constant.StaticValue.*; + +@Getter +@AllArgsConstructor +public enum GlobalErrorCode implements BaseResponseCode { + + BAD_REQUEST_ERROR("GLOBAL_400_1", BAD_REQUEST, "잘못된 요청입니다."), + INVALID_HTTP_MESSAGE_BODY("GLOBAL_400_2", BAD_REQUEST, "HTTP 요청 바디의 형식이 잘못되었습니다."), + ACCESS_DENIED_REQUEST("GLOBAL_403", FORBIDDEN, "해당 요청에 접근 권한이 없습니다."), + UNSUPPORTED_HTTP_METHOD("GLOBAL_405", METHOD_NOT_ALLOWED, "지원하지 않는 HTTP 메서드입니다."), + SERVER_ERROR( "GLOBAL_500", INTERNAL_SERVER_ERROR, "서버 내부에서 알 수 없는 오류가 발생했습니다."); + + private final String code; + private final int httpStatus; + private final String message; +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalSuccessCode.java b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalSuccessCode.java new file mode 100644 index 0000000..d899f6a --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/java/com/likelion/demo/global/response/code/GlobalSuccessCode.java @@ -0,0 +1,19 @@ +package com.likelion.demo.global.response.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import static com.likelion.demo.global.constant.StaticValue.*; + + +@Getter +@AllArgsConstructor +public enum GlobalSuccessCode implements BaseResponseCode { + SUCCESS_OK( "SUCCESS_200", OK,"호출에 성공하였습니다."), + SUCCESS_CREATED("CREATED_201", CREATED, "호출에 성공하였습니다."); + + private final String code; + private final int httpStatus; + private final String message; + +} diff --git a/Eunji/week7/springboot-base-project-main-final/src/main/resources/application.properties b/Eunji/week7/springboot-base-project-main-final/src/main/resources/application.properties new file mode 100644 index 0000000..84932fd --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/main/resources/application.properties @@ -0,0 +1,25 @@ +spring.application.name=demo +server.servlet.context-path=/api + +# application-secret.properties +spring.config.import=optional:application-secret.properties + +# Datasource +#spring.datasource.url=${DATABASE_URL} +#spring.datasource.username=${DATABASE_USERNAME} +#spring.datasource.password=${DATABASE_PASSWORD} + +# DB (local) +spring.datasource.url=jdbc:mysql://localhost:3306/demo +spring.datasource.username=root +spring.datasource.password=12341234 + +# JPA +spring.jpa.hibernate.ddl-auto=update +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true + +# H2 +# spring.datasource.driver-class-name=org.h2.Driver +# spring.jpa.database-platform=org.hibernate.dialect.H2Dialect diff --git a/Eunji/week7/springboot-base-project-main-final/src/test/java/com/likelion/demo/DemoApplicationTests.java b/Eunji/week7/springboot-base-project-main-final/src/test/java/com/likelion/demo/DemoApplicationTests.java new file mode 100644 index 0000000..296a6af --- /dev/null +++ b/Eunji/week7/springboot-base-project-main-final/src/test/java/com/likelion/demo/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.likelion.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +}