File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
src/main/java/com/back/domain/user/service Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 11package com .back .domain .user .service ;
22
33import com .back .domain .user .entity .User ;
4+ import com .back .domain .user .enums .UserStatus ;
45import com .back .domain .user .repository .UserRepository ;
6+ import com .back .global .exception .ServiceException ;
7+ import com .back .global .jwt .refreshToken .service .RefreshTokenService ;
58import lombok .RequiredArgsConstructor ;
69import org .springframework .stereotype .Service ;
710import org .springframework .transaction .annotation .Transactional ;
1114public class UserService {
1215
1316 private final UserRepository userRepository ;
17+ private final RefreshTokenService refreshTokenService ;
1418
1519 @ Transactional (readOnly = true )
1620 public User findById (Long id ) {
1721 return userRepository .findById (id )
1822 .orElseThrow (() -> new IllegalArgumentException ("User not found. id=" + id ));
1923 }
2024
25+ @ Transactional
26+ public void deactivateAccount (Long id ) {
27+ User user = userRepository .findById (id )
28+ .orElseThrow (() -> new ServiceException (404 , "사용자를 찾을 수 없습니다." ));
2129
30+ if (user .getStatus () == UserStatus .DELETED ) {
31+ throw new ServiceException (409 , "이미 탈퇴한 사용자입니다." );
32+ }
2233
34+ user .markDeleted ("탈퇴한 사용자" );
35+ userRepository .save (user );
2336
24- }
37+ // 모든 세션(리프레시 토큰) 폐기
38+ refreshTokenService .revokeAllForUser (id );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments