-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#147 예산 수정 - 예산 변경 이력 추적 #148
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
12 commits
Select commit
Hold shift + click to select a range
1e0bc26
:sparkles: feat: 예산 수정 시점 추적을 위한 BudgetHistory 엔티티 추가
kingmingyu eb89e0d
:sparkles: feat: 예산 수정 시 BudgetHistory 저장
kingmingyu 8c4f496
:sparkles: feat: 예산 변경 이력 기간 조회 쿼리 추가
kingmingyu 876a31a
:sparkles: feat: 타임라인 상세 조회 응답에 BudgetHistory 추가
kingmingyu 0653cc6
:sparkles: feat: 타임라인 상세 조회 시 BudgetHistory 반환 로직 추가
kingmingyu 9be362f
:sparkles: feat: 대시보드 응답에 예산 변경 이력 응답 추가
kingmingyu 95bdaa9
:sparkles: feat: 예산 변경 이력 조회 로직 추가
kingmingyu f20767c
:sparkles: feat: 예산 변경 이력 조회 API 추가
kingmingyu 5a7459a
:sparkles: feat: 예산 수정 시 이전 값과 동일한 경우 예외 처리 추가
kingmingyu a39f10c
:sparkles: feat: BudgetHistory cascade 삭제 적용
kingmingyu 6ff413d
:bug: fix: 광고그룹 예산/입찰가 동일값 검증 조건 수정
kingmingyu b3b2fe0
Merge branch 'develop' into feat/#147
kingmingyu 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
7 changes: 7 additions & 0 deletions
7
...java/com/whereyouad/WhereYouAd/domains/advertisement/domain/constant/BudgetFieldType.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,7 @@ | ||
| package com.whereyouad.WhereYouAd.domains.advertisement.domain.constant; | ||
|
|
||
| public enum BudgetFieldType { | ||
| CAMPAIGN_BUDGET, | ||
| AD_GROUP_BUDGET, | ||
| BID_AMOUNT | ||
| } |
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
51 changes: 51 additions & 0 deletions
51
...ava/com/whereyouad/WhereYouAd/domains/advertisement/persistence/entity/BudgetHistory.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,51 @@ | ||
| package com.whereyouad.WhereYouAd.domains.advertisement.persistence.entity; | ||
|
|
||
| import com.whereyouad.WhereYouAd.domains.advertisement.domain.constant.BudgetFieldType; | ||
| import com.whereyouad.WhereYouAd.domains.advertisement.domain.constant.Provider; | ||
| import com.whereyouad.WhereYouAd.global.common.BaseEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
| import org.hibernate.annotations.OnDelete; | ||
| import org.hibernate.annotations.OnDeleteAction; | ||
|
|
||
| @Entity | ||
| @Table(name = "budget_history") | ||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| public class BudgetHistory extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "budget_history_id") | ||
| private Long id; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "field_type", nullable = false) | ||
| private BudgetFieldType fieldType; | ||
|
|
||
| @Column(name = "previous_value") | ||
| private Long previousValue; | ||
|
|
||
| @Column(name = "new_value") | ||
| private Long newValue; | ||
|
|
||
| @Column(name = "changed_by", nullable = false) | ||
| private Long changedBy; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "provider", nullable = false) | ||
| private Provider provider; | ||
|
|
||
| // 연관 관계 (nullable로 2개 중에 1개만 연결 가능) | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "ad_campaign_id") | ||
| @OnDelete(action = OnDeleteAction.CASCADE) | ||
| private AdCampaign adCampaign; | ||
|
ojy0903 marked this conversation as resolved.
|
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "ad_group_id") | ||
| @OnDelete(action = OnDeleteAction.CASCADE) | ||
| private AdGroup adGroup; | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
...ouad/WhereYouAd/domains/advertisement/persistence/repository/BudgetHistoryRepository.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,26 @@ | ||
| package com.whereyouad.WhereYouAd.domains.advertisement.persistence.repository; | ||
|
|
||
| import com.whereyouad.WhereYouAd.domains.advertisement.persistence.entity.BudgetHistory; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| public interface BudgetHistoryRepository extends JpaRepository<BudgetHistory, Long> { | ||
|
|
||
| @Query(""" | ||
| SELECT bh FROM BudgetHistory bh | ||
| LEFT JOIN bh.adCampaign ac | ||
| LEFT JOIN bh.adGroup ag | ||
| LEFT JOIN ag.adCampaign agc | ||
| WHERE (ac.organization.id = :orgId OR agc.organization.id = :orgId) | ||
| AND bh.createdAt BETWEEN :start AND :end | ||
| ORDER BY bh.createdAt DESC | ||
| """) | ||
| List<BudgetHistory> findByOrgAndPeriod( | ||
| @Param("orgId") Long orgId, | ||
| @Param("start") LocalDateTime start, | ||
| @Param("end") LocalDateTime end); | ||
| } |
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
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.
P3: 여기서 입찰가나 예산 중 하나라도 이전과 같은 값으로 수정하게 되면 예외가 발생하는데, 사용자가 둘 중 하나만 값을 변경하는 경우를 위해 값이 아무것도 변경 되지 않은 경우에만 예외를 던지는 건 어떨까요?
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.
오 감사합니다! &&로 묶어서 수정했습니다!