-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/#66 chatbot api #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.catchtable.chatbot.dto.create; | ||
|
|
||
| public class PendingPaymentHolder { | ||
| private static final ThreadLocal<PendingPaymentInfo> holder = new ThreadLocal<>(); | ||
|
|
||
| public static void set(PendingPaymentInfo info) { | ||
| holder.set(info); | ||
| } | ||
|
|
||
| public static PendingPaymentInfo get() { | ||
| return holder.get(); | ||
| } | ||
|
|
||
| public static void clear() { | ||
| holder.remove(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.catchtable.chatbot.dto.create; | ||
|
|
||
| public record PendingPaymentInfo( | ||
| Long reservationId, | ||
| String orderId, | ||
| int amount | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ | |
| import com.catchtable.store.repository.StoreRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.ai.chat.model.ToolContext; | ||
| import org.springframework.ai.tool.annotation.Tool; | ||
| import org.springframework.ai.tool.annotation.ToolParam; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
|
|
@@ -76,6 +79,37 @@ public void generateMonthlyRemain(StoreRemainCreateRequestDto request) { | |
| storeRemainRepository.saveAll(remainsToSave); | ||
| } | ||
|
|
||
| @Tool(description = "ํน์ ๋งค์ฅ์ ํน์ ๋ ์ง์ ์์ฝ ๊ฐ๋ฅํ ์๊ฐ๋๋ฅผ ์กฐํํฉ๋๋ค. '๋ก์ฝํํ 5์ 20์ผ ์์ฝ ๊ฐ๋ฅํ ์๊ฐ', 'โโ ๋งค์ฅ ์ธ์ ์์ฝ๋ผ' ๋ฑ์ ์์ฒญ์ ์ฌ์ฉํ์ธ์.") | ||
| @Transactional(readOnly = true) | ||
| public String getAvailableTimeSlotsForAi( | ||
| @ToolParam(description = "๋งค์ฅ ์ด๋ฆ (์ ํํ ์ด๋ฆ)") String storeName, | ||
| @ToolParam(description = "์กฐํํ ๋ ์ง, ISO ํ์ (์: 2025-05-20)") LocalDate date | ||
| ) { | ||
| Store store = storeRepository.findAllByIsDeletedFalse().stream() | ||
| .filter(s -> s.getStoreName().equalsIgnoreCase(storeName)) | ||
| .findFirst() | ||
| .orElse(null); | ||
|
Comment on lines
+88
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ชจ๋ ํ์ฑ ๋งค์ฅ ๋ชฉ๋ก์ ๋ฉ๋ชจ๋ฆฌ๋ก ๊ฐ์ ธ์จ ํ ์คํธ๋ฆผ ํํฐ๋ฅผ ์ฌ์ฉํ์ฌ ๋งค์ฅ์ ์ฐพ๋ ๋ฐฉ์์ ๋งค์ฅ ์๊ฐ ๋์ด๋ ์๋ก ์ฑ๋ฅ์ด ์ ํ๋ฉ๋๋ค. |
||
|
|
||
| if (store == null) { | ||
| return "'" + storeName + "' ๋งค์ฅ์ ์ฐพ์ ์ ์์ต๋๋ค. ๋งค์ฅ ์ด๋ฆ์ ๋ค์ ํ์ธํด์ฃผ์ธ์."; | ||
| } | ||
|
|
||
| List<StoreRemain> remains = storeRemainRepository.findAllByStoreIdAndDate(store.getId(), date) | ||
| .stream() | ||
| .filter(r -> r.getRemainTeam() > 0) | ||
| .toList(); | ||
|
|
||
| if (remains.isEmpty()) { | ||
| return date + "์ " + storeName + " ์์ฝ ๊ฐ๋ฅํ ์๊ฐ๋๊ฐ ์์ต๋๋ค."; | ||
| } | ||
|
|
||
| String times = remains.stream() | ||
| .map(r -> r.getRemainTime().format(DateTimeFormatter.ofPattern("HH:mm"))) | ||
| .collect(java.util.stream.Collectors.joining(", ")); | ||
|
|
||
| return date + " " + storeName + " ์์ฝ ๊ฐ๋ฅํ ์๊ฐ: " + times; | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<StoreRemainResponseDto> getStoreRemains(Long storeId, LocalDate date) { | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฌ์ฉ์์ ๋ฉ์์ง๋ฅผ ์ฒ๋ฆฌํ๋ ๊ณผ์ ์์ ๋ํ ์์ฝ์ ์ํด ๋ณ๋์ AI ํธ์ถ์ ๋๊ธฐ์ ์ผ๋ก ์ํํ๊ณ ์์ต๋๋ค. ์ด๋ ์ฑ๋ด์ ์ ์ฒด ์๋ต ์ง์ฐ ์๊ฐ(Latency)์ ํฌ๊ฒ ์ฆ๊ฐ์ํค๋ ์์ธ์ด ๋ฉ๋๋ค. ์์ฝ ์์ ์ ๋น๋๊ธฐ์ ์ผ๋ก ์ฒ๋ฆฌํ๊ฑฐ๋, ๋ํ ์ด๋ ฅ์ด ํน์ ์๊ณ์น ์ด์ ์์์ ๋๋ง ์์ฝ์ ์ํํ๋ ๋ฑ์ ์ต์ ํ ์ ๋ต์ ๊ณ ๋ คํด ๋ณด์๊ธฐ ๋ฐ๋๋๋ค.