Skip to content

Commit a4749fd

Browse files
committed
BankSimulator: Add AuthController.java
1 parent 7ae1614 commit a4749fd

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package prod.oldboy.controllers;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import lombok.RequiredArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.validation.annotation.Validated;
8+
import org.springframework.web.bind.annotation.PostMapping;
9+
import org.springframework.web.bind.annotation.RequestBody;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RestController;
12+
import prod.oldboy.dto.jwt_dto.JwtAuthRequest;
13+
import prod.oldboy.dto.jwt_dto.JwtAuthResponse;
14+
import prod.oldboy.service.AuthService;
15+
import prod.oldboy.validation.group.LogInAction;
16+
17+
@Slf4j
18+
@RestController
19+
@RequestMapping("/api/v1/auth")
20+
@RequiredArgsConstructor
21+
@Tag(name = "Authentication", description = "Method for authenticates account (enter login and password)")
22+
public class AuthController {
23+
24+
private final AuthService authService;
25+
26+
@PostMapping("/login")
27+
@Operation(summary = "Log in to the system",
28+
description = "Log in to the system and receive AccessToken")
29+
public JwtAuthResponse login(@Validated(LogInAction.class)
30+
@RequestBody JwtAuthRequest loginRequest) {
31+
32+
log.info("AuthController: login method is start");
33+
34+
JwtAuthResponse response = authService.login(loginRequest);
35+
36+
log.info("AuthController: login method is finished:" + response);
37+
38+
return response;
39+
}
40+
}
41+

0 commit comments

Comments
 (0)