From 93d5f89bfce4c9a19933264437d28e87a0e30371 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Tue, 14 Nov 2023 01:52:04 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=EC=9C=A0=EC=A0=80=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=82=AD=EC=A0=9C=20API=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmususer/user/controller/UserController.java | 9 +++++++++ .../farmususer/user/repository/UserRepository.java | 4 ++++ .../server/farmususer/user/service/UserService.java | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java b/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java index f329e32..79f4a3f 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java +++ b/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java @@ -127,6 +127,15 @@ public BaseResponseDto reissueToken(HttpServletRequest request) { return reissueTokenResponseDto; } + @PatchMapping(value = "/delete/user-profile") + public BaseResponseDto deleteUserProfile(HttpServletRequest request) { + + String userId = jwtTokenProvider.getUserId(request); + + return userService.deleteUserProfile(Long.valueOf(userId)); + } + + @GetMapping(value = "/all-user") public BaseResponseDto allUser() { diff --git a/src/main/java/modernfarmer/server/farmususer/user/repository/UserRepository.java b/src/main/java/modernfarmer/server/farmususer/user/repository/UserRepository.java index 599e401..eb2dd76 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/repository/UserRepository.java +++ b/src/main/java/modernfarmer/server/farmususer/user/repository/UserRepository.java @@ -33,6 +33,10 @@ public interface UserRepository extends JpaRepository { @Query("update User as u set u.early = 0 where u.id = :userId") void updateEarly( @Param("userId") Long userId); + @Modifying + @Query("update User as u set u.profileImage = null where u.id = :userId") + void updateUserProfileDefault( @Param("userId") Long userId); + // @Modifying // @Query("update User as u set u.profileImage = :profileImage where u.id = :userId") diff --git a/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java b/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java index 997e95e..d12b9b4 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java +++ b/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java @@ -120,6 +120,15 @@ public BaseResponseDto allUser() { } + public BaseResponseDto deleteUserProfile(Long userId) { + + userRepository.updateUserProfileDefault(userId); + + log.info("유저 프로필 삭제 완료"); + return BaseResponseDto.of(SuccessMessage.SUCCESS, null); + + } + public BaseResponseDto specificUser(Long userId) {