diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..c5c99abf Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..485dee64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/discodeit/.DS_Store b/discodeit/.DS_Store new file mode 100644 index 00000000..e7f5874f Binary files /dev/null and b/discodeit/.DS_Store differ diff --git a/discodeit/.gradle/8.14.4/checksums/checksums.lock b/discodeit/.gradle/8.14.4/checksums/checksums.lock new file mode 100644 index 00000000..ea32d831 Binary files /dev/null and b/discodeit/.gradle/8.14.4/checksums/checksums.lock differ diff --git a/discodeit/.gradle/8.14.4/checksums/md5-checksums.bin b/discodeit/.gradle/8.14.4/checksums/md5-checksums.bin new file mode 100644 index 00000000..36a57994 Binary files /dev/null and b/discodeit/.gradle/8.14.4/checksums/md5-checksums.bin differ diff --git a/discodeit/.gradle/8.14.4/checksums/sha1-checksums.bin b/discodeit/.gradle/8.14.4/checksums/sha1-checksums.bin new file mode 100644 index 00000000..4c35352c Binary files /dev/null and b/discodeit/.gradle/8.14.4/checksums/sha1-checksums.bin differ diff --git a/discodeit/.gradle/8.14.4/executionHistory/executionHistory.lock b/discodeit/.gradle/8.14.4/executionHistory/executionHistory.lock new file mode 100644 index 00000000..0385a465 Binary files /dev/null and b/discodeit/.gradle/8.14.4/executionHistory/executionHistory.lock differ diff --git a/discodeit/.gradle/8.14.4/fileChanges/last-build.bin b/discodeit/.gradle/8.14.4/fileChanges/last-build.bin new file mode 100644 index 00000000..f76dd238 Binary files /dev/null and b/discodeit/.gradle/8.14.4/fileChanges/last-build.bin differ diff --git a/discodeit/.gradle/8.14.4/fileHashes/fileHashes.bin b/discodeit/.gradle/8.14.4/fileHashes/fileHashes.bin new file mode 100644 index 00000000..6b97a148 Binary files /dev/null and b/discodeit/.gradle/8.14.4/fileHashes/fileHashes.bin differ diff --git a/discodeit/.gradle/8.14.4/fileHashes/fileHashes.lock b/discodeit/.gradle/8.14.4/fileHashes/fileHashes.lock new file mode 100644 index 00000000..b38d5032 Binary files /dev/null and b/discodeit/.gradle/8.14.4/fileHashes/fileHashes.lock differ diff --git a/discodeit/.gradle/8.14.4/gc.properties b/discodeit/.gradle/8.14.4/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/.gradle/8.8/checksums/checksums.lock b/discodeit/.gradle/8.8/checksums/checksums.lock new file mode 100644 index 00000000..f76177ce Binary files /dev/null and b/discodeit/.gradle/8.8/checksums/checksums.lock differ diff --git a/discodeit/.gradle/8.8/checksums/md5-checksums.bin b/discodeit/.gradle/8.8/checksums/md5-checksums.bin new file mode 100644 index 00000000..a11d3ec9 Binary files /dev/null and b/discodeit/.gradle/8.8/checksums/md5-checksums.bin differ diff --git a/discodeit/.gradle/8.8/checksums/sha1-checksums.bin b/discodeit/.gradle/8.8/checksums/sha1-checksums.bin new file mode 100644 index 00000000..536952cb Binary files /dev/null and b/discodeit/.gradle/8.8/checksums/sha1-checksums.bin differ diff --git a/discodeit/.gradle/8.8/dependencies-accessors/gc.properties b/discodeit/.gradle/8.8/dependencies-accessors/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/.gradle/8.8/executionHistory/executionHistory.bin b/discodeit/.gradle/8.8/executionHistory/executionHistory.bin new file mode 100644 index 00000000..c36bbf25 Binary files /dev/null and b/discodeit/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/discodeit/.gradle/8.8/executionHistory/executionHistory.lock b/discodeit/.gradle/8.8/executionHistory/executionHistory.lock new file mode 100644 index 00000000..522957d1 Binary files /dev/null and b/discodeit/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/discodeit/.gradle/8.8/fileChanges/last-build.bin b/discodeit/.gradle/8.8/fileChanges/last-build.bin new file mode 100644 index 00000000..f76dd238 Binary files /dev/null and b/discodeit/.gradle/8.8/fileChanges/last-build.bin differ diff --git a/discodeit/.gradle/8.8/fileHashes/fileHashes.bin b/discodeit/.gradle/8.8/fileHashes/fileHashes.bin new file mode 100644 index 00000000..9192afef Binary files /dev/null and b/discodeit/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/discodeit/.gradle/8.8/fileHashes/fileHashes.lock b/discodeit/.gradle/8.8/fileHashes/fileHashes.lock new file mode 100644 index 00000000..e03c1a27 Binary files /dev/null and b/discodeit/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/discodeit/.gradle/8.8/fileHashes/resourceHashesCache.bin b/discodeit/.gradle/8.8/fileHashes/resourceHashesCache.bin new file mode 100644 index 00000000..a33197b2 Binary files /dev/null and b/discodeit/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/discodeit/.gradle/8.8/gc.properties b/discodeit/.gradle/8.8/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/.gradle/9.0.0/checksums/checksums.lock b/discodeit/.gradle/9.0.0/checksums/checksums.lock new file mode 100644 index 00000000..91a84718 Binary files /dev/null and b/discodeit/.gradle/9.0.0/checksums/checksums.lock differ diff --git a/discodeit/.gradle/9.0.0/executionHistory/executionHistory.bin b/discodeit/.gradle/9.0.0/executionHistory/executionHistory.bin new file mode 100644 index 00000000..811bb1dc Binary files /dev/null and b/discodeit/.gradle/9.0.0/executionHistory/executionHistory.bin differ diff --git a/discodeit/.gradle/9.0.0/executionHistory/executionHistory.lock b/discodeit/.gradle/9.0.0/executionHistory/executionHistory.lock new file mode 100644 index 00000000..dcc918ce Binary files /dev/null and b/discodeit/.gradle/9.0.0/executionHistory/executionHistory.lock differ diff --git a/discodeit/.gradle/9.0.0/fileChanges/last-build.bin b/discodeit/.gradle/9.0.0/fileChanges/last-build.bin new file mode 100644 index 00000000..f76dd238 Binary files /dev/null and b/discodeit/.gradle/9.0.0/fileChanges/last-build.bin differ diff --git a/discodeit/.gradle/9.0.0/fileHashes/fileHashes.bin b/discodeit/.gradle/9.0.0/fileHashes/fileHashes.bin new file mode 100644 index 00000000..002db7c0 Binary files /dev/null and b/discodeit/.gradle/9.0.0/fileHashes/fileHashes.bin differ diff --git a/discodeit/.gradle/9.0.0/fileHashes/fileHashes.lock b/discodeit/.gradle/9.0.0/fileHashes/fileHashes.lock new file mode 100644 index 00000000..ae178675 Binary files /dev/null and b/discodeit/.gradle/9.0.0/fileHashes/fileHashes.lock differ diff --git a/discodeit/.gradle/9.0.0/gc.properties b/discodeit/.gradle/9.0.0/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/discodeit/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 00000000..36706b78 Binary files /dev/null and b/discodeit/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/discodeit/.gradle/buildOutputCleanup/cache.properties b/discodeit/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 00000000..65ecabbb --- /dev/null +++ b/discodeit/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Jan 28 10:07:26 KST 2026 +gradle.version=8.8 diff --git a/discodeit/.gradle/buildOutputCleanup/outputFiles.bin b/discodeit/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 00000000..12d8b6b0 Binary files /dev/null and b/discodeit/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/discodeit/.gradle/file-system.probe b/discodeit/.gradle/file-system.probe new file mode 100644 index 00000000..b70d598a Binary files /dev/null and b/discodeit/.gradle/file-system.probe differ diff --git a/discodeit/.gradle/vcs-1/gc.properties b/discodeit/.gradle/vcs-1/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/HELP.md b/discodeit/HELP.md new file mode 100644 index 00000000..98bfdf4f --- /dev/null +++ b/discodeit/HELP.md @@ -0,0 +1,22 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Gradle documentation](https://docs.gradle.org) +* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/3.5.10/gradle-plugin) +* [Create an OCI image](https://docs.spring.io/spring-boot/3.5.10/gradle-plugin/packaging-oci-image.html) +* [Spring Web](https://docs.spring.io/spring-boot/3.5.10/reference/web/servlet.html) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) + +### Additional Links +These additional references should also help you: + +* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) + diff --git a/discodeit/README.md b/discodeit/README.md new file mode 100644 index 00000000..815bede5 --- /dev/null +++ b/discodeit/README.md @@ -0,0 +1,2 @@ +# 0-spring-mission +스프린트 미션 모범 답안 리포지토리입니다. diff --git a/discodeit/build.gradle b/discodeit/build.gradle new file mode 100644 index 00000000..1d3800a6 --- /dev/null +++ b/discodeit/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.5.10' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'com.sprint.mission' +version = '0.0.1-SNAPSHOT' +description = 'Demo project for Spring Boot' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/DiscodeitApplication.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/DiscodeitApplication.class new file mode 100644 index 00000000..6200525f Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/DiscodeitApplication.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/JavaApplication.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/JavaApplication.class new file mode 100644 index 00000000..27259b16 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/JavaApplication.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserCreateDto.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserCreateDto.class new file mode 100644 index 00000000..b8175fcb Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserCreateDto.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserProfileDto.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserProfileDto.class new file mode 100644 index 00000000..cb5edc8a Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserProfileDto.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserResponseDto.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserResponseDto.class new file mode 100644 index 00000000..9a477792 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserResponseDto.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserUpdateDto.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserUpdateDto.class new file mode 100644 index 00000000..cdabffa2 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/dto/UserUpdateDto.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/BinaryContent.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/BinaryContent.class new file mode 100644 index 00000000..d84c63ac Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/BinaryContent.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class new file mode 100644 index 00000000..0a6175f1 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ChannelType.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ChannelType.class new file mode 100644 index 00000000..11379b80 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ChannelType.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class new file mode 100644 index 00000000..43b0b2a6 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ReadStatus.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ReadStatus.class new file mode 100644 index 00000000..851aaf10 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/ReadStatus.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class new file mode 100644 index 00000000..72349b3a Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/UserStatus.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/UserStatus.class new file mode 100644 index 00000000..cc769460 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/entity/UserStatus.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/ChannelRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/ChannelRepository.class new file mode 100644 index 00000000..bf392ca2 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/ChannelRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/MessageRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/MessageRepository.class new file mode 100644 index 00000000..617e92c2 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/MessageRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/UserRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/UserRepository.class new file mode 100644 index 00000000..f9039ee1 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/UserRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileChannelRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileChannelRepository.class new file mode 100644 index 00000000..8fcd7536 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileChannelRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileMessageRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileMessageRepository.class new file mode 100644 index 00000000..86191aeb Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileMessageRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileUserRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileUserRepository.class new file mode 100644 index 00000000..acb8e8d8 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/file/FileUserRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.class new file mode 100644 index 00000000..bf15f0d3 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.class new file mode 100644 index 00000000..511d2931 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.class new file mode 100644 index 00000000..ad6ba7d0 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class new file mode 100644 index 00000000..7febb837 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class new file mode 100644 index 00000000..95cd735b Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class new file mode 100644 index 00000000..7b217e56 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicChannelService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicChannelService.class new file mode 100644 index 00000000..cad72366 Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicChannelService.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicMessageService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicMessageService.class new file mode 100644 index 00000000..208a84bc Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicMessageService.class differ diff --git a/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicUserService.class b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicUserService.class new file mode 100644 index 00000000..7f1908fe Binary files /dev/null and b/discodeit/build/classes/java/main/com/sprint/mission/discodeit/service/basic/BasicUserService.class differ diff --git a/discodeit/build/resources/main/application.properties b/discodeit/build/resources/main/application.properties new file mode 100644 index 00000000..545cf9f0 --- /dev/null +++ b/discodeit/build/resources/main/application.properties @@ -0,0 +1 @@ +spring.application.name=discodeit diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicChannelService.class.uniqueId7 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicChannelService.class.uniqueId7 new file mode 100644 index 00000000..a17b2caf Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicChannelService.class.uniqueId7 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicMessageService.class.uniqueId13 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicMessageService.class.uniqueId13 new file mode 100644 index 00000000..34fe6ba8 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicMessageService.class.uniqueId13 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicUserService.class.uniqueId10 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicUserService.class.uniqueId10 new file mode 100644 index 00000000..cdfcf972 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/BasicUserService.class.uniqueId10 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Channel.class.uniqueId5 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Channel.class.uniqueId5 new file mode 100644 index 00000000..c0e70968 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Channel.class.uniqueId5 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelRepository.class.uniqueId4 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelRepository.class.uniqueId4 new file mode 100644 index 00000000..bf392ca2 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelRepository.class.uniqueId4 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelService.class.uniqueId16 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelService.class.uniqueId16 new file mode 100644 index 00000000..7febb837 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/ChannelService.class.uniqueId16 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/DiscodeitApplication.class.uniqueId12 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/DiscodeitApplication.class.uniqueId12 new file mode 100644 index 00000000..39e5ec49 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/DiscodeitApplication.class.uniqueId12 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileChannelRepository.class.uniqueId18 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileChannelRepository.class.uniqueId18 new file mode 100644 index 00000000..44784962 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileChannelRepository.class.uniqueId18 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileMessageRepository.class.uniqueId15 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileMessageRepository.class.uniqueId15 new file mode 100644 index 00000000..a60fa281 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileMessageRepository.class.uniqueId15 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileUserRepository.class.uniqueId3 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileUserRepository.class.uniqueId3 new file mode 100644 index 00000000..94b4ff7f Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/FileUserRepository.class.uniqueId3 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFChannelRepository.class.uniqueId11 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFChannelRepository.class.uniqueId11 new file mode 100644 index 00000000..bf15f0d3 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFChannelRepository.class.uniqueId11 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFMessageRepository.class.uniqueId19 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFMessageRepository.class.uniqueId19 new file mode 100644 index 00000000..511d2931 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFMessageRepository.class.uniqueId19 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFUserRepository.class.uniqueId9 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFUserRepository.class.uniqueId9 new file mode 100644 index 00000000..ad6ba7d0 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JCFUserRepository.class.uniqueId9 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JavaApplication.class.uniqueId17 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JavaApplication.class.uniqueId17 new file mode 100644 index 00000000..27259b16 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/JavaApplication.class.uniqueId17 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Message.class.uniqueId8 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Message.class.uniqueId8 new file mode 100644 index 00000000..8a1d7803 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/Message.class.uniqueId8 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageRepository.class.uniqueId0 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageRepository.class.uniqueId0 new file mode 100644 index 00000000..617e92c2 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageRepository.class.uniqueId0 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageService.class.uniqueId6 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageService.class.uniqueId6 new file mode 100644 index 00000000..95cd735b Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/MessageService.class.uniqueId6 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/User.class.uniqueId1 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/User.class.uniqueId1 new file mode 100644 index 00000000..3aacaf49 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/User.class.uniqueId1 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserRepository.class.uniqueId2 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserRepository.class.uniqueId2 new file mode 100644 index 00000000..f9039ee1 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserRepository.class.uniqueId2 differ diff --git a/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserService.class.uniqueId14 b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserService.class.uniqueId14 new file mode 100644 index 00000000..7b217e56 Binary files /dev/null and b/discodeit/build/tmp/compileJava/compileTransaction/stash-dir/UserService.class.uniqueId14 differ diff --git a/discodeit/build/tmp/compileJava/previous-compilation-data.bin b/discodeit/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 00000000..2be22826 Binary files /dev/null and b/discodeit/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/discodeit/file-data-map/Channel/083d5d8b-0667-407c-bf5d-acd5a5e14070.ser b/discodeit/file-data-map/Channel/083d5d8b-0667-407c-bf5d-acd5a5e14070.ser new file mode 100644 index 00000000..ff3091cf Binary files /dev/null and b/discodeit/file-data-map/Channel/083d5d8b-0667-407c-bf5d-acd5a5e14070.ser differ diff --git a/discodeit/file-data-map/Channel/422775fc-de56-4a75-8f6b-48c5e4ad42d0.ser b/discodeit/file-data-map/Channel/422775fc-de56-4a75-8f6b-48c5e4ad42d0.ser new file mode 100644 index 00000000..7c64b44e Binary files /dev/null and b/discodeit/file-data-map/Channel/422775fc-de56-4a75-8f6b-48c5e4ad42d0.ser differ diff --git a/discodeit/file-data-map/Message/a0aa6aae-7325-4e88-bef4-a48c1b4640ba.ser b/discodeit/file-data-map/Message/a0aa6aae-7325-4e88-bef4-a48c1b4640ba.ser new file mode 100644 index 00000000..25fff1ee Binary files /dev/null and b/discodeit/file-data-map/Message/a0aa6aae-7325-4e88-bef4-a48c1b4640ba.ser differ diff --git a/discodeit/file-data-map/Message/a9f39f2a-fbbe-4254-8d68-16fb11960d94.ser b/discodeit/file-data-map/Message/a9f39f2a-fbbe-4254-8d68-16fb11960d94.ser new file mode 100644 index 00000000..e842d3f0 Binary files /dev/null and b/discodeit/file-data-map/Message/a9f39f2a-fbbe-4254-8d68-16fb11960d94.ser differ diff --git a/discodeit/file-data-map/User/19ac7f8c-c079-435e-a6f0-1d07bc5c5722.ser b/discodeit/file-data-map/User/19ac7f8c-c079-435e-a6f0-1d07bc5c5722.ser new file mode 100644 index 00000000..634626cc Binary files /dev/null and b/discodeit/file-data-map/User/19ac7f8c-c079-435e-a6f0-1d07bc5c5722.ser differ diff --git a/discodeit/file-data-map/User/e62fcd9b-5a60-4a0e-8309-91fa9437439d.ser b/discodeit/file-data-map/User/e62fcd9b-5a60-4a0e-8309-91fa9437439d.ser new file mode 100644 index 00000000..04897e9a Binary files /dev/null and b/discodeit/file-data-map/User/e62fcd9b-5a60-4a0e-8309-91fa9437439d.ser differ diff --git a/discodeit/gradle/wrapper/gradle-wrapper.jar b/discodeit/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..249e5832 Binary files /dev/null and b/discodeit/gradle/wrapper/gradle-wrapper.jar differ diff --git a/discodeit/gradle/wrapper/gradle-wrapper.properties b/discodeit/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ce219115 --- /dev/null +++ b/discodeit/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 02 14:48:55 KST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/discodeit/gradlew b/discodeit/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/discodeit/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/discodeit/gradlew.bat b/discodeit/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/discodeit/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/discodeit/settings.gradle b/discodeit/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/discodeit/src/.DS_Store b/discodeit/src/.DS_Store new file mode 100644 index 00000000..ee0bfac7 Binary files /dev/null and b/discodeit/src/.DS_Store differ diff --git a/discodeit/src/main/.DS_Store b/discodeit/src/main/.DS_Store new file mode 100644 index 00000000..9c587049 Binary files /dev/null and b/discodeit/src/main/.DS_Store differ diff --git a/discodeit/src/main/java/.DS_Store b/discodeit/src/main/java/.DS_Store new file mode 100644 index 00000000..a2b4558a Binary files /dev/null and b/discodeit/src/main/java/.DS_Store differ diff --git a/discodeit/src/main/java/com/.DS_Store b/discodeit/src/main/java/com/.DS_Store new file mode 100644 index 00000000..e34b8cae Binary files /dev/null and b/discodeit/src/main/java/com/.DS_Store differ diff --git a/discodeit/src/main/java/com/sprint/.DS_Store b/discodeit/src/main/java/com/sprint/.DS_Store new file mode 100644 index 00000000..faa41c72 Binary files /dev/null and b/discodeit/src/main/java/com/sprint/.DS_Store differ diff --git a/discodeit/src/main/java/com/sprint/mission/.DS_Store b/discodeit/src/main/java/com/sprint/mission/.DS_Store new file mode 100644 index 00000000..66f2e4e6 Binary files /dev/null and b/discodeit/src/main/java/com/sprint/mission/.DS_Store differ diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java b/discodeit/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java new file mode 100644 index 00000000..b4870e6a --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java @@ -0,0 +1,46 @@ +package com.sprint.mission.discodeit; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.entity.ChannelType; +import com.sprint.mission.discodeit.entity.Message; +import com.sprint.mission.discodeit.entity.User; +import com.sprint.mission.discodeit.service.ChannelService; +import com.sprint.mission.discodeit.service.MessageService; +import com.sprint.mission.discodeit.service.UserService; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; + +@SpringBootApplication +public class DiscodeitApplication { + + public static void main(String[] args) { + ConfigurableApplicationContext context = SpringApplication.run(DiscodeitApplication.class, args); + + // ⭐️ Spring Context에서 Bean 조회 + UserService userService = context.getBean(UserService.class); + ChannelService channelService = context.getBean(ChannelService.class); + MessageService messageService = context.getBean(MessageService.class); + + // 이후 기존 JavaApplication에서 하던 테스트 코드 그대로 사용 + User user = setupUser(userService); + Channel channel = setupChannel(channelService); + messageCreateTest(messageService, channel, user); + + } + + static User setupUser(UserService userService) { + User user = userService.create("woody", "woody@codeit.com", "woody1234"); + return user; + } + + static Channel setupChannel(ChannelService channelService) { + Channel channel = channelService.create(ChannelType.PUBLIC, "공지", "공지 채널입니다."); + return channel; + } + + static void messageCreateTest(MessageService messageService, Channel channel, User author) { + Message message = messageService.create("안녕하세요.", channel.getId(), author.getId()); + System.out.println("메시지 생성: " + message.getId()); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/JavaApplication.java b/discodeit/src/main/java/com/sprint/mission/discodeit/JavaApplication.java new file mode 100644 index 00000000..599bfab6 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/JavaApplication.java @@ -0,0 +1,53 @@ +package com.sprint.mission.discodeit; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.entity.ChannelType; +import com.sprint.mission.discodeit.entity.Message; +import com.sprint.mission.discodeit.entity.User; +import com.sprint.mission.discodeit.repository.ChannelRepository; +import com.sprint.mission.discodeit.repository.MessageRepository; +import com.sprint.mission.discodeit.repository.UserRepository; +import com.sprint.mission.discodeit.repository.file.FileChannelRepository; +import com.sprint.mission.discodeit.repository.file.FileMessageRepository; +import com.sprint.mission.discodeit.repository.file.FileUserRepository; +import com.sprint.mission.discodeit.service.ChannelService; +import com.sprint.mission.discodeit.service.MessageService; +import com.sprint.mission.discodeit.service.UserService; +import com.sprint.mission.discodeit.service.basic.BasicChannelService; +import com.sprint.mission.discodeit.service.basic.BasicMessageService; +import com.sprint.mission.discodeit.service.basic.BasicUserService; + +public class JavaApplication { + static User setupUser(UserService userService) { + User user = userService.create("woody", "woody@codeit.com", "woody1234"); + return user; + } + + static Channel setupChannel(ChannelService channelService) { + Channel channel = channelService.create(ChannelType.PUBLIC, "공지", "공지 채널입니다."); + return channel; + } + + static void messageCreateTest(MessageService messageService, Channel channel, User author) { + Message message = messageService.create("안녕하세요.", channel.getId(), author.getId()); + System.out.println("메시지 생성: " + message.getId()); + } + + public static void main(String[] args) { + // 레포지토리 초기화 + UserRepository userRepository = new FileUserRepository(); + ChannelRepository channelRepository = new FileChannelRepository(); + MessageRepository messageRepository = new FileMessageRepository(); + + // 서비스 초기화 + UserService userService = new BasicUserService(userRepository); + ChannelService channelService = new BasicChannelService(channelRepository); + MessageService messageService = new BasicMessageService(messageRepository, channelRepository, userRepository); + + // 셋업 + User user = setupUser(userService); + Channel channel = setupChannel(channelService); + // 테스트 + messageCreateTest(messageService, channel, user); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserCreateDto.java b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserCreateDto.java new file mode 100644 index 00000000..90741441 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserCreateDto.java @@ -0,0 +1,7 @@ +package com.sprint.mission.discodeit.dto; + +public record UserCreateDto( + String username, + String email, + String password +) {} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserProfileDto.java b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserProfileDto.java new file mode 100644 index 00000000..3bbcc876 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserProfileDto.java @@ -0,0 +1,7 @@ +package com.sprint.mission.discodeit.dto; + +public record UserProfileDto( + String fileName, + byte[] bytes, + String contentType +) {} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserResponseDto.java b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserResponseDto.java new file mode 100644 index 00000000..e60a4261 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserResponseDto.java @@ -0,0 +1,11 @@ +package com.sprint.mission.discodeit.dto; + +import java.util.UUID; + +public record UserResponseDto( + UUID id, + String username, + String email, + boolean online, + UUID profileImageId +) {} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserUpdateDto.java b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserUpdateDto.java new file mode 100644 index 00000000..abae81b2 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/dto/UserUpdateDto.java @@ -0,0 +1,11 @@ +package com.sprint.mission.discodeit.dto; + +import java.util.UUID; + +public record UserUpdateDto( + UUID userId, + String username, + String email, + String password +) {} + diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java new file mode 100644 index 00000000..8ea792da --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java @@ -0,0 +1,37 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.time.Instant; +import java.util.UUID; + +@Getter +public class BinaryContent { + + private final UUID id; + private final Instant createdAt; + + private final UUID ownerUserId; // 프로필 이미지용 + private final UUID messageId; // 메시지 첨부용 + + private final String filename; + private final byte[] data; + private final String contentType; + + public BinaryContent( + UUID ownerUserId, + UUID messageId, + String filename, + byte[] data, + String contentType + ) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + this.ownerUserId = ownerUserId; + this.messageId = messageId; + this.filename = filename; + this.data = data; + this.contentType = contentType; + } + +} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Channel.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Channel.java new file mode 100644 index 00000000..157a76c0 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Channel.java @@ -0,0 +1,44 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; + +@Getter +public class Channel implements Serializable { + private static final long serialVersionUID = 1L; + private UUID id; + private Instant createdAt; + private Instant updatedAt; + // + private ChannelType type; + private String name; + private String description; + + public Channel(ChannelType type, String name, String description) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + this.type = type; + this.name = name; + this.description = description; + } + + + public void update(String newName, String newDescription) { + boolean anyValueUpdated = false; + if (newName != null && !newName.equals(this.name)) { + this.name = newName; + anyValueUpdated = true; + } + if (newDescription != null && !newDescription.equals(this.description)) { + this.description = newDescription; + anyValueUpdated = true; + } + + if (anyValueUpdated) { + this.updatedAt = Instant.now(); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java new file mode 100644 index 00000000..9a2ff3f0 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java @@ -0,0 +1,6 @@ +package com.sprint.mission.discodeit.entity; + +public enum ChannelType { + PUBLIC, + PRIVATE, +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Message.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Message.java new file mode 100644 index 00000000..94dba18e --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/Message.java @@ -0,0 +1,43 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; + +@Getter +public class Message implements Serializable { + private static final long serialVersionUID = 1L; + + private UUID id; + private Instant createdAt; + private Instant updatedAt; + // + private String content; + // + private UUID channelId; + private UUID authorId; + + public Message(String content, UUID channelId, UUID authorId) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + // + this.content = content; + this.channelId = channelId; + this.authorId = authorId; + } + + + public void update(String newContent) { + boolean anyValueUpdated = false; + if (newContent != null && !newContent.equals(this.content)) { + this.content = newContent; + anyValueUpdated = true; + } + + if (anyValueUpdated) { + this.updatedAt = Instant.now(); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java new file mode 100644 index 00000000..b9516934 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java @@ -0,0 +1,32 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.time.Instant; +import java.util.UUID; + +@Getter +public class ReadStatus { + + private final UUID id; + private final Instant createdAt; + private Instant updatedAt; + + private final UUID userId; + private final UUID channelId; + private Instant lastReadAt; + + public ReadStatus(UUID userId, UUID channelId, Instant lastReadAt) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + this.userId = userId; + this.channelId = channelId; + this.lastReadAt = lastReadAt; + this.updatedAt = this.createdAt; + } + + public void updateLastReadAt(Instant lastReadAt) { + this.lastReadAt = lastReadAt; + this.updatedAt = Instant.now(); + } +} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/User.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/User.java new file mode 100644 index 00000000..319f5ce7 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/User.java @@ -0,0 +1,49 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; + +@Getter +public class User implements Serializable { + private static final long serialVersionUID = 1L; + + private UUID id; + private Instant createdAt; + private Instant updatedAt; + // + private String username; + private String email; + private String password; + + public User(String username, String email, String password) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + // + this.username = username; + this.email = email; + this.password = password; + } + + public void update(String newUsername, String newEmail, String newPassword) { + boolean anyValueUpdated = false; + if (newUsername != null && !newUsername.equals(this.username)) { + this.username = newUsername; + anyValueUpdated = true; + } + if (newEmail != null && !newEmail.equals(this.email)) { + this.email = newEmail; + anyValueUpdated = true; + } + if (newPassword != null && !newPassword.equals(this.password)) { + this.password = newPassword; + anyValueUpdated = true; + } + + if (anyValueUpdated) { + this.updatedAt = Instant.now(); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java new file mode 100644 index 00000000..f609931c --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java @@ -0,0 +1,38 @@ +package com.sprint.mission.discodeit.entity; + +import lombok.Getter; + +import java.time.Duration; +import java.time.Instant; +import java.util.UUID; + +@Getter +public class UserStatus { + + private final UUID id; + private final Instant createdAt; + private Instant updatedAt; + + private final UUID userId; + private Instant lastActiveAt; + + public UserStatus(UUID userId) { + this.id = UUID.randomUUID(); + this.createdAt = Instant.now(); + this.userId = userId; + this.lastActiveAt = lastActiveAt; + this.updatedAt = this.createdAt; + } + + public void updateLastActiveAt(Instant time) { + this.lastActiveAt = time; + this.updatedAt = Instant.now(); + } + + /** + * 마지막 접속이 5분 이내면 온라인 + */ + public boolean isOnline() { + return Duration.between(lastActiveAt, Instant.now()).toMinutes() < 5; + } +} \ No newline at end of file diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java new file mode 100644 index 00000000..326a84f4 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.repository; + +import com.sprint.mission.discodeit.entity.Channel; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface ChannelRepository { + Channel save(Channel channel); + Optional findById(UUID id); + List findAll(); + boolean existsById(UUID id); + void deleteById(UUID id); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java new file mode 100644 index 00000000..1477de72 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.repository; + +import com.sprint.mission.discodeit.entity.Message; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface MessageRepository { + Message save(Message message); + Optional findById(UUID id); + List findAll(); + boolean existsById(UUID id); + void deleteById(UUID id); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/BinaryContentRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/BinaryContentRepository.java new file mode 100644 index 00000000..ce70458a --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/BinaryContentRepository.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.repository.User; + +import com.sprint.mission.discodeit.entity.BinaryContent; + +import java.util.Optional; +import java.util.UUID; + +public interface BinaryContentRepository { + + BinaryContent save(BinaryContent content); + + Optional findById(UUID id); + + void deleteByOwnerId(UUID ownerId); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/UserStatusRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/UserStatusRepository.java new file mode 100644 index 00000000..2acb5f9f --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/User/UserStatusRepository.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.repository.User; + +import com.sprint.mission.discodeit.entity.UserStatus; + +import java.util.Optional; +import java.util.UUID; + +public interface UserStatusRepository { + + UserStatus save(UserStatus userStatus); + + Optional findByUserId(UUID userId); + + void deleteByUserId(UUID userId); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java new file mode 100644 index 00000000..ebdbcb9e --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.repository; + +import com.sprint.mission.discodeit.entity.User; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface UserRepository { + User save(User user); + Optional findById(UUID id); + List findAll(); + boolean existsById(UUID id); + void deleteById(UUID id); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java new file mode 100644 index 00000000..20fac7cf --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java @@ -0,0 +1,103 @@ +package com.sprint.mission.discodeit.repository.file; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.repository.ChannelRepository; +import org.springframework.stereotype.Repository; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Repository +public class FileChannelRepository implements ChannelRepository { + private final Path DIRECTORY; + private final String EXTENSION = ".ser"; + + public FileChannelRepository() { + this.DIRECTORY = Paths.get(System.getProperty("user.dir"), "file-data-map", Channel.class.getSimpleName()); + if (Files.notExists(DIRECTORY)) { + try { + Files.createDirectories(DIRECTORY); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + private Path resolvePath(UUID id) { + + return DIRECTORY.resolve(id + EXTENSION); + } + + @Override + public Channel save(Channel channel) { + Path path = resolvePath(channel.getId()); + try ( + FileOutputStream fos = new FileOutputStream(path.toFile()); + ObjectOutputStream oos = new ObjectOutputStream(fos) + ) { + oos.writeObject(channel); + } catch (IOException e) { + throw new RuntimeException(e); + } + return channel; + } + + @Override + public Optional findById(UUID id) { + Channel channelNullable = null; + Path path = resolvePath(id); + if (Files.exists(path)) { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + channelNullable = (Channel) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + return Optional.ofNullable(channelNullable); + } + + @Override + public List findAll() { + try { + return Files.list(DIRECTORY) + .filter(path -> path.toString().endsWith(EXTENSION)) + .map(path -> { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + return (Channel) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + }) + .toList(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean existsById(UUID id) { + Path path = resolvePath(id); + return Files.exists(path); + } + + @Override + public void deleteById(UUID id) { + Path path = resolvePath(id); + try { + Files.delete(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java new file mode 100644 index 00000000..a85d7a3a --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java @@ -0,0 +1,103 @@ +package com.sprint.mission.discodeit.repository.file; + +import com.sprint.mission.discodeit.entity.Message; +import com.sprint.mission.discodeit.repository.MessageRepository; +import org.springframework.stereotype.Repository; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Repository +public class FileMessageRepository implements MessageRepository { + private final Path DIRECTORY; + private final String EXTENSION = ".ser"; + + public FileMessageRepository() { + this.DIRECTORY = Paths.get(System.getProperty("user.dir"), "file-data-map", Message.class.getSimpleName()); + if (Files.notExists(DIRECTORY)) { + try { + Files.createDirectories(DIRECTORY); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + private Path resolvePath(UUID id) { + + return DIRECTORY.resolve(id + EXTENSION); + } + + @Override + public Message save(Message message) { + Path path = resolvePath(message.getId()); + try ( + FileOutputStream fos = new FileOutputStream(path.toFile()); + ObjectOutputStream oos = new ObjectOutputStream(fos) + ) { + oos.writeObject(message); + } catch (IOException e) { + throw new RuntimeException(e); + } + return message; + } + + @Override + public Optional findById(UUID id) { + Message messageNullable = null; + Path path = resolvePath(id); + if (Files.exists(path)) { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + messageNullable = (Message) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + return Optional.ofNullable(messageNullable); + } + + @Override + public List findAll() { + try { + return Files.list(DIRECTORY) + .filter(path -> path.toString().endsWith(EXTENSION)) + .map(path -> { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + return (Message) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + }) + .toList(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean existsById(UUID id) { + Path path = resolvePath(id); + return Files.exists(path); + } + + @Override + public void deleteById(UUID id) { + Path path = resolvePath(id); + try { + Files.delete(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java new file mode 100644 index 00000000..05e9e975 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java @@ -0,0 +1,104 @@ +package com.sprint.mission.discodeit.repository.file; + +import com.sprint.mission.discodeit.entity.User; +import com.sprint.mission.discodeit.repository.UserRepository; +import org.springframework.stereotype.Repository; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + + +@Repository +public class FileUserRepository implements UserRepository { + private final Path DIRECTORY; + private final String EXTENSION = ".ser"; + + public FileUserRepository() { + this.DIRECTORY = Paths.get(System.getProperty("user.dir"), "file-data-map", User.class.getSimpleName()); + if (Files.notExists(DIRECTORY)) { + try { + Files.createDirectories(DIRECTORY); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + private Path resolvePath(UUID id) { + + return DIRECTORY.resolve(id + EXTENSION); + } + + @Override + public User save(User user) { + Path path = resolvePath(user.getId()); + try ( + FileOutputStream fos = new FileOutputStream(path.toFile()); + ObjectOutputStream oos = new ObjectOutputStream(fos) + ) { + oos.writeObject(user); + } catch (IOException e) { + throw new RuntimeException(e); + } + return user; + } + + @Override + public Optional findById(UUID id) { + User userNullable = null; + Path path = resolvePath(id); + if (Files.exists(path)) { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + userNullable = (User) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + return Optional.ofNullable(userNullable); + } + + @Override + public List findAll() { + try { + return Files.list(DIRECTORY) + .filter(path -> path.toString().endsWith(EXTENSION)) + .map(path -> { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + return (User) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + }) + .toList(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean existsById(UUID id) { + Path path = resolvePath(id); + return Files.exists(path); + } + + @Override + public void deleteById(UUID id) { + Path path = resolvePath(id); + try { + Files.delete(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java new file mode 100644 index 00000000..e11c92da --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java @@ -0,0 +1,40 @@ +package com.sprint.mission.discodeit.repository.jcf; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.repository.ChannelRepository; + +import java.util.*; + +public class JCFChannelRepository implements ChannelRepository { + private final Map data; + + public JCFChannelRepository() { + this.data = new HashMap<>(); + } + + @Override + public Channel save(Channel channel) { + this.data.put(channel.getId(), channel); + return channel; + } + + @Override + public Optional findById(UUID id) { + return Optional.ofNullable(this.data.get(id)); + } + + @Override + public List findAll() { + return this.data.values().stream().toList(); + } + + @Override + public boolean existsById(UUID id) { + return this.data.containsKey(id); + } + + @Override + public void deleteById(UUID id) { + this.data.remove(id); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java new file mode 100644 index 00000000..5ad8b355 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java @@ -0,0 +1,40 @@ +package com.sprint.mission.discodeit.repository.jcf; + +import com.sprint.mission.discodeit.entity.Message; +import com.sprint.mission.discodeit.repository.MessageRepository; + +import java.util.*; + +public class JCFMessageRepository implements MessageRepository { + private final Map data; + + public JCFMessageRepository() { + this.data = new HashMap<>(); + } + + @Override + public Message save(Message message) { + this.data.put(message.getId(), message); + return message; + } + + @Override + public Optional findById(UUID id) { + return Optional.ofNullable(this.data.get(id)); + } + + @Override + public List findAll() { + return this.data.values().stream().toList(); + } + + @Override + public boolean existsById(UUID id) { + return this.data.containsKey(id); + } + + @Override + public void deleteById(UUID id) { + this.data.remove(id); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java new file mode 100644 index 00000000..a60363a3 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java @@ -0,0 +1,40 @@ +package com.sprint.mission.discodeit.repository.jcf; + +import com.sprint.mission.discodeit.entity.User; +import com.sprint.mission.discodeit.repository.UserRepository; + +import java.util.*; + +public class JCFUserRepository implements UserRepository { + private final Map data; + + public JCFUserRepository() { + this.data = new HashMap<>(); + } + + @Override + public User save(User user) { + this.data.put(user.getId(), user); + return user; + } + + @Override + public Optional findById(UUID id) { + return Optional.ofNullable(this.data.get(id)); + } + + @Override + public List findAll() { + return this.data.values().stream().toList(); + } + + @Override + public boolean existsById(UUID id) { + return this.data.containsKey(id); + } + + @Override + public void deleteById(UUID id) { + this.data.remove(id); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java new file mode 100644 index 00000000..eaa8e07d --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java @@ -0,0 +1,15 @@ +package com.sprint.mission.discodeit.service; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.entity.ChannelType; + +import java.util.List; +import java.util.UUID; + +public interface ChannelService { + Channel create(ChannelType type, String name, String description); + Channel find(UUID channelId); + List findAll(); + Channel update(UUID channelId, String newName, String newDescription); + void delete(UUID channelId); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/MessageService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/MessageService.java new file mode 100644 index 00000000..e7662d0c --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/MessageService.java @@ -0,0 +1,14 @@ +package com.sprint.mission.discodeit.service; + +import com.sprint.mission.discodeit.entity.Message; + +import java.util.List; +import java.util.UUID; + +public interface MessageService { + Message create(String content, UUID channelId, UUID authorId); + Message find(UUID messageId); + List findAll(); + Message update(UUID messageId, String newContent); + void delete(UUID messageId); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/UserService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/UserService.java new file mode 100644 index 00000000..79111d55 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/UserService.java @@ -0,0 +1,14 @@ +package com.sprint.mission.discodeit.service; + +import com.sprint.mission.discodeit.entity.User; + +import java.util.List; +import java.util.UUID; + +public interface UserService { + User create(String username, String email, String password); + User find(UUID userId); + List findAll(); + User update(UUID userId, String newUsername, String newEmail, String newPassword); + void delete(UUID userId); +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java new file mode 100644 index 00000000..e83ad39d --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java @@ -0,0 +1,51 @@ +package com.sprint.mission.discodeit.service.basic; + +import com.sprint.mission.discodeit.entity.Channel; +import com.sprint.mission.discodeit.entity.ChannelType; +import com.sprint.mission.discodeit.repository.ChannelRepository; +import com.sprint.mission.discodeit.service.ChannelService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.NoSuchElementException; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class BasicChannelService implements ChannelService { + private final ChannelRepository channelRepository; + + @Override + public Channel create(ChannelType type, String name, String description) { + Channel channel = new Channel(type, name, description); + return channelRepository.save(channel); + } + + @Override + public Channel find(UUID channelId) { + return channelRepository.findById(channelId) + .orElseThrow(() -> new NoSuchElementException("Channel with id " + channelId + " not found")); + } + + @Override + public List findAll() { + return channelRepository.findAll(); + } + + @Override + public Channel update(UUID channelId, String newName, String newDescription) { + Channel channel = channelRepository.findById(channelId) + .orElseThrow(() -> new NoSuchElementException("Channel with id " + channelId + " not found")); + channel.update(newName, newDescription); + return channelRepository.save(channel); + } + + @Override + public void delete(UUID channelId) { + if (!channelRepository.existsById(channelId)) { + throw new NoSuchElementException("Channel with id " + channelId + " not found"); + } + channelRepository.deleteById(channelId); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java new file mode 100644 index 00000000..ca66ed8c --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java @@ -0,0 +1,63 @@ +package com.sprint.mission.discodeit.service.basic; + +import com.sprint.mission.discodeit.entity.Message; +import com.sprint.mission.discodeit.repository.ChannelRepository; +import com.sprint.mission.discodeit.repository.MessageRepository; +import com.sprint.mission.discodeit.repository.UserRepository; +import com.sprint.mission.discodeit.service.MessageService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class BasicMessageService implements MessageService { + private final MessageRepository messageRepository; + // + private final ChannelRepository channelRepository; + private final UserRepository userRepository; + + @Override + public Message create(String content, UUID channelId, UUID authorId) { + if (!channelRepository.existsById(channelId)) { + throw new NoSuchElementException("Channel not found with id " + channelId); + } + if (!userRepository.existsById(authorId)) { + throw new NoSuchElementException("Author not found with id " + authorId); + } + + Message message = new Message(content, channelId, authorId); + return messageRepository.save(message); + } + + @Override + public Message find(UUID messageId) { + return messageRepository.findById(messageId) + .orElseThrow(() -> new NoSuchElementException("Message with id " + messageId + " not found")); + } + + @Override + public List findAll() { + return messageRepository.findAll(); + } + + @Override + public Message update(UUID messageId, String newContent) { + Message message = messageRepository.findById(messageId) + .orElseThrow(() -> new NoSuchElementException("Message with id " + messageId + " not found")); + message.update(newContent); + return messageRepository.save(message); + } + + @Override + public void delete(UUID messageId) { + if (!messageRepository.existsById(messageId)) { + throw new NoSuchElementException("Message with id " + messageId + " not found"); + } + messageRepository.deleteById(messageId); + } +} diff --git a/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java new file mode 100644 index 00000000..817ff754 --- /dev/null +++ b/discodeit/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java @@ -0,0 +1,160 @@ +package com.sprint.mission.discodeit.service.basic; + +import com.sprint.mission.discodeit.dto.UserProfileDto; +import com.sprint.mission.discodeit.dto.UserResponseDto; +import com.sprint.mission.discodeit.dto.UserUpdateDto; +import com.sprint.mission.discodeit.entity.BinaryContent; +import com.sprint.mission.discodeit.entity.User; +import com.sprint.mission.discodeit.entity.UserStatus; +import com.sprint.mission.discodeit.repository.User.BinaryContentRepository; +import com.sprint.mission.discodeit.repository.User.UserStatusRepository; +import com.sprint.mission.discodeit.repository.UserRepository; +import com.sprint.mission.discodeit.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.NoSuchElementException; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class BasicUserService implements UserService { + private final UserRepository userRepository; + private final BinaryContentRepository binaryContentRepository; + private final UserStatusRepository userStatusRepository; + + /* ====================== + CREATE + ====================== */ + @Override + public UserResponse create( + UserCreateRequest userRequest, + ProfileImageRequest imageRequest + ) { + if (userRepository.existsByUsername(userRequest.username())) { + throw new IllegalArgumentException("Username already exists"); + } + if (userRepository.existsByEmail(userRequest.email())) { + throw new IllegalArgumentException("Email already exists"); + } + + User user = new User( + userRequest.username(), + userRequest.email(), + userRequest.password() + ); + userRepository.save(user); + + UserStatus status = new UserStatus(user.getId()); + userStatusRepository.save(status); + +// UUID profileImageId = null; +// if (imageRequest != null) { +// +// } +// +// return new UserResponse( +// user.getId(), +// user.getUsername(), +// user.getEmail(), +// status.isOnline(), +// profileImageId +// ); +// } + + /* ====================== + FIND + ====================== */ + @Override + public UserResponseDto find(UUID userId) { + User user = userRepository.findById(userId) + .orElseThrow(() -> new NoSuchElementException("User not found")); + + UserStatus status = userStatusRepository.findByUserId(userId) + .orElseThrow(); + + return new UserResponse( + user.getId(), + user.getUsername(), + user.getEmail(), + status.isOnline(), + user.getProfileImageId() + ); + } + + @Override + public List findAll() { + return userRepository.findAll().stream() + .map(user -> { + UserStatus status = userStatusRepository + .findByUserId(user.getId()) + .orElseThrow(); + + return new UserResponse( + user.getId(), + user.getUsername(), + user.getEmail(), + status.isOnline(), + user.getProfileImageId() + ); + }) + .toList(); + } + + /* ====================== + UPDATE + ====================== */ + @Override + public UserResponseDto update( + UserUpdateDto request, + UserProfileDto imageRequest + ) { + User user = userRepository.findById(request.userId()) + .orElseThrow(() -> new NoSuchElementException("User not found")); + + user.update( + request.username(), + request.email(), + request.password() + ); + userRepository.save(user); + + if (imageRequest != null) { + binaryContentRepository.deleteByOwnerId(user.getId()); + + BinaryContent newImage = new BinaryContent( + imageRequest.fileName(), + imageRequest.bytes(), + imageRequest.contentType(), + user.getId() + ); + binaryContentRepository.save(newImage); + } + + UserStatus status = userStatusRepository + .findByUserId(user.getId()) + .orElseThrow(); + + return new UserResponse( + user.getId(), + user.getUsername(), + user.getEmail(), + status.isOnline(), + user.getProfileImageId() + ); + } + + /* ====================== + DELETE + ====================== */ + @Override + public void delete(UUID userId) { + userStatusRepository.deleteByUserId(userId); + binaryContentRepository.deleteByOwnerId(userId); + userRepository.deleteById(userId); + } + + + +} diff --git a/discodeit/src/main/resources/application.properties b/discodeit/src/main/resources/application.properties new file mode 100644 index 00000000..545cf9f0 --- /dev/null +++ b/discodeit/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=discodeit diff --git a/discodeit/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java b/discodeit/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java new file mode 100644 index 00000000..3a987a21 --- /dev/null +++ b/discodeit/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java @@ -0,0 +1,13 @@ +package com.sprint.mission.discodeit; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DiscodeitApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/discordit.iml b/discordit.iml new file mode 100644 index 00000000..e6db0928 --- /dev/null +++ b/discordit.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/discordit/.gradle/9.0.0/checksums/checksums.lock b/discordit/.gradle/9.0.0/checksums/checksums.lock new file mode 100644 index 00000000..81351ce2 Binary files /dev/null and b/discordit/.gradle/9.0.0/checksums/checksums.lock differ diff --git a/discordit/.gradle/9.0.0/executionHistory/executionHistory.bin b/discordit/.gradle/9.0.0/executionHistory/executionHistory.bin new file mode 100644 index 00000000..c040c2da Binary files /dev/null and b/discordit/.gradle/9.0.0/executionHistory/executionHistory.bin differ diff --git a/discordit/.gradle/9.0.0/executionHistory/executionHistory.lock b/discordit/.gradle/9.0.0/executionHistory/executionHistory.lock new file mode 100644 index 00000000..dd66098c Binary files /dev/null and b/discordit/.gradle/9.0.0/executionHistory/executionHistory.lock differ diff --git a/discordit/.gradle/9.0.0/fileChanges/last-build.bin b/discordit/.gradle/9.0.0/fileChanges/last-build.bin new file mode 100644 index 00000000..f76dd238 Binary files /dev/null and b/discordit/.gradle/9.0.0/fileChanges/last-build.bin differ diff --git a/discordit/.gradle/9.0.0/fileHashes/fileHashes.bin b/discordit/.gradle/9.0.0/fileHashes/fileHashes.bin new file mode 100644 index 00000000..4b1aae58 Binary files /dev/null and b/discordit/.gradle/9.0.0/fileHashes/fileHashes.bin differ diff --git a/discordit/.gradle/9.0.0/fileHashes/fileHashes.lock b/discordit/.gradle/9.0.0/fileHashes/fileHashes.lock new file mode 100644 index 00000000..ab39f30a Binary files /dev/null and b/discordit/.gradle/9.0.0/fileHashes/fileHashes.lock differ diff --git a/discordit/.gradle/9.0.0/fileHashes/resourceHashesCache.bin b/discordit/.gradle/9.0.0/fileHashes/resourceHashesCache.bin new file mode 100644 index 00000000..df879a7c Binary files /dev/null and b/discordit/.gradle/9.0.0/fileHashes/resourceHashesCache.bin differ diff --git a/discordit/.gradle/9.0.0/gc.properties b/discordit/.gradle/9.0.0/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discordit/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/discordit/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 00000000..2c43e9d1 Binary files /dev/null and b/discordit/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/discordit/.gradle/buildOutputCleanup/cache.properties b/discordit/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 00000000..1928a7b3 --- /dev/null +++ b/discordit/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri Jan 09 14:23:24 KST 2026 +gradle.version=9.0.0 diff --git a/discordit/.gradle/buildOutputCleanup/outputFiles.bin b/discordit/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 00000000..4e120419 Binary files /dev/null and b/discordit/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/discordit/.gradle/file-system.probe b/discordit/.gradle/file-system.probe new file mode 100644 index 00000000..ded2f97a Binary files /dev/null and b/discordit/.gradle/file-system.probe differ diff --git a/discordit/.gradle/vcs-1/gc.properties b/discordit/.gradle/vcs-1/gc.properties new file mode 100644 index 00000000..e69de29b diff --git a/discordit/build.gradle b/discordit/build.gradle new file mode 100644 index 00000000..973cc485 --- /dev/null +++ b/discordit/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java' +} + +group = 'org.example' +version = '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform('org.junit:junit-bom:5.10.0') + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/discordit/build/reports/problems/problems-report.html b/discordit/build/reports/problems/problems-report.html new file mode 100644 index 00000000..2e25a546 --- /dev/null +++ b/discordit/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/discordit/gradle/wrapper/gradle-wrapper.jar b/discordit/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..8bdaf60c Binary files /dev/null and b/discordit/gradle/wrapper/gradle-wrapper.jar differ diff --git a/discordit/gradle/wrapper/gradle-wrapper.properties b/discordit/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..2a84e188 --- /dev/null +++ b/discordit/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/discordit/gradlew b/discordit/gradlew new file mode 100755 index 00000000..ef07e016 --- /dev/null +++ b/discordit/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/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="\\\"\\\"" + + +# 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" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/discordit/gradlew.bat b/discordit/gradlew.bat new file mode 100644 index 00000000..5eed7ee8 --- /dev/null +++ b/discordit/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= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/discordit/settings.gradle b/discordit/settings.gradle new file mode 100644 index 00000000..955baf54 --- /dev/null +++ b/discordit/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'discordit' \ No newline at end of file diff --git a/discordit/src/main/java/JavaApplication.java b/discordit/src/main/java/JavaApplication.java new file mode 100644 index 00000000..cedbb8e4 --- /dev/null +++ b/discordit/src/main/java/JavaApplication.java @@ -0,0 +1,194 @@ +import entity.Channel; +import entity.User; +import entity.Message; + +import service.ChannelService; +import service.MessageService; +import service.UserService; + +import service.jcf.JCFUserService; +import service.jcf.JCFChannelService; +import service.jcf.JCFMessageService; + +import java.util.List; +import java.util.UUID; + + +public class JavaApplication { + static void userCRUDTest(UserService userService) { + + User user1 = userService.addUser("임혜민", "ellen@gmail.com","010-1111-1111"); + User user2 = userService.addUser("홍길동", "david@gmail.com","010-2222-2222"); + + //중복 확인 +// User user3 = userService.addUser("임혜민", "ellen@naver.com","010-4444-4444"); +// System.out.println(user3); + + //유저 생성 CREATE + /* + boolean addFlag = userService.addUser(user1); + if(addFlag) + System.out.println("========== <<추가 완료>> =========="); + else + System.out.println("========== <<추가 실패>> =========="); + + boolean addFlag2 = userService.addUser(user2); + if(addFlag2) + System.out.println("========== <<추가 완료>> =========="); + else + System.out.println("========== <<추가 실패>> =========="); +*/ + System.out.println("======= (CREATE)유저 생성 ======="); + System.out.println("유저 생성: " + user1.getId()); + System.out.println("유저 생성: " + user2.getId()); + + //중복확인 확인하기 + + System.out.println("======= (CREATE)중복 유저 ======="); + try { + User user3 = userService.addUser("임혜민", "ellen@naver.com","010-4444-4444"); + } + catch (IllegalStateException e){ + System.out.println(); + System.out.println(e.getMessage()); + + } + + //System.out.println("유저 생성: " + user3.getId()); + + //유저 조회 READ, user2에 대한 정보를 조회한다. + User foundUser = userService.getUser(user2.getId()); + System.out.println("======= (READ)유저2 정보 조회 ======="); + System.out.println("유저 ID : "+ foundUser.getId()); + System.out.println("개인유저 정보 조회: \n"+ foundUser); + + //유저 전체목록 조회 READ ALL + System.out.println("======= (READ)전체유저 조회 ======="); + List foundUsers = userService.getAllUser(); + for (User user : foundUsers) { + System.out.println(user); + } + + //System.out.println(userService.getAllUser()); + System.out.println("전체 유저수 : " + foundUsers.size() ); + + //수정 및 조회 + userService.updateUser( + user1.getId(), + "임혜민수정", + "ELLEN@gmail.com", + "010-3333-3333" + ); + System.out.println("======= (UPDATE)유저 수정 ======="); + System.out.println(userService.getUser(user1.getId())); + + //유저 삭제 DELETE + userService.deleteUser(user2.getId()); + List removeUser = userService.getAllUser(); + System.out.println("======= (REMAIN)남은 유저 ======="); + System.out.println(removeUser); + System.out.println("남은 유저수 : " + removeUser.size()); + + + } + + static void channelCRUDTest(ChannelService channelService){ + + //채널 생성 CREATE + //ChannelType.PUBLIC(채널의 공개여부) < foundChannels = channelService.getAllChannel(); + for (Channel channel : foundChannels) { + System.out.println(channel); + } + //System.out.println(channelService.getAllChannel()); + System.out.println("전체 채널수 : " + foundChannels.size()); + + //채널 수정 UPDATE + Channel updatedChannel = channelService.updateChannel( + channel1.getId(), + "공지방", + "이곳은 공지를 작성하는 방입니다." + ); + System.out.println("======= (UPDATE)채널 수정 ======="); +// System.out.println(updatedChannel.getChannelName() +"\n"+ updatedChannel.getDescription()); + System.out.println(channelService.getChannel(channel1.getId())); + + //채널 삭제 DELETE + channelService.deleteChannel(channel1.getId()); + List removeChannel = channelService.getAllChannel(); + System.out.println("======= (REMAIN)남은 채널 ======="); + System.out.println(removeChannel); + System.out.println("남은 채널수 : " + removeChannel.size()); + + + + } + + static void messageCRUDTest(MessageService messageService) { + UUID channelId = UUID.randomUUID(); + UUID authorId = UUID.randomUUID(); + + //메세지 생성 + Message message1 = messageService.addMessage("저는 임헤민입니다.", channelId, authorId); + Message message2 = messageService.addMessage("Hello, my name is Ellen", channelId, authorId); + System.out.println("======= (CREATE)메세지 생성 ======="); + System.out.println("메세지 생성: " + message1.getId()); + System.out.println("메세지 생성: " + message2.getId()); + + //단건 조회 + // message변수의 id를 getID메소드를 통해 불러와서 그 값으로 + // getMessage메소드에서 해당 ID값에 해당하는 메세지 정보를 찾아서 foundMessage에 저장 + Message foundMessage = messageService.getMessage(message2.getId()); + System.out.println("======= (READ)메시지 조회 ======="); + System.out.println("메세지 ID : " + foundMessage.getId()); + System.out.println("개인유저 정보 조회: \n"+ foundMessage); + + //다건 조회 + System.out.println("======= (READ)전체 메세지 ======="); + List messages = messageService.getAllMessage(); + System.out.println(messageService.getAllMessage()); + System.out.println("전체 메세지수 : " + messages.size()); + + //메세지 수정 + messageService.updateMessage(message1.getId(), "다들 반갑습니다!!!"); + System.out.println("======= (UPDATE)메세지 수정 ======="); + System.out.println(messageService.getMessage(message1.getId())); + + + //메세지 삭제 + messageService.deleteMessage(message2.getId()); + List removeMessage = messageService.getAllMessage(); + System.out.println("======= (REMAIN)남은 메세지 ======="); + System.out.println(removeMessage); + System.out.println("남은 메세지수 : " + removeMessage.size()); + + } + + public static void main(String[] args) { + // 서비스 초기화 + UserService userService = new JCFUserService(); + ChannelService channelService = new JCFChannelService(); + MessageService messageService = new JCFMessageService(userService,channelService); + + // 테스트 + userCRUDTest(userService); + channelCRUDTest(channelService); + messageCRUDTest(messageService); + } + +} diff --git a/discordit/src/main/java/entity/Channel.java b/discordit/src/main/java/entity/Channel.java new file mode 100644 index 00000000..63a1e8c4 --- /dev/null +++ b/discordit/src/main/java/entity/Channel.java @@ -0,0 +1,72 @@ +package entity; + +import java.util.UUID; + +public class Channel { + + public enum ChannelType { + PUBLIC, + PRIVATE + } + + private final UUID id; + private Long createdAt; + private Long updatedAt; + private String channelName; + private String description; + private ChannelType channelType; + + + + + //더 낮은 시간대로 내려가면 차이가 있기 않겠냐 + // + + public Channel(ChannelType channelType, String channelName, String description) { + this.id = UUID.randomUUID(); + + this.createdAt = System.currentTimeMillis(); + this.updatedAt = System.currentTimeMillis(); + this.channelName = channelName; + this.description = description; + } + + public UUID getId() { + return id; + } + + public Long getCreatedAt() { + return createdAt; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public String getChannelName() { + return channelName; + } + + public String getDescription() { + return description; + } + + public void updateChannel(String channelName, String description){ + this.channelName = channelName; + this.description = description; + this.updatedAt = System.currentTimeMillis(); + } + + @Override + public String toString() { + return + "[Channel정보] \n"+ + "createdAt : " + createdAt +"\n"+ + "updatedAt : " + updatedAt +"\n"+ + "C.id : " + id + "\n"+ + "channelName : " + channelName + "\n"+ + "description : " + description + '\n' + + ; + } +} diff --git a/discordit/src/main/java/entity/Message.java b/discordit/src/main/java/entity/Message.java new file mode 100644 index 00000000..8be50565 --- /dev/null +++ b/discordit/src/main/java/entity/Message.java @@ -0,0 +1,65 @@ +package entity; + +import java.util.UUID; + +public class Message { + private final UUID id; + private final Long createdAt; + private Long updatedAt; + + private String newMessage; + private UUID channelId; + private UUID authorId; + + public Message(String newMessage, UUID channelId, UUID authorId) { + this.id = UUID.randomUUID(); + this.createdAt = System.currentTimeMillis(); + this.updatedAt = System.currentTimeMillis(); + this.newMessage = newMessage; + this.channelId = channelId; + this.authorId = authorId; + } + + public UUID getId() { + return id; + } + + public Long getCreatedAt() { + return createdAt; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public String getMessage() { + return newMessage; + } + + public UUID getChannelId() { + return channelId; + } + + public UUID getAuthorId() { + return authorId; + } + + public void getAllMessage(){ } + + public void updateMessage(UUID id, String newMessage){ + this.newMessage = newMessage; + this.updatedAt = System.currentTimeMillis(); + } + + @Override + public String toString() { + return + "[Message정보] \n"+ + "createdAt : " + createdAt +"\n"+ + "updatedAt : " + updatedAt +"\n"+ + "M.id : " + id + "\n"+ + "message : " + newMessage + "\n" + ; + } + +} diff --git a/discordit/src/main/java/entity/User.java b/discordit/src/main/java/entity/User.java new file mode 100644 index 00000000..b809ddf1 --- /dev/null +++ b/discordit/src/main/java/entity/User.java @@ -0,0 +1,73 @@ +package entity; + +import java.util.UUID; + +public class User { + private final UUID id; + private final Long createdAt; + private Long updatedAt; + + //추가적으로 필요한 필드들 추가. 예시) 유저네임, + private String displayName; + private String email; + private String phoneNumber; + + //생성자 메소드 + public User(String displayName, String email, String phoneNumber) { + this.id = UUID.randomUUID(); + this.displayName = displayName; + this.email = email; + this.phoneNumber = phoneNumber; + this.createdAt = System.currentTimeMillis(); + this.updatedAt = System.currentTimeMillis(); + } + + public UUID getId() { + return id; + } + + public Long getCreatedAt() { + return createdAt; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public String getDisplayName() { + return displayName; + } + + public String getEmail() { + return email; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void getAllUser() { + } + + //TODO 업데이트 추가 + + public void updateUser(UUID id, String displayName, String email, String phoneNumber){ + this.displayName = displayName; + this.email = email; + this.phoneNumber = phoneNumber; + this.updatedAt = System.currentTimeMillis(); + } + + @Override + public String toString() { + return + "[User정보] \n"+ + "createdAt : " + createdAt +"\n"+ + "updatedAt : " + updatedAt +"\n"+ + "U.id : " + id + "\n"+ + "name : " + displayName + "\n"+ + "email : " + email + '\n' + + "phoneNumber : " + phoneNumber + '\n' + ; + } +} diff --git a/discordit/src/main/java/repository/ChannelRepository.java b/discordit/src/main/java/repository/ChannelRepository.java new file mode 100644 index 00000000..f8ebf28d --- /dev/null +++ b/discordit/src/main/java/repository/ChannelRepository.java @@ -0,0 +1,4 @@ +package repository; + +public interface ChannelRepository { +} diff --git a/discordit/src/main/java/repository/MessageRepository.java b/discordit/src/main/java/repository/MessageRepository.java new file mode 100644 index 00000000..a6635bac --- /dev/null +++ b/discordit/src/main/java/repository/MessageRepository.java @@ -0,0 +1,4 @@ +package repository; + +public interface MessageRepository { +} diff --git a/discordit/src/main/java/repository/UserRepository.java b/discordit/src/main/java/repository/UserRepository.java new file mode 100644 index 00000000..e3c7da09 --- /dev/null +++ b/discordit/src/main/java/repository/UserRepository.java @@ -0,0 +1,18 @@ +package repository; + +import entity.User; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface UserRepository { + User addUser(String displayName, String email, String phoneNumber); + Optional getUser(UUID id); + List getAllUser(); + +// boolean existsById(UUID id); + void deleteUser(UUID id); + + boolean existsByDisplayName(String displayName); +} \ No newline at end of file diff --git a/discordit/src/main/java/repository/file/FileChannelRepository.java b/discordit/src/main/java/repository/file/FileChannelRepository.java new file mode 100644 index 00000000..962b83cb --- /dev/null +++ b/discordit/src/main/java/repository/file/FileChannelRepository.java @@ -0,0 +1,4 @@ +package repository.file; + +public class FileChannelRepository { +} diff --git a/discordit/src/main/java/repository/file/FileMessageRepository.java b/discordit/src/main/java/repository/file/FileMessageRepository.java new file mode 100644 index 00000000..1cfd0b9e --- /dev/null +++ b/discordit/src/main/java/repository/file/FileMessageRepository.java @@ -0,0 +1,4 @@ +package repository.file; + +public class FileMessageRepository { +} diff --git a/discordit/src/main/java/repository/file/FileUserRepository.java b/discordit/src/main/java/repository/file/FileUserRepository.java new file mode 100644 index 00000000..ad9a5163 --- /dev/null +++ b/discordit/src/main/java/repository/file/FileUserRepository.java @@ -0,0 +1,65 @@ +package repository.file; + +import entity.User; +import repository.UserRepository; + +import java.io.*; +import java.util.*; + +public class FileUserRepository implements UserRepository { + + private final File file = new File("users.dat"); + + private Map load() { + if (!file.exists()) return new HashMap<>(); + + try (ObjectInputStream ois = + new ObjectInputStream(new FileInputStream(file))) { + return (Map) ois.readObject(); + } catch (Exception e) { + return new HashMap<>(); + } + } + + private void saveFile(Map data) { + try (ObjectOutputStream oos = + new ObjectOutputStream(new FileOutputStream(file))) { + oos.writeObject(data); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public User addUser(String displayName, String email, String phoneNumber) { + Map data = load(); + User user = new User(displayName, email, phoneNumber); + data.put(user.getId(), user); + saveFile(data); + + return user; + } + + @Override + public Optional getUser(UUID id) { + return Optional.ofNullable(load().get(id)); + } + + @Override + public List getAllUser() { + return new ArrayList<>(load().values()); + } + + @Override + public void deleteUser(UUID id) { + Map data = load(); + data.remove(id); + saveFile(data); + } + + @Override + public boolean existsByDisplayName(String displayName) { + return load().values().stream() + .anyMatch(u -> u.getDisplayName().equals(displayName)); + } +} \ No newline at end of file diff --git a/discordit/src/main/java/repository/jcf/JCFChannelRepository.java b/discordit/src/main/java/repository/jcf/JCFChannelRepository.java new file mode 100644 index 00000000..4a3469c7 --- /dev/null +++ b/discordit/src/main/java/repository/jcf/JCFChannelRepository.java @@ -0,0 +1,4 @@ +package repository.jcf; + +public class JCFChannelRepository { +} diff --git a/discordit/src/main/java/repository/jcf/JCFMessageRepository.java b/discordit/src/main/java/repository/jcf/JCFMessageRepository.java new file mode 100644 index 00000000..008c0a5d --- /dev/null +++ b/discordit/src/main/java/repository/jcf/JCFMessageRepository.java @@ -0,0 +1,4 @@ +package repository.jcf; + +public class JCFMessageRepository { +} diff --git a/discordit/src/main/java/repository/jcf/JCFUserRepository.java b/discordit/src/main/java/repository/jcf/JCFUserRepository.java new file mode 100644 index 00000000..1789590f --- /dev/null +++ b/discordit/src/main/java/repository/jcf/JCFUserRepository.java @@ -0,0 +1,82 @@ +package repository.jcf; + +import entity.User; +import repository.UserRepository; + +import java.util.*; + +public class JCFUserRepository implements UserRepository { + private final Map data ; + + //생성자에서 초기화 + public JCFUserRepository(){ + this.data = new HashMap<>(); + } + + //멘토링 조언 + /* + @Override + public boolean addUser(User user) { + //boolean guess = true; + //boolean flag = data.containsKey(user.getId()); + //user객체를 다시 만들어줘야함 + // + + if(data.containsKey(user.getId())){ + System.out.println("이미 존재하는 유저입니다!"); + return false; + } + data.put(user.getId(),user); + return true; + + 서비스에서 중요한 데이터를 표현한게 엔티티 + + adduser(데이터 개별적으로 생성) >> + + 항상 올바른 데이터를 전달해주지 않을 수도 있기 때문에 + 검증하는 단계를 서비스에서 진행 + + 실제로 만들어진 user 엔티티를 리턴해주는게 좋다 + */ + //예외처리 다른방법 + //boolean flag = data.add(user); + //if(flag){ return user;} + //else throw new Exception(); <<이런 방법도 있다 라고 참고만! + // 익셉션을 활용하는게 더 좋음. + + //CREATE 생성 + @Override + public User addUser(String displayName, String email, String phoneNumber){ + boolean flag = data.values().stream() + .anyMatch(user -> user.getDisplayName().equals(displayName)); + + if (flag) { + throw new IllegalStateException("이미 존재하는 유저입니다!!"); + } + //중복된 유저가 아니라면 입력받은 데이터를 USER 엔티티에 추가! + User user = new User(displayName, email, phoneNumber); + data.put(user.getId(), user); + return user; + } + + //READ 조회 + @Override + public Optional getUser(UUID id) { + return data.get(id); + } + + @Override + public List getAllUser() { + return new ArrayList<>(data.values()); + + } + + @Override + public void deleteUser(UUID id) { + User user = data.remove(id); + System.out.println("======= (DELETE)삭제된 유저 ======= \n" + user); + + } + + +} diff --git a/discordit/src/main/java/service/ChannelService.java b/discordit/src/main/java/service/ChannelService.java new file mode 100644 index 00000000..5860bf88 --- /dev/null +++ b/discordit/src/main/java/service/ChannelService.java @@ -0,0 +1,25 @@ +package service; + +import entity.Channel; + +import java.util.List; +import java.util.UUID; + + +public interface ChannelService { + + //생성 + Channel addChannel(Channel.ChannelType channelType,String channelName, String description); + + //조회 + Channel getChannel(UUID id); + + //전체조회 + List getAllChannel(); + + //수정 + Channel updateChannel(UUID id, String channelName, String description); + + //삭제 + void deleteChannel(UUID id); +} diff --git a/discordit/src/main/java/service/DiscordService.java b/discordit/src/main/java/service/DiscordService.java new file mode 100644 index 00000000..852b583d --- /dev/null +++ b/discordit/src/main/java/service/DiscordService.java @@ -0,0 +1,4 @@ +package service; + +public interface DiscordService { +} diff --git a/discordit/src/main/java/service/MessageService.java b/discordit/src/main/java/service/MessageService.java new file mode 100644 index 00000000..ca5b54ba --- /dev/null +++ b/discordit/src/main/java/service/MessageService.java @@ -0,0 +1,18 @@ +package service; + +import entity.Message; + +import java.util.List; +import java.util.UUID; + +public interface MessageService { + Message addMessage(String newMessage, UUID channelId, UUID authorId); + + Message getMessage(UUID id); + + List getAllMessage(); + + void updateMessage(UUID id, String newMessage); + + void deleteMessage(UUID id); +} diff --git a/discordit/src/main/java/service/UserService.java b/discordit/src/main/java/service/UserService.java new file mode 100644 index 00000000..212a3b31 --- /dev/null +++ b/discordit/src/main/java/service/UserService.java @@ -0,0 +1,26 @@ +package service; + +import entity.User; + +import java.util.List; +import java.util.UUID; + +public interface UserService { + //생성 + User addUser(String displayName, String email, String phoneNumber); + + //조회 + User getUser(UUID id); + + //전체조회 + List getAllUser(); + + //수정 + + void updateUser(UUID id, String displayName, String email, String phoneNumber); + + //삭제 + //전체목록 검색 -> User객체 가져오기 -> 가져온 User 객체 안에서 id 조회 -> 리스트에서 검색 후 삭제 + //삭제가 되었는지 체크하는 것이 중요 + void deleteUser(UUID id); +} diff --git a/discordit/src/main/java/service/file/FileChannelService.java b/discordit/src/main/java/service/file/FileChannelService.java new file mode 100644 index 00000000..47cc710b --- /dev/null +++ b/discordit/src/main/java/service/file/FileChannelService.java @@ -0,0 +1,4 @@ +package service.file; + +public class FileChannelService { +} diff --git a/discordit/src/main/java/service/file/FileMessageService.java b/discordit/src/main/java/service/file/FileMessageService.java new file mode 100644 index 00000000..ad2d6dd6 --- /dev/null +++ b/discordit/src/main/java/service/file/FileMessageService.java @@ -0,0 +1,4 @@ +package service.file; + +public class FileMessageService { +} diff --git a/discordit/src/main/java/service/file/FileUserService.java b/discordit/src/main/java/service/file/FileUserService.java new file mode 100644 index 00000000..5b258cc9 --- /dev/null +++ b/discordit/src/main/java/service/file/FileUserService.java @@ -0,0 +1,139 @@ +package service.file; + +import entity.Channel; +import entity.User; +import entity.Message; + +import service.ChannelService; +import service.MessageService; +import service.UserService; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.UUID; + +public class FileUserService implements UserService { + private final Path DIRECTORY; + private final String EXTENSION = ".ser"; + + public FileUserService() { + this.DIRECTORY = Paths.get(System.getProperty("user.dir"), "file-data-map", User.class.getSimpleName()); + if (Files.notExists(DIRECTORY)) { + try { + Files.createDirectories(DIRECTORY); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + private Path resolvePath(UUID id) { + return DIRECTORY.resolve(id + EXTENSION); + } + + @Override + public User addUser(String username, String email, String password) { + User user = new User(username, email, password); + Path path = resolvePath(user.getId()); + try ( + FileOutputStream fos = new FileOutputStream(path.toFile()); + ObjectOutputStream oos = new ObjectOutputStream(fos) + ) { + oos.writeObject(user); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return user; + } + + @Override + public User getUser(UUID userId) { + User userNullable = null; + Path path = resolvePath(userId); + if (Files.exists(path)) { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + userNullable = (User) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + return Optional.ofNullable(userNullable) + .orElseThrow(() -> new NoSuchElementException("User with id " + userId + " not found")); + } + + @Override + public List getAllUser() { + try { + return Files.list(DIRECTORY) + .filter(path -> path.toString().endsWith(EXTENSION)) + .map(path -> { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + return (User) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + }) + .toList(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void updateUser(UUID userId, String displayName, String email, String phoneNumber) { + User userNullable = null; + Path path = resolvePath(userId); + if (Files.exists(path)) { + try ( + FileInputStream fis = new FileInputStream(path.toFile()); + ObjectInputStream ois = new ObjectInputStream(fis) + ) { + userNullable = (User) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + User user = Optional.ofNullable(userNullable) + .orElseThrow(() -> new NoSuchElementException("User with id " + userId + " not found")); + user.updateUser(userId, displayName, email, phoneNumber); + + try( + FileOutputStream fos = new FileOutputStream(path.toFile()); + ObjectOutputStream oos = new ObjectOutputStream(fos) + ) { + oos.writeObject(user); + } catch (IOException e) { + throw new RuntimeException(e); + } + + + } + + @Override + public void deleteUser(UUID userId) { + Path path = resolvePath(userId); + if (Files.notExists(path)) { + throw new NoSuchElementException("User with id " + userId + " not found"); + } + try { + Files.delete(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} +// diff --git a/discordit/src/main/java/service/jcf/JCFChannelService.java b/discordit/src/main/java/service/jcf/JCFChannelService.java new file mode 100644 index 00000000..9b642fa6 --- /dev/null +++ b/discordit/src/main/java/service/jcf/JCFChannelService.java @@ -0,0 +1,50 @@ +package service.jcf; + +import entity.Channel; +import service.ChannelService; + +import java.util.*; + +public class JCFChannelService implements ChannelService{ + + private final Map data; + + public JCFChannelService(){ this.data = new HashMap<>();} + + + @Override + public Channel addChannel(Channel.ChannelType channelType,String channelName, String description) { + boolean flag = data.values().stream() + .anyMatch(channel -> channel.getChannelName().equals(channelName)); + if (flag){ + throw new IllegalStateException("이미 존재하는 채널명입니다."); + } + Channel channel = new Channel(channelType,channelName, description); + data.put(channel.getId(),channel); + return channel; + } + + @Override + public Channel getChannel(UUID id) { return data.get(id); } + + @Override + public List getAllChannel() { return new ArrayList<>(data.values()); } + + @Override + public Channel updateChannel(UUID id, String channelName, String description) { + Channel channel = data.get(id); + if (channel!=null){ + channel.updateChannel(channelName,description); + return channel; + } + else { + return null; + } + } + + @Override + public void deleteChannel(UUID id) { + Channel channel = data.remove(id); + System.out.println("======= (DELETE)삭제된 채널 ======= \n" + channel); + } +} diff --git a/discordit/src/main/java/service/jcf/JCFDiscordService.java b/discordit/src/main/java/service/jcf/JCFDiscordService.java new file mode 100644 index 00000000..987bb6f8 --- /dev/null +++ b/discordit/src/main/java/service/jcf/JCFDiscordService.java @@ -0,0 +1,42 @@ +package service.jcf; + +import entity.User; +import entity.Channel; +import entity.Message; +import service.UserService; +import service.ChannelService; +import service.MessageService; + +import java.util.UUID; + +public class JCFDiscordService { + private final JCFUserService userService; + private final JCFChannelService channelService; + private final JCFMessageService messageService; + + //생성자 초기화 + public JCFDiscordService( + JCFUserService userService, + JCFChannelService channelService, + JCFMessageService messageService) { + this.userService = userService; + this.channelService = channelService; + this.messageService = messageService; + } + + public Message sendMessage(String newMessage, UUID authorId, UUID channelId) { + + // 1. 유저 존재 확인 + userService.getUser(authorId); + + // 2. 채널 존재 확인 + channelService.getChannel(channelId); + + // 3. 메시지 생성 + return messageService.addMessage(newMessage, channelId, authorId); + + + } + + +} diff --git a/discordit/src/main/java/service/jcf/JCFMessageService.java b/discordit/src/main/java/service/jcf/JCFMessageService.java new file mode 100644 index 00000000..28552828 --- /dev/null +++ b/discordit/src/main/java/service/jcf/JCFMessageService.java @@ -0,0 +1,97 @@ +package service.jcf; + +import entity.Channel; +import entity.Message; +import entity.User; +import service.ChannelService; +import service.MessageService; +import service.UserService; + +import java.util.*; + +public class JCFMessageService implements MessageService{ + private final Map data; + private final UserService userService; + private final ChannelService channelService; + + // 🔥 핵심: 생성자 주입 + public JCFMessageService(UserService userService, + ChannelService channelService) { + this.data = new HashMap<>(); + this.userService = userService; + this.channelService = channelService; + } + + + @Override + public Message addMessage(String newMessage, UUID channelId, UUID authorId) { + User user = userService.getUser(authorId); + Channel channel = channelService.getChannel(channelId); + + Message message = new Message(newMessage, channelId, authorId); + data.put(message.getId(), message); + return message; + + } + + @Override + public Message getMessage(UUID id) { + return data.get(id); + } + + @Override + public List getAllMessage() { + return new ArrayList<>(data.values()); + } + + @Override + public void updateMessage(UUID id, String newMessage) { + Message message = data.get(id); + if(message!=null){ + message.updateMessage(id, newMessage); + } + } + + @Override + public void deleteMessage(UUID id) { + Message message = data.remove(id); + System.out.println("======= (DELETE)삭제된 메세지 ======= \n" + message); + } +} +/* + private final Map data = new HashMap<>(); + + private final UserService userService; + private final ChannelService channelService; + + // 🔥 핵심: 생성자 주입 + public JCFMessageService(UserService userService, + ChannelService channelService) { + this.userService = userService; + this.channelService = channelService; + } + + @Override + public Message create(UUID userId, UUID channelId, String content) { + + // 1️⃣ 유저 존재 검증 + User user = userService.getUser(userId); + + // 2️⃣ 채널 존재 검증 + Channel channel = channelService.getChannel(channelId); + + // 3️⃣ 메시지 생성 + Message message = new Message(userId, channelId, content); + data.put(message.getId(), message); + + // 4️⃣ 결과 출력 (요구사항 핵심) + System.out.println( + user.getDisplayName() + + " 님이 [" + + channel.getChannelName() + + "] 채널에 메시지를 작성했습니다: " + + content + ); + + return message; + */ diff --git a/discordit/src/main/java/service/jcf/JCFUserService.java b/discordit/src/main/java/service/jcf/JCFUserService.java new file mode 100644 index 00000000..d609a612 --- /dev/null +++ b/discordit/src/main/java/service/jcf/JCFUserService.java @@ -0,0 +1,90 @@ +package service.jcf; + +import entity.User; +import service.UserService; + +import java.util.*; + +public class JCFUserService implements UserService { + + private final Map data ; + + //생성자에서 초기화 + public JCFUserService(){ + this.data = new HashMap<>(); + } + + //멘토링 조언 + /* + @Override + public boolean addUser(User user) { + //boolean guess = true; + //boolean flag = data.containsKey(user.getId()); + //user객체를 다시 만들어줘야함 + // + + if(data.containsKey(user.getId())){ + System.out.println("이미 존재하는 유저입니다!"); + return false; + } + data.put(user.getId(),user); + return true; + + 서비스에서 중요한 데이터를 표현한게 엔티티 + + adduser(데이터 개별적으로 생성) >> + + 항상 올바른 데이터를 전달해주지 않을 수도 있기 때문에 + 검증하는 단계를 서비스에서 진행 + + 실제로 만들어진 user 엔티티를 리턴해주는게 좋다 + */ + //예외처리 다른방법 + //boolean flag = data.add(user); + //if(flag){ return user;} + //else throw new Exception(); <<이런 방법도 있다 라고 참고만! + // 익셉션을 활용하는게 더 좋음. + + //CREATE 생성 + @Override + public User addUser(String displayName, String email, String phoneNumber){ + boolean flag = data.values().stream() + .anyMatch(user -> user.getDisplayName().equals(displayName)); + + if (flag) { + throw new IllegalStateException("이미 존재하는 유저입니다!!"); + } + //중복된 유저가 아니라면 입력받은 데이터를 USER 엔티티에 추가! + User user = new User(displayName, email, phoneNumber); + data.put(user.getId(), user); + return user; + } + + //READ 조회 + @Override + public User getUser(UUID id) { + return data.get(id); + } + + @Override + public List getAllUser() { + return new ArrayList<>(data.values()); + + } + + //Update 업데이트 + @Override + public void updateUser(UUID id, String displayName, String email, String phoneNumber) { + User user = data.get(id); + if(user!=null){ + user.updateUser(id,displayName,email,phoneNumber); + } + } + + @Override + public void deleteUser(UUID id) { + User user = data.remove(id); + System.out.println("======= (DELETE)삭제된 유저 ======= \n" + user); + + } +} diff --git a/file-data-map/Channel/fcd81e3e-884b-4f56-b777-dad45e6f6f9d.ser b/file-data-map/Channel/fcd81e3e-884b-4f56-b777-dad45e6f6f9d.ser new file mode 100644 index 00000000..03c6926b Binary files /dev/null and b/file-data-map/Channel/fcd81e3e-884b-4f56-b777-dad45e6f6f9d.ser differ diff --git a/file-data-map/Message/24b61ba3-e15d-4d90-a6f3-8c53002a67a4.ser b/file-data-map/Message/24b61ba3-e15d-4d90-a6f3-8c53002a67a4.ser new file mode 100644 index 00000000..5274eb6f Binary files /dev/null and b/file-data-map/Message/24b61ba3-e15d-4d90-a6f3-8c53002a67a4.ser differ diff --git a/file-data-map/User/58c01899-95da-4e81-b490-93c4cdbf8cf0.ser b/file-data-map/User/58c01899-95da-4e81-b490-93c4cdbf8cf0.ser new file mode 100644 index 00000000..1b515fa2 Binary files /dev/null and b/file-data-map/User/58c01899-95da-4e81-b490-93c4cdbf8cf0.ser differ