-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
42 changes: 30 additions & 12 deletions
42
backend/src/main/java/mouda/backend/auth/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
package mouda.backend.auth.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import mouda.backend.auth.dto.request.LoginRequest; | ||
import mouda.backend.auth.dto.response.LoginResponse; | ||
import mouda.backend.auth.service.AuthService; | ||
import mouda.backend.common.RestResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
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 lombok.RequiredArgsConstructor; | ||
import mouda.backend.auth.dto.request.LoginRequest; | ||
import mouda.backend.auth.dto.response.LoginResponse; | ||
import mouda.backend.auth.service.AuthService; | ||
import mouda.backend.common.RestResponse; | ||
import mouda.backend.member.domain.Member; | ||
import mouda.backend.member.repository.MemberRepository; | ||
|
||
@RestController | ||
@RequestMapping("/v1/auth") | ||
@RequiredArgsConstructor | ||
public class AuthController implements AuthSwagger { | ||
|
||
private final AuthService authService; | ||
private final AuthService authService; | ||
private final MemberRepository memberRepository; | ||
|
||
@Override | ||
@PostMapping("/login") | ||
public ResponseEntity<RestResponse<LoginResponse>> login(@RequestBody LoginRequest loginRequest) { | ||
LoginResponse response = authService.login(loginRequest); | ||
|
||
@Override | ||
@PostMapping("/login") | ||
public ResponseEntity<RestResponse<LoginResponse>> login(@RequestBody LoginRequest loginRequest) { | ||
LoginResponse response = authService.login(loginRequest); | ||
return ResponseEntity.ok().body(new RestResponse<>(response)); | ||
} | ||
|
||
return ResponseEntity.ok().body(new RestResponse<>(response)); | ||
} | ||
@GetMapping("/kakao/oauth") | ||
public void kakao( | ||
@RequestParam("code") String code, | ||
@RequestParam("error") String error, | ||
@RequestParam("error_description") String error_description, | ||
@RequestParam("state") String state | ||
) { | ||
System.out.println(code); | ||
Member member = new Member(code); | ||
memberRepository.save(member); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters