-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #63
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
Merged
Develop #63
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
7826076
feat: ์ค์ผ์ค๋ฌ ์ธํ๋ผ ๋์
๋ฐ KST ํ์์กด ์ค์
johe00123 bd6ae47
feat: ์ฟ ํฐ ์๋ ๋ง๋ฃ ์ค์ผ์ค๋ฌ ๊ตฌํ
johe00123 21b07e1
feat: ์์ฝ NOSHOW ์๋ ์ ํ ์ค์ผ์ค๋ฌ ๊ตฌํ
johe00123 5a384d2
refactor: ์์ฝ ๋ฆฌ๋ง์ธ๋ ์๋ฆผ์ ์ด๋ฒคํธ ๊ธฐ๋ฐ in-app ์๋ฆผ์ผ๋ก ์ ํ
johe00123 abb4229
feat: ์ฌ์ฉ์ ๋ฐฉ๋ฌธ ํ์ API ์ถ๊ฐ
johe00123 e2e71b2
feat : ์ฑ๋ด ๊ธฐ๋ฅ db ์ ์ ๊ตฌํ(์์ฝ ์์ฑ ์์ด์ ํธ)
silkair a53807b
Merge branch 'develop' into feat/#50-chatbot-agent
silkair 3c02248
๋งค์ฅ ์์ฝ ์ ์ด๋ฆ ์ ํํ๊ฒ ์
๋ ฅํ๋๋ก ์์
silkair c18a25e
feat : ์ฑ๋ด์์ฝ ํธ๋์ ์
์ถ๊ฐ + ์๋ฆผ ์์ฑ
silkair 5d06c21
fix: ๋ฐฉ๋ฌธ ํ์ ์คํจ ์ ๋ถ์ ํํ ์๋ฌ ๋ฉ์์ง ์์
johe00123 7f47ff5
Merge pull request #58 from catchtable-clone/feat/#53-visit-api
johe00123 6827f7b
Merge branch 'develop' into feat/#50-chatbot-agent
silkair 61f1ab7
Merge branch 'feat/#50-chatbot-agent' of https://github.com/catchtablโฆ
silkair 0b20279
fix: ๋ฆฌ๋ง์ธ๋ ์๋์ฐ ์์ ๊ฒฝ๊ณ ์ฒ๋ฆฌ ๋ฒ๊ทธ ์์
johe00123 2213eb4
refactor: ์ฟ ํฐ ๋ง๋ฃ ์ฟผ๋ฆฌ์์ ์๋ธ์ฟผ๋ฆฌ ๋์ ๊ฒฝ๋ก ํํ์ ์ฌ์ฉ
johe00123 0fe65b8
refactor: NOSHOW ์ ํ ๋ก์ง์ ๋ฒํฌ UPDATE๋ก ๋ณ๊ฒฝ
johe00123 4e81958
feat : ์ฑ๋ด ๊ธฐ๋ฅ db ์ ์ ๊ตฌํ(์์ฝ ์์ฑ ์์ด์ ํธ)
silkair e281310
feat : ์ฑ๋ด ์์ฝ ์ฟ ํฐ ์ค์ ์ถ๊ฐ
silkair 2a8fbeb
Refactor: ๋ณ์ , ๋ฆฌ๋ทฐ ์ ๊ณ์ฐ ์์ / ์์ฝ ์ํ ์์
jaebeom79 dcc8553
Merge remote-tracking branch 'origin/develop' into feat/#49-image-upload
jaebeom79 2b1301e
Fix: ์๋ฆผ ์ค๋ณต ์ ์ก ์์
jaebeom79 15a9f77
Refactor: ๋ณ์ , ๋ฆฌ๋ทฐ ์ ๋น๋๊ธฐ ๊ฐฑ์
jaebeom79 a633717
Merge pull request #62 from catchtable-clone/feat/#49-image-upload
jaebeom79 dca8eb5
feat : ์ฑ๋ดรฌ์์ฝ ์ฟ ํฐ ์ ์ฉ ์ค์
silkair 47306fc
merge develop
silkair e108be4
test
silkair 87a0758
Merge branch 'develop' of https://github.com/catchtable-clone/backendโฆ
johe00123 04c0fa9
Merge pull request #57 from catchtable-clone/feat/#52-scheduler
johe00123 ae1cffd
Merge branch 'develop' into feat/#50-chatbot-agent
silkair 28e0995
feat : ์ฑ๋ด ์์ฝ ์ฟ ํฐ ์ค์ ์ถ๊ฐ
silkair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/catchtable/coupon/scheduler/CouponExpirationScheduler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.catchtable.coupon.scheduler; | ||
|
|
||
| import com.catchtable.coupon.repository.CouponRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class CouponExpirationScheduler { | ||
|
|
||
| private final CouponRepository couponRepository; | ||
| private final Clock clock; | ||
|
|
||
| /** | ||
| * 5๋ถ ์ฃผ๊ธฐ๋ก ๋ง๋ฃ๋ ์ฟ ํฐ์ EXPIRED ์ํ๋ก ์ ํํ๋ค. | ||
| * ๋ฒํฌ UPDATE ๋จ์ผ ์ฟผ๋ฆฌ๋ก ์ฒ๋ฆฌํ๋ฏ๋ก ํธ๋์ญ์ ๋ถ๋ด์ด ์๋ค. | ||
| */ | ||
| @Scheduled(cron = "0 */5 * * * *") | ||
| @Transactional | ||
| public void expireCoupons() { | ||
| LocalDateTime now = LocalDateTime.now(clock); | ||
| int affected = couponRepository.expireCoupons(now); | ||
|
|
||
| if (affected > 0) { | ||
| log.info("[์ฟ ํฐ ๋ง๋ฃ] {}๊ฑด EXPIRED ์ฒ๋ฆฌ ์๋ฃ", affected); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| import com.catchtable.coupon.dto.read.CouponReadResponse; | ||
| import com.catchtable.coupon.dto.read.CouponTemplateActiveResponse; | ||
| import com.catchtable.coupon.entity.Coupon; | ||
| import com.catchtable.coupon.entity.CouponStatus; | ||
| import com.catchtable.coupon.entity.CouponTemplate; | ||
| import com.catchtable.coupon.repository.CouponRepository; | ||
| import com.catchtable.coupon.repository.CouponTemplateRepository; | ||
|
|
@@ -14,12 +15,17 @@ | |
| import com.catchtable.user.entity.User; | ||
| import com.catchtable.user.repository.UserRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.ai.tool.annotation.Tool; | ||
| import org.springframework.ai.chat.model.ToolContext; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class CouponService { | ||
|
|
@@ -96,4 +102,35 @@ public void returnCoupon(Long couponId) { | |
|
|
||
| coupon.returnCoupon(); | ||
| } | ||
|
|
||
| @Tool(description = "์ฌ์ฉ์๊ฐ ์์ฝ ์ ์ฌ์ฉํ ์ ์๋ ์ฟ ํฐ ๋ชฉ๋ก์ ์กฐํํฉ๋๋ค. " + | ||
| "์ฟ ํฐ ID์ ํ ์ธ ์ ๋ณด๋ฅผ ํฌํจํ์ฌ ์ฌ์ฉ์์๊ฒ ์ด๋ค ์ฟ ํฐ์ ์ฌ์ฉํ ์ง ๋ฌผ์ด๋ณผ ๋ ์ฌ์ฉ๋ฉ๋๋ค.") | ||
| @Transactional(readOnly = true) | ||
| public String getAvailableCouponsForAi(ToolContext toolContext) { | ||
| Long userId = (Long) toolContext.getContext().get("userId"); | ||
| log.info("AI Tool ํธ์ถ: getAvailableCouponsForAi, userId={}", userId); | ||
|
|
||
| List<Coupon> availableCoupons = couponRepository.findAllByUserId(userId).stream() | ||
| .filter(coupon -> coupon.getStatus() == CouponStatus.UNUSED && coupon.getCouponTemplate().getExpiredAt().isAfter(LocalDateTime.now())) | ||
|
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. |
||
| .collect(Collectors.toList()); | ||
|
|
||
| if (availableCoupons.isEmpty()) { | ||
| return "์ฌ์ฉ ๊ฐ๋ฅํ ์ฟ ํฐ์ด ์์ต๋๋ค."; | ||
| } | ||
|
|
||
| return availableCoupons.stream() | ||
| .map(coupon -> { | ||
| String discountInfo; | ||
| if (coupon.getCouponTemplate().getDiscountRate() != null) { | ||
| discountInfo = coupon.getCouponTemplate().getDiscountRate() + "% ํ ์ธ"; | ||
| } else { | ||
| discountInfo = coupon.getCouponTemplate().getAmount() + "์ ํ ์ธ"; | ||
| } | ||
| return String.format("%s (ID: %d, %s)", | ||
| coupon.getCouponTemplate().getCouponName(), | ||
| coupon.getId(), | ||
| discountInfo); | ||
| }) | ||
| .collect(Collectors.joining(", ")); | ||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
src/main/java/com/catchtable/global/config/SchedulerConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.catchtable.global.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.ZoneId; | ||
|
|
||
| @Configuration | ||
| @EnableScheduling | ||
| public class SchedulerConfig { | ||
|
|
||
| /** | ||
| * ์ค์ผ์ค๋ฌ ๋ฐ ์๊ฐ ๋น๊ต ๋ก์ง์์ ์ฌ์ฉํ Clock. | ||
| * KST(Asia/Seoul) ๊ธฐ์ค์ผ๋ก ๊ณ ์ ํ์ฌ Docker ์ปจํ ์ด๋ ๊ธฐ๋ณธ ํ์์กด(UTC) ์ํฅ์ ๋ฐ์ง ์๋๋ก ํ๋ค. | ||
| * LocalDateTime.now(clock) ํํ๋ก ์ฌ์ฉํ๋ฉด ํ์์กด ์ผ๊ด์ฑ๊ณผ ํ ์คํธ ๊ฐ๋ฅ์ฑ์ด ๋ชจ๋ ํ๋ณด๋๋ค. | ||
| */ | ||
| @Bean | ||
| public Clock clock() { | ||
| return Clock.system(ZoneId.of("Asia/Seoul")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
java.time.LocalDate.now()๋ฅผ ์ง์ ์ฌ์ฉํ๋ฉด ์์คํ ํ์์กด์ ์์กดํ๊ฒ ๋์ด ํ๊ฒฝ๋ณ๋ก ๊ฒฐ๊ณผ๊ฐ ๋ฌ๋ผ์ง ์ ์๊ณ ํ ์คํธ ์ ์๊ฐ์ ์ ์ดํ๊ธฐ ์ด๋ ต์ต๋๋ค.SchedulerConfig์ ์ ์๋Clock๋น์ ์ฃผ์ ๋ฐ์LocalDate.now(clock)์ ์ฌ์ฉํ๋ ๋ฐฉ์์ ๊ถ์ฅํฉ๋๋ค.