Skip to content

Commit

Permalink
feat: 유저 탈퇴 API 구현 (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
qzzloz authored Nov 9, 2024
1 parent b79defe commit 1f3306e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@

import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import com.soongsil.CoffeeChat.controller.handler.ApiResponseGenerator;
import com.soongsil.CoffeeChat.dto.MenteeJoinRequestDto;
Expand Down Expand Up @@ -176,4 +169,16 @@ public ResponseEntity<ApiResponseGenerator<UserGetDto>> getUserInfo(Authenticati
);
}

@DeleteMapping()
@Operation(summary = "탈퇴하기")
@ApiResponse(responseCode = "200", description = "성공!")
public ResponseEntity<ApiResponseGenerator<Void>> deleteUser(Authentication authentication) throws Exception {
userService.deleteUser(getUserNameByAuthentication(authentication));
return ResponseEntity.ok().body(
ApiResponseGenerator.onSuccessOK(
null
)
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,8 @@ public UserGetDto findUserInfo(String username) {
//return UserGetUpdateDto.toDto(user);
}

public void deleteUser(String username) {
User user = findUserByUsername(username);
userRepository.delete(user);
}
}

0 comments on commit 1f3306e

Please sign in to comment.