-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathAuthController.java
More file actions
61 lines (55 loc) · 2.7 KB
/
AuthController.java
File metadata and controls
61 lines (55 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.sprint.mission.discodeit.controller;
import com.sprint.mission.discodeit.dto.LoginRequest;
import com.sprint.mission.discodeit.dto.UserDto;
import com.sprint.mission.discodeit.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/auth")
@Tag(name = "Auth", description = "인증 관련 API")
public class AuthController {
private final AuthService authService;
// 로그인
@Operation(summary = "로그인", description = "사용자 인증 수행")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "로그인 성공",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = UserDto.class),
examples = @ExampleObject(value = """
{
"userId": "550e8400-e29b-41d4-a716-446655440000",
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "2026-02-20T14:00:00Z",
"newUsername": "달선",
"status": "ONLINE",
"email": "dalsun@naver.com",
"profileId": "3f3fb215-32aa-4281-904c-45b9dd8b96fb",
"online": true
}
"""))),
@ApiResponse(responseCode = "400", description = "비밀번호가 일치하지 않음"),
@ApiResponse(responseCode = "404", description = "존재하지 않는 사용자입니다.")
})
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<UserDto> login(@RequestBody @Valid LoginRequest dto) {
System.out.println("newUsername = " + dto.username());
System.out.println("password = " + dto.password());
return ResponseEntity
.status(HttpStatus.OK)
.body(authService.login(dto));
}
}