From a75347e41f27784e4cc3ff4a22d547f41ce64dc6 Mon Sep 17 00:00:00 2001 From: hyzoon Date: Thu, 21 Nov 2024 20:47:58 +0900 Subject: [PATCH] fix: match the proper json path for website and logo properties --- .../jobInfo/dto/response/JobInfoResponse.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/scg/stop/jobInfo/dto/response/JobInfoResponse.java b/src/main/java/com/scg/stop/jobInfo/dto/response/JobInfoResponse.java index 442194db..4a4dd627 100644 --- a/src/main/java/com/scg/stop/jobInfo/dto/response/JobInfoResponse.java +++ b/src/main/java/com/scg/stop/jobInfo/dto/response/JobInfoResponse.java @@ -50,7 +50,7 @@ public void setProperties(JsonNode properties) { this.position = extractTextFromProperty(properties, "채용 포지션", "rich_text"); this.logo = extractLogoUrl(properties, "logo"); this.salary = extractTextFromProperty(properties, "연봉", "rich_text"); - this.website = extractTextFromProperty(properties, "웹사이트", "url"); + this.website = extractUrl(properties, "웹사이트"); this.state = extractMultiSelect(properties, "채용 상태"); this.hiringTime = extractTextFromProperty(properties, "채용 시점", "rich_text"); } @@ -99,13 +99,37 @@ private String extractLogoUrl(JsonNode properties, String fieldName) { if (properties.has(fieldName)) { JsonNode filesNode = properties.get(fieldName).get("files"); if (filesNode.isArray() && filesNode.size() > 0) { - JsonNode firstFileNode = filesNode.get(0).get("file"); - if (firstFileNode != null && firstFileNode.has("url")) { - return firstFileNode.get("url").asText(); + JsonNode firstFileNode = filesNode.get(0); + + // Handle internal file type + if (firstFileNode.has("file")) { + JsonNode fileNode = firstFileNode.get("file"); + if (fileNode != null && fileNode.has("url")) { + return fileNode.get("url").asText(); + } + } + + // Handle external file type + if (firstFileNode.has("external")) { + JsonNode externalNode = firstFileNode.get("external"); + if (externalNode != null && externalNode.has("url")) { + return externalNode.get("url").asText(); + } } } } return null; } + // Extract url from website property + private String extractUrl(JsonNode properties, String fieldName) { + if (properties.has(fieldName)) { + JsonNode urlNode = properties.get(fieldName).get("url"); + if (urlNode != null && !urlNode.isNull()) { + return urlNode.asText(); + } + } + return null; + } + }