BaseRestController - IP white 적용

UMS 연동 코드 개선
This commit is contained in:
Rinjae
2026-02-02 15:32:23 +09:00
parent cd3e0f1dba
commit 878f1da4ad
6 changed files with 312 additions and 3 deletions
@@ -1,5 +1,7 @@
package com.eactive.ext.kjb.util;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.MonitoringProperty;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.MonitoringPropertyId;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import com.eactive.ext.kjb.common.KjbProperty;
import com.eactive.ext.kjb.common.KjbPropertyValue;
@@ -7,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
import java.util.Optional;
@Slf4j
public class KjbPropertyInjector {
@@ -69,6 +72,11 @@ public class KjbPropertyInjector {
if (anno != null) {
String key = anno.key();
// DB에 속성이 없으면 기본값으로 자동 생성
ensurePropertyExists(groupId, key, anno.defaultValue());
// 값 조회
String rawValue = monitoringPropertyService.getPropertyValue(groupId, key, anno.defaultValue());
Object convertedValue = convertValue(field.getType(), rawValue);
@@ -85,6 +93,32 @@ public class KjbPropertyInjector {
return property;
}
/**
* 속성이 DB에 존재하는지 확인하고, 없으면 기본값으로 생성
*
* @param groupName 속성 그룹명
* @param key 속성 키
* @param defaultValue 기본값
*/
private void ensurePropertyExists(String groupName, String key, String defaultValue) {
MonitoringPropertyId id = new MonitoringPropertyId();
id.setPrptyGroupName(groupName);
id.setPrptyName(key);
Optional<MonitoringProperty> existing = monitoringPropertyService.findById(id);
if (!existing.isPresent()) {
log.info("Property not found in DB, creating - Group: {}, Key: {}, DefaultValue: {}", groupName, key, defaultValue);
MonitoringProperty property = new MonitoringProperty();
property.setId(id);
property.setPrpty2Val(defaultValue);
monitoringPropertyService.save(property);
log.info("Property created successfully - Group: {}, Key: {}", groupName, key);
}
}
private static Object convertValue(Class<?> type, String rawValue) {
if (rawValue == null) return null;