Skip to content

Commit

Permalink
fix: 상품 검색 정규식 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
nowgnas committed Jan 21, 2024
1 parent a79c8a4 commit d825bc0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public Page<Product> findProductsByFlowerId(Long flowerId, Pageable pageable) {
.is(flowerId)
.and("product_sale_status")
.is("SALE"));
query.with(Sort.by(Order.desc("createdAt")));
query.with(pageable);
List<Product> products = mongoTemplate.find(query, Product.class);
return PageableExecutionUtils.getPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d825bc0

Please sign in to comment.