251202_01_ENH: User 관련 기능 구현
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.contact.server.dto.LoginRequestDto;
|
||||
import com.kri.contact.server.dto.LoginResponseDto;
|
||||
import com.kri.contact.server.service.AuthService;
|
||||
import com.kri.contact.server.service.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Auth", description = "인증 API")
|
||||
public class AuthController {
|
||||
private final AuthService authService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto tryLogin(@RequestBody LoginRequestDto request, RequestUserContext ctx){
|
||||
LoginResponseDto response = authService.tryLogin(request);
|
||||
systemEventLogService.writeLoginLog(response.getUser().getUserId(), ctx.getClientIp());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping("/logout/{userId}")
|
||||
public boolean logout(@PathVariable String userId, RequestUserContext ctx){
|
||||
systemEventLogService.writeLogoutLog(userId, ctx.getClientIp());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user