From 94741e79d0fcec4e329dbd88c02b834be62d2d8a Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 09:47:18 +0900 Subject: [PATCH 01/18] =?UTF-8?q?chore:=20user=20=ED=8E=98=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{user => }/controller/UserController.java | 20 +++++++++---------- .../note/back/{user => data}/entity/User.java | 10 +++++----- .../repository/UserRepository.java | 4 ++-- .../back/{user => }/service/UserService.java | 16 +++++++-------- .../user/controller/UserControllerTest.java | 19 +++++++++--------- .../back/user/service/UserServiceTest.java | 15 +++++++------- 6 files changed, 43 insertions(+), 41 deletions(-) rename src/main/java/my/music/note/back/{user => }/controller/UserController.java (72%) rename src/main/java/my/music/note/back/{user => data}/entity/User.java (84%) rename src/main/java/my/music/note/back/{user => data}/repository/UserRepository.java (77%) rename src/main/java/my/music/note/back/{user => }/service/UserService.java (75%) diff --git a/src/main/java/my/music/note/back/user/controller/UserController.java b/src/main/java/my/music/note/back/controller/UserController.java similarity index 72% rename from src/main/java/my/music/note/back/user/controller/UserController.java rename to src/main/java/my/music/note/back/controller/UserController.java index cd27c75..2db79a9 100644 --- a/src/main/java/my/music/note/back/user/controller/UserController.java +++ b/src/main/java/my/music/note/back/controller/UserController.java @@ -1,15 +1,15 @@ -package my.music.note.back.user.controller; +package my.music.note.back.controller; import lombok.RequiredArgsConstructor; -import my.music.note.back.jwt.dto.response.TokenCreateResponse; -import my.music.note.back.jwt.service.TokenService; -import my.music.note.back.user.dto.request.DeleteAccountRequest; -import my.music.note.back.user.dto.request.FindUserRequest; -import my.music.note.back.user.dto.request.LoginOrRegisterRequest; -import my.music.note.back.user.dto.request.ModifyNameRequest; -import my.music.note.back.user.dto.response.FindUserResponse; -import my.music.note.back.user.entity.User; -import my.music.note.back.user.service.UserService; +import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; +import my.music.note.back.service.TokenService; +import my.music.note.back.data.dto.request.user.DeleteAccountRequest; +import my.music.note.back.data.dto.request.user.FindUserRequest; +import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; +import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.entity.User; +import my.music.note.back.service.UserService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/my/music/note/back/user/entity/User.java b/src/main/java/my/music/note/back/data/entity/User.java similarity index 84% rename from src/main/java/my/music/note/back/user/entity/User.java rename to src/main/java/my/music/note/back/data/entity/User.java index a741a32..681d8a8 100644 --- a/src/main/java/my/music/note/back/user/entity/User.java +++ b/src/main/java/my/music/note/back/data/entity/User.java @@ -1,15 +1,15 @@ -package my.music.note.back.user.entity; +package my.music.note.back.data.entity; import jakarta.persistence.*; import lombok.NoArgsConstructor; -import my.music.note.back.user.dto.request.LoginOrRegisterRequest; -import my.music.note.back.user.dto.request.ModifyNameRequest; -import my.music.note.back.user.dto.response.FindUserResponse; +import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; +import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.user.FindUserResponse; import java.time.LocalDateTime; @Entity -@Table(name = "users") +@Table(name = "user") @NoArgsConstructor public class User { diff --git a/src/main/java/my/music/note/back/user/repository/UserRepository.java b/src/main/java/my/music/note/back/data/repository/UserRepository.java similarity index 77% rename from src/main/java/my/music/note/back/user/repository/UserRepository.java rename to src/main/java/my/music/note/back/data/repository/UserRepository.java index ef2bcf4..fe4bcb3 100644 --- a/src/main/java/my/music/note/back/user/repository/UserRepository.java +++ b/src/main/java/my/music/note/back/data/repository/UserRepository.java @@ -1,6 +1,6 @@ -package my.music.note.back.user.repository; +package my.music.note.back.data.repository; -import my.music.note.back.user.entity.User; +import my.music.note.back.data.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; diff --git a/src/main/java/my/music/note/back/user/service/UserService.java b/src/main/java/my/music/note/back/service/UserService.java similarity index 75% rename from src/main/java/my/music/note/back/user/service/UserService.java rename to src/main/java/my/music/note/back/service/UserService.java index 504ce1a..9b8871d 100644 --- a/src/main/java/my/music/note/back/user/service/UserService.java +++ b/src/main/java/my/music/note/back/service/UserService.java @@ -1,15 +1,15 @@ -package my.music.note.back.user.service; +package my.music.note.back.service; import jakarta.transaction.Transactional; import lombok.AllArgsConstructor; -import my.music.note.back.user.dto.request.DeleteAccountRequest; -import my.music.note.back.user.dto.request.FindUserRequest; -import my.music.note.back.user.dto.request.LoginOrRegisterRequest; -import my.music.note.back.user.dto.request.ModifyNameRequest; -import my.music.note.back.user.dto.response.FindUserResponse; -import my.music.note.back.user.entity.User; -import my.music.note.back.user.repository.UserRepository; +import my.music.note.back.data.dto.request.user.DeleteAccountRequest; +import my.music.note.back.data.dto.request.user.FindUserRequest; +import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; +import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.entity.User; +import my.music.note.back.data.repository.UserRepository; import org.springframework.stereotype.Service; import java.util.Optional; diff --git a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java index 9417ef2..ed637c8 100644 --- a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java +++ b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java @@ -2,15 +2,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.servlet.http.Cookie; -import my.music.note.back.jwt.dto.response.TokenCreateResponse; -import my.music.note.back.jwt.service.TokenService; -import my.music.note.back.user.dto.request.DeleteAccountRequest; -import my.music.note.back.user.dto.request.FindUserRequest; -import my.music.note.back.user.dto.request.LoginOrRegisterRequest; -import my.music.note.back.user.dto.request.ModifyNameRequest; -import my.music.note.back.user.dto.response.FindUserResponse; -import my.music.note.back.user.entity.User; -import my.music.note.back.user.service.UserService; +import my.music.note.back.controller.UserController; +import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; +import my.music.note.back.service.TokenService; +import my.music.note.back.data.dto.request.user.DeleteAccountRequest; +import my.music.note.back.data.dto.request.user.FindUserRequest; +import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; +import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.entity.User; +import my.music.note.back.service.UserService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/my/music/note/back/user/service/UserServiceTest.java b/src/test/java/my/music/note/back/user/service/UserServiceTest.java index 1dedf70..d5b15bb 100644 --- a/src/test/java/my/music/note/back/user/service/UserServiceTest.java +++ b/src/test/java/my/music/note/back/user/service/UserServiceTest.java @@ -1,12 +1,13 @@ package my.music.note.back.user.service; -import my.music.note.back.user.dto.request.DeleteAccountRequest; -import my.music.note.back.user.dto.request.FindUserRequest; -import my.music.note.back.user.dto.request.LoginOrRegisterRequest; -import my.music.note.back.user.dto.request.ModifyNameRequest; -import my.music.note.back.user.dto.response.FindUserResponse; -import my.music.note.back.user.entity.User; -import my.music.note.back.user.repository.UserRepository; +import my.music.note.back.data.dto.request.user.DeleteAccountRequest; +import my.music.note.back.data.dto.request.user.FindUserRequest; +import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; +import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.entity.User; +import my.music.note.back.data.repository.UserRepository; +import my.music.note.back.service.UserService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; From 2562709834639732256de2b6b06406fa02ffa89d Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 09:47:31 +0900 Subject: [PATCH 02/18] =?UTF-8?q?chore:=20token=20=ED=8E=98=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/jwt}/TokenCreateRequest.java | 2 +- .../dto/response/jwt}/TokenCreateResponse.java | 2 +- .../music/note/back/{jwt => }/service/TokenService.java | 8 +++----- .../note/back/{jwt => }/validator/TokenValidator.java | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) rename src/main/java/my/music/note/back/{jwt/dto/request => data/dto/request/jwt}/TokenCreateRequest.java (60%) rename src/main/java/my/music/note/back/{jwt/dto/response => data/dto/response/jwt}/TokenCreateResponse.java (51%) rename src/main/java/my/music/note/back/{jwt => }/service/TokenService.java (85%) rename src/main/java/my/music/note/back/{jwt => }/validator/TokenValidator.java (94%) diff --git a/src/main/java/my/music/note/back/jwt/dto/request/TokenCreateRequest.java b/src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java similarity index 60% rename from src/main/java/my/music/note/back/jwt/dto/request/TokenCreateRequest.java rename to src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java index 698813c..7702486 100644 --- a/src/main/java/my/music/note/back/jwt/dto/request/TokenCreateRequest.java +++ b/src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.jwt.dto.request; +package my.music.note.back.data.dto.request.jwt; public record TokenCreateRequest(String providerId, boolean isAdmin) { diff --git a/src/main/java/my/music/note/back/jwt/dto/response/TokenCreateResponse.java b/src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java similarity index 51% rename from src/main/java/my/music/note/back/jwt/dto/response/TokenCreateResponse.java rename to src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java index 159ca7f..a102ffe 100644 --- a/src/main/java/my/music/note/back/jwt/dto/response/TokenCreateResponse.java +++ b/src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java @@ -1,4 +1,4 @@ -package my.music.note.back.jwt.dto.response; +package my.music.note.back.data.dto.response.jwt; public record TokenCreateResponse(String token) { } diff --git a/src/main/java/my/music/note/back/jwt/service/TokenService.java b/src/main/java/my/music/note/back/service/TokenService.java similarity index 85% rename from src/main/java/my/music/note/back/jwt/service/TokenService.java rename to src/main/java/my/music/note/back/service/TokenService.java index 12f12b7..76bda99 100644 --- a/src/main/java/my/music/note/back/jwt/service/TokenService.java +++ b/src/main/java/my/music/note/back/service/TokenService.java @@ -1,14 +1,12 @@ -package my.music.note.back.jwt.service; +package my.music.note.back.service; import com.auth0.jwt.JWT; import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.interfaces.DecodedJWT; import lombok.RequiredArgsConstructor; import my.music.note.back.config.TokenConfig; -import my.music.note.back.jwt.dto.response.TokenCreateResponse; -import my.music.note.back.jwt.validator.TokenValidator; -import my.music.note.back.user.dto.request.DeleteAccountRequest; +import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; +import my.music.note.back.validator.TokenValidator; import org.springframework.stereotype.Service; import java.util.Date; diff --git a/src/main/java/my/music/note/back/jwt/validator/TokenValidator.java b/src/main/java/my/music/note/back/validator/TokenValidator.java similarity index 94% rename from src/main/java/my/music/note/back/jwt/validator/TokenValidator.java rename to src/main/java/my/music/note/back/validator/TokenValidator.java index 9cab422..66b05f5 100644 --- a/src/main/java/my/music/note/back/jwt/validator/TokenValidator.java +++ b/src/main/java/my/music/note/back/validator/TokenValidator.java @@ -1,4 +1,4 @@ -package my.music.note.back.jwt.validator; +package my.music.note.back.validator; import com.auth0.jwt.JWT; import com.auth0.jwt.JWTVerifier; From 92ab52071b5427b2cfeb4a7fdd21d2cc10f62956 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 09:47:41 +0900 Subject: [PATCH 03/18] =?UTF-8?q?chore:=20gpt=20=ED=8E=98=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/{gpt => }/controller/ChatGPTController.java | 6 +++--- .../dto => data/dto/request/gpt}/ChatCompletionDto.java | 2 +- .../dto => data/dto/request/gpt}/ChatRequestMsgDto.java | 2 +- .../music/note/back/{gpt => }/service/ChatGPTService.java | 4 ++-- .../note/back/gpt/controller/ChatGPTControllerTest.java | 8 ++++---- .../music/note/back/gpt/service/ChatGPTServiceTest.java | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-) rename src/main/java/my/music/note/back/{gpt => }/controller/ChatGPTController.java (86%) rename src/main/java/my/music/note/back/{gpt/dto => data/dto/request/gpt}/ChatCompletionDto.java (89%) rename src/main/java/my/music/note/back/{gpt/dto => data/dto/request/gpt}/ChatRequestMsgDto.java (86%) rename src/main/java/my/music/note/back/{gpt => }/service/ChatGPTService.java (94%) diff --git a/src/main/java/my/music/note/back/gpt/controller/ChatGPTController.java b/src/main/java/my/music/note/back/controller/ChatGPTController.java similarity index 86% rename from src/main/java/my/music/note/back/gpt/controller/ChatGPTController.java rename to src/main/java/my/music/note/back/controller/ChatGPTController.java index 139c2e1..2803327 100644 --- a/src/main/java/my/music/note/back/gpt/controller/ChatGPTController.java +++ b/src/main/java/my/music/note/back/controller/ChatGPTController.java @@ -1,9 +1,9 @@ -package my.music.note.back.gpt.controller; +package my.music.note.back.controller; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import my.music.note.back.gpt.dto.ChatCompletionDto; -import my.music.note.back.gpt.service.ChatGPTService; +import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; +import my.music.note.back.service.ChatGPTService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/my/music/note/back/gpt/dto/ChatCompletionDto.java b/src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java similarity index 89% rename from src/main/java/my/music/note/back/gpt/dto/ChatCompletionDto.java rename to src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java index 5eabb6a..1b6498c 100644 --- a/src/main/java/my/music/note/back/gpt/dto/ChatCompletionDto.java +++ b/src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java @@ -1,4 +1,4 @@ -package my.music.note.back.gpt.dto; +package my.music.note.back.data.dto.request.gpt; import lombok.*; diff --git a/src/main/java/my/music/note/back/gpt/dto/ChatRequestMsgDto.java b/src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java similarity index 86% rename from src/main/java/my/music/note/back/gpt/dto/ChatRequestMsgDto.java rename to src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java index de45ef7..0903841 100644 --- a/src/main/java/my/music/note/back/gpt/dto/ChatRequestMsgDto.java +++ b/src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java @@ -1,4 +1,4 @@ -package my.music.note.back.gpt.dto; +package my.music.note.back.data.dto.request.gpt; import lombok.*; diff --git a/src/main/java/my/music/note/back/gpt/service/ChatGPTService.java b/src/main/java/my/music/note/back/service/ChatGPTService.java similarity index 94% rename from src/main/java/my/music/note/back/gpt/service/ChatGPTService.java rename to src/main/java/my/music/note/back/service/ChatGPTService.java index 7127854..26fc851 100644 --- a/src/main/java/my/music/note/back/gpt/service/ChatGPTService.java +++ b/src/main/java/my/music/note/back/service/ChatGPTService.java @@ -1,4 +1,4 @@ -package my.music.note.back.gpt.service; +package my.music.note.back.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -6,7 +6,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import my.music.note.back.config.ChatGPTConfig; -import my.music.note.back.gpt.dto.ChatCompletionDto; +import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java b/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java index 591e9db..b5f6251 100644 --- a/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java +++ b/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java @@ -1,13 +1,13 @@ package my.music.note.back.gpt.controller; import com.fasterxml.jackson.databind.ObjectMapper; -import my.music.note.back.gpt.dto.ChatCompletionDto; -import my.music.note.back.gpt.dto.ChatRequestMsgDto; -import my.music.note.back.gpt.service.ChatGPTService; +import my.music.note.back.controller.ChatGPTController; +import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; +import my.music.note.back.data.dto.request.gpt.ChatRequestMsgDto; +import my.music.note.back.service.ChatGPTService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; diff --git a/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java b/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java index 22929a9..cdf4590 100644 --- a/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java +++ b/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java @@ -1,8 +1,9 @@ package my.music.note.back.gpt.service; import my.music.note.back.config.ChatGPTConfig; -import my.music.note.back.gpt.dto.ChatCompletionDto; -import my.music.note.back.gpt.dto.ChatRequestMsgDto; +import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; +import my.music.note.back.data.dto.request.gpt.ChatRequestMsgDto; +import my.music.note.back.service.ChatGPTService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From e2acb5b201039937350fc6548a2e7c596b3ca999 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 09:47:59 +0900 Subject: [PATCH 04/18] =?UTF-8?q?chore:=20user=20dto=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/data/dto/request/user/DeleteAccountRequest.java | 4 ++++ .../note/back/data/dto/request/user/FindUserRequest.java | 4 ++++ .../dto/request/user}/LoginOrRegisterRequest.java | 2 +- .../request => data/dto/request/user}/ModifyNameRequest.java | 2 +- .../response => data/dto/response/user}/FindUserResponse.java | 2 +- .../note/back/user/dto/request/DeleteAccountRequest.java | 4 ---- .../my/music/note/back/user/dto/request/FindUserRequest.java | 4 ---- 7 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java create mode 100644 src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java rename src/main/java/my/music/note/back/{user/dto/request => data/dto/request/user}/LoginOrRegisterRequest.java (67%) rename src/main/java/my/music/note/back/{user/dto/request => data/dto/request/user}/ModifyNameRequest.java (50%) rename src/main/java/my/music/note/back/{user/dto/response => data/dto/response/user}/FindUserResponse.java (60%) delete mode 100644 src/main/java/my/music/note/back/user/dto/request/DeleteAccountRequest.java delete mode 100644 src/main/java/my/music/note/back/user/dto/request/FindUserRequest.java diff --git a/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java new file mode 100644 index 0000000..4aff526 --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.request.user; + +public record DeleteAccountRequest(Long id) { +} diff --git a/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java new file mode 100644 index 0000000..ed0d3d2 --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.request.user; + +public record FindUserRequest(Long id) { +} diff --git a/src/main/java/my/music/note/back/user/dto/request/LoginOrRegisterRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java similarity index 67% rename from src/main/java/my/music/note/back/user/dto/request/LoginOrRegisterRequest.java rename to src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java index 7d099cd..3bf58a0 100644 --- a/src/main/java/my/music/note/back/user/dto/request/LoginOrRegisterRequest.java +++ b/src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.user.dto.request; +package my.music.note.back.data.dto.request.user; public record LoginOrRegisterRequest(String name, String email, String provider, String providerId) { diff --git a/src/main/java/my/music/note/back/user/dto/request/ModifyNameRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java similarity index 50% rename from src/main/java/my/music/note/back/user/dto/request/ModifyNameRequest.java rename to src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java index 36c0252..2ab1993 100644 --- a/src/main/java/my/music/note/back/user/dto/request/ModifyNameRequest.java +++ b/src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.user.dto.request; +package my.music.note.back.data.dto.request.user; public record ModifyNameRequest(String name) { } diff --git a/src/main/java/my/music/note/back/user/dto/response/FindUserResponse.java b/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java similarity index 60% rename from src/main/java/my/music/note/back/user/dto/response/FindUserResponse.java rename to src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java index f434fae..3305204 100644 --- a/src/main/java/my/music/note/back/user/dto/response/FindUserResponse.java +++ b/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java @@ -1,4 +1,4 @@ -package my.music.note.back.user.dto.response; +package my.music.note.back.data.dto.response.user; public record FindUserResponse(String name,String email,Boolean isAdmin) { } diff --git a/src/main/java/my/music/note/back/user/dto/request/DeleteAccountRequest.java b/src/main/java/my/music/note/back/user/dto/request/DeleteAccountRequest.java deleted file mode 100644 index f221c30..0000000 --- a/src/main/java/my/music/note/back/user/dto/request/DeleteAccountRequest.java +++ /dev/null @@ -1,4 +0,0 @@ -package my.music.note.back.user.dto.request; - -public record DeleteAccountRequest(Long id) { -} diff --git a/src/main/java/my/music/note/back/user/dto/request/FindUserRequest.java b/src/main/java/my/music/note/back/user/dto/request/FindUserRequest.java deleted file mode 100644 index d0891c0..0000000 --- a/src/main/java/my/music/note/back/user/dto/request/FindUserRequest.java +++ /dev/null @@ -1,4 +0,0 @@ -package my.music.note.back.user.dto.request; - -public record FindUserRequest(Long id) { -} From 727401cbab444355da4fe2ac145a0b3c71f79e32 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 09:51:07 +0900 Subject: [PATCH 05/18] =?UTF-8?q?feat:=20user=20entity=20access=20modifier?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20default=20->=20private?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../my/music/note/back/data/entity/User.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/my/music/note/back/data/entity/User.java b/src/main/java/my/music/note/back/data/entity/User.java index 681d8a8..dd937d5 100644 --- a/src/main/java/my/music/note/back/data/entity/User.java +++ b/src/main/java/my/music/note/back/data/entity/User.java @@ -25,21 +25,21 @@ private User(String name, LocalDateTime createdAt, String email, String provider @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - Long id; + private Long id; - String name; + private String name; - LocalDateTime createdAt; + private LocalDateTime createdAt; - String email; + private String email; - String provider; + private String provider; - String providerId; + private String providerId; - Boolean isAdmin; + private Boolean isAdmin; - Boolean isDeleted; + private Boolean isDeleted; public Long getUserId() { return id; From 59bc781169755596de6837027120ad04d56a1d54 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:20:11 +0900 Subject: [PATCH 06/18] =?UTF-8?q?feat:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20save=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/my/music/note/back/service/UserService.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/my/music/note/back/service/UserService.java b/src/main/java/my/music/note/back/service/UserService.java index 9b8871d..8fdbdd3 100644 --- a/src/main/java/my/music/note/back/service/UserService.java +++ b/src/main/java/my/music/note/back/service/UserService.java @@ -34,11 +34,9 @@ public User loginOrRegister(LoginOrRegisterRequest request) { public void deleteUser(DeleteAccountRequest request) { Optional optionalUser = userRepository.findById(request.id()); - + User user = optionalUser.orElseThrow(RuntimeException::new); - - user.deleteAccount(); - userRepository.save(user); + user.deleteAccount();; } public void modifyName(ModifyNameRequest request, Long userId) { @@ -47,7 +45,6 @@ public void modifyName(ModifyNameRequest request, Long userId) { User user = optionalUser.orElseThrow(RuntimeException::new); user.modifyName(request); - userRepository.save(user); } public FindUserResponse findUser(FindUserRequest request) { From 83424c203fa6091e807b8317423e14fce67ccd29 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:20:20 +0900 Subject: [PATCH 07/18] =?UTF-8?q?test:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20save=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/my/music/note/back/user/service/UserServiceTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/my/music/note/back/user/service/UserServiceTest.java b/src/test/java/my/music/note/back/user/service/UserServiceTest.java index d5b15bb..5960676 100644 --- a/src/test/java/my/music/note/back/user/service/UserServiceTest.java +++ b/src/test/java/my/music/note/back/user/service/UserServiceTest.java @@ -71,7 +71,6 @@ void givenDeleteAccountRequest_whenCallDeleteUser_thenReturnVoid(@Mock DeleteAcc verify(userRepository, times(1)).findById(1L); verify(user, times(1)).deleteAccount(); - verify(userRepository, times(1)).save(user); } @Test @@ -85,7 +84,6 @@ void givenModifyNameRequestAndUserId_whenCallModifyName_thenReturnVoid(@Mock Mod verify(userRepository, times(1)).findById(1L); verify(user, times(1)).modifyName(modifyNameRequest); - verify(userRepository, times(1)).save(user); } From 1738c32c79cd897715e1ed73e1055b6652b4f9c7 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:22:21 +0900 Subject: [PATCH 08/18] =?UTF-8?q?refactor:=20user=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EC=9E=AC=EC=A0=95?= =?UTF-8?q?=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/my/music/note/back/controller/UserController.java | 2 +- .../note/back/data/dto/response/user/FindUserResponse.java | 2 +- src/main/java/my/music/note/back/data/entity/User.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/my/music/note/back/controller/UserController.java b/src/main/java/my/music/note/back/controller/UserController.java index 2db79a9..c5ab787 100644 --- a/src/main/java/my/music/note/back/controller/UserController.java +++ b/src/main/java/my/music/note/back/controller/UserController.java @@ -47,7 +47,7 @@ public void modifyName(@CookieValue String token, @RequestBody ModifyNameRequest } @GetMapping - public ResponseEntity findUserInfo(@CookieValue String token) { + public ResponseEntity findUser(@CookieValue String token) { Long userId = tokenService.getUserId(token); diff --git a/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java b/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java index 3305204..119e31a 100644 --- a/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java +++ b/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java @@ -1,4 +1,4 @@ package my.music.note.back.data.dto.response.user; -public record FindUserResponse(String name,String email,Boolean isAdmin) { +public record FindUserResponse(String name, String email, Boolean isAdmin) { } diff --git a/src/main/java/my/music/note/back/data/entity/User.java b/src/main/java/my/music/note/back/data/entity/User.java index dd937d5..2619829 100644 --- a/src/main/java/my/music/note/back/data/entity/User.java +++ b/src/main/java/my/music/note/back/data/entity/User.java @@ -9,7 +9,7 @@ import java.time.LocalDateTime; @Entity -@Table(name = "user") +@Table(name = "users") @NoArgsConstructor public class User { From 39ed64040cbae6cc76320c37247047d886e3bc9f Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:23:03 +0900 Subject: [PATCH 09/18] =?UTF-8?q?feat:=20Diary=20Entity=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../my/music/note/back/data/entity/Diary.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/my/music/note/back/data/entity/Diary.java diff --git a/src/main/java/my/music/note/back/data/entity/Diary.java b/src/main/java/my/music/note/back/data/entity/Diary.java new file mode 100644 index 0000000..4a33a5f --- /dev/null +++ b/src/main/java/my/music/note/back/data/entity/Diary.java @@ -0,0 +1,55 @@ +package my.music.note.back.data.entity; + +import jakarta.persistence.*; +import lombok.NoArgsConstructor; +import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; +import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; +import my.music.note.back.data.dto.response.diary.FindDiaryResponse; + +import java.time.LocalDateTime; + +@Entity +@Table(name = "diary") +@NoArgsConstructor +public class Diary { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + private String content; + + private LocalDateTime createdAt; + + private LocalDateTime currentModifiedAt; + + private Boolean isLongEntry; + + private Boolean isDeleted; + + private Diary(LocalDateTime createdAt, String content, Boolean isLongEntry) { + this.createdAt = createdAt; + this.content = content; + this.isLongEntry = isLongEntry; + this.isDeleted = false; + } + + public static Diary of(DiaryCreateRequest request) { + return new Diary(LocalDateTime.now(), request.content(), request.isLongEntry()); + } + + public void modifyDiaryContent(DiaryModifyRequest request) { + this.content = request.content(); + this.currentModifiedAt = LocalDateTime.now(); + } + + + public FindDiaryResponse convertToFindDiaryResponse() { + return new FindDiaryResponse(this.id, this.content, this.isLongEntry, this.createdAt, this.currentModifiedAt); + } + +} From 60a81bd2f127cb0a9db61218d0aa644a14e5498d Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:23:27 +0900 Subject: [PATCH 10/18] =?UTF-8?q?feat:=20Diary=20Request=20DTO=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/data/dto/request/diary/DiaryCreateRequest.java | 4 ++++ .../note/back/data/dto/request/diary/DiaryDeleteRequest.java | 4 ++++ .../note/back/data/dto/request/diary/DiaryModifyRequest.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java create mode 100644 src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java create mode 100644 src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java new file mode 100644 index 0000000..3e88a7f --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.request.diary; + +public record DiaryCreateRequest(String content,Boolean isLongEntry) { +} diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java new file mode 100644 index 0000000..8f7dabc --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.request.diary; + +public record DiaryDeleteRequest(Long diaryId) { +} diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java new file mode 100644 index 0000000..4d0cbd5 --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.request.diary; + +public record DiaryModifyRequest(Long id,String content) { +} From e5ee6e1e24c8eb4d5cc2894e6d2d3067c32a009e Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:23:39 +0900 Subject: [PATCH 11/18] =?UTF-8?q?feat:=20Diary=20Response=20DTO=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/data/dto/response/diary/FindDiaryResponse.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java diff --git a/src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java b/src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java new file mode 100644 index 0000000..22f8dab --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java @@ -0,0 +1,8 @@ +package my.music.note.back.data.dto.response.diary; + +import java.time.LocalDateTime; + +public record FindDiaryResponse(Long id, String content, Boolean isLongEntry, LocalDateTime createdAt, + LocalDateTime currentModifiedAt) { +} + From 2fa2e730a5e3aff2ab27274f67e0e3a4ae57a333 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:23:47 +0900 Subject: [PATCH 12/18] =?UTF-8?q?feat:=20Diary=20Repository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/data/repository/DiaryRepository.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/my/music/note/back/data/repository/DiaryRepository.java diff --git a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java new file mode 100644 index 0000000..85af007 --- /dev/null +++ b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java @@ -0,0 +1,13 @@ +package my.music.note.back.data.repository; + +import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.entity.Diary; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface DiaryRepository extends JpaRepository { + + List findAllByUserId(Long userId); + +} From 9e74c96bf14d107f328e2f97cecd621c1c200d02 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:24:04 +0900 Subject: [PATCH 13/18] =?UTF-8?q?feat:=20Diary=20Service=20(CRUD)=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../music/note/back/service/DiaryService.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/my/music/note/back/service/DiaryService.java diff --git a/src/main/java/my/music/note/back/service/DiaryService.java b/src/main/java/my/music/note/back/service/DiaryService.java new file mode 100644 index 0000000..932f94d --- /dev/null +++ b/src/main/java/my/music/note/back/service/DiaryService.java @@ -0,0 +1,51 @@ +package my.music.note.back.service; + +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; +import my.music.note.back.data.dto.request.diary.DiaryDeleteRequest; +import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; +import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.entity.Diary; +import my.music.note.back.data.repository.DiaryRepository; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +@Transactional +@RequiredArgsConstructor +public class DiaryService { + + private final DiaryRepository diaryRepository; + + public void createDiary(DiaryCreateRequest diaryCreateRequest) { + + Diary diary = Diary.of(diaryCreateRequest); + diaryRepository.save(diary); + } + + public void deleteDiary(DiaryDeleteRequest diaryDeleteRequest) { + diaryRepository.deleteById(diaryDeleteRequest.diaryId()); + } + + public void modifyDiary(DiaryModifyRequest diaryModifyRequest) { + + Optional optionalDiary = diaryRepository.findById(diaryModifyRequest.id()); + + Diary diary = optionalDiary.orElseThrow(IllegalArgumentException::new); + diary.modifyDiaryContent(diaryModifyRequest); + } + + public List findDiaries(Long userId) { + return diaryRepository.findAllByUserId(userId); + } + + public FindDiaryResponse findDiary(Long diaryId) { + Optional optionalDiary = diaryRepository.findById(diaryId); + Diary diary = optionalDiary.orElseThrow(IllegalArgumentException::new); + return diary.convertToFindDiaryResponse(); + } + +} From 71d291b36bcc8d8f9ac64b9e1eeca3295968cb37 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:24:38 +0900 Subject: [PATCH 14/18] =?UTF-8?q?feat:=20Diary=20Controller=20(CRUD)=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/controller/DiaryController.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/my/music/note/back/controller/DiaryController.java diff --git a/src/main/java/my/music/note/back/controller/DiaryController.java b/src/main/java/my/music/note/back/controller/DiaryController.java new file mode 100644 index 0000000..2f72aa3 --- /dev/null +++ b/src/main/java/my/music/note/back/controller/DiaryController.java @@ -0,0 +1,61 @@ +package my.music.note.back.controller; + +import lombok.RequiredArgsConstructor; +import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; +import my.music.note.back.data.dto.request.diary.DiaryDeleteRequest; +import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; +import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.service.DiaryService; +import my.music.note.back.service.TokenService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController("/api/diaries") +@RequiredArgsConstructor +public class DiaryController { + + private final DiaryService diaryService; + + private final TokenService tokenService; + + + @PostMapping + @ResponseStatus(HttpStatus.OK) + public void createDiary(@RequestBody DiaryCreateRequest request) { + diaryService.createDiary(request); + } + + @DeleteMapping + @ResponseStatus(HttpStatus.NO_CONTENT) + public void deleteDiary(@RequestBody DiaryDeleteRequest request) { + diaryService.deleteDiary(request); + } + + @PutMapping + public void modifyDiary(@RequestBody DiaryModifyRequest request) { + + diaryService.modifyDiary(request); + } + + @GetMapping("/{diaryId}") + public ResponseEntity FindDiaryResponse(@PathVariable Long diaryId) { + + FindDiaryResponse response = diaryService.findDiary(diaryId); + return new ResponseEntity<>(response, HttpStatus.OK); + + } + + @GetMapping + public ResponseEntity> FindDiaryResponse(@CookieValue String token) { + + Long userId = tokenService.getUserId(token); + List response = diaryService.findDiaries(userId); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + + +} From d45182fd044750f9d7d904fab9f4f604cc91554f Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 11:38:38 +0900 Subject: [PATCH 15/18] =?UTF-8?q?feat:=20authorization=20=EC=8A=A4?= =?UTF-8?q?=ED=8E=99=EB=B3=80=EA=B2=BD=20Cookie=20->=20Header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/controller/DiaryController.java | 3 +-- .../note/back/controller/UserController.java | 6 +++--- .../music/note/back/BackApplicationTests.java | 13 +++++++++++++ .../user/controller/UserControllerTest.java | 19 +++++++++---------- 4 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 src/test/java/my/music/note/back/BackApplicationTests.java diff --git a/src/main/java/my/music/note/back/controller/DiaryController.java b/src/main/java/my/music/note/back/controller/DiaryController.java index 2f72aa3..efe675f 100644 --- a/src/main/java/my/music/note/back/controller/DiaryController.java +++ b/src/main/java/my/music/note/back/controller/DiaryController.java @@ -21,7 +21,6 @@ public class DiaryController { private final TokenService tokenService; - @PostMapping @ResponseStatus(HttpStatus.OK) public void createDiary(@RequestBody DiaryCreateRequest request) { @@ -49,7 +48,7 @@ public ResponseEntity FindDiaryResponse(@PathVariable Long di } @GetMapping - public ResponseEntity> FindDiaryResponse(@CookieValue String token) { + public ResponseEntity> FindDiaryResponse(@RequestHeader("Authorization") String token) { Long userId = tokenService.getUserId(token); List response = diaryService.findDiaries(userId); diff --git a/src/main/java/my/music/note/back/controller/UserController.java b/src/main/java/my/music/note/back/controller/UserController.java index c5ab787..089a9ba 100644 --- a/src/main/java/my/music/note/back/controller/UserController.java +++ b/src/main/java/my/music/note/back/controller/UserController.java @@ -34,20 +34,20 @@ public ResponseEntity loginOrRegister(@RequestBody LoginOrR @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) - public void deleteAccount(@CookieValue String token) { + public void deleteAccount(@RequestHeader("Authorization") String token) { Long userId = tokenService.getUserId(token); userService.deleteUser(new DeleteAccountRequest(userId)); } @PutMapping @ResponseStatus(HttpStatus.OK) - public void modifyName(@CookieValue String token, @RequestBody ModifyNameRequest request) { + public void modifyName(@RequestHeader("Authorization") String token, @RequestBody ModifyNameRequest request) { Long userId = tokenService.getUserId(token); userService.modifyName(request, userId); } @GetMapping - public ResponseEntity findUser(@CookieValue String token) { + public ResponseEntity findUser(@RequestHeader("Authorization") String token) { Long userId = tokenService.getUserId(token); diff --git a/src/test/java/my/music/note/back/BackApplicationTests.java b/src/test/java/my/music/note/back/BackApplicationTests.java new file mode 100644 index 0000000..d281ced --- /dev/null +++ b/src/test/java/my/music/note/back/BackApplicationTests.java @@ -0,0 +1,13 @@ +package my.music.note.back; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BackApplicationTests { + + @Test + void contextLoads() { + } + +} \ No newline at end of file diff --git a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java index ed637c8..50b3efb 100644 --- a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java +++ b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java @@ -1,16 +1,15 @@ package my.music.note.back.user.controller; import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.servlet.http.Cookie; import my.music.note.back.controller.UserController; -import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; -import my.music.note.back.service.TokenService; import my.music.note.back.data.dto.request.user.DeleteAccountRequest; import my.music.note.back.data.dto.request.user.FindUserRequest; import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; import my.music.note.back.data.dto.request.user.ModifyNameRequest; +import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; import my.music.note.back.data.dto.response.user.FindUserResponse; import my.music.note.back.data.entity.User; +import my.music.note.back.service.TokenService; import my.music.note.back.service.UserService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -45,7 +44,7 @@ class UserControllerTest { @MockBean TokenService tokenService; - Cookie tokenCookie = new Cookie("token", "test-token"); + String token = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJteS1tdXNpYy1ub3RlIiwic3ViIjoiMiIsImlhdCI6MTczMDY4NzIxNCwiZXhwIjoxNzMwNjg5MDE0LCJhdXRob3JpdHkiOiJST0xFX1VTRVIifQ.0JKeOVEmnlKDiZSKl9OJz6rtjLFnpXrXxCb-3hYuBAt9yFGTZIc8aX-jzmpFDL0e9EzSoOHIVhiDFViNC6T9vw"; @Test @@ -65,8 +64,8 @@ void givenLoginOrRegisterRequest_whenCallLoginOrRegister_thenReturnTokenCreateRe .andExpect(status().isOk()) .andExpect(jsonPath("$.token").value("this-is-test-token")); - verify(userService,times(1)).loginOrRegister(any(LoginOrRegisterRequest.class)); - verify(tokenService,times(1)).createToken(anyLong(), anyBoolean()); + verify(userService, times(1)).loginOrRegister(any(LoginOrRegisterRequest.class)); + verify(tokenService, times(1)).createToken(anyLong(), anyBoolean()); } @Test @@ -76,11 +75,11 @@ void givenToken_whenCallDeleteAccount_thenReturnOK(@Mock DeleteAccountRequest de doNothing().when(userService).deleteUser(deleteAccountRequest); mockmvc.perform(delete("/api/users") - .cookie(tokenCookie) + .header("Authorization", token) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNoContent()); - verify(userService,times(1)).deleteUser(any(DeleteAccountRequest.class)); + verify(userService, times(1)).deleteUser(any(DeleteAccountRequest.class)); } @Test @@ -92,7 +91,7 @@ void givenTokenAndModifyNameRequest_whenCallModifyName_thenReturnOK(@Mock Modify String content = objectMapper.writeValueAsString(modifyNameRequest); mockmvc.perform(put("/api/users") - .cookie(tokenCookie) + .header("Authorization", token) .contentType(MediaType.APPLICATION_JSON) .content(content)) .andExpect(status().isOk()); @@ -109,7 +108,7 @@ void givenToken_whenCallFindUserInfo_thenReturnOK() throws Exception { when(userService.findUser(any(FindUserRequest.class))).thenReturn(findUserResponse); mockmvc.perform(get("/api/users") - .cookie(tokenCookie) + .header("Authorization", token) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.name").value("test-user")) From ea8bfa6679e7437fd75527b99d750b853bbc3251 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 12:53:56 +0900 Subject: [PATCH 16/18] =?UTF-8?q?feat:=20Diary=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=20=EC=82=AD=EC=A0=9C=20=ED=99=95=EC=9D=B8=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/my/music/note/back/data/entity/Diary.java | 4 ++++ src/main/java/my/music/note/back/service/DiaryService.java | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/my/music/note/back/data/entity/Diary.java b/src/main/java/my/music/note/back/data/entity/Diary.java index 4a33a5f..15feac3 100644 --- a/src/main/java/my/music/note/back/data/entity/Diary.java +++ b/src/main/java/my/music/note/back/data/entity/Diary.java @@ -47,6 +47,10 @@ public void modifyDiaryContent(DiaryModifyRequest request) { this.currentModifiedAt = LocalDateTime.now(); } + public boolean isDeleted() { + return this.isDeleted; + } + public FindDiaryResponse convertToFindDiaryResponse() { return new FindDiaryResponse(this.id, this.content, this.isLongEntry, this.createdAt, this.currentModifiedAt); diff --git a/src/main/java/my/music/note/back/service/DiaryService.java b/src/main/java/my/music/note/back/service/DiaryService.java index 932f94d..7b01dd3 100644 --- a/src/main/java/my/music/note/back/service/DiaryService.java +++ b/src/main/java/my/music/note/back/service/DiaryService.java @@ -39,12 +39,17 @@ public void modifyDiary(DiaryModifyRequest diaryModifyRequest) { } public List findDiaries(Long userId) { - return diaryRepository.findAllByUserId(userId); + return diaryRepository.findAllByUserIdAndIsDeletedFalse(userId); } public FindDiaryResponse findDiary(Long diaryId) { Optional optionalDiary = diaryRepository.findById(diaryId); Diary diary = optionalDiary.orElseThrow(IllegalArgumentException::new); + + if (diary.isDeleted()) { + throw new IllegalArgumentException(); + } + return diary.convertToFindDiaryResponse(); } From 3837ccf7a1472b4611002095878f760561100c84 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 4 Nov 2024 12:54:13 +0900 Subject: [PATCH 17/18] =?UTF-8?q?feat:=20Diary=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=20=EC=82=AD=EC=A0=9C=20=ED=99=95=EC=9D=B8(Repo)=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../my/music/note/back/data/repository/DiaryRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java index 85af007..ec51411 100644 --- a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java +++ b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java @@ -8,6 +8,6 @@ public interface DiaryRepository extends JpaRepository { - List findAllByUserId(Long userId); + List findAllByUserIdAndIsDeletedFalse(Long userId); } From 45f8adde074adf1b8787bc1f243ffda44e52beca Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Wed, 4 Dec 2024 05:01:49 +0900 Subject: [PATCH 18/18] =?UTF-8?q?refactor:=20=ED=8E=98=ED=82=A4=EC=A7=80?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note/back/controller/ChatGPTController.java | 2 +- .../note/back/controller/DiaryController.java | 11 +++++------ .../note/back/controller/UserController.java | 15 +++++++-------- .../request}/DiaryCreateRequest.java | 2 +- .../request}/DiaryDeleteRequest.java | 2 +- .../request}/DiaryModifyRequest.java | 2 +- .../response}/FindDiaryResponse.java | 2 +- .../gpt => gpt/request}/ChatCompletionDto.java | 2 +- .../gpt => gpt/request}/ChatRequestMsgDto.java | 2 +- .../jwt => jwt/request}/TokenCreateRequest.java | 2 +- .../jwt => jwt/response}/TokenCreateResponse.java | 2 +- .../dto/request/user/DeleteAccountRequest.java | 4 ---- .../data/dto/request/user/FindUserRequest.java | 4 ---- .../dto/user/request/DeleteAccountRequest.java | 4 ++++ .../data/dto/user/request/FindUserRequest.java | 4 ++++ .../request}/LoginOrRegisterRequest.java | 2 +- .../user => user/request}/ModifyNameRequest.java | 2 +- .../user => user/response}/FindUserResponse.java | 2 +- .../my/music/note/back/data/entity/Diary.java | 6 +++--- .../java/my/music/note/back/data/entity/User.java | 6 +++--- .../back/data/repository/DiaryRepository.java | 2 +- .../music/note/back/service/ChatGPTService.java | 2 +- .../my/music/note/back/service/DiaryService.java | 9 ++++----- .../my/music/note/back/service/TokenService.java | 2 +- .../my/music/note/back/service/UserService.java | 10 +++++----- .../gpt/controller/ChatGPTControllerTest.java | 4 ++-- .../note/back/gpt/service/ChatGPTServiceTest.java | 4 ++-- .../back/user/controller/UserControllerTest.java | 12 ++++++------ .../note/back/user/service/UserServiceTest.java | 10 +++++----- 29 files changed, 65 insertions(+), 68 deletions(-) rename src/main/java/my/music/note/back/data/dto/{request/diary => diary/request}/DiaryCreateRequest.java (59%) rename src/main/java/my/music/note/back/data/dto/{request/diary => diary/request}/DiaryDeleteRequest.java (50%) rename src/main/java/my/music/note/back/data/dto/{request/diary => diary/request}/DiaryModifyRequest.java (54%) rename src/main/java/my/music/note/back/data/dto/{response/diary => diary/response}/FindDiaryResponse.java (79%) rename src/main/java/my/music/note/back/data/dto/{request/gpt => gpt/request}/ChatCompletionDto.java (89%) rename src/main/java/my/music/note/back/data/dto/{request/gpt => gpt/request}/ChatRequestMsgDto.java (86%) rename src/main/java/my/music/note/back/data/dto/{request/jwt => jwt/request}/TokenCreateRequest.java (60%) rename src/main/java/my/music/note/back/data/dto/{response/jwt => jwt/response}/TokenCreateResponse.java (51%) delete mode 100644 src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java delete mode 100644 src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java create mode 100644 src/main/java/my/music/note/back/data/dto/user/request/DeleteAccountRequest.java create mode 100644 src/main/java/my/music/note/back/data/dto/user/request/FindUserRequest.java rename src/main/java/my/music/note/back/data/dto/{request/user => user/request}/LoginOrRegisterRequest.java (67%) rename src/main/java/my/music/note/back/data/dto/{request/user => user/request}/ModifyNameRequest.java (50%) rename src/main/java/my/music/note/back/data/dto/{response/user => user/response}/FindUserResponse.java (61%) diff --git a/src/main/java/my/music/note/back/controller/ChatGPTController.java b/src/main/java/my/music/note/back/controller/ChatGPTController.java index 2803327..45fba6a 100644 --- a/src/main/java/my/music/note/back/controller/ChatGPTController.java +++ b/src/main/java/my/music/note/back/controller/ChatGPTController.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; +import my.music.note.back.data.dto.gpt.request.ChatCompletionDto; import my.music.note.back.service.ChatGPTService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/my/music/note/back/controller/DiaryController.java b/src/main/java/my/music/note/back/controller/DiaryController.java index efe675f..8e43182 100644 --- a/src/main/java/my/music/note/back/controller/DiaryController.java +++ b/src/main/java/my/music/note/back/controller/DiaryController.java @@ -1,10 +1,10 @@ package my.music.note.back.controller; import lombok.RequiredArgsConstructor; -import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; -import my.music.note.back.data.dto.request.diary.DiaryDeleteRequest; -import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; -import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.dto.diary.request.DiaryCreateRequest; +import my.music.note.back.data.dto.diary.request.DiaryDeleteRequest; +import my.music.note.back.data.dto.diary.request.DiaryModifyRequest; +import my.music.note.back.data.dto.diary.response.FindDiaryResponse; import my.music.note.back.service.DiaryService; import my.music.note.back.service.TokenService; import org.springframework.http.HttpStatus; @@ -34,8 +34,8 @@ public void deleteDiary(@RequestBody DiaryDeleteRequest request) { } @PutMapping + @ResponseStatus(HttpStatus.OK) public void modifyDiary(@RequestBody DiaryModifyRequest request) { - diaryService.modifyDiary(request); } @@ -44,7 +44,6 @@ public ResponseEntity FindDiaryResponse(@PathVariable Long di FindDiaryResponse response = diaryService.findDiary(diaryId); return new ResponseEntity<>(response, HttpStatus.OK); - } @GetMapping diff --git a/src/main/java/my/music/note/back/controller/UserController.java b/src/main/java/my/music/note/back/controller/UserController.java index 089a9ba..b3cd400 100644 --- a/src/main/java/my/music/note/back/controller/UserController.java +++ b/src/main/java/my/music/note/back/controller/UserController.java @@ -1,14 +1,14 @@ package my.music.note.back.controller; import lombok.RequiredArgsConstructor; -import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; -import my.music.note.back.service.TokenService; -import my.music.note.back.data.dto.request.user.DeleteAccountRequest; -import my.music.note.back.data.dto.request.user.FindUserRequest; -import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; -import my.music.note.back.data.dto.request.user.ModifyNameRequest; -import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.dto.jwt.response.TokenCreateResponse; +import my.music.note.back.data.dto.user.request.DeleteAccountRequest; +import my.music.note.back.data.dto.user.request.FindUserRequest; +import my.music.note.back.data.dto.user.request.LoginOrRegisterRequest; +import my.music.note.back.data.dto.user.request.ModifyNameRequest; +import my.music.note.back.data.dto.user.response.FindUserResponse; import my.music.note.back.data.entity.User; +import my.music.note.back.service.TokenService; import my.music.note.back.service.UserService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -31,7 +31,6 @@ public ResponseEntity loginOrRegister(@RequestBody LoginOrR return new ResponseEntity<>(response, HttpStatus.OK); } - @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteAccount(@RequestHeader("Authorization") String token) { diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryCreateRequest.java similarity index 59% rename from src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java rename to src/main/java/my/music/note/back/data/dto/diary/request/DiaryCreateRequest.java index 3e88a7f..2773ce5 100644 --- a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryCreateRequest.java +++ b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryCreateRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.diary; +package my.music.note.back.data.dto.diary.request; public record DiaryCreateRequest(String content,Boolean isLongEntry) { } diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryDeleteRequest.java similarity index 50% rename from src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java rename to src/main/java/my/music/note/back/data/dto/diary/request/DiaryDeleteRequest.java index 8f7dabc..a2836ac 100644 --- a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryDeleteRequest.java +++ b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryDeleteRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.diary; +package my.music.note.back.data.dto.diary.request; public record DiaryDeleteRequest(Long diaryId) { } diff --git a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryModifyRequest.java similarity index 54% rename from src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java rename to src/main/java/my/music/note/back/data/dto/diary/request/DiaryModifyRequest.java index 4d0cbd5..7c6bb8b 100644 --- a/src/main/java/my/music/note/back/data/dto/request/diary/DiaryModifyRequest.java +++ b/src/main/java/my/music/note/back/data/dto/diary/request/DiaryModifyRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.diary; +package my.music.note.back.data.dto.diary.request; public record DiaryModifyRequest(Long id,String content) { } diff --git a/src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java b/src/main/java/my/music/note/back/data/dto/diary/response/FindDiaryResponse.java similarity index 79% rename from src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java rename to src/main/java/my/music/note/back/data/dto/diary/response/FindDiaryResponse.java index 22f8dab..9519ff4 100644 --- a/src/main/java/my/music/note/back/data/dto/response/diary/FindDiaryResponse.java +++ b/src/main/java/my/music/note/back/data/dto/diary/response/FindDiaryResponse.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.response.diary; +package my.music.note.back.data.dto.diary.response; import java.time.LocalDateTime; diff --git a/src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java b/src/main/java/my/music/note/back/data/dto/gpt/request/ChatCompletionDto.java similarity index 89% rename from src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java rename to src/main/java/my/music/note/back/data/dto/gpt/request/ChatCompletionDto.java index 1b6498c..1ec95cf 100644 --- a/src/main/java/my/music/note/back/data/dto/request/gpt/ChatCompletionDto.java +++ b/src/main/java/my/music/note/back/data/dto/gpt/request/ChatCompletionDto.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.gpt; +package my.music.note.back.data.dto.gpt.request; import lombok.*; diff --git a/src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java b/src/main/java/my/music/note/back/data/dto/gpt/request/ChatRequestMsgDto.java similarity index 86% rename from src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java rename to src/main/java/my/music/note/back/data/dto/gpt/request/ChatRequestMsgDto.java index 0903841..c11f902 100644 --- a/src/main/java/my/music/note/back/data/dto/request/gpt/ChatRequestMsgDto.java +++ b/src/main/java/my/music/note/back/data/dto/gpt/request/ChatRequestMsgDto.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.gpt; +package my.music.note.back.data.dto.gpt.request; import lombok.*; diff --git a/src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java b/src/main/java/my/music/note/back/data/dto/jwt/request/TokenCreateRequest.java similarity index 60% rename from src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java rename to src/main/java/my/music/note/back/data/dto/jwt/request/TokenCreateRequest.java index 7702486..097dad1 100644 --- a/src/main/java/my/music/note/back/data/dto/request/jwt/TokenCreateRequest.java +++ b/src/main/java/my/music/note/back/data/dto/jwt/request/TokenCreateRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.jwt; +package my.music.note.back.data.dto.jwt.request; public record TokenCreateRequest(String providerId, boolean isAdmin) { diff --git a/src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java b/src/main/java/my/music/note/back/data/dto/jwt/response/TokenCreateResponse.java similarity index 51% rename from src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java rename to src/main/java/my/music/note/back/data/dto/jwt/response/TokenCreateResponse.java index a102ffe..c1e033b 100644 --- a/src/main/java/my/music/note/back/data/dto/response/jwt/TokenCreateResponse.java +++ b/src/main/java/my/music/note/back/data/dto/jwt/response/TokenCreateResponse.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.response.jwt; +package my.music.note.back.data.dto.jwt.response; public record TokenCreateResponse(String token) { } diff --git a/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java deleted file mode 100644 index 4aff526..0000000 --- a/src/main/java/my/music/note/back/data/dto/request/user/DeleteAccountRequest.java +++ /dev/null @@ -1,4 +0,0 @@ -package my.music.note.back.data.dto.request.user; - -public record DeleteAccountRequest(Long id) { -} diff --git a/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java b/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java deleted file mode 100644 index ed0d3d2..0000000 --- a/src/main/java/my/music/note/back/data/dto/request/user/FindUserRequest.java +++ /dev/null @@ -1,4 +0,0 @@ -package my.music.note.back.data.dto.request.user; - -public record FindUserRequest(Long id) { -} diff --git a/src/main/java/my/music/note/back/data/dto/user/request/DeleteAccountRequest.java b/src/main/java/my/music/note/back/data/dto/user/request/DeleteAccountRequest.java new file mode 100644 index 0000000..e11d68e --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/user/request/DeleteAccountRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.user.request; + +public record DeleteAccountRequest(Long id) { +} diff --git a/src/main/java/my/music/note/back/data/dto/user/request/FindUserRequest.java b/src/main/java/my/music/note/back/data/dto/user/request/FindUserRequest.java new file mode 100644 index 0000000..511fd2e --- /dev/null +++ b/src/main/java/my/music/note/back/data/dto/user/request/FindUserRequest.java @@ -0,0 +1,4 @@ +package my.music.note.back.data.dto.user.request; + +public record FindUserRequest(Long id) { +} diff --git a/src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java b/src/main/java/my/music/note/back/data/dto/user/request/LoginOrRegisterRequest.java similarity index 67% rename from src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java rename to src/main/java/my/music/note/back/data/dto/user/request/LoginOrRegisterRequest.java index 3bf58a0..3018b89 100644 --- a/src/main/java/my/music/note/back/data/dto/request/user/LoginOrRegisterRequest.java +++ b/src/main/java/my/music/note/back/data/dto/user/request/LoginOrRegisterRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.user; +package my.music.note.back.data.dto.user.request; public record LoginOrRegisterRequest(String name, String email, String provider, String providerId) { diff --git a/src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java b/src/main/java/my/music/note/back/data/dto/user/request/ModifyNameRequest.java similarity index 50% rename from src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java rename to src/main/java/my/music/note/back/data/dto/user/request/ModifyNameRequest.java index 2ab1993..19c90a6 100644 --- a/src/main/java/my/music/note/back/data/dto/request/user/ModifyNameRequest.java +++ b/src/main/java/my/music/note/back/data/dto/user/request/ModifyNameRequest.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.request.user; +package my.music.note.back.data.dto.user.request; public record ModifyNameRequest(String name) { } diff --git a/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java b/src/main/java/my/music/note/back/data/dto/user/response/FindUserResponse.java similarity index 61% rename from src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java rename to src/main/java/my/music/note/back/data/dto/user/response/FindUserResponse.java index 119e31a..7baa7b8 100644 --- a/src/main/java/my/music/note/back/data/dto/response/user/FindUserResponse.java +++ b/src/main/java/my/music/note/back/data/dto/user/response/FindUserResponse.java @@ -1,4 +1,4 @@ -package my.music.note.back.data.dto.response.user; +package my.music.note.back.data.dto.user.response; public record FindUserResponse(String name, String email, Boolean isAdmin) { } diff --git a/src/main/java/my/music/note/back/data/entity/Diary.java b/src/main/java/my/music/note/back/data/entity/Diary.java index 15feac3..164fcf3 100644 --- a/src/main/java/my/music/note/back/data/entity/Diary.java +++ b/src/main/java/my/music/note/back/data/entity/Diary.java @@ -2,9 +2,9 @@ import jakarta.persistence.*; import lombok.NoArgsConstructor; -import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; -import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; -import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.dto.diary.request.DiaryCreateRequest; +import my.music.note.back.data.dto.diary.request.DiaryModifyRequest; +import my.music.note.back.data.dto.diary.response.FindDiaryResponse; import java.time.LocalDateTime; diff --git a/src/main/java/my/music/note/back/data/entity/User.java b/src/main/java/my/music/note/back/data/entity/User.java index 2619829..4839c9f 100644 --- a/src/main/java/my/music/note/back/data/entity/User.java +++ b/src/main/java/my/music/note/back/data/entity/User.java @@ -2,9 +2,9 @@ import jakarta.persistence.*; import lombok.NoArgsConstructor; -import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; -import my.music.note.back.data.dto.request.user.ModifyNameRequest; -import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.dto.user.request.LoginOrRegisterRequest; +import my.music.note.back.data.dto.user.request.ModifyNameRequest; +import my.music.note.back.data.dto.user.response.FindUserResponse; import java.time.LocalDateTime; diff --git a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java index ec51411..9f88120 100644 --- a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java +++ b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java @@ -1,6 +1,6 @@ package my.music.note.back.data.repository; -import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.dto.diary.response.FindDiaryResponse; import my.music.note.back.data.entity.Diary; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/my/music/note/back/service/ChatGPTService.java b/src/main/java/my/music/note/back/service/ChatGPTService.java index 26fc851..a9e8d3d 100644 --- a/src/main/java/my/music/note/back/service/ChatGPTService.java +++ b/src/main/java/my/music/note/back/service/ChatGPTService.java @@ -6,7 +6,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import my.music.note.back.config.ChatGPTConfig; -import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; +import my.music.note.back.data.dto.gpt.request.ChatCompletionDto; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/src/main/java/my/music/note/back/service/DiaryService.java b/src/main/java/my/music/note/back/service/DiaryService.java index 7b01dd3..26994d1 100644 --- a/src/main/java/my/music/note/back/service/DiaryService.java +++ b/src/main/java/my/music/note/back/service/DiaryService.java @@ -2,14 +2,13 @@ import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; -import my.music.note.back.data.dto.request.diary.DiaryCreateRequest; -import my.music.note.back.data.dto.request.diary.DiaryDeleteRequest; -import my.music.note.back.data.dto.request.diary.DiaryModifyRequest; -import my.music.note.back.data.dto.response.diary.FindDiaryResponse; +import my.music.note.back.data.dto.diary.request.DiaryCreateRequest; +import my.music.note.back.data.dto.diary.request.DiaryDeleteRequest; +import my.music.note.back.data.dto.diary.request.DiaryModifyRequest; +import my.music.note.back.data.dto.diary.response.FindDiaryResponse; import my.music.note.back.data.entity.Diary; import my.music.note.back.data.repository.DiaryRepository; import org.springframework.stereotype.Service; - import java.util.List; import java.util.Optional; diff --git a/src/main/java/my/music/note/back/service/TokenService.java b/src/main/java/my/music/note/back/service/TokenService.java index 76bda99..0b4273a 100644 --- a/src/main/java/my/music/note/back/service/TokenService.java +++ b/src/main/java/my/music/note/back/service/TokenService.java @@ -5,7 +5,7 @@ import com.auth0.jwt.interfaces.DecodedJWT; import lombok.RequiredArgsConstructor; import my.music.note.back.config.TokenConfig; -import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; +import my.music.note.back.data.dto.jwt.response.TokenCreateResponse; import my.music.note.back.validator.TokenValidator; import org.springframework.stereotype.Service; diff --git a/src/main/java/my/music/note/back/service/UserService.java b/src/main/java/my/music/note/back/service/UserService.java index 8fdbdd3..ab7345f 100644 --- a/src/main/java/my/music/note/back/service/UserService.java +++ b/src/main/java/my/music/note/back/service/UserService.java @@ -3,11 +3,11 @@ import jakarta.transaction.Transactional; import lombok.AllArgsConstructor; -import my.music.note.back.data.dto.request.user.DeleteAccountRequest; -import my.music.note.back.data.dto.request.user.FindUserRequest; -import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; -import my.music.note.back.data.dto.request.user.ModifyNameRequest; -import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.dto.user.request.DeleteAccountRequest; +import my.music.note.back.data.dto.user.request.FindUserRequest; +import my.music.note.back.data.dto.user.request.LoginOrRegisterRequest; +import my.music.note.back.data.dto.user.request.ModifyNameRequest; +import my.music.note.back.data.dto.user.response.FindUserResponse; import my.music.note.back.data.entity.User; import my.music.note.back.data.repository.UserRepository; import org.springframework.stereotype.Service; diff --git a/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java b/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java index b5f6251..c52a3f8 100644 --- a/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java +++ b/src/test/java/my/music/note/back/gpt/controller/ChatGPTControllerTest.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import my.music.note.back.controller.ChatGPTController; -import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; -import my.music.note.back.data.dto.request.gpt.ChatRequestMsgDto; +import my.music.note.back.data.dto.gpt.request.ChatCompletionDto; +import my.music.note.back.data.dto.gpt.request.ChatRequestMsgDto; import my.music.note.back.service.ChatGPTService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java b/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java index cdf4590..fe83297 100644 --- a/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java +++ b/src/test/java/my/music/note/back/gpt/service/ChatGPTServiceTest.java @@ -1,8 +1,8 @@ package my.music.note.back.gpt.service; import my.music.note.back.config.ChatGPTConfig; -import my.music.note.back.data.dto.request.gpt.ChatCompletionDto; -import my.music.note.back.data.dto.request.gpt.ChatRequestMsgDto; +import my.music.note.back.data.dto.gpt.request.ChatCompletionDto; +import my.music.note.back.data.dto.gpt.request.ChatRequestMsgDto; import my.music.note.back.service.ChatGPTService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java index 50b3efb..903c08d 100644 --- a/src/test/java/my/music/note/back/user/controller/UserControllerTest.java +++ b/src/test/java/my/music/note/back/user/controller/UserControllerTest.java @@ -2,12 +2,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import my.music.note.back.controller.UserController; -import my.music.note.back.data.dto.request.user.DeleteAccountRequest; -import my.music.note.back.data.dto.request.user.FindUserRequest; -import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; -import my.music.note.back.data.dto.request.user.ModifyNameRequest; -import my.music.note.back.data.dto.response.jwt.TokenCreateResponse; -import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.dto.jwt.response.TokenCreateResponse; +import my.music.note.back.data.dto.user.request.DeleteAccountRequest; +import my.music.note.back.data.dto.user.request.FindUserRequest; +import my.music.note.back.data.dto.user.request.LoginOrRegisterRequest; +import my.music.note.back.data.dto.user.request.ModifyNameRequest; +import my.music.note.back.data.dto.user.response.FindUserResponse; import my.music.note.back.data.entity.User; import my.music.note.back.service.TokenService; import my.music.note.back.service.UserService; diff --git a/src/test/java/my/music/note/back/user/service/UserServiceTest.java b/src/test/java/my/music/note/back/user/service/UserServiceTest.java index 5960676..5fa4e05 100644 --- a/src/test/java/my/music/note/back/user/service/UserServiceTest.java +++ b/src/test/java/my/music/note/back/user/service/UserServiceTest.java @@ -1,10 +1,10 @@ package my.music.note.back.user.service; -import my.music.note.back.data.dto.request.user.DeleteAccountRequest; -import my.music.note.back.data.dto.request.user.FindUserRequest; -import my.music.note.back.data.dto.request.user.LoginOrRegisterRequest; -import my.music.note.back.data.dto.request.user.ModifyNameRequest; -import my.music.note.back.data.dto.response.user.FindUserResponse; +import my.music.note.back.data.dto.user.request.DeleteAccountRequest; +import my.music.note.back.data.dto.user.request.FindUserRequest; +import my.music.note.back.data.dto.user.request.LoginOrRegisterRequest; +import my.music.note.back.data.dto.user.request.ModifyNameRequest; +import my.music.note.back.data.dto.user.response.FindUserResponse; import my.music.note.back.data.entity.User; import my.music.note.back.data.repository.UserRepository; import my.music.note.back.service.UserService;