-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: 이미지 업로드 알림 로직 분리 #1124
Merged
dradnats1012
merged 17 commits into
develop
from
refactor/image-upload-notify-seperation
Dec 15, 2024
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5ae6187
feat: DiningTypeNotFoundException 클래스 구현
dradnats1012 791f90d
feat: CoopShopService 클래스 diningType 찾는 메서드 구현
dradnats1012 55d73aa
feat: DiningNotifyCache Redis 클래스 생성
dradnats1012 9792acb
feat: DiningNotifyCacheRepository Redis용 클래스 구현
dradnats1012 c659c0d
feat: DiningRepository 날짜, 타입, 장소 기준으로 이미지 업로드 여부 확인 메서드 구현
dradnats1012 3b2708a
feat: 식단 이미지 저장시 알림 발송 삭제, 스케줄러용 알림 발송 로직 구현
dradnats1012 9f353bc
feat: CoopScheduler 클래스 구현
dradnats1012 e6dd396
Merge branch 'develop' into refactor/image-upload-notify-seperation
dradnats1012 e0a1706
feat: LocalTime clock 추가
dradnats1012 8aee7d2
feat: test 완성
dradnats1012 fdd46d2
fix: 10분전 알림 로직 수정
dradnats1012 f2bf73c
fix: 테스트용 코드 삭제
dradnats1012 d8b9964
fix: 테스트 수정
dradnats1012 ca4c6de
Merge branch 'develop' into refactor/image-upload-notify-seperation
dradnats1012 ef80465
Merge branch 'develop' into refactor/image-upload-notify-seperation
dradnats1012 48f04c3
fix: conflict 해결
dradnats1012 c505ea6
fix: 리뷰 반영
dradnats1012 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 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/in/koreatech/koin/domain/coop/model/DiningNotifyCache.java
This file contains 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 in.koreatech.koin.domain.coop.model; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.springframework.data.redis.core.RedisHash; | ||
import org.springframework.data.redis.core.TimeToLive; | ||
|
||
import jakarta.persistence.Id; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@RedisHash("DiningNotify") | ||
public class DiningNotifyCache { | ||
|
||
private static final long CACHE_EXPIRE_HOUR_BY_COOP = 3L; | ||
|
||
@Id | ||
private String id; | ||
|
||
@TimeToLive(unit = TimeUnit.HOURS) | ||
private final Long expiration; | ||
|
||
@Builder | ||
private DiningNotifyCache(String id, Long expiration){ | ||
this.id = id; | ||
this.expiration = CACHE_EXPIRE_HOUR_BY_COOP; | ||
} | ||
|
||
public static DiningNotifyCache from(String diningId){ | ||
return DiningNotifyCache.builder() | ||
.id(diningId) | ||
.build(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/in/koreatech/koin/domain/coop/repository/DiningNotifyCacheRepository.java
This file contains 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,22 @@ | ||
package in.koreatech.koin.domain.coop.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.repository.Repository; | ||
|
||
import in.koreatech.koin.domain.coop.exception.DiningCacheNotFoundException; | ||
import in.koreatech.koin.domain.coop.model.DiningNotifyCache; | ||
|
||
public interface DiningNotifyCacheRepository extends Repository<DiningNotifyCache, String> { | ||
|
||
DiningNotifyCache save(DiningNotifyCache diningNotifyCache); | ||
|
||
boolean existsById(String diningNotifyId); | ||
|
||
Optional<DiningNotifyCache> findById(String diningPlace); | ||
|
||
default DiningNotifyCache getById(String diningPlace) { | ||
return findById(diningPlace).orElseThrow( | ||
() -> DiningCacheNotFoundException.withDetail("diningSoldOutCache: " + diningPlace)); | ||
} | ||
} |
This file contains 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
27 changes: 27 additions & 0 deletions
27
src/main/java/in/koreatech/koin/domain/coop/util/CoopScheduler.java
This file contains 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,27 @@ | ||
package in.koreatech.koin.domain.coop.util; | ||
|
||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import in.koreatech.koin.domain.coop.service.CoopService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class CoopScheduler { | ||
|
||
private final CoopService coopService; | ||
|
||
@Scheduled(cron = "0 0/6 7 * * *") | ||
@Scheduled(cron = "0 30/6 10-11 * * *") | ||
@Scheduled(cron = "0 30/6 16-17 * * *") | ||
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. A |
||
public void notifyDiningImageUpload() { | ||
try { | ||
coopService.sendDiningNotify(); | ||
} catch (Exception e) { | ||
log.warn("식단 이미지 알림 과정에서 오류가 발생했습니다."); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/in/koreatech/koin/domain/coopshop/exception/DiningTypeNotFoundException.java
This file contains 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,20 @@ | ||
package in.koreatech.koin.domain.coopshop.exception; | ||
|
||
import in.koreatech.koin.global.exception.DataNotFoundException; | ||
|
||
public class DiningTypeNotFoundException extends DataNotFoundException { | ||
|
||
private static final String DEFAULT_MESSAGE = "해당하는 식단 타입이 존재하지 않습니다."; | ||
|
||
public DiningTypeNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public DiningTypeNotFoundException(String message, String detail) { | ||
super(message, detail); | ||
} | ||
|
||
public static DiningTypeNotFoundException withDetail(String detail) { | ||
return new DiningTypeNotFoundException(DEFAULT_MESSAGE, detail); | ||
} | ||
} |
This file contains 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 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.
C
여기 접근 제어 안해줘도 되나요?
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.
오 나이스입니다