1
1
package com .example .security .jwt .account .application ;
2
2
3
+ import com .example .security .jwt .account .application .dto .RequestAccount ;
3
4
import com .example .security .jwt .account .application .dto .ResponseAccount ;
5
+ import com .example .security .jwt .account .domain .AccountRepository ;
6
+ import com .example .security .jwt .account .domain .entity .Account ;
4
7
import com .example .security .jwt .account .domain .entity .AccountAdapter ;
8
+ import com .example .security .jwt .global .exception .ApplicationException ;
9
+ import com .example .security .jwt .global .exception .CommonErrorCode ;
5
10
import com .example .security .jwt .global .security .TokenProvider ;
6
11
import lombok .RequiredArgsConstructor ;
12
+ import org .springframework .context .ApplicationContextException ;
7
13
import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
8
14
import org .springframework .security .config .annotation .authentication .builders .AuthenticationManagerBuilder ;
9
15
import org .springframework .security .core .Authentication ;
10
16
import org .springframework .stereotype .Service ;
17
+ import org .springframework .transaction .annotation .Transactional ;
18
+
19
+ import java .util .Optional ;
11
20
12
21
@ Service
13
22
@ RequiredArgsConstructor
14
23
public class AccountServiceImpl implements AccountService {
15
24
16
25
private final TokenProvider tokenProvider ;
17
26
private final AuthenticationManagerBuilder authenticationManagerBuilder ;
27
+ private final AccountRepository accountRepository ;
18
28
// private final RefreshTokenProvider refreshTokenProvider;
19
29
20
30
@@ -41,4 +51,16 @@ public ResponseAccount.Token authenticate(String username, String password) {
41
51
//.refreshToke()
42
52
.build ();
43
53
}
54
+
55
+ @ Transactional
56
+ @ Override
57
+ public ResponseAccount .Information registerMember (RequestAccount .RegisterMember registerMemberDto ) {
58
+ Optional <Account > accountOptional = accountRepository .findOneWithAuthoritiesByUsername (registerMemberDto .username ());
59
+
60
+ if (accountOptional .isPresent ()) {
61
+ throw new ApplicationException (CommonErrorCode .CONFLICT , "이미 가입되어있는 유저" );
62
+ }
63
+
64
+ return null ;
65
+ }
44
66
}
0 commit comments