메인 페이지 서비스 조회 기능 구현

This commit is contained in:
현성필
2025-11-21 17:33:06 +09:00
parent 74f9a4feb9
commit 82d1bb1eb4
4 changed files with 19 additions and 71 deletions
@@ -41,14 +41,7 @@ public class IndexController {
@GetMapping("/")
public String index(Model model) {
Map<String, String> propertyMap = portalPropertyService.getPortalPropertiesAsMap("Portal");
String serviceList = propertyMap.get("main.service.list");
// Step 1: Fetch and sort API services
List<ApiServiceDTO> apiServices = getSortedApiServices(null);
// Step 2: Calculate total API count
int totalApiCount = calculateTotalApiCount(apiServices);
List<ApiServiceDTO> services = mainApiFacade.getOpenApiServices();
List<String> hashTags = mainApiFacade.getHashTags();
ApiGroupSearch search = new ApiGroupSearch();
@@ -56,34 +49,19 @@ public class IndexController {
int selectedApiCount = (int) searchResult.get("selectedApiCount");
// 서비스 이용 수
int serviceCount = ((List<?>) searchResult.get("services")).size();
// 승인된 기업 건수
int approvedOrgCount = mainApiFacade.getApprovedOrgCount();
addAttributesToModel(model, apiServices, totalApiCount, hashTags, serviceCount, approvedOrgCount, selectedApiCount);
addAttributesToModel(model, services, hashTags, serviceCount, approvedOrgCount, selectedApiCount);
return "apps/main/index";
}
private List<ApiServiceDTO> getSortedApiServices(String apiId) {
List<ApiServiceDTO> apiServices = mainApiFacade.getOpenApiServices(apiId);
apiServices.sort(Comparator.comparing(ApiServiceDTO::getDisplayOrder));
return apiServices;
}
private int calculateTotalApiCount(List<ApiServiceDTO> apiServices) {
return apiServices.stream()
.mapToInt(service -> service.getApiGroupApiList().size())
.sum();
}
private void addAttributesToModel(Model model, List<ApiServiceDTO> apiServices,
int totalApiCount, List<String> hashTags, int serviceCount, int approvedOrgCount, int selectedApiCount) {
private void addAttributesToModel(Model model, List<ApiServiceDTO> apiServices, List<String> hashTags, int serviceCount, int approvedOrgCount, int selectedApiCount) {
model.addAttribute("services", apiServices);
model.addAttribute("totalApiCount", totalApiCount);
model.addAttribute("hashtags", hashTags);
model.addAttribute("serviceCount", serviceCount);
@@ -7,17 +7,13 @@ import com.eactive.apim.portal.apps.apiservice.dto.ApiServiceDTO;
import com.eactive.apim.portal.apps.apiservice.service.ApiServiceService;
import com.eactive.apim.portal.apps.user.service.PortalOrgService;
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@Transactional
@Service
@@ -34,17 +30,13 @@ public class MainApiFacade {
return portalOrgService.getActiveApprovedOrgCount();
}
public List<ApiServiceDTO> getOpenApiServices(String serviceId) {
public List<ApiServiceDTO> getOpenApiServices() {
ApiGroupSearch search = new ApiGroupSearch();
Map<String, String> property = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY);
String services = property.getOrDefault("main.service.list", "");
if (StringUtils.hasText(serviceId) && services.contains(serviceId)) {
search.setGroupIds(Collections.singletonList(serviceId));
} else {
search.setGroupIds(Arrays.asList(services.split(",")));
}
search.setGroupIds(Arrays.asList(services.replace(" ", "").split(",")));
return apiServiceService.searchApiGroups(search);
}
@@ -147,44 +147,22 @@
</div>
<div class="api-cards-container">
<div class="api-card">
<h3 class="card-title">금융서비스</h3>
<!-- Services 데이터를 반복하여 API 카드 표시 (최대 4개) -->
<div class="api-card" th:each="service, iterStat : ${services}"
th:if="${iterStat.index < 4}"
th:onclick="${service.id != null} ? |location.href='@{/apis(groupId=${service.id})}'| : |location.href='@{/apis}'|">
<h3 class="card-title" th:text="${service.groupName}">API 서비스</h3>
<p class="card-description">
금융 서비스 설명이 표시됩니다. 금융 서비스 설명이 표시됩니다. 금융 서비스 설명이 표시됩니다.
<span th:if="${service.groupDesc != null and !#strings.isEmpty(service.groupDesc)}"
th:text="${service.groupDesc}">서비스 설명</span>
<span th:unless="${service.groupDesc != null and !#strings.isEmpty(service.groupDesc)}">
광주은행 API 서비스를 이용해보세요.
</span>
</p>
<div class="card-illustration">
<img th:src="@{/img/api_icon_finance.png}" alt="금융서비스">
</div>
</div>
<div class="api-card">
<h3 class="card-title">대출금리비교</h3>
<p class="card-description">
대출금리비교 설명이 표시됩니다. 대출금리비교 설명이 표시됩니다. 대출금리비교 설명이 표시됩니다.
</p>
<div class="card-illustration">
<img th:src="@{/img/api_icon_loan.png}" alt="대출금리비교">
</div>
</div>
<div class="api-card">
<h3 class="card-title">소액해외송금</h3>
<p class="card-description">
소액해외송금 설명이 표시됩니다. 소액해외송금 설명이 표시됩니다. 소액해외송금 설명이 표시됩니다.
</p>
<div class="card-illustration">
<img th:src="@{/img/api_icon_remittance.png}" alt="소액해외송금">
</div>
</div>
<!-- 간편결제 -->
<div class="api-card">
<h3 class="card-title">P2P투자대출</h3>
<p class="card-description">
P2P투자대출 설명이 표시됩니다. P2P투자대출 설명이 표시됩니다. P2P투자대출 설명이 표시됩니다.
</p>
<div class="card-illustration">
<img th:src="@{/img/api_icon_p2p.png}" alt="간편결제">
<!-- 서비스별 아이콘 매핑 - base64 인코딩된 이미지 사용 -->
<img th:src="${service.mainIcon != null and !#strings.isEmpty(service.mainIcon)} ? ${service.mainIcon} : @{/img/api_icon_default.png}"
th:alt="${service.groupName}">
</div>
</div>
</div>
@@ -24,7 +24,7 @@
<div class="org-form-input-wrapper">
<input type="text" name="organizationId" class="org-form-input input-readonly"
th:value="${user.portalOrg.orgCode}"
placeholder="k000000001"
placeholder="XXXXXX-01"
disabled="disabled">
</div>
</div>