인덱스 API 통계 부분 실 데이터 적용
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
@EMSDataSource
|
@EMSDataSource
|
||||||
public interface CredentialRepository extends BaseRepository<Credential, String> {
|
public interface CredentialRepository extends BaseRepository<Credential, String> {
|
||||||
@@ -18,4 +20,26 @@ public interface CredentialRepository extends BaseRepository<Credential, String>
|
|||||||
List<Credential> findAllByOrgid(String orgid);
|
List<Credential> findAllByOrgid(String orgid);
|
||||||
|
|
||||||
Optional<Credential> findByClientidAndOrgid(String clientid, String orgid);
|
Optional<Credential> findByClientidAndOrgid(String clientid, String orgid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 특정 기관 ID 목록에 속하고 이용 가능 상태(appstatus='1')인 앱의 수를 조회
|
||||||
|
*/
|
||||||
|
@Query("SELECT COUNT(c) FROM Credential c WHERE c.appstatus = '1' AND c.orgid IN :orgIds")
|
||||||
|
long countActiveAppsByOrgIds(@Param("orgIds") List<String> orgIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 특정 기관 ID 목록에 속하고 이용 가능 상태(appstatus='1')인 앱 목록 조회
|
||||||
|
*/
|
||||||
|
@Query("SELECT c FROM Credential c WHERE c.appstatus = '1' AND c.orgid IN :orgIds")
|
||||||
|
List<Credential> findActiveAppsByOrgIds(@Param("orgIds") List<String> orgIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이용 가능 상태인 모든 앱의 수를 조회
|
||||||
|
*/
|
||||||
|
long countByAppstatus(String appstatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이용 가능 상태인 모든 앱 목록 조회
|
||||||
|
*/
|
||||||
|
List<Credential> findByAppstatus(String appstatus);
|
||||||
}
|
}
|
||||||
|
|||||||
+55
@@ -2,21 +2,27 @@ package com.eactive.apim.portal.portalproperty.service;
|
|||||||
|
|
||||||
import com.eactive.apim.portal.portalproperty.entity.PortalProperty;
|
import com.eactive.apim.portal.portalproperty.entity.PortalProperty;
|
||||||
import com.eactive.apim.portal.portalproperty.entity.PortalPropertyGroup;
|
import com.eactive.apim.portal.portalproperty.entity.PortalPropertyGroup;
|
||||||
|
import com.eactive.apim.portal.portalproperty.entity.PortalPropertyId;
|
||||||
import com.eactive.apim.portal.portalproperty.repository.PortalPropertyGroupRepository;
|
import com.eactive.apim.portal.portalproperty.repository.PortalPropertyGroupRepository;
|
||||||
|
import com.eactive.apim.portal.portalproperty.repository.PortalPropertyRepository;
|
||||||
import com.eactive.eai.data.jpa.AbstractDataService;
|
import com.eactive.eai.data.jpa.AbstractDataService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Transactional
|
@Transactional
|
||||||
public class PortalPropertyService extends AbstractDataService<PortalPropertyGroup, String, PortalPropertyGroupRepository> {
|
public class PortalPropertyService extends AbstractDataService<PortalPropertyGroup, String, PortalPropertyGroupRepository> {
|
||||||
|
|
||||||
private final PortalPropertyGroupRepository portalPropertyGroupRepository;
|
private final PortalPropertyGroupRepository portalPropertyGroupRepository;
|
||||||
|
private final PortalPropertyRepository portalPropertyRepository;
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Map<String, String> getPortalPropertiesAsMap(String propertyGroupName) {
|
public Map<String, String> getPortalPropertiesAsMap(String propertyGroupName) {
|
||||||
@@ -31,5 +37,54 @@ public class PortalPropertyService extends AbstractDataService<PortalPropertyGro
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 프로퍼티 값을 조회하고, 없으면 기본값을 DB에 저장 후 반환
|
||||||
|
*
|
||||||
|
* @param groupName 프로퍼티 그룹명
|
||||||
|
* @param propertyName 프로퍼티명
|
||||||
|
* @param defaultValue 기본값
|
||||||
|
* @param description 프로퍼티 설명 (신규 생성 시 사용)
|
||||||
|
* @return 프로퍼티 값
|
||||||
|
*/
|
||||||
|
public String getOrCreateProperty(String groupName, String propertyName, String defaultValue, String description) {
|
||||||
|
PortalPropertyId propertyId = new PortalPropertyId(groupName, propertyName);
|
||||||
|
Optional<PortalProperty> existingProperty = portalPropertyRepository.findById(propertyId);
|
||||||
|
|
||||||
|
if (existingProperty.isPresent()) {
|
||||||
|
return existingProperty.get().getPropertyValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 프로퍼티가 없으면 기본값으로 생성
|
||||||
|
return createDefaultProperty(groupName, propertyName, defaultValue, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 기본 프로퍼티를 DB에 생성
|
||||||
|
*/
|
||||||
|
private String createDefaultProperty(String groupName, String propertyName, String defaultValue, String description) {
|
||||||
|
try {
|
||||||
|
// 그룹이 존재하는지 확인
|
||||||
|
PortalPropertyGroup group = portalPropertyGroupRepository.findById(groupName)
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (group == null) {
|
||||||
|
log.warn("프로퍼티 그룹 '{}'이 존재하지 않아 기본값 저장을 건너뜁니다.", groupName);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 새 프로퍼티 생성
|
||||||
|
PortalProperty newProperty = new PortalProperty();
|
||||||
|
newProperty.setId(new PortalPropertyId(groupName, propertyName));
|
||||||
|
newProperty.setPropertyValue(defaultValue);
|
||||||
|
newProperty.setPropertyDesc(description);
|
||||||
|
|
||||||
|
portalPropertyRepository.save(newProperty);
|
||||||
|
log.info("기본 프로퍼티 생성 완료 - 그룹: {}, 키: {}, 값: {}", groupName, propertyName, defaultValue);
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("기본 프로퍼티 생성 실패 - 그룹: {}, 키: {}", groupName, propertyName, e);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user