-
Notifications
You must be signed in to change notification settings - Fork 2
feat : payment 실패시 status 변경 #74
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
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
18998d8
feat: 학교 데이터 캐싱 및 초기 로딩 기능 추가
polyglot-k a08cb25
refactor: PaymentRequest에서 applicationIds를 applicationSchoolIds로 변경
polyglot-k 7eead85
refactor: PreparePaymentRequest에서 applicationId를 applicationSchoolIds…
polyglot-k 52d1541
feat: RedisConfig 클래스 추가 및 RedisTemplate 설정
polyglot-k fdc800a
feat: SchoolApplicationProjection 및 SchoolRepository에 학교 이름별 카운트 쿼리 추가
polyglot-k f929d47
style: 코드 스타일 개선을 위한 공백 정리 및 임포트 정리
polyglot-k 4a7c8d4
refactor: applicationId를 applicationSchoolId로 변경
polyglot-k 7190c9a
refactor: ApplicationSchoolJpaRepository 삭제 및 관련 쿼리 제거
polyglot-k 4756527
refactor: applicationIds를 applicationSchoolIds로 변경
polyglot-k 3b0d4f1
refactor: applicationId를 applicationSchoolId로 변경 및 관련 리포지토리 수정
polyglot-k d374e46
refactor: ApplicationSchoolJpaRepository 임포트 위치 수정
polyglot-k 9833ef1
refactor: ApplicationSchoolJpaRepository 임포트 위치 수정
polyglot-k 91ec011
refactor: applicationId를 applicationSchoolId로 변경하여 쿼리 수정
polyglot-k 52c700e
fix: 파일 끝에 개행 추가
polyglot-k 1dde35c
refactor: existsByUserIdAndSchoolId 메서드 시그니처 수정 및 불필요한 임포트 제거
polyglot-k ed28177
feat: RetryConfig 클래스 추가 및 Spring Retry 활성화
polyglot-k 3b8bc02
fix: null 체크 추가하여 decreaseApplicationCount 메서드 안정성 향상
polyglot-k a324f73
fix: 변수 이름을 명확하게 변경하여 가독성 향상
polyglot-k de95afe
fix: Item 클래스의 applicationSchoolId 변수 이름 수정 및 메시지 변경
polyglot-k 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
64 changes: 64 additions & 0 deletions
64
src/main/java/life/mosu/mosuserver/application/school/SchoolQuotaCacheManager.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,64 @@ | ||
| package life.mosu.mosuserver.application.school; | ||
|
|
||
| import java.util.List; | ||
| import life.mosu.mosuserver.domain.school.SchoolApplicationProjection; | ||
| import life.mosu.mosuserver.domain.school.SchoolJpaEntity; | ||
| import life.mosu.mosuserver.domain.school.SchoolRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.redis.core.RedisTemplate; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class SchoolQuotaCacheManager { | ||
|
|
||
| private static final String REDIS_KEY_SCHOOL_MAX_CAPACITY = "school:max_capacity:"; | ||
| private static final String REDIS_KEY_SCHOOL_CURRENT_APPLICATIONS = "school:current_applications:"; | ||
|
|
||
| private final RedisTemplate<String, Long> redisTemplate; | ||
| private final SchoolRepository schoolRepository; | ||
|
|
||
| public void cacheSchoolMaxCapacities() { | ||
| List<SchoolJpaEntity> schools = schoolRepository.findAll(); | ||
| for (SchoolJpaEntity school : schools) { | ||
| String key = REDIS_KEY_SCHOOL_MAX_CAPACITY + school.getSchoolName(); | ||
| redisTemplate.opsForValue().set(key, school.getCapacity()); | ||
| } | ||
| } | ||
|
|
||
| public void cacheSchoolCurrentApplicationCounts() { | ||
| List<SchoolApplicationProjection> schoolApplications = schoolRepository.countBySchoolNameGroupBy(); | ||
| for (SchoolApplicationProjection projection : schoolApplications) { | ||
| String key = REDIS_KEY_SCHOOL_CURRENT_APPLICATIONS + projection.schoolName(); | ||
| redisTemplate.opsForValue().set(key, projection.count()); | ||
| } | ||
| } | ||
|
|
||
| public Long getSchoolApplicationCounts(String schoolName) { | ||
| return redisTemplate.opsForValue() | ||
| .get(REDIS_KEY_SCHOOL_CURRENT_APPLICATIONS + schoolName); | ||
| } | ||
|
|
||
| public Long getSchoolCapacities(String schoolName) { | ||
| return redisTemplate.opsForValue() | ||
| .get(REDIS_KEY_SCHOOL_MAX_CAPACITY + schoolName); | ||
| } | ||
polyglot-k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public void increaseApplicationCount(String schoolName) { | ||
| String key = REDIS_KEY_SCHOOL_CURRENT_APPLICATIONS + schoolName; | ||
| redisTemplate.opsForValue().increment(key); | ||
| } | ||
|
|
||
| public void decreaseApplicationCount(String schoolName) { | ||
| String key = REDIS_KEY_SCHOOL_CURRENT_APPLICATIONS + schoolName; | ||
| Long currentValue = redisTemplate.opsForValue().get(key); | ||
| if (currentValue != null && currentValue > 0) { | ||
| redisTemplate.opsForValue().decrement(key); | ||
| } | ||
| } | ||
|
|
||
| public void preloadSchoolData() { | ||
| cacheSchoolMaxCapacities(); | ||
| cacheSchoolCurrentApplicationCounts(); | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,4 +55,4 @@ public ApplicationJpaEntity( | |
| this.agreedToRefundPolicy = agreedToRefundPolicy; | ||
| } | ||
|
|
||
| } | ||
| } | ||
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
15 changes: 0 additions & 15 deletions
15
src/main/java/life/mosu/mosuserver/domain/application/ApplicationSchoolJpaRepository.java
This file was deleted.
Oops, something went wrong.
9 changes: 7 additions & 2 deletions
9
...in/java/life/mosu/mosuserver/domain/applicationschool/ApplicationSchoolJpaRepository.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 |
|---|---|---|
| @@ -1,16 +1,21 @@ | ||
| package life.mosu.mosuserver.domain.applicationschool; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface ApplicationSchoolJpaRepository extends | ||
| JpaRepository<ApplicationSchoolJpaEntity, Long> { | ||
|
|
||
|
|
||
| boolean existsByUserIdAndSchoolIdIn(Long userId, Collection<Long> schoolIds); | ||
| boolean existsByUserIdAndSchoolId(Long userId, Long schoolId); | ||
|
|
||
| List<ApplicationSchoolJpaEntity> findAllByApplicationId(Long applicationId); | ||
|
|
||
| boolean existsByApplicationId(Long applicationId); | ||
|
|
||
| @Query("SELECT COUNT(a) = :size FROM ApplicationSchoolJpaEntity a WHERE a.id IN :applicationSchoolIds") | ||
| boolean existsAllByIds(@Param("applicationSchoolIds") List<Long> applicationSchoolIds, | ||
| @Param("size") long size); | ||
| } |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/life/mosu/mosuserver/domain/school/SchoolApplicationProjection.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,5 @@ | ||
| package life.mosu.mosuserver.domain.school; | ||
|
|
||
| public record SchoolApplicationProjection(Long schoolId, String schoolName, Long count) { | ||
|
|
||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.