Skip to content

Commit

Permalink
Merge pull request #101 from Team-KeepGoing/feature/#100
Browse files Browse the repository at this point in the history
add delete user api
  • Loading branch information
miraexhoi authored Oct 21, 2024
2 parents 461d037 + cfd9392 commit 91aa45b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.keepgoing.keepserver.domain.user.controller;

import com.keepgoing.keepserver.domain.user.dto.request.StatusRequest;
import com.keepgoing.keepserver.domain.user.dto.request.LoginRequest;
import com.keepgoing.keepserver.domain.user.dto.request.SignupRequest;
import com.keepgoing.keepserver.domain.user.dto.request.StatusRequest;
import com.keepgoing.keepserver.domain.user.dto.request.UserInfoRequest;
import com.keepgoing.keepserver.domain.user.service.user.UserService;
import com.keepgoing.keepserver.global.exception.BusinessException;
Expand Down Expand Up @@ -35,6 +35,12 @@ public ResponseEntity<?> registerAndAuthenticateUser(@RequestBody SignupRequest
return ResponseEntity.ok().body(userService.registerUser(signupRequest));
}

@Operation(summary = "회원탈퇴", description = "회원탈퇴를 진행합니다.")
@DeleteMapping("/delete/{userId}")
public ResponseEntity<?> withdrawMember(@PathVariable Long userId){
return ResponseEntity.ok().body(userService.deleteUser(userId));
}

@Operation(summary = "프로필", description = "토큰을 이용하여 유저 정보와 대여한 기자재 및 도서 목록을 조회합니다.")
@GetMapping("/userinfo")
public ResponseEntity<?> provideUserInfo(Authentication authentication) {
Expand All @@ -57,4 +63,4 @@ public ResponseEntity<?> getNoticeByUser(Authentication authentication){
public ResponseEntity<?> updateUserStatus(@Valid @RequestBody StatusRequest statusRequest, Authentication authentication){
return ResponseEntity.ok().body(userService.updateUserStatus(statusRequest,authentication));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public interface UserService {

ResponseEntity<String> updateUserData(UserInfoRequest request, Authentication authentication);

ResponseEntity<String> deleteUser(Long id);

UserDto provideUserInfo(Authentication authentication);

JwtResponse authenticateAndGenerateJWT(String email, String password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public ResponseEntity<String> updateUserData(UserInfoRequest request, Authentica
return ResponseEntity.ok().body("");
}

@Override
@Transactional
public ResponseEntity<String> deleteUser(Long id) {
try {
userRepository.deleteById(id);
return ResponseEntity.ok().body("회원탈퇴 성공");
} catch (Exception ex) {
throw new RuntimeException("회원탈퇴 실패", ex);
}
}

@Override
public UserDto provideUserInfo(Authentication authentication) {
UserDetailsImpl ud = (UserDetailsImpl) authentication.getPrincipal();
Expand Down

0 comments on commit 91aa45b

Please sign in to comment.