메인 페이지 서비스 조회 기능 구현
This commit is contained in:
@@ -41,14 +41,7 @@ public class IndexController {
|
|||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index(Model model) {
|
public String index(Model model) {
|
||||||
|
|
||||||
Map<String, String> propertyMap = portalPropertyService.getPortalPropertiesAsMap("Portal");
|
List<ApiServiceDTO> services = mainApiFacade.getOpenApiServices();
|
||||||
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<String> hashTags = mainApiFacade.getHashTags();
|
List<String> hashTags = mainApiFacade.getHashTags();
|
||||||
|
|
||||||
ApiGroupSearch search = new ApiGroupSearch();
|
ApiGroupSearch search = new ApiGroupSearch();
|
||||||
@@ -56,34 +49,19 @@ public class IndexController {
|
|||||||
|
|
||||||
int selectedApiCount = (int) searchResult.get("selectedApiCount");
|
int selectedApiCount = (int) searchResult.get("selectedApiCount");
|
||||||
|
|
||||||
// 서비스 이용 수
|
|
||||||
int serviceCount = ((List<?>) searchResult.get("services")).size();
|
int serviceCount = ((List<?>) searchResult.get("services")).size();
|
||||||
|
|
||||||
// 승인된 기업 건수
|
// 승인된 기업 건수
|
||||||
int approvedOrgCount = mainApiFacade.getApprovedOrgCount();
|
int approvedOrgCount = mainApiFacade.getApprovedOrgCount();
|
||||||
|
|
||||||
addAttributesToModel(model, apiServices, totalApiCount, hashTags, serviceCount, approvedOrgCount, selectedApiCount);
|
addAttributesToModel(model, services, hashTags, serviceCount, approvedOrgCount, selectedApiCount);
|
||||||
|
|
||||||
return "apps/main/index";
|
return "apps/main/index";
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ApiServiceDTO> getSortedApiServices(String apiId) {
|
private void addAttributesToModel(Model model, List<ApiServiceDTO> apiServices, List<String> hashTags, int serviceCount, int approvedOrgCount, int selectedApiCount) {
|
||||||
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) {
|
|
||||||
|
|
||||||
model.addAttribute("services", apiServices);
|
model.addAttribute("services", apiServices);
|
||||||
model.addAttribute("totalApiCount", totalApiCount);
|
|
||||||
model.addAttribute("hashtags", hashTags);
|
model.addAttribute("hashtags", hashTags);
|
||||||
|
|
||||||
model.addAttribute("serviceCount", serviceCount);
|
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.apiservice.service.ApiServiceService;
|
||||||
import com.eactive.apim.portal.apps.user.service.PortalOrgService;
|
import com.eactive.apim.portal.apps.user.service.PortalOrgService;
|
||||||
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
|
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Service
|
@Service
|
||||||
@@ -34,17 +30,13 @@ public class MainApiFacade {
|
|||||||
return portalOrgService.getActiveApprovedOrgCount();
|
return portalOrgService.getActiveApprovedOrgCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiServiceDTO> getOpenApiServices(String serviceId) {
|
public List<ApiServiceDTO> getOpenApiServices() {
|
||||||
ApiGroupSearch search = new ApiGroupSearch();
|
ApiGroupSearch search = new ApiGroupSearch();
|
||||||
|
|
||||||
Map<String, String> property = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY);
|
Map<String, String> property = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY);
|
||||||
String services = property.getOrDefault("main.service.list", "");
|
String services = property.getOrDefault("main.service.list", "");
|
||||||
|
|
||||||
if (StringUtils.hasText(serviceId) && services.contains(serviceId)) {
|
search.setGroupIds(Arrays.asList(services.replace(" ", "").split(",")));
|
||||||
search.setGroupIds(Collections.singletonList(serviceId));
|
|
||||||
} else {
|
|
||||||
search.setGroupIds(Arrays.asList(services.split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiServiceService.searchApiGroups(search);
|
return apiServiceService.searchApiGroups(search);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,44 +147,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="api-cards-container">
|
<div class="api-cards-container">
|
||||||
<div class="api-card">
|
<!-- Services 데이터를 반복하여 API 카드 표시 (최대 4개) -->
|
||||||
<h3 class="card-title">금융서비스</h3>
|
<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">
|
<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>
|
</p>
|
||||||
<div class="card-illustration">
|
<div class="card-illustration">
|
||||||
<img th:src="@{/img/api_icon_finance.png}" alt="금융서비스">
|
<!-- 서비스별 아이콘 매핑 - base64 인코딩된 이미지 사용 -->
|
||||||
</div>
|
<img th:src="${service.mainIcon != null and !#strings.isEmpty(service.mainIcon)} ? ${service.mainIcon} : @{/img/api_icon_default.png}"
|
||||||
</div>
|
th:alt="${service.groupName}">
|
||||||
|
|
||||||
<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="간편결제">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<div class="org-form-input-wrapper">
|
<div class="org-form-input-wrapper">
|
||||||
<input type="text" name="organizationId" class="org-form-input input-readonly"
|
<input type="text" name="organizationId" class="org-form-input input-readonly"
|
||||||
th:value="${user.portalOrg.orgCode}"
|
th:value="${user.portalOrg.orgCode}"
|
||||||
placeholder="k000000001"
|
placeholder="XXXXXX-01"
|
||||||
disabled="disabled">
|
disabled="disabled">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user