diff --git a/server/build/classes/java/main/com/swdc/server/controller/TextController.class b/server/build/classes/java/main/com/swdc/server/controller/TextController.class index ca29b8f..ce19d04 100644 Binary files a/server/build/classes/java/main/com/swdc/server/controller/TextController.class and b/server/build/classes/java/main/com/swdc/server/controller/TextController.class differ diff --git a/server/build/classes/java/main/com/swdc/server/domain/storage/Product.class b/server/build/classes/java/main/com/swdc/server/domain/storage/Product.class index ca62fa8..23a04c2 100644 Binary files a/server/build/classes/java/main/com/swdc/server/domain/storage/Product.class and b/server/build/classes/java/main/com/swdc/server/domain/storage/Product.class differ diff --git a/server/build/classes/java/main/com/swdc/server/service/PriceService.class b/server/build/classes/java/main/com/swdc/server/service/PriceService.class index 5552753..acbc551 100644 Binary files a/server/build/classes/java/main/com/swdc/server/service/PriceService.class and b/server/build/classes/java/main/com/swdc/server/service/PriceService.class differ diff --git a/server/build/classes/java/main/com/swdc/server/service/TextService.class b/server/build/classes/java/main/com/swdc/server/service/TextService.class index c275045..b456b45 100644 Binary files a/server/build/classes/java/main/com/swdc/server/service/TextService.class and b/server/build/classes/java/main/com/swdc/server/service/TextService.class differ diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceController.class.uniqueId0 b/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceController.class.uniqueId0 new file mode 100644 index 0000000..147393b Binary files /dev/null and b/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceController.class.uniqueId0 differ diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceService.class.uniqueId1 b/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceService.class.uniqueId1 new file mode 100644 index 0000000..5552753 Binary files /dev/null and b/server/build/tmp/compileJava/compileTransaction/stash-dir/PriceService.class.uniqueId1 differ diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/Product.class.uniqueId3 b/server/build/tmp/compileJava/compileTransaction/stash-dir/Product.class.uniqueId3 new file mode 100644 index 0000000..ca62fa8 Binary files /dev/null and b/server/build/tmp/compileJava/compileTransaction/stash-dir/Product.class.uniqueId3 differ diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/TextController.class.uniqueId0 b/server/build/tmp/compileJava/compileTransaction/stash-dir/TextController.class.uniqueId2 similarity index 100% rename from server/build/tmp/compileJava/compileTransaction/stash-dir/TextController.class.uniqueId0 rename to server/build/tmp/compileJava/compileTransaction/stash-dir/TextController.class.uniqueId2 diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId1 b/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId1 deleted file mode 100644 index b7d4637..0000000 Binary files a/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId1 and /dev/null differ diff --git a/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId4 b/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId4 new file mode 100644 index 0000000..c275045 Binary files /dev/null and b/server/build/tmp/compileJava/compileTransaction/stash-dir/TextService.class.uniqueId4 differ diff --git a/server/build/tmp/compileJava/previous-compilation-data.bin b/server/build/tmp/compileJava/previous-compilation-data.bin index cae2ccc..4345e6b 100644 Binary files a/server/build/tmp/compileJava/previous-compilation-data.bin and b/server/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/server/src/main/java/com/swdc/server/service/PriceService.java b/server/src/main/java/com/swdc/server/service/PriceService.java index 34670e3..8826f93 100644 --- a/server/src/main/java/com/swdc/server/service/PriceService.java +++ b/server/src/main/java/com/swdc/server/service/PriceService.java @@ -42,6 +42,8 @@ public class PriceService { * * file system에서 "{fileSystemPath}/platform/category_name/product_id.txt"에 해당하는 product의 가격 정보를 반환 * + * 가격이 변경되는 시점 & 하루가 바뀌는 시점의 가격 정보만 가져옴 + * */ public Price getProductDetails(String platform, String category_name, String product_id) { Path fileSystemPath = Paths.get(BASE_PATH); @@ -52,28 +54,24 @@ public Price getProductDetails(String platform, String category_name, String pro try (BufferedReader bufferedReader = Files.newBufferedReader(productPath)) { String previousLine = null; String currentLine; + String previousDate = null; while ((currentLine = bufferedReader.readLine()) != null) { String[] parts = currentLine.split(","); String dateTime = parts[0] + "," + parts[1]; int currentPrice = Integer.parseInt(parts[2]); + String currentDate = parts[0]; - // 이전 라인의 가격 정보와 비교 - if (previousLine != null) { - String[] prevParts = previousLine.split(","); - int previousPrice = Integer.parseInt(prevParts[2]); - - // 가격이 달라졌을 때만 기록 - if (previousPrice != currentPrice) { - prices.add(Map.of(dateTime, currentPrice)); - } - } else { - // 첫 번째 라인은 비교할 이전 가격이 없으므로 기록 + if (previousLine == null || !previousLine.split(",")[2].equals(parts[2])) { + prices.add(Map.of(dateTime, currentPrice)); + } + + if (previousDate != null && !currentDate.equals(previousDate) && parts[1].equals("00:00")) { prices.add(Map.of(dateTime, currentPrice)); } - // 현재 라인을 이전 라인으로 업데이트 previousLine = currentLine; + previousDate = currentDate; } } catch (FileNotFoundException e) { System.err.println("File not found: " + productPath + ". Error: " + e.getMessage()); @@ -101,7 +99,6 @@ public Price getProductDetailsWithoutCategory(String platform, String product_id List> allPrices = new ArrayList<>(); try { - // Traverse all directories and files under the platform directory Files.walk(basePath) .filter(Files::isRegularFile) .filter(path -> path.getFileName().toString().equals(product_id + ".txt")) @@ -116,21 +113,16 @@ public Price getProductDetailsWithoutCategory(String platform, String product_id String dateTime = parts[0] + "," + parts[1]; int currentPrice = Integer.parseInt(parts[2]); - // 이전 라인의 가격과 비교 if (previousLine != null) { String[] prevParts = previousLine.split(","); int previousPrice = Integer.parseInt(prevParts[2]); - // 가격이 변동되었을 때만 기록 if (previousPrice != currentPrice) { allPrices.add(Map.of(dateTime, currentPrice)); } } else { - // 첫 번째 라인은 비교 대상이 없으므로 기록 allPrices.add(Map.of(dateTime, currentPrice)); } - - // 현재 라인을 이전 라인으로 설정 previousLine = currentLine; } } catch (IOException e) {