34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
package com.goldenchart.controller;
|
|
|
|
import com.goldenchart.trading.TradingAccess;
|
|
|
|
import java.util.Map;
|
|
|
|
/** 매매·모의·전략 API — 정식 로그인(userId) 필수 */
|
|
public final class TradingControllerSupport {
|
|
|
|
private TradingControllerSupport() {}
|
|
|
|
public static long requireRegisteredUser(Map<String, String> headers) {
|
|
String raw = headers.get("x-user-id");
|
|
if (raw == null || raw.isBlank()) {
|
|
throw new com.goldenchart.trading.TradingAccessDeniedException();
|
|
}
|
|
try {
|
|
return TradingAccess.requireUserId(Long.parseLong(raw.trim()));
|
|
} catch (NumberFormatException e) {
|
|
throw new com.goldenchart.trading.TradingAccessDeniedException();
|
|
}
|
|
}
|
|
|
|
public static Long parseUserId(Map<String, String> headers) {
|
|
String raw = headers.get("x-user-id");
|
|
if (raw == null || raw.isBlank()) return null;
|
|
try {
|
|
return Long.parseLong(raw.trim());
|
|
} catch (NumberFormatException e) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|