diff --git a/src/main/java/kr/bb/product/domain/product/adapter/out/mongo/ProductQueryRepository.java b/src/main/java/kr/bb/product/domain/product/adapter/out/mongo/ProductQueryRepository.java index 650a08d..50e7f46 100644 --- a/src/main/java/kr/bb/product/domain/product/adapter/out/mongo/ProductQueryRepository.java +++ b/src/main/java/kr/bb/product/domain/product/adapter/out/mongo/ProductQueryRepository.java @@ -295,6 +295,7 @@ public Page findProductsByFlowerId(Long flowerId, Pageable pageable) { .is(flowerId) .and("product_sale_status") .is("SALE")); + query.with(Sort.by(Order.desc("createdAt"))); query.with(pageable); List products = mongoTemplate.find(query, Product.class); return PageableExecutionUtils.getPage( diff --git a/src/main/java/kr/bb/product/domain/product/application/port/in/ProductQueryInputPort.java b/src/main/java/kr/bb/product/domain/product/application/port/in/ProductQueryInputPort.java index 6f89de5..e2543fc 100644 --- a/src/main/java/kr/bb/product/domain/product/application/port/in/ProductQueryInputPort.java +++ b/src/main/java/kr/bb/product/domain/product/application/port/in/ProductQueryInputPort.java @@ -392,9 +392,11 @@ public ProductList searchByUser(Long userId, String sentence, Pageable pageable) @NotNull private Long getFlowerId(String sentence) { + String regex = "[^0-9]"; String prompt = getPrompt(sentence); String response = chatgptService.sendMessage(prompt); - return Long.valueOf(response.split(":")[1].trim()); + + return Long.valueOf(response.replaceAll(regex, "")); } private String getPrompt(String sentence) {