API 목록, 상세 페이지 적용
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.eactive.apim.portal.apps.apis.controller;
|
||||
|
||||
|
||||
import com.eactive.apim.portal.apps.apis.dto.ApiSearchData;
|
||||
import com.eactive.apim.portal.apps.apis.dto.ApiSpecInfoDto;
|
||||
import com.eactive.apim.portal.apps.apis.service.ApiSearchFacade;
|
||||
import com.eactive.apim.portal.apps.apis.service.ApiService;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
@RequestMapping("/apis")
|
||||
@RequiredArgsConstructor
|
||||
public class ApiController {
|
||||
|
||||
private static final String NOT_FOUND_MESSAGE = "찾을 수 없습니다.";
|
||||
private final ApiService apiService;
|
||||
private final ApiServiceService apiServiceService;
|
||||
@@ -33,15 +35,20 @@ public class ApiController {
|
||||
|
||||
@GetMapping("/detail")
|
||||
public String apidetail(@RequestParam(value = "id", required = false) String id, ModelMap model) {
|
||||
if( id ==null) {
|
||||
if (id == null) {
|
||||
return "redirect:/apis/common";
|
||||
}
|
||||
|
||||
ApiSpecInfoDto api = apiService.selectDetail(id);
|
||||
if(api==null){
|
||||
if (api == null) {
|
||||
throw new NotFoundException(NOT_FOUND_MESSAGE);
|
||||
}
|
||||
|
||||
Map<String, Object> searchResult = apiSearchFacade.searchApis(new ApiGroupSearch());
|
||||
|
||||
model.addAttribute("apiSpecInfo", api);
|
||||
model.addAttribute("totalApiCount", searchResult.get("totalApiCount"));
|
||||
model.addAttribute("services", searchResult.get("services"));
|
||||
return "apps/apis/mainApiDetail";
|
||||
}
|
||||
|
||||
@@ -54,7 +61,7 @@ public class ApiController {
|
||||
model.addAttribute("apis", searchResult.get("apis"));
|
||||
model.addAttribute("totalApiCount", searchResult.get("totalApiCount"));
|
||||
model.addAttribute("selectedApiCount", searchResult.get("selectedApiCount"));
|
||||
model.addAttribute("selected", search.getGroupIds().size() >0 ? search.getGroupIds().get(0) : "-1");
|
||||
model.addAttribute("selected", search.getGroupIds().size() > 0 ? search.getGroupIds().get(0) : "-1");
|
||||
|
||||
return "apps/apis/mainApiList";
|
||||
}
|
||||
|
||||
+11
-6
@@ -1,7 +1,11 @@
|
||||
package com.eactive.apim.portal.apps.apis.controller;
|
||||
|
||||
import com.eactive.apim.portal.apispec.entity.ApiSpecInfo;
|
||||
import com.eactive.apim.portal.apispec.service.ApiSpecInfoService;
|
||||
import com.eactive.apim.portal.apps.apis.service.ApiService;
|
||||
import com.eactive.apim.portal.apps.apiservice.service.ApiSpecService;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -10,6 +14,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -21,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class TestbedSpecController {
|
||||
|
||||
@Autowired
|
||||
ApiSpecService apiSpecService;
|
||||
private ApiSpecInfoService apiSpecInfoService;
|
||||
|
||||
private static final String DEFAULT_TOKEN_API_ID = "default-token-api-spec";
|
||||
private static final String DEFAULT_SPEC_PATH = "swagger/default-token-api-spec.json";
|
||||
@@ -40,12 +45,12 @@ public class TestbedSpecController {
|
||||
}
|
||||
}
|
||||
|
||||
String testbedSpec = apiSpecService.generateApiServiceTestbedSpec(id);
|
||||
Optional<ApiSpecInfo> spec = apiSpecInfoService.findById(id);
|
||||
|
||||
if (testbedSpec.isEmpty()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
} else {
|
||||
return ResponseEntity.ok().body(testbedSpec);
|
||||
if (!spec.isPresent()) {
|
||||
StringUtils.hasText(spec.get().getTestbedSpec());
|
||||
}
|
||||
return ResponseEntity.ok().body(spec.get().getTestbedSpec());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,6 @@ public class ApiSpecInfoDto {
|
||||
private String displayOrg;
|
||||
|
||||
private String displayRoleCode;
|
||||
|
||||
private String apiGroupName;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,11 @@ public class ApiSearchFacadeImpl implements ApiSearchFacade {
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
filteredApis.forEach(api -> {
|
||||
api.setMainIcon(apiData.getServicesByApiId().get(api.getApiId()).getMainIcon());
|
||||
ApiServiceDTO service = apiData.getServicesByApiId().get(api.getApiId());
|
||||
if (service != null) {
|
||||
api.setMainIcon(service.getMainIcon());
|
||||
api.setApiGroupName(service.getGroupName());
|
||||
}
|
||||
});
|
||||
|
||||
List<ApiServiceDTO> servicesToReturn = apiData.getAllServices().stream()
|
||||
@@ -143,6 +147,7 @@ public class ApiSearchFacadeImpl implements ApiSearchFacade {
|
||||
result.put("services", servicesToReturn);
|
||||
result.put("apis", sortedApis);
|
||||
result.put("selectedApiCount", sortedApis.size());
|
||||
result.put("totalApiCount", apiData.getApiSpecsById().size());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -51,9 +52,12 @@ public class MainApiFacade {
|
||||
|
||||
public List<String> getHashTags() {
|
||||
Map<String, String> property = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY);
|
||||
String hashTags = property.getOrDefault("main.keyword.list", "#인증, #대출, #예금");
|
||||
//split with , and return as a list
|
||||
return Arrays.asList(hashTags.split(","));
|
||||
String hashTags = property.getOrDefault("main.keyword.list", "#계좌조회, #송금API, #실시간결제, #오픈뱅킹");
|
||||
//split with , and clean each tag (remove # and trim)
|
||||
return Arrays.stream(hashTags.split(","))
|
||||
.map(tag -> tag.trim().replaceFirst("^#", ""))
|
||||
.filter(tag -> !tag.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<ApiSpecInfoDto> getOpenApis(List<String> apiIds) {
|
||||
|
||||
Reference in New Issue
Block a user