-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a876369
commit 3c16b71
Showing
14 changed files
with
239 additions
and
11 deletions.
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
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
21 changes: 21 additions & 0 deletions
21
src/main/java/org/petmarket/advertisements/advertisement/listener/AdvertisementListener.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,21 @@ | ||
package org.petmarket.advertisements.advertisement.listener; | ||
|
||
import jakarta.persistence.PostPersist; | ||
import jakarta.persistence.PostUpdate; | ||
import org.petmarket.advertisements.advertisement.entity.Advertisement; | ||
import org.petmarket.advertisements.advertisement.service.AdvertisementService; | ||
import org.springframework.context.annotation.Lazy; | ||
|
||
public class AdvertisementListener { | ||
// private final AdvertisementService advertisementService; | ||
// | ||
// public AdvertisementListener(@Lazy AdvertisementService advertisementService) { | ||
// this.advertisementService = advertisementService; | ||
// } | ||
// | ||
// @PostPersist | ||
// @PostUpdate | ||
// public void updateTopRating(Advertisement advertisement) { | ||
// advertisementService.updateTopRating(advertisement); | ||
// } | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...in/java/org/petmarket/advertisements/advertisement/service/AdvertisementServiceProxy.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,16 @@ | ||
package org.petmarket.advertisements.advertisement.service; | ||
|
||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Aspect | ||
@Component | ||
public class AdvertisementServiceProxy { | ||
private final AdvertisementService advertisementService; | ||
|
||
@Autowired | ||
public AdvertisementServiceProxy(AdvertisementService advertisementService) { | ||
this.advertisementService = advertisementService; | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/org/petmarket/review/listener/ReviewListener.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 org.petmarket.review.listener; | ||
|
||
import jakarta.persistence.*; | ||
import org.petmarket.advertisements.advertisement.service.AdvertisementService; | ||
import org.petmarket.review.entity.Review; | ||
import org.springframework.context.annotation.Lazy; | ||
|
||
public class ReviewListener { | ||
private final AdvertisementService advertisementService; | ||
|
||
public ReviewListener(@Lazy AdvertisementService advertisementService) { | ||
this.advertisementService = advertisementService; | ||
} | ||
|
||
@PostPersist | ||
@PostUpdate | ||
@PostRemove | ||
public void updateRating(Review review) { | ||
advertisementService.updateRating(review); | ||
advertisementService.updateTopRating(review.getAdvertisement()); | ||
} | ||
} |
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
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
2 changes: 2 additions & 0 deletions
2
src/main/resources/db/migration/V2024.06.27.001__add_adv_top_rating.sql
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,2 @@ | ||
ALTER TABLE advertisements | ||
ADD COLUMN top_rating INTEGER NOT NULL DEFAULT 0; |
3 changes: 3 additions & 0 deletions
3
src/main/resources/db/migration/V2024.06.30.001__drop_review_triggers.sql
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,3 @@ | ||
DROP TRIGGER IF EXISTS `review_trigger_insert`; | ||
DROP TRIGGER IF EXISTS `review_trigger_delete`; | ||
DROP TRIGGER IF EXISTS `review_trigger_update`; |