File tree Expand file tree Collapse file tree
src/main/java/org/inhahackers/optmo_user_be/function Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import org .inhahackers .optmo_user_be .service .UserService ;
1313import org .springframework .context .ApplicationContext ;
1414import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
15+ import org .springframework .stereotype .Component ;
1516
1617import java .util .Optional ;
1718
19+ @ Component
1820@ RequiredArgsConstructor
1921public class UserFunction {
2022
21- private static final ThreadLocal <ApplicationContext > contextHolder =
22- ThreadLocal .withInitial (() ->
23- new AnnotationConfigApplicationContext ("org.inhahackers.optmo_user_be" )
24- );
23+ private final JwtTokenService jwtTokenService ;
24+ private final UserService userService ;
2525
2626 @ FunctionName ("userFunction" )
2727 public HttpResponseMessage run (
@@ -36,11 +36,12 @@ public HttpResponseMessage run(
3636
3737 try {
3838 // 요청 바디 파싱
39- ApplicationContext context = contextHolder .get ();
40- JwtTokenService jwtTokenService = context .getBean (JwtTokenService .class );
41- UserService userService = context .getBean (UserService .class );
42-
4339 String email = request .getQueryParameters ().get ("email" );
40+ if (email == null || email .isEmpty ()) {
41+ return request .createResponseBuilder (HttpStatus .BAD_REQUEST )
42+ .body ("Email parameter is required" )
43+ .build ();
44+ }
4445
4546 // 유저 정보 조회 및 생성
4647 var user = userService .findOrCreateUserByEmail (email );
You can’t perform that action at this time.
0 commit comments