diff --git a/.github/pull-request-template.md b/.github/pull-request-template.md deleted file mode 100644 index 8b17f79e91..0000000000 --- a/.github/pull-request-template.md +++ /dev/null @@ -1,20 +0,0 @@ -## 요구사항 - -### 기본 -- [x] 기본 항목 1 -- [ ] 기본 항목 2 - -### 심화 -- [ ] 심화 항목 1 -- [ ] 심화 항목 2 - -## 주요 변경사항 -- -- - -## 스크린샷 -![image](이미지url) - -## 멘토에게 -- 셀프 코드 리뷰를 통해 질문 이어가겠습니다. -- \ No newline at end of file diff --git a/.gitignore b/.gitignore index b086c937f8..bce6250a6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,66 @@ -.gradle +# 빌드 폴더 +.gradle/ build/ -!gradle/wrapper/gradle-wrapper.jar -!src/main/main/**/build/ -!**/src/test/**/build/ - -### IntelliJ IDEA ### -.idea -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ + +# IDE 설정 파일 +.idea/ *.iws *.iml *.ipr -out/ -!src/main/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated .classpath -.factorypath .project -.settings -.springBeans -.sts4-cache +.settings/ + +# OS 및 에디터 관련 파일 +.DS_Store +Thumbs.db +.vscode/ + +# 환경설정 파일 (비밀정보) +application.yaml +application.properties +.env +config.json + +# 데이터베이스 및 로그 +*.db +*.sqlite +logs/ +*.log + +# 업로드 및 캐시 파일 +#uploads/ +temp/ + +# 패키지 매니저 +node_modules/ +package-lock.json +yarn.lock +__pycache__/ +*.pyc + +# 실행 파일 +*.jar +*.war +*.zip +*.tar.gz +*.out +*.exe +*.dll +*.bat + + bin/ -!src/main/main/**/bin/ -!**/src/test/**/bin/ -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ +gradlew/ +gradlew +gradlew.* +settings.gradle +gradle/ +build.gradle +HELP.md -### VS Code ### -.vscode/ +out/ +*.ser -### Mac OS ### -.DS_Store \ No newline at end of file +application.yml \ No newline at end of file diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock deleted file mode 100644 index 7107e339d7..0000000000 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and /dev/null differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties deleted file mode 100644 index fad2bb09bd..0000000000 --- a/.gradle/buildOutputCleanup/cache.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Tue Feb 11 11:58:38 KST 2025 -gradle.version=8.12.1 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin deleted file mode 100644 index 2c6a6c2277..0000000000 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and /dev/null differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b0..0000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/1-sprint-mission.iml b/.idea/1-sprint-mission.iml deleted file mode 100644 index f76df2b77e..0000000000 --- a/.idea/1-sprint-mission.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index b31d79c39e..0000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index a396feb759..0000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbb..0000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/HELP.md b/HELP.md deleted file mode 100644 index 2bf68ada24..0000000000 --- a/HELP.md +++ /dev/null @@ -1,22 +0,0 @@ -# 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.4.2/gradle-plugin) -* [Create an OCI image](https://docs.spring.io/spring-boot/3.4.2/gradle-plugin/packaging-oci-image.html) -* [Spring Web](https://docs.spring.io/spring-boot/3.4.2/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/Postman/\354\212\244\355\224\204\353\246\260\355\212\270 \353\257\270\354\205\230 4.postman_collection.json" "b/Postman/\354\212\244\355\224\204\353\246\260\355\212\270 \353\257\270\354\205\230 4.postman_collection.json" new file mode 100644 index 0000000000..c831b50402 --- /dev/null +++ "b/Postman/\354\212\244\355\224\204\353\246\260\355\212\270 \353\257\270\354\205\230 4.postman_collection.json" @@ -0,0 +1,1349 @@ +{ + "info": { + "_postman_id": "705ea16e-6f15-40d9-8850-8ce30c342f80", + "name": "스프린트 미션 4", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "29695569" + }, + "item": [ + { + "name": "사용자 등록", + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"user\",\n \"email\": \"test@test.com\",\n \"password\": \"test1234\"\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users/register", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "register" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 07:58:11 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": \"5943d53a-c4a8-4d24-aa99-553226bc1c08\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T07:58:11.169791Z\",\n \"updatedAt\": \"2025-02-20T07:58:11.169803Z\"\n}" + } + ] + }, + { + "name": "모든 사용자 조회", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 07:59:56 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": \"5943d53a-c4a8-4d24-aa99-553226bc1c08\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T07:58:11.169791Z\",\n \"updatedAt\": \"2025-02-20T07:58:11.169803Z\"\n }\n]" + } + ] + }, + { + "name": "특정 사용자 조회", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [ + { + "key": "id", + "value": "5943d53a-c4a8-4d24-aa99-553226bc1c08", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [] + }, + "url": { + "raw": "http://localhost:8080/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "id", + "value": "5943d53a-c4a8-4d24-aa99-553226bc1c08", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [] + }, + "url": { + "raw": "http://localhost:8080/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:02:24 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": \"5943d53a-c4a8-4d24-aa99-553226bc1c08\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T07:58:11.169791Z\",\n \"updatedAt\": \"2025-02-20T07:58:11.169803Z\"\n }\n]" + } + ] + }, + { + "name": "사용자 정보 수정", + "request": { + "auth": { + "type": "noauth" + }, + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"updatedUser\",\n \"email\": \"updated@example.com\",\n \"profileId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"online\": false\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users/5943d53a-c4a8-4d24-aa99-553226bc1c08", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "5943d53a-c4a8-4d24-aa99-553226bc1c08" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "PUT", + "header": [ + { + "key": "id", + "value": "5943d53a-c4a8-4d24-aa99-553226bc1c08", + "type": "text", + "disabled": true + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"updatedUser\",\n \"email\": \"updated@example.com\",\n \"profileId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"online\": false\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/users/5943d53a-c4a8-4d24-aa99-553226bc1c08", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "5943d53a-c4a8-4d24-aa99-553226bc1c08" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:04:06 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": \"5943d53a-c4a8-4d24-aa99-553226bc1c08\",\n \"username\": \"updatedUser\",\n \"email\": \"updated@example.com\",\n \"profileId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"online\": false,\n \"createdAt\": \"2025-02-20T07:58:11.169791Z\",\n \"updatedAt\": \"2025-02-20T08:04:06.576411Z\"\n}" + } + ] + }, + { + "name": "온라인 상태 업데이트", + "request": { + "method": "PATCH", + "header": [], + "url": { + "raw": "http://localhost:8080/users/5943d53a-c4a8-4d24-aa99-553226bc1c08/status?status=false", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "5943d53a-c4a8-4d24-aa99-553226bc1c08", + "status" + ], + "query": [ + { + "key": "status", + "value": "false" + } + ] + } + }, + "response": [ + { + "name": "204 No Content", + "originalRequest": { + "method": "PATCH", + "header": [], + "url": { + "raw": "http://localhost:8080/users/5943d53a-c4a8-4d24-aa99-553226bc1c08/status?status=true", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "5943d53a-c4a8-4d24-aa99-553226bc1c08", + "status" + ], + "query": [ + { + "key": "status", + "value": "true" + } + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:05:59 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "사용자 삭제", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/users/123e4567-e89b-12d3-a456-426614174000", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "123e4567-e89b-12d3-a456-426614174000" + ] + } + }, + "response": [ + { + "name": "204 No Content", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/users/123e4567-e89b-12d3-a456-426614174000", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "users", + "123e4567-e89b-12d3-a456-426614174000" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:06:49 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "메시지 전송", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"content\": \"Hello, this is a test message!\",\n \"channel\": {\n \"id\": 2\n },\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\"\n }\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/messages", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"content\": \"Hello, this is a test message!\",\n \"channel\": {\n \"id\": 2\n },\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\"\n }\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/messages", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:51:23 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": 2,\n \"content\": \"Hello, this is a test message!\",\n \"channel\": {\n \"id\": 2,\n \"name\": null,\n \"user\": null,\n \"private\": false\n },\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": null,\n \"email\": null,\n \"profileId\": null,\n \"online\": false,\n \"createdAt\": null,\n \"updatedAt\": null\n },\n \"createdAt\": \"2025-02-20T09:51:23.905277Z\"\n}" + } + ] + }, + { + "name": "특정 채널의 메시지 목록 조회", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/messages/channel/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "channel", + "2" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/messages/channel/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "channel", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:52:20 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 2,\n \"content\": \"Hello, this is a test message!\",\n \"channel\": {\n \"id\": 2,\n \"name\": \"general\",\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:50:13.018048Z\",\n \"updatedAt\": \"2025-02-20T09:50:13.018059Z\"\n },\n \"private\": false\n },\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:50:13.018048Z\",\n \"updatedAt\": \"2025-02-20T09:50:13.018059Z\"\n },\n \"createdAt\": \"2025-02-20T09:51:23.905277Z\"\n }\n]" + } + ] + }, + { + "name": "메시지 수정", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "\"Updated message content\"", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/messages/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "2" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "\"Updated message content\"", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/messages/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:53:49 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": 2,\n \"content\": \"\\\"Updated message content\\\"\",\n \"channel\": {\n \"id\": 2,\n \"name\": \"general\",\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:50:13.018048Z\",\n \"updatedAt\": \"2025-02-20T09:50:13.018059Z\"\n },\n \"private\": false\n },\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:50:13.018048Z\",\n \"updatedAt\": \"2025-02-20T09:50:13.018059Z\"\n },\n \"createdAt\": \"2025-02-20T09:51:23.905277Z\"\n}" + } + ] + }, + { + "name": "메세지 삭제", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/messages/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "2" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/messages/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "messages", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Content-Length", + "value": "0" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:54:33 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "메시지 수신 정보 생성", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"message\": {\n \"id\": 4\n },\n \"user\": {\n \"id\": \"e2a9b4da-4e64-43b5-b53d-766077eb64ef\"\n },\n \"received\": true\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/receipts", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "receipts" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"message\": {\n \"id\": 4\n },\n \"user\": {\n \"id\": \"e2a9b4da-4e64-43b5-b53d-766077eb64ef\"\n },\n \"received\": true\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/receipts", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "receipts" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:56:51 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": 2,\n \"message\": {\n \"id\": 4,\n \"content\": null,\n \"channel\": null,\n \"user\": null,\n \"createdAt\": null\n },\n \"user\": {\n \"id\": \"e2a9b4da-4e64-43b5-b53d-766077eb64ef\",\n \"username\": null,\n \"email\": null,\n \"profileId\": null,\n \"online\": false,\n \"createdAt\": null,\n \"updatedAt\": null\n },\n \"received\": true\n}" + } + ] + }, + { + "name": "특정 사용자의 메시지 수신 정보 조회", + "request": { + "method": "GET", + "header": [] + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/receipts/user/e2a9b4da-4e64-43b5-b53d-766077eb64ef", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "receipts", + "user", + "e2a9b4da-4e64-43b5-b53d-766077eb64ef" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 09:58:07 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 2,\n \"message\": {\n \"id\": 4,\n \"content\": \"Hello, this is a test message!\",\n \"channel\": {\n \"id\": 2,\n \"name\": \"general\",\n \"user\": {\n \"id\": \"030409b7-f966-4895-93ba-3a9eb9af030a\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:50:13.018048Z\",\n \"updatedAt\": \"2025-02-20T09:50:13.018059Z\"\n },\n \"private\": false\n },\n \"user\": {\n \"id\": \"e2a9b4da-4e64-43b5-b53d-766077eb64ef\",\n \"username\": \"testUser1\",\n \"email\": \"test1@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:56:18.812909Z\",\n \"updatedAt\": \"2025-02-20T09:56:18.812915Z\"\n },\n \"createdAt\": \"2025-02-20T09:56:44.472798Z\"\n },\n \"user\": {\n \"id\": \"e2a9b4da-4e64-43b5-b53d-766077eb64ef\",\n \"username\": \"testUser1\",\n \"email\": \"test1@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T09:56:18.812909Z\",\n \"updatedAt\": \"2025-02-20T09:56:18.812915Z\"\n },\n \"received\": true\n }\n]" + } + ] + }, + { + "name": "채널 생성", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"general\",\n \"isPrivate\": false,\n \"user\": {\n \"id\": \"a82db833-878c-4959-88f1-2fea8ac62908\"\n }\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/channels", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"general\",\n \"isPrivate\": false,\n \"user\": {\n \"id\": \"a82db833-878c-4959-88f1-2fea8ac62908\"\n }\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/channels", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:39:08 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": 2,\n \"name\": \"general\",\n \"user\": {\n \"id\": \"a82db833-878c-4959-88f1-2fea8ac62908\",\n \"username\": null,\n \"email\": null,\n \"profileId\": null,\n \"online\": false,\n \"createdAt\": null,\n \"updatedAt\": null\n },\n \"private\": false\n}" + } + ] + }, + { + "name": "모든 채널 조회", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/channels", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/channels", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:40:28 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 2,\n \"name\": \"general\",\n \"user\": {\n \"id\": \"a82db833-878c-4959-88f1-2fea8ac62908\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T08:38:49.651634Z\",\n \"updatedAt\": \"2025-02-20T08:38:49.651658Z\"\n },\n \"private\": false\n }\n]" + } + ] + }, + { + "name": "채널 수정", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"updated_channel\",\n \"isPrivate\": true\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/channels/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels", + "2" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"updated_channel\",\n \"isPrivate\": true\n}\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8080/channels/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:42:08 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "{\n \"id\": 2,\n \"name\": \"updated_channel\",\n \"user\": {\n \"id\": \"a82db833-878c-4959-88f1-2fea8ac62908\",\n \"username\": \"testUser\",\n \"email\": \"test@example.com\",\n \"profileId\": null,\n \"online\": true,\n \"createdAt\": \"2025-02-20T08:38:49.651634Z\",\n \"updatedAt\": \"2025-02-20T08:38:49.651658Z\"\n },\n \"private\": false\n}" + } + ] + }, + { + "name": "채널 삭제", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/channels/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels", + "2" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8080/channels/2", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "channels", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Content-Length", + "value": "0" + }, + { + "key": "Date", + "value": "Thu, 20 Feb 2025 08:42:51 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "파일 다운로드", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/files/ee7ec40f-ea90-4c71-a00b-e17c613dd5e2_진이.jpeg", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "files", + "ee7ec40f-ea90-4c71-a00b-e17c613dd5e2_진이.jpeg" + ] + } + }, + "response": [] + }, + { + "name": "파일 업로드", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "postman-cloud:///1eff017a-8a69-4c20-96f2-47f33ceafb5d" + } + ] + }, + "url": { + "raw": "http://localhost:8080/files/upload", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "files", + "upload" + ] + } + }, + "response": [ + { + "name": "200 OK", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "postman-cloud:///1eff017a-8a69-4c20-96f2-47f33ceafb5d" + } + ] + }, + "url": { + "raw": "http://localhost:8080/files/upload", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "files", + "upload" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Content-Type", + "value": "text/plain;charset=UTF-8" + }, + { + "key": "Content-Length", + "value": "48" + }, + { + "key": "Date", + "value": "Fri, 21 Feb 2025 06:35:44 GMT" + }, + { + "key": "Keep-Alive", + "value": "timeout=60" + }, + { + "key": "Connection", + "value": "keep-alive" + } + ], + "cookie": [], + "body": "File uploaded successfully: 진이.jpeg" + } + ] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 815bede54f..ca930b83cd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# 0-spring-mission -스프린트 미션 모범 답안 리포지토리입니다. +# sprint-mission4 diff --git a/build.gradle b/build.gradle deleted file mode 100644 index b70fe880c9..0000000000 --- a/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -plugins { - id 'java' - id 'org.springframework.boot' version '3.4.2' - id 'io.spring.dependency-management' version '1.1.7' -} - -group = 'com.sprint.mission' -version = '0.0.1-SNAPSHOT' - -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/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class b/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class deleted file mode 100644 index 521d0eab1d..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/entity/Channel.class and /dev/null differ diff --git a/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class b/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class deleted file mode 100644 index 8a1d7803e2..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/entity/Message.class and /dev/null differ diff --git a/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class b/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class deleted file mode 100644 index 3aacaf498f..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/entity/User.class and /dev/null differ diff --git a/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class b/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class deleted file mode 100644 index 7febb837b7..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/service/ChannelService.class and /dev/null differ diff --git a/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class b/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class deleted file mode 100644 index 95cd735b15..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/service/MessageService.class and /dev/null differ diff --git a/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class b/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class deleted file mode 100644 index 7b217e56bc..0000000000 Binary files a/build/classes/java/main/com/sprint/mission/discodeit/service/UserService.class and /dev/null differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin deleted file mode 100644 index b20797c2cc..0000000000 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and /dev/null differ diff --git a/file-data-map/Channel/0e42568f-22e9-47b7-b955-ec2cce1b9d29.ser b/file-data-map/Channel/0e42568f-22e9-47b7-b955-ec2cce1b9d29.ser deleted file mode 100644 index dab7d6bd6d..0000000000 Binary files a/file-data-map/Channel/0e42568f-22e9-47b7-b955-ec2cce1b9d29.ser and /dev/null differ diff --git a/file-data-map/Channel/47dfa2b8-ee62-40da-b81c-64e10b7d42b1.ser b/file-data-map/Channel/47dfa2b8-ee62-40da-b81c-64e10b7d42b1.ser deleted file mode 100644 index 4a00ff9193..0000000000 Binary files a/file-data-map/Channel/47dfa2b8-ee62-40da-b81c-64e10b7d42b1.ser and /dev/null differ diff --git a/file-data-map/Channel/61857768-34eb-40dc-9ec1-9decdcd58590.ser b/file-data-map/Channel/61857768-34eb-40dc-9ec1-9decdcd58590.ser deleted file mode 100644 index b23ef3d1cc..0000000000 Binary files a/file-data-map/Channel/61857768-34eb-40dc-9ec1-9decdcd58590.ser and /dev/null differ diff --git a/file-data-map/Channel/8e54c725-a738-4c92-943c-cbddd231a70b.ser b/file-data-map/Channel/8e54c725-a738-4c92-943c-cbddd231a70b.ser deleted file mode 100644 index 0f506cfb71..0000000000 Binary files a/file-data-map/Channel/8e54c725-a738-4c92-943c-cbddd231a70b.ser and /dev/null differ diff --git a/file-data-map/Channel/98e84062-670b-4c1a-973f-57bc2e971edc.ser b/file-data-map/Channel/98e84062-670b-4c1a-973f-57bc2e971edc.ser deleted file mode 100644 index 76c486d5b1..0000000000 Binary files a/file-data-map/Channel/98e84062-670b-4c1a-973f-57bc2e971edc.ser and /dev/null differ diff --git a/file-data-map/Channel/9d5733a5-c950-4f00-8fda-6f5e09555b8d.ser b/file-data-map/Channel/9d5733a5-c950-4f00-8fda-6f5e09555b8d.ser deleted file mode 100644 index 13d39caf8e..0000000000 Binary files a/file-data-map/Channel/9d5733a5-c950-4f00-8fda-6f5e09555b8d.ser and /dev/null differ diff --git a/file-data-map/Channel/ba1d89b3-20aa-4853-91fe-09302a369463.ser b/file-data-map/Channel/ba1d89b3-20aa-4853-91fe-09302a369463.ser deleted file mode 100644 index a1a8faedcb..0000000000 Binary files a/file-data-map/Channel/ba1d89b3-20aa-4853-91fe-09302a369463.ser and /dev/null differ diff --git a/file-data-map/Message/4077f6b0-304e-4d82-b2b7-f4a498389321.ser b/file-data-map/Message/4077f6b0-304e-4d82-b2b7-f4a498389321.ser deleted file mode 100644 index 4dd0c4b818..0000000000 Binary files a/file-data-map/Message/4077f6b0-304e-4d82-b2b7-f4a498389321.ser and /dev/null differ diff --git a/file-data-map/Message/73747422-bba9-49eb-b218-ec99debf50b5.ser b/file-data-map/Message/73747422-bba9-49eb-b218-ec99debf50b5.ser deleted file mode 100644 index 2d24524ae8..0000000000 Binary files a/file-data-map/Message/73747422-bba9-49eb-b218-ec99debf50b5.ser and /dev/null differ diff --git a/file-data-map/Message/7dde1fbd-fe7a-4573-ae63-859f550f9c2c.ser b/file-data-map/Message/7dde1fbd-fe7a-4573-ae63-859f550f9c2c.ser deleted file mode 100644 index 39c29c5924..0000000000 Binary files a/file-data-map/Message/7dde1fbd-fe7a-4573-ae63-859f550f9c2c.ser and /dev/null differ diff --git a/file-data-map/Message/7ebae7d9-03fd-4b00-bd35-a2fa71159a8e.ser b/file-data-map/Message/7ebae7d9-03fd-4b00-bd35-a2fa71159a8e.ser deleted file mode 100644 index 9468fb592b..0000000000 Binary files a/file-data-map/Message/7ebae7d9-03fd-4b00-bd35-a2fa71159a8e.ser and /dev/null differ diff --git a/file-data-map/Message/88ea2dd9-3c26-4abd-9ae2-b955809f6f79.ser b/file-data-map/Message/88ea2dd9-3c26-4abd-9ae2-b955809f6f79.ser deleted file mode 100644 index b5aa283ad4..0000000000 Binary files a/file-data-map/Message/88ea2dd9-3c26-4abd-9ae2-b955809f6f79.ser and /dev/null differ diff --git a/file-data-map/Message/aa42414c-d71e-4c83-b99c-f6ef1cc88397.ser b/file-data-map/Message/aa42414c-d71e-4c83-b99c-f6ef1cc88397.ser deleted file mode 100644 index 5cb7d544f3..0000000000 Binary files a/file-data-map/Message/aa42414c-d71e-4c83-b99c-f6ef1cc88397.ser and /dev/null differ diff --git a/file-data-map/Message/ef61b55b-4a18-4d87-b907-7c7d85d01016.ser b/file-data-map/Message/ef61b55b-4a18-4d87-b907-7c7d85d01016.ser deleted file mode 100644 index 2d6813ae86..0000000000 Binary files a/file-data-map/Message/ef61b55b-4a18-4d87-b907-7c7d85d01016.ser and /dev/null differ diff --git a/file-data-map/User/0c038bf7-982c-4c45-88aa-fccf6281157d.ser b/file-data-map/User/0c038bf7-982c-4c45-88aa-fccf6281157d.ser deleted file mode 100644 index 1e9d414851..0000000000 Binary files a/file-data-map/User/0c038bf7-982c-4c45-88aa-fccf6281157d.ser and /dev/null differ diff --git a/file-data-map/User/3a093662-81b9-48d6-b01f-d5424d9c64c8.ser b/file-data-map/User/3a093662-81b9-48d6-b01f-d5424d9c64c8.ser deleted file mode 100644 index a032494bca..0000000000 Binary files a/file-data-map/User/3a093662-81b9-48d6-b01f-d5424d9c64c8.ser and /dev/null differ diff --git a/file-data-map/User/4f022323-1e3e-4735-a4ab-57da1d4d7fbc.ser b/file-data-map/User/4f022323-1e3e-4735-a4ab-57da1d4d7fbc.ser deleted file mode 100644 index ea5366e447..0000000000 Binary files a/file-data-map/User/4f022323-1e3e-4735-a4ab-57da1d4d7fbc.ser and /dev/null differ diff --git a/file-data-map/User/588cd8d4-54c6-4982-9281-bee82e7d1ad7.ser b/file-data-map/User/588cd8d4-54c6-4982-9281-bee82e7d1ad7.ser deleted file mode 100644 index 96503149fc..0000000000 Binary files a/file-data-map/User/588cd8d4-54c6-4982-9281-bee82e7d1ad7.ser and /dev/null differ diff --git a/file-data-map/User/5e708e95-7280-47e3-b113-b82bfecfa128.ser b/file-data-map/User/5e708e95-7280-47e3-b113-b82bfecfa128.ser deleted file mode 100644 index f6f4cbd1d5..0000000000 Binary files a/file-data-map/User/5e708e95-7280-47e3-b113-b82bfecfa128.ser and /dev/null differ diff --git a/file-data-map/User/64c68e14-5fda-4df6-b732-9966d55d2977.ser b/file-data-map/User/64c68e14-5fda-4df6-b732-9966d55d2977.ser deleted file mode 100644 index 57df82c5b7..0000000000 Binary files a/file-data-map/User/64c68e14-5fda-4df6-b732-9966d55d2977.ser and /dev/null differ diff --git a/file-data-map/User/c6bc6992-0e5a-42bf-837f-40c80da03385.ser b/file-data-map/User/c6bc6992-0e5a-42bf-837f-40c80da03385.ser deleted file mode 100644 index 904d6de987..0000000000 Binary files a/file-data-map/User/c6bc6992-0e5a-42bf-837f-40c80da03385.ser and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a4b76b9530..0000000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e18bc253b8..0000000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 2437dfb29c..45d95274de 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'discodeit' +rootProject.name = 'demo1' diff --git a/src/main/java/com/example/mission/discodeit/MainApplication.java b/src/main/java/com/example/mission/discodeit/MainApplication.java new file mode 100644 index 0000000000..9f71fc9c01 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/MainApplication.java @@ -0,0 +1,13 @@ +package com.example.mission.discodeit; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MainApplication { + + public static void main(String[] args) { + SpringApplication.run(MainApplication.class, args); + } + +} diff --git a/src/main/java/com/example/mission/discodeit/controller/ChannelController.java b/src/main/java/com/example/mission/discodeit/controller/ChannelController.java new file mode 100644 index 0000000000..ef4fa61458 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/controller/ChannelController.java @@ -0,0 +1,35 @@ +package com.example.mission.discodeit.controller; + +import com.example.mission.discodeit.entity.Channel; +import com.example.mission.discodeit.service.ChannelService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/channels") +@RequiredArgsConstructor +public class ChannelController { + private final ChannelService channelService; + + @PostMapping + public Channel createChannel(@RequestBody Channel channel) { + return channelService.createChannel(channel); + } + + @GetMapping + public List getAllChannels() { + return channelService.getAllChannels(); + } + + @PutMapping("/{id}") + public Channel updateChannel(@PathVariable Long id, @RequestBody Channel channel) { + return channelService.updateChannel(id, channel); + } + + @DeleteMapping("/{id}") + public void deleteChannel(@PathVariable Long id) { + channelService.deleteChannel(id); + } +} diff --git a/src/main/java/com/example/mission/discodeit/controller/FileController.java b/src/main/java/com/example/mission/discodeit/controller/FileController.java new file mode 100644 index 0000000000..52736ae249 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/controller/FileController.java @@ -0,0 +1,51 @@ +package com.example.mission.discodeit.controller; + +import com.example.mission.discodeit.service.FileService; +import lombok.RequiredArgsConstructor; +import org.springframework.core.io.Resource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +@RestController +@RequestMapping("/files") +@RequiredArgsConstructor +public class FileController { + private final FileService fileService; + + @PostMapping("/upload") + public ResponseEntity uploadFile(@RequestParam("file") MultipartFile file) { + try { + String fileName = fileService.storeFile(file); + return ResponseEntity.ok("File uploaded successfully: " + fileName); + } catch (IOException e) { + return ResponseEntity.internalServerError().body("File upload failed"); + } + } + + + @GetMapping("/{fileName}") + public ResponseEntity downloadFile(@PathVariable String fileName) { + Resource resource = fileService.loadFileAsResource(fileName); + + String contentType; + try { + Path filePath = Paths.get("uploads/").resolve(fileName).normalize(); + contentType = Files.probeContentType(filePath); + } catch (IOException e) { + contentType = "application/octet-stream"; + } + + return ResponseEntity.ok() + .contentType(MediaType.parseMediaType(contentType)) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"") + .body(resource); + } +} diff --git a/src/main/java/com/example/mission/discodeit/controller/MessageController.java b/src/main/java/com/example/mission/discodeit/controller/MessageController.java new file mode 100644 index 0000000000..d82b2cbdb5 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/controller/MessageController.java @@ -0,0 +1,35 @@ +package com.example.mission.discodeit.controller; + +import com.example.mission.discodeit.entity.Message; +import com.example.mission.discodeit.service.MessageService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/messages") +@RequiredArgsConstructor +public class MessageController { + private final MessageService messageService; + + @PostMapping + public Message sendMessage(@RequestBody Message message) { + return messageService.sendMessage(message); + } + + @GetMapping("/channel/{channelId}") + public List getMessagesByChannel(@PathVariable Long channelId) { + return messageService.getMessagesByChannel(channelId); + } + + @PutMapping("/{id}") + public Message updateMessage(@PathVariable Long id, @RequestBody String content) { + return messageService.updateMessage(id, content); + } + + @DeleteMapping("/{id}") + public void deleteMessage(@PathVariable Long id) { + messageService.deleteMessage(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/controller/MessageReceiptController.java b/src/main/java/com/example/mission/discodeit/controller/MessageReceiptController.java new file mode 100644 index 0000000000..58d3316183 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/controller/MessageReceiptController.java @@ -0,0 +1,26 @@ +package com.example.mission.discodeit.controller; + +import com.example.mission.discodeit.entity.MessageReceipt; +import com.example.mission.discodeit.service.MessageReceiptService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.UUID; + +@RestController +@RequestMapping("/receipts") +@RequiredArgsConstructor +public class MessageReceiptController { + private final MessageReceiptService receiptService; + + @PostMapping + public MessageReceipt createReceipt(@RequestBody MessageReceipt receipt) { + return receiptService.createReceipt(receipt); + } + + @GetMapping("/user/{userId}") + public List getReceiptsByUser(@PathVariable UUID userId) { + return receiptService.getReceiptsByUser(userId); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/controller/UserController.java b/src/main/java/com/example/mission/discodeit/controller/UserController.java new file mode 100644 index 0000000000..bd45ffdeab --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/controller/UserController.java @@ -0,0 +1,63 @@ +package com.example.mission.discodeit.controller; + +import com.example.mission.discodeit.entity.Channel; +import com.example.mission.discodeit.entity.User; +import com.example.mission.discodeit.dto.UserDto; +import com.example.mission.discodeit.service.ChannelService; +import com.example.mission.discodeit.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@RestController +@RequestMapping("/users") +@RequiredArgsConstructor +public class UserController { + + private final UserService userService; + private final ChannelService channelService; + + @GetMapping("/{userId}/channels") + public ResponseEntity> getUserChannels(@PathVariable UUID userId) { + List channels = channelService.getUserChannels(userId); + return ResponseEntity.ok(channels); + } + + @PostMapping("/register") + public ResponseEntity registerUser(@RequestBody UserDto userDto) { + return ResponseEntity.ok(userService.registerUser(userDto)); + } + + @GetMapping + public ResponseEntity> getAllUsers() { + return ResponseEntity.ok(userService.getAllUsers()); + } + + @GetMapping("/{id}") + public ResponseEntity> getUserById(@PathVariable UUID id) { + return ResponseEntity.ok(userService.getUserById(id)); + } + + @PutMapping("/{id}") + public ResponseEntity updateUser(@PathVariable UUID id, @RequestBody UserDto userDto) { + return ResponseEntity.ok(userService.updateUser(id, userDto)); + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteUser(@PathVariable UUID id) { + userService.deleteUser(id); + return ResponseEntity.noContent().build(); + } + + @PatchMapping("/{id}/status") + public ResponseEntity updateOnlineStatus(@PathVariable UUID id, @RequestParam boolean status) { + userService.updateOnlineStatus(id, status); + return ResponseEntity.noContent().build(); + } + +} + diff --git a/src/main/java/com/example/mission/discodeit/dto/ChannelDto.java b/src/main/java/com/example/mission/discodeit/dto/ChannelDto.java new file mode 100644 index 0000000000..b790a30e8f --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/dto/ChannelDto.java @@ -0,0 +1,18 @@ +package com.example.mission.discodeit.dto; + +import lombok.*; + +import java.util.UUID; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder + +public class ChannelDto { + private Long id; + private String name; + private boolean isPrivate; + private UUID userId; +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/dto/UserDto.java b/src/main/java/com/example/mission/discodeit/dto/UserDto.java new file mode 100644 index 0000000000..5b5ce08b57 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/dto/UserDto.java @@ -0,0 +1,17 @@ +package com.example.mission.discodeit.dto; + +import lombok.Data; + +import java.time.Instant; +import java.util.UUID; + +@Data +public class UserDto { + private UUID id; + private Instant createdAt; + private Instant updatedAt; + private String username; + private String email; + private UUID profileId; + private Boolean online; +} diff --git a/src/main/java/com/example/mission/discodeit/entity/Channel.java b/src/main/java/com/example/mission/discodeit/entity/Channel.java new file mode 100644 index 0000000000..eb889ad508 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/entity/Channel.java @@ -0,0 +1,26 @@ +package com.example.mission.discodeit.entity; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "channels") +public class Channel { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String name; + private boolean isPrivate; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; +} diff --git a/src/main/java/com/example/mission/discodeit/entity/FileEntity.java b/src/main/java/com/example/mission/discodeit/entity/FileEntity.java new file mode 100644 index 0000000000..3066b7e82b --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/entity/FileEntity.java @@ -0,0 +1,29 @@ +package com.example.mission.discodeit.entity; + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.CreationTimestamp; + +import java.time.Instant; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Table(name = "files") +public class FileEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String fileName; + private String fileType; + + @Lob + private byte[] data; + + @CreationTimestamp + private Instant createdAt; +} diff --git a/src/main/java/com/example/mission/discodeit/entity/Message.java b/src/main/java/com/example/mission/discodeit/entity/Message.java new file mode 100644 index 0000000000..dbb495e63b --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/entity/Message.java @@ -0,0 +1,35 @@ +package com.example.mission.discodeit.entity; + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.CreationTimestamp; + +import java.time.Instant; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Table(name = "messages") + +public class Message { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private String content; + + @ManyToOne + @JoinColumn(name = "channel_id") + private Channel channel; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @CreationTimestamp + private Instant createdAt; +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/entity/MessageReceipt.java b/src/main/java/com/example/mission/discodeit/entity/MessageReceipt.java new file mode 100644 index 0000000000..4a12111499 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/entity/MessageReceipt.java @@ -0,0 +1,27 @@ +package com.example.mission.discodeit.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Table(name = "message_receipts") +public class MessageReceipt { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "message_id") + private Message message; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + private boolean received; +} diff --git a/src/main/java/com/example/mission/discodeit/entity/User.java b/src/main/java/com/example/mission/discodeit/entity/User.java new file mode 100644 index 0000000000..b22058d2b5 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/entity/User.java @@ -0,0 +1,39 @@ +package com.example.mission.discodeit.entity; + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; + +import java.time.Instant; +import java.util.UUID; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private UUID id; // 사용자 ID + + @Column(nullable = false, unique = true) + private String username; // 사용자명 + + @Column(nullable = false) + private String email; // 이메일 + + private UUID profileId; // 프로필 사진 ID (파일 UUID) + + private Boolean online = false; // 온라인 상태 (기본값 false) + + @CreationTimestamp + private Instant createdAt; // 생성일 + + @UpdateTimestamp + private Instant updatedAt; // 업데이트일 +} diff --git a/src/main/java/com/example/mission/discodeit/repository/ChannelRepository.java b/src/main/java/com/example/mission/discodeit/repository/ChannelRepository.java new file mode 100644 index 0000000000..415cfb8cd2 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/repository/ChannelRepository.java @@ -0,0 +1,15 @@ +package com.example.mission.discodeit.repository; + +import com.example.mission.discodeit.entity.Channel; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.UUID; + + +@Repository +public interface ChannelRepository extends JpaRepository { + List findByUserId(UUID userId); +} + diff --git a/src/main/java/com/example/mission/discodeit/repository/FileRepository.java b/src/main/java/com/example/mission/discodeit/repository/FileRepository.java new file mode 100644 index 0000000000..e778c0de8e --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/repository/FileRepository.java @@ -0,0 +1,9 @@ +package com.example.mission.discodeit.repository; + +import com.example.mission.discodeit.entity.FileEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface FileRepository extends JpaRepository {} + diff --git a/src/main/java/com/example/mission/discodeit/repository/MessageReceiptRepository.java b/src/main/java/com/example/mission/discodeit/repository/MessageReceiptRepository.java new file mode 100644 index 0000000000..e89ea72227 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/repository/MessageReceiptRepository.java @@ -0,0 +1,13 @@ +package com.example.mission.discodeit.repository; + +import com.example.mission.discodeit.entity.MessageReceipt; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.UUID; + +@Repository +public interface MessageReceiptRepository extends JpaRepository { + List findByUserId(UUID userId); +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/repository/MessageRepository.java b/src/main/java/com/example/mission/discodeit/repository/MessageRepository.java new file mode 100644 index 0000000000..f6afe8aa74 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/repository/MessageRepository.java @@ -0,0 +1,12 @@ +package com.example.mission.discodeit.repository; + +import com.example.mission.discodeit.entity.Message; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface MessageRepository extends JpaRepository { + List findByChannelId(Long channelId); +} \ No newline at end of file diff --git a/src/main/java/com/example/mission/discodeit/repository/UserRepository.java b/src/main/java/com/example/mission/discodeit/repository/UserRepository.java new file mode 100644 index 0000000000..d28019a49a --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/repository/UserRepository.java @@ -0,0 +1,11 @@ +package com.example.mission.discodeit.repository; + + +import com.example.mission.discodeit.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface UserRepository extends JpaRepository { +} + diff --git a/src/main/java/com/example/mission/discodeit/service/ChannelService.java b/src/main/java/com/example/mission/discodeit/service/ChannelService.java new file mode 100644 index 0000000000..6d3eb18e09 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/service/ChannelService.java @@ -0,0 +1,39 @@ +package com.example.mission.discodeit.service; + +import com.example.mission.discodeit.entity.Channel; +import com.example.mission.discodeit.repository.ChannelRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class ChannelService { + private final ChannelRepository channelRepository; + + public Channel createChannel(Channel channel) { + return channelRepository.save(channel); + } + + public List getAllChannels() { + return channelRepository.findAll(); + } + + public Channel updateChannel(Long id, Channel channelDetails) { + return channelRepository.findById(id).map(channel -> { + channel.setName(channelDetails.getName()); + channel.setPrivate(channelDetails.isPrivate()); + return channelRepository.save(channel); + }).orElseThrow(() -> new RuntimeException("Channel not found")); + } + + public void deleteChannel(Long id) { + channelRepository.deleteById(id); + } + + public List getUserChannels(UUID userId) { + return channelRepository.findByUserId(userId); + } +} diff --git a/src/main/java/com/example/mission/discodeit/service/FileService.java b/src/main/java/com/example/mission/discodeit/service/FileService.java new file mode 100644 index 0000000000..49f73e308f --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/service/FileService.java @@ -0,0 +1,46 @@ +package com.example.mission.discodeit.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.web.server.ResponseStatusException; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +@Service +@RequiredArgsConstructor +public class FileService { + private static final String UPLOAD_DIR = "uploads/"; + + + public String storeFile(org.springframework.web.multipart.MultipartFile file) throws IOException { + String fileName = file.getOriginalFilename(); + Path filePath = Paths.get(UPLOAD_DIR).resolve(fileName).normalize(); + + java.nio.file.Files.createDirectories(filePath.getParent()); + + java.nio.file.Files.write(filePath, file.getBytes()); + + return fileName; + } + + + public Resource loadFileAsResource(String fileName) { + try { + Path filePath = Paths.get(UPLOAD_DIR).resolve(fileName).normalize(); + Resource resource = new UrlResource(filePath.toUri()); + + if (!resource.exists() || !resource.isReadable()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "File not found: " + fileName); + } + + return resource; + } catch (IOException e) { + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Error loading file: " + fileName, e); + } + } +} diff --git a/src/main/java/com/example/mission/discodeit/service/MessageReceiptService.java b/src/main/java/com/example/mission/discodeit/service/MessageReceiptService.java new file mode 100644 index 0000000000..3d97f3e628 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/service/MessageReceiptService.java @@ -0,0 +1,23 @@ +package com.example.mission.discodeit.service; + +import com.example.mission.discodeit.entity.MessageReceipt; +import com.example.mission.discodeit.repository.MessageReceiptRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class MessageReceiptService { + private final MessageReceiptRepository messageReceiptRepository; + + public MessageReceipt createReceipt(MessageReceipt receipt) { + return messageReceiptRepository.save(receipt); + } + + public List getReceiptsByUser(UUID userId) { + return messageReceiptRepository.findByUserId(userId); + } +} diff --git a/src/main/java/com/example/mission/discodeit/service/MessageService.java b/src/main/java/com/example/mission/discodeit/service/MessageService.java new file mode 100644 index 0000000000..cad8b1f945 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/service/MessageService.java @@ -0,0 +1,33 @@ +package com.example.mission.discodeit.service; + +import com.example.mission.discodeit.entity.Message; +import com.example.mission.discodeit.repository.MessageRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class MessageService { + private final MessageRepository messageRepository; + + public Message sendMessage(Message message) { + return messageRepository.save(message); + } + + public List getMessagesByChannel(Long channelId) { + return messageRepository.findByChannelId(channelId); + } + + public Message updateMessage(Long id, String content) { + return messageRepository.findById(id).map(message -> { + message.setContent(content); + return messageRepository.save(message); + }).orElseThrow(() -> new RuntimeException("Message not found")); + } + + public void deleteMessage(Long id) { + messageRepository.deleteById(id); + } +} diff --git a/src/main/java/com/example/mission/discodeit/service/UserService.java b/src/main/java/com/example/mission/discodeit/service/UserService.java new file mode 100644 index 0000000000..671b7e1f52 --- /dev/null +++ b/src/main/java/com/example/mission/discodeit/service/UserService.java @@ -0,0 +1,64 @@ +package com.example.mission.discodeit.service; + +import com.example.mission.discodeit.entity.User; +import com.example.mission.discodeit.dto.UserDto; +import com.example.mission.discodeit.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class UserService { + + private final UserRepository userRepository; + + public User registerUser(UserDto userDto) { + User user = User.builder() + .username(userDto.getUsername()) + .email(userDto.getEmail()) + .profileId(userDto.getProfileId()) // 프로필 사진 ID (없으면 null) + .online(userDto.getOnline() != null ? userDto.getOnline() : false) + .build(); + return userRepository.save(user); + } + + public List getAllUsers() { + return userRepository.findAll(); + } + + public Optional getUserById(UUID id) { + return userRepository.findById(id); + } + + public User updateUser(UUID id, UserDto userDto) { + return userRepository.findById(id).map(user -> { + user.setUsername(userDto.getUsername()); + user.setEmail(userDto.getEmail()); + user.setProfileId(userDto.getProfileId()); + user.setOnline(userDto.getOnline()); + return userRepository.save(user); + }).orElseThrow(() -> new RuntimeException("User not found")); + } + + public void deleteUser(UUID id) { + userRepository.deleteById(id); + } + + public void updateOnlineStatus(UUID id, boolean status) { + userRepository.findById(id).ifPresent(user -> { + user.setOnline(status); + userRepository.save(user); + }); + } + +// public void updateProfileId(UUID userId, UUID profileId) { +// userRepository.findById(userId).ifPresent(user -> { +// user.setProfileId(profileId); +// userRepository.save(user); +// }); +// } +} diff --git a/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java b/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java deleted file mode 100644 index 70e09ac28b..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java +++ /dev/null @@ -1,87 +0,0 @@ -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; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class DiscodeitApplication { - - public static void main(String[] args) { - SpringApplication.run(DiscodeitApplication.class, args); - } - - // ✅ Repository Bean 등록 - @Bean - public UserRepository userRepository() { - return new FileUserRepository(); - } - - @Bean - public ChannelRepository channelRepository() { - return new FileChannelRepository(); - } - - @Bean - public MessageRepository messageRepository() { - return new FileMessageRepository(); - } - - // ✅ Service Bean 등록 - @Bean - public UserService userService(UserRepository userRepository) { - return new BasicUserService(userRepository); - } - - @Bean - public ChannelService channelService(ChannelRepository channelRepository) { - return new BasicChannelService(channelRepository); - } - - @Bean - public MessageService messageService(MessageRepository messageRepository, - ChannelRepository channelRepository, - UserRepository userRepository) { - return new BasicMessageService(messageRepository, channelRepository, userRepository); - } - - // ✅ 기존 JavaApplication의 테스트 로직 이동 - @Bean - public CommandLineRunner runner(UserService userService, ChannelService channelService, MessageService messageService) { - return args -> { - User user = setupUser(userService); - Channel channel = setupChannel(channelService); - messageCreateTest(messageService, channel, user); - }; - } - - static User setupUser(UserService userService) { - return userService.create("woody", "woody@codeit.com", "woody1234"); - } - - static Channel setupChannel(ChannelService channelService) { - return channelService.create(ChannelType.PUBLIC, "공지", "공지 채널입니다."); - } - - 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/src/main/java/com/sprint/mission/discodeit/entity/BaseEntity.java b/src/main/java/com/sprint/mission/discodeit/entity/BaseEntity.java deleted file mode 100644 index 9e50fca4cb..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/BaseEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.time.Instant; -import java.util.UUID; - -public abstract class BaseEntity { - protected UUID id; - protected Instant createdAt; - protected Instant updatedAt; -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java b/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java deleted file mode 100644 index c55ef74e32..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/BinaryContent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.time.Instant; -import java.util.UUID; - -// BinaryContent: 이미지 및 파일 저장 (수정 불가) -public class BinaryContent { - private UUID id; - private Instant createdAt; - private UUID ownerId; // User or Message owner - private byte[] content; -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/Channel.java b/src/main/java/com/sprint/mission/discodeit/entity/Channel.java deleted file mode 100644 index b3942d9680..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/Channel.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - -public class Channel implements Serializable { - private static final long serialVersionUID = 1L; - private UUID id; - private Long createdAt; - private Long 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().getEpochSecond(); - this.type = type; - this.name = name; - this.description = description; - } - - public UUID getId() { - return id; - } - - public Long getCreatedAt() { - return createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public ChannelType getType() { - return type; - } - - public String getName() { - return name; - } - - public String getDescription() { - return 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().getEpochSecond(); - } - } -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java b/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java deleted file mode 100644 index 9a2ff3f0fd..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/ChannelType.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -public enum ChannelType { - PUBLIC, - PRIVATE, -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/Message.java b/src/main/java/com/sprint/mission/discodeit/entity/Message.java deleted file mode 100644 index e622318a5a..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/Message.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - -public class Message implements Serializable { - private static final long serialVersionUID = 1L; - - private UUID id; - private Long createdAt; - private Long 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().getEpochSecond(); - // - this.content = content; - this.channelId = channelId; - this.authorId = authorId; - } - - public UUID getId() { - return id; - } - - public Long getCreatedAt() { - return createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public String getContent() { - return content; - } - - public UUID getChannelId() { - return channelId; - } - - public UUID getAuthorId() { - return 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().getEpochSecond(); - } - } -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java b/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java deleted file mode 100644 index f849e709a7..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/ReadStatus.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.time.Instant; -import java.util.UUID; - -// ReadStatus: 사용자의 채널별 마지막 메시지 읽은 시간 관리 -public class ReadStatus extends BaseEntity { - private UUID userId; - private UUID channelId; - private Instant lastReadAt; -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/User.java b/src/main/java/com/sprint/mission/discodeit/entity/User.java deleted file mode 100644 index c4f0faaa3e..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/User.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - -public class User implements Serializable { - private static final long serialVersionUID = 1L; - - private UUID id; - private Long createdAt; - private Long 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().getEpochSecond(); - // - this.username = username; - this.email = email; - this.password = password; - } - - public UUID getId() { - return id; - } - - public Long getCreatedAt() { - return createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public String getUsername() { - return username; - } - - public String getEmail() { - return email; - } - - public String getPassword() { - return 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().getEpochSecond(); - } - } -} diff --git a/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java b/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java deleted file mode 100644 index df3e351512..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/entity/UserStatus.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.sprint.mission.discodeit.entity; - -import java.time.Instant; -import java.util.UUID; - -// UserStatus: 사용자의 마지막 접속 시간 관리 및 온라인 상태 확인 -public class UserStatus extends BaseEntity { - private UUID userId; - private Instant lastSeenAt; - - // 현재 접속 상태 여부 (5분 이내 접속) - public boolean isOnline() { - return lastSeenAt != null && Instant.now().minusSeconds(300).isBefore(lastSeenAt); - } -} diff --git a/src/main/java/com/sprint/mission/discodeit/repository/BinaryContentRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/BinaryContentRepository.java deleted file mode 100644 index 8af3de476a..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/BinaryContentRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.sprint.mission.discodeit.repository; - -import com.sprint.mission.discodeit.entity.BinaryContent; - -import java.util.UUID; - -public interface BinaryContentRepository { - BinaryContent findById(UUID id); -} - diff --git a/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java deleted file mode 100644 index 326a84f4ba..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/ChannelRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java deleted file mode 100644 index 1477de7216..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/MessageRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/repository/ReadStatusRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/ReadStatusRepository.java deleted file mode 100644 index 56db0e4cd1..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/ReadStatusRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.sprint.mission.discodeit.repository; - -import com.sprint.mission.discodeit.entity.*; -import java.util.UUID; - -public interface ReadStatusRepository { - ReadStatus findByUserIdAndChannelId(UUID userId, UUID channelId); -} diff --git a/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java deleted file mode 100644 index ebdbcb9e48..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/UserRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/repository/UserStatusRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/UserStatusRepository.java deleted file mode 100644 index 85b88a64bd..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/UserStatusRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.sprint.mission.discodeit.repository; - -import com.sprint.mission.discodeit.entity.UserStatus; - -import java.util.UUID; - -public interface UserStatusRepository { - UserStatus findByUserId(UUID userId); -} diff --git a/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java deleted file mode 100644 index 48b7de3422..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/file/FileChannelRepository.java +++ /dev/null @@ -1,102 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java deleted file mode 100644 index bf71910fbc..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/file/FileMessageRepository.java +++ /dev/null @@ -1,102 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java deleted file mode 100644 index 1c34af6115..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/file/FileUserRepository.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.sprint.mission.discodeit.repository.file; - -import com.sprint.mission.discodeit.entity.User; -import com.sprint.mission.discodeit.repository.UserRepository; -import org.springframework.context.annotation.Primary; -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 -@Primary -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/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java deleted file mode 100644 index 3885eb0d78..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFChannelRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sprint.mission.discodeit.repository.jcf; - -import com.sprint.mission.discodeit.entity.Channel; -import com.sprint.mission.discodeit.repository.ChannelRepository; -import org.springframework.stereotype.Repository; - -import java.util.*; - -@Repository -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/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java deleted file mode 100644 index f5c241c3b8..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFMessageRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sprint.mission.discodeit.repository.jcf; - -import com.sprint.mission.discodeit.entity.Message; -import com.sprint.mission.discodeit.repository.MessageRepository; -import org.springframework.stereotype.Repository; - -import java.util.*; - -@Repository -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/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java b/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java deleted file mode 100644 index e5ba8b3c5f..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/repository/jcf/JCFUserRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sprint.mission.discodeit.repository.jcf; - -import com.sprint.mission.discodeit.entity.User; -import com.sprint.mission.discodeit.repository.UserRepository; -import org.springframework.stereotype.Repository; - -import java.util.*; - -@Repository -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/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java b/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java deleted file mode 100644 index eaa8e07d5e..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/ChannelService.java +++ /dev/null @@ -1,15 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/service/MessageService.java b/src/main/java/com/sprint/mission/discodeit/service/MessageService.java deleted file mode 100644 index e7662d0cd6..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/MessageService.java +++ /dev/null @@ -1,14 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/service/UserService.java b/src/main/java/com/sprint/mission/discodeit/service/UserService.java deleted file mode 100644 index 79111d5553..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/UserService.java +++ /dev/null @@ -1,14 +0,0 @@ -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/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java b/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java deleted file mode 100644 index 35273e12ee..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/basic/BasicChannelService.java +++ /dev/null @@ -1,50 +0,0 @@ -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; - -@RequiredArgsConstructor -@Service -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 = find(channelId); - 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/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java b/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java deleted file mode 100644 index 6770a59123..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/basic/BasicMessageService.java +++ /dev/null @@ -1,60 +0,0 @@ -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.UUID; - -@RequiredArgsConstructor -@Service -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 = find(messageId); - 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/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java b/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java deleted file mode 100644 index 37a7b99431..0000000000 --- a/src/main/java/com/sprint/mission/discodeit/service/basic/BasicUserService.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sprint.mission.discodeit.service.basic; - -import com.sprint.mission.discodeit.entity.User; -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; - -@RequiredArgsConstructor -@Service -public class BasicUserService implements UserService { - private final UserRepository userRepository; - - @Override - public User create(String username, String email, String password) { - User user = new User(username, email, password); - return userRepository.save(user); - } - - @Override - public User find(UUID userId) { - return userRepository.findById(userId) - .orElseThrow(() -> new NoSuchElementException("User with id " + userId + " not found")); - } - - @Override - public List findAll() { - return userRepository.findAll(); - } - - @Override - public User update(UUID userId, String newUsername, String newEmail, String newPassword) { - User user = find(userId); - user.update(newUsername, newEmail, newPassword); - return userRepository.save(user); - } - - @Override - public void delete(UUID userId) { - if (!userRepository.existsById(userId)) { - throw new NoSuchElementException("User with id " + userId + " not found"); - } - userRepository.deleteById(userId); - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index 24910bdf1c..0000000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,6 +0,0 @@ -server: - port: 8080 - -spring: - application: - name: discodeit diff --git a/src/main/resources/static/script.js b/src/main/resources/static/script.js new file mode 100644 index 0000000000..e63118b89c --- /dev/null +++ b/src/main/resources/static/script.js @@ -0,0 +1,67 @@ +// API endpoints +const API_BASE_URL = '/api'; +const ENDPOINTS = { + USERS: `${API_BASE_URL}/user/findAll`, + BINARY_CONTENT: `${API_BASE_URL}/binaryContent/find` +}; + +// Initialize the application +document.addEventListener('DOMContentLoaded', () => { + fetchAndRenderUsers(); +}); + +// Fetch users from the API +async function fetchAndRenderUsers() { + try { + const response = await fetch(ENDPOINTS.USERS); + if (!response.ok) throw new Error('Failed to fetch users'); + const users = await response.json(); + renderUserList(users); + } catch (error) { + console.error('Error fetching users:', error); + } +} + +// Fetch user profile image +async function fetchUserProfile(profileId) { + try { + const response = await fetch(`${ENDPOINTS.BINARY_CONTENT}?binaryContentId=${profileId}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + const profile = await response.json(); + + // Convert base64 encoded bytes to data URL + return `data:${profile.contentType};base64,${profile.bytes}`; + } catch (error) { + console.error('Error fetching profile:', error); + return '/default-avatar.png'; // Fallback to default avatar + } +} + +// Render user list +async function renderUserList(users) { + const userListElement = document.getElementById('userList'); + userListElement.innerHTML = ''; // Clear existing content + + for (const user of users) { + const userElement = document.createElement('div'); + userElement.className = 'user-item'; + + // Get profile image URL + const profileUrl = user.profileId ? + await fetchUserProfile(user.profileId) : + '/default-avatar.png'; + + userElement.innerHTML = ` + ${user.username} + +
+ ${user.online ? '온라인' : '오프라인'} +
+ `; + + userListElement.appendChild(userElement); + } +} \ No newline at end of file diff --git a/src/main/resources/static/styles.css b/src/main/resources/static/styles.css new file mode 100644 index 0000000000..b45f4e7042 --- /dev/null +++ b/src/main/resources/static/styles.css @@ -0,0 +1,80 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: Arial, sans-serif; + background-color: #f5f5f5; +} + +.container { + max-width: 800px; + margin: 0 auto; + padding: 20px; +} + +h1 { + text-align: center; + margin-bottom: 30px; + color: #333; +} + +.user-list { + background-color: white; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.user-item { + display: flex; + align-items: center; + padding: 20px; + border-bottom: 1px solid #eee; +} + +.user-item:last-child { + border-bottom: none; +} + +.user-avatar { + width: 60px; + height: 60px; + border-radius: 50%; + margin-right: 20px; + object-fit: cover; +} + +.user-info { + flex-grow: 1; +} + +.user-name { + font-size: 18px; + font-weight: bold; + color: #333; + margin-bottom: 5px; +} + +.user-email { + font-size: 14px; + color: #666; +} + +.status-badge { + padding: 6px 12px; + border-radius: 20px; + font-size: 14px; + font-weight: bold; +} + +.online { + background-color: #4CAF50; + color: white; +} + +.offline { + background-color: #9e9e9e; + color: white; +} \ No newline at end of file diff --git a/src/main/resources/static/user-list.html b/src/main/resources/static/user-list.html new file mode 100644 index 0000000000..f3acfdb596 --- /dev/null +++ b/src/main/resources/static/user-list.html @@ -0,0 +1,18 @@ + + + + + + 사용자 목록 + + + +
+

사용자 목록

+
+ +
+
+ + + \ No newline at end of file diff --git a/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java b/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java deleted file mode 100644 index f6096d0b0c..0000000000 --- a/src/test/java/com/sprint/mission/discodeit/DiscodeitApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sprint.mission.discodeit; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = DiscodeitApplication.class) -class DiscodeitApplicationTests { - - @Test - void contextLoads() { - // Spring Boot 컨텍스트가 정상적으로 로드되는지 확인하는 테스트 - } -} diff --git "a/uploads/ee7ec40f-ea90-4c71-a00b-e17c613dd5e2_\354\247\204\354\235\264.jpeg" "b/uploads/ee7ec40f-ea90-4c71-a00b-e17c613dd5e2_\354\247\204\354\235\264.jpeg" new file mode 100644 index 0000000000..cc497b1b0e Binary files /dev/null and "b/uploads/ee7ec40f-ea90-4c71-a00b-e17c613dd5e2_\354\247\204\354\235\264.jpeg" differ diff --git "a/uploads/\354\247\204\354\235\264.jpeg" "b/uploads/\354\247\204\354\235\264.jpeg" new file mode 100644 index 0000000000..cc497b1b0e Binary files /dev/null and "b/uploads/\354\247\204\354\235\264.jpeg" differ