File tree Expand file tree Collapse file tree 5 files changed +49
-0
lines changed
api/src/main/java/com/mbtips/user
repository/src/main/java/com/mbtips/user Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,10 @@ public String login(LoginUserRequestDto requestDto) {
3131 throw new CustomException (CommonException .JSON_PROCESS_ERROR );
3232 }
3333 }
34+
35+ @ Transactional
36+ public void deleteUser (String userId ) {
37+ userService .delete (userId );
38+ // TODO : 회원 탈퇴시 진행되어야 하는 구조를 여기 넣으면 됩니다.
39+ }
3440}
Original file line number Diff line number Diff line change @@ -24,4 +24,8 @@ public User findById(String userId){
2424 return userRepository .findById (userId )
2525 .orElseThrow (() -> new CustomException (UserException .USER_NOT_FOUND ));
2626 }
27+
28+ public void delete (String userId ) {
29+ userRepository .delete (userId );
30+ }
2731}
Original file line number Diff line number Diff line change 1+ package com .mbtips .user .controller ;
2+
3+ import com .mbtips .common .annotation .LoginUser ;
4+ import com .mbtips .common .response .ApiResponse ;
5+ import com .mbtips .domain .user .User ;
6+ import com .mbtips .user .application .manager .UserManager ;
7+ import io .swagger .v3 .oas .annotations .Operation ;
8+ import io .swagger .v3 .oas .annotations .security .SecurityRequirements ;
9+ import io .swagger .v3 .oas .annotations .tags .Tag ;
10+ import lombok .RequiredArgsConstructor ;
11+ import lombok .extern .slf4j .Slf4j ;
12+ import org .springframework .web .bind .annotation .DeleteMapping ;
13+ import org .springframework .web .bind .annotation .RequestMapping ;
14+ import org .springframework .web .bind .annotation .RestController ;
15+
16+ @ Slf4j
17+ @ RestController
18+ @ SecurityRequirements
19+ @ RequiredArgsConstructor
20+ @ RequestMapping ("/api/users" )
21+ @ Tag (name = "회원 관련 API" , description = "회원 관련 API" )
22+ public class UserController {
23+
24+ private final UserManager userManager ;
25+
26+ @ DeleteMapping
27+ @ Operation (summary = "회원 탈퇴 API" , description = "로그인된 정보로 회원 탈퇴를 합니다." )
28+ public ApiResponse <Void > deleteUser (@ LoginUser User user ) {
29+ userManager .deleteUser (user .getUserId ());
30+ return ApiResponse .success ();
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -11,4 +11,6 @@ public interface UserRepository {
1111 User save (User user );
1212
1313 Optional <User > findById (String userId );
14+
15+ void delete (String userId );
1416}
Original file line number Diff line number Diff line change @@ -24,4 +24,9 @@ public Optional<User> findById(String userId) {
2424 return userJpaRepository .findById (userId )
2525 .map (UserEntity ::toDomain );
2626 }
27+
28+ @ Override
29+ public void delete (String userId ) {
30+ userJpaRepository .deleteById (userId );
31+ }
2732}
You can’t perform that action at this time.
0 commit comments