Spring Boot 3.5 / Java 17 + React 19 + PostgreSQL 단일 JAR. 멀티테넌트(LGINNOTEK/LGIT/EMART/ZIOINFO), HCore 게이트웨이 관제, POS 연동 가격 자동 업데이트, Ollama 온프레미스 AI 알람 분석·POS 분류. 레거시 ESN 6개 프로젝트(Spring Boot 1.5/Java 8) 현대화 통합. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
package com.zioinfo.esn.auth;
|
|
|
|
import com.zioinfo.esn.common.ApiResponse;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Map;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/auth")
|
|
@RequiredArgsConstructor
|
|
public class AuthController {
|
|
|
|
private final AuthService authService;
|
|
|
|
@PostMapping("/login")
|
|
public ApiResponse<Map<String, String>> login(@RequestBody LoginRequest req) {
|
|
String token = authService.login(req.username(), req.password());
|
|
return ApiResponse.ok(Map.of("token", token, "type", "Bearer"));
|
|
}
|
|
|
|
@GetMapping("/me")
|
|
public ApiResponse<Map<String, String>> me(@RequestHeader("Authorization") String header) {
|
|
String token = header.replace("Bearer ", "");
|
|
return ApiResponse.ok(authService.me(token));
|
|
}
|
|
|
|
@PostMapping("/logout")
|
|
public ApiResponse<Void> logout() {
|
|
// JWT stateless — 클라이언트에서 토큰 삭제
|
|
return ApiResponse.ok("로그아웃 성공", null);
|
|
}
|
|
|
|
record LoginRequest(String username, String password) {}
|
|
}
|