261016_01_ENH: 1차 마이그레이션 완료

This commit is contained in:
2026-10-16 12:21:37 +09:00
parent 7ca665397e
commit 26088f6fd0
188 changed files with 10522 additions and 573 deletions

View File

@@ -1,9 +0,0 @@
package com.kri.kart.server.common.consts;
public final class ExampleConstant {
public static final int DEFAULT_BATCH_SIZE = 1_000;
private ExampleConstant() {
}
}

View File

@@ -1,6 +0,0 @@
package com.kri.kart.server.common.enums;
public enum ExampleStatus {
ACTIVE,
INACTIVE
}

View File

@@ -0,0 +1,31 @@
package com.kri.kart.server.common.enums;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.kri.common.feature.enums.CodeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter(onMethod_ = @JsonValue)
@RequiredArgsConstructor
@Schema(description = "프로젝트 유형: 0=KON, 1=KIWI")
public enum ProjectType implements CodeEnum<Integer> {
KON(0),
KIWI(1);
private final Integer code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ProjectType fromCode(Integer code) {
if (code == null) {
return null;
}
for (ProjectType s : values()) {
if (s.code.equals(code)) {
return s;
}
}
throw new IllegalArgumentException("Unknown ProjectType code: " + code);
}
}

View File

@@ -0,0 +1,105 @@
package com.kri.kart.server.common.external.intranet;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kri.common.feature.http.ExternalApiClient;
import com.kri.common.feature.http.ExternalApiResponse;
import com.kri.common.feature.web.BusinessException;
import com.kri.kart.server.dto.auth.LoginRequestDto;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Component
public class IntranetExtensionApiClient {
private final ExternalApiClient externalApiClient;
private final ObjectMapper objectMapper;
private final String intranetExtensionBaseUrl;
private final String apiKey;
private final String apiKeyHeaderName;
public IntranetExtensionApiClient(
ExternalApiClient externalApiClient,
ObjectMapper objectMapper,
@Value("${kri.api-url.intranet-extension}") String intranetExtensionBaseUrl,
@Value("${kri.auth.apikey.key}") String apiKey,
@Value("${kri.auth.apikey.header-name:X-API-Key}") String apiKeyHeaderName) {
this.externalApiClient = externalApiClient;
this.objectMapper = objectMapper;
this.intranetExtensionBaseUrl = intranetExtensionBaseUrl;
this.apiKey = apiKey;
this.apiKeyHeaderName = apiKeyHeaderName;
}
public IntranetUserDto searchLoginInfo(LoginRequestDto request) {
try {
ExternalApiResponse response =
externalApiClient.post(
url("/user/login-info"), headers(), objectMapper.writeValueAsString(request));
if (response.getStatusCode() != 200) {
return null;
}
IntranetUserDto intranetUser =
objectMapper.readValue(response.getBody(), IntranetUserDto.class);
if (intranetUser == null
|| intranetUser.getUserId() == null
|| intranetUser.getUserId().isBlank()
|| intranetUser.getUserRole() == null) return null;
return intranetUser;
} catch (Exception ignored) {
// Failed authentication, HTTP errors, timeouts and malformed responses all fall back.
// Never log the request password, headers or upstream response body.
return null;
}
}
public List<String> getExcludedOwnerIds() {
try {
ExternalApiResponse response = externalApiClient.get(url("/user/list"), headers());
if (response.getStatusCode() != 200) {
throw new IllegalStateException("Upstream unavailable");
}
List<IntranetUserDto> users =
objectMapper.readValue(response.getBody(), new TypeReference<>() {});
if (users == null
|| users.stream()
.anyMatch(u -> u == null || u.getUserId() == null || u.getUserId().isBlank())) {
throw new IllegalStateException("Invalid upstream response");
}
return users.stream()
.filter(u -> "S101".equals(u.getUserTeam()) || "S201".equals(u.getUserTeam()))
.map(IntranetUserDto::getUserId)
.map(
id -> {
if (id == null || id.isBlank()) {
throw new IllegalStateException("Missing upstream ID");
}
return id;
})
.distinct()
.toList();
} catch (Exception ignored) {
// Do not silently broaden the project list when the exclusion source is unavailable.
throw BusinessException.of(
HttpStatus.SERVICE_UNAVAILABLE,
"INTRANET_USER_LIST_UNAVAILABLE",
"프로젝트 제외 대상 사용자 목록을 조회할 수 없습니다.");
}
}
private String url(String path) {
if (intranetExtensionBaseUrl == null || intranetExtensionBaseUrl.isBlank()) {
throw new IllegalStateException("Intranet base URL is not configured");
}
return intranetExtensionBaseUrl.replaceAll("/+$", "") + path;
}
private Map<String, String> headers() {
if (apiKey == null || apiKey.isBlank()) {
throw new IllegalStateException("Intranet API key is not configured");
}
return Map.of(apiKeyHeaderName, apiKey);
}
}

View File

@@ -0,0 +1,16 @@
package com.kri.kart.server.common.external.intranet;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class IntranetUserDto {
private String userId;
private String userCmpn;
private String userNm;
private String userTeam;
private Integer userRole;
}

View File

@@ -0,0 +1,21 @@
package com.kri.kart.server.common.util;
import java.util.Locale;
public final class DateTimeUtil {
private DateTimeUtil() {}
public static String formatSeconds(String seconds) {
if (seconds == null || seconds.isBlank()) {
return "";
}
try {
int value = Integer.parseInt(seconds);
return String.format(
Locale.ROOT, "%02d:%02d:%02d", value / 3600, value % 3600 / 60, value % 3600 % 60);
} catch (NumberFormatException ignored) {
return "";
}
}
}

View File

@@ -1,13 +0,0 @@
package com.kri.kart.server.common.util;
public final class StringNormalizer {
private StringNormalizer() {
}
public static String trimToNull(String value) {
if (value == null) return null;
String normalized = value.trim();
return normalized.isEmpty() ? null : normalized;
}
}

View File

@@ -1,4 +1,2 @@
/**
* 프로젝트 전용 Bean Validation annotation과 validator를 배치합니다.
*/
/** 프로젝트 전용 Bean Validation annotation과 validator를 배치합니다. */
package com.kri.kart.server.common.validation;