Skip to content

Commit c831966

Browse files
Merge pull request #23 from TajudeenBusari/add-more-event-producer-to-Order-Service
more events(delete and update) added to the order service
2 parents 4e0c03f + c655e4d commit c831966

File tree

43 files changed

+920
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+920
-138
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ yarn-error.log*
3838
#ignore coverage folder
3939
coverage/
4040
#ignore .next folder
41-
.next/
42-
cls
41+
.next/

README.md

-36.1 KB
Loading

common-utils/src/main/java/com/tjtechy/CreateInventoryDto.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import jakarta.validation.constraints.FutureOrPresent;
1010
import jakarta.validation.constraints.NotNull;
11+
import jakarta.validation.constraints.PastOrPresent;
1112
import jakarta.validation.constraints.Positive;
1213

1314
import java.time.LocalDate;
@@ -23,15 +24,21 @@ public record CreateInventoryDto(
2324
@NotNull(message = "Product reserve available is required")
2425
Integer reservedQuantity, //by default, it is 1
2526

27+
@PastOrPresent(message = "Manufactured date must be a past or present date")
28+
@NotNull(message = "Manufactured date is required")
29+
LocalDate manufacturedDate,
30+
2631
/**
27-
* //Todo: add the product expiry date to this record because it should
32+
* //Done: add the product expiry date to this record because it should
2833
* not be possible to add inventory for an expired product
2934
* It should not be possible to add inventory for an expired product.
3035
*/
3136
@NotNull(message = "Expiry date is required")
3237
@FutureOrPresent(message = "Expiry date must be a future or present date")
3338
LocalDate expiryDate
3439

40+
41+
3542
) {
3643

3744

common-utils/src/main/java/com/tjtechy/ProductDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public record ProductDto(
2222
String productDescription,
2323
Integer productQuantity,
2424
Integer availableStock,
25+
LocalDate manufacturedDate,
2526
LocalDate expiryDate,
2627
BigDecimal productPrice
2728

common-utils/src/main/java/com/tjtechy/client/InventoryServiceClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void createInventoryForProductAsync(CreateInventoryDto createInventoryDto
107107

108108
/**
109109
* Restores inventory for a given product by the specified quantity.
110-
* This method is typically called when an order is cancelled, returned, or updated,
110+
* This method is typically called when an order is canceled, returned, or updated,
111111
* and the inventory needs to be restored.
112112
* @param productId the UUID of the product
113113
* @param quantityToRestore the quantity to restore to inventory

notification-service/src/main/java/com/tjtechy/notification_service/listener/OrderEventListener.java renamed to common-utils/src/main/java/com/tjtechy/events/orderEvent/ActionBy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* @Version = 1.0
66
* This file is part of EcommerceMicroservices module of the Ecommerce Microservices project.
77
*/
8+
package com.tjtechy.events.orderEvent;
89

9-
package com.tjtechy.notification_service.listener;
10-
11-
public class OrderEventListener {
10+
public enum ActionBy {
11+
USER,
12+
ADMIN,
13+
SYSTEM
1214
}

common-utils/src/main/java/com/tjtechy/events/orderEvent/OrderCancelledEvent.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@
88

99
package com.tjtechy.events.orderEvent;
1010

11+
import jakarta.persistence.EnumType;
12+
import jakarta.persistence.Enumerated;
13+
14+
import java.time.LocalDate;
15+
1116
public record OrderCancelledEvent(
1217
Long orderId,
1318
String customerEmail,
1419
String customDeviceToken,
15-
String customerPhoneNumber
20+
String customerPhoneNumber,
21+
LocalDate cancellationDate,
22+
@Enumerated(EnumType.STRING)
23+
ActionBy actionBy,
24+
@Enumerated(EnumType.STRING)
25+
Reason reason
1626
) {
1727
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright © 2025
3+
*
4+
* @Author = TJTechy (Tajudeen Busari)
5+
* @Version = 1.0
6+
* This file is part of EcommerceMicroservices module of the Ecommerce Microservices project.
7+
*/
8+
9+
package com.tjtechy.events.orderEvent;
10+
11+
import jakarta.persistence.EnumType;
12+
import jakarta.persistence.Enumerated;
13+
14+
import java.time.LocalDate;
15+
16+
public record OrderDeletedEvent(
17+
Long orderId,
18+
String customerEmail,
19+
String customDeviceToken,
20+
String customerPhoneNumber,
21+
@Enumerated(EnumType.STRING)
22+
Reason reason, /// USER_REQUEST, ADMIN_ACTION, SYSTEM_CLEANUP, FRAUD_DETECTION, OTHER
23+
@Enumerated(EnumType.STRING)
24+
ActionBy deletedBy, /// e.g., "USER", "ADMIN", "SYSTEM"
25+
LocalDate deletionDate
26+
) {
27+
28+
}

common-utils/src/main/java/com/tjtechy/events/orderEvent/OrderPlacedEvent.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@
88

99
package com.tjtechy.events.orderEvent;
1010

11+
import jakarta.persistence.EnumType;
12+
import jakarta.persistence.Enumerated;
13+
14+
import java.time.LocalDate;
15+
1116
public record OrderPlacedEvent(
1217
Long orderId,
1318
String customerEmail,
1419
String customDeviceToken,
15-
String customerPhoneNumber
20+
String customerPhoneNumber,
21+
LocalDate orderDate,
22+
@Enumerated(EnumType.STRING)
23+
ActionBy actionBy,
24+
@Enumerated(EnumType.STRING)
25+
Reason reason
1626
) {
1727
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright © 2025
3+
*
4+
* @Author = TJTechy (Tajudeen Busari)
5+
* @Version = 1.0
6+
* This file is part of EcommerceMicroservices module of the Ecommerce Microservices project.
7+
*/
8+
9+
package com.tjtechy.events.orderEvent;
10+
11+
import jakarta.persistence.EnumType;
12+
import jakarta.persistence.Enumerated;
13+
14+
import java.time.LocalDate;
15+
16+
public record OrderUpdatedEvent(
17+
Long orderId,
18+
String customerEmail,
19+
String customDeviceToken,
20+
String customerPhoneNumber,
21+
@Enumerated(EnumType.STRING)
22+
ActionBy actionBy,
23+
@Enumerated(EnumType.STRING)
24+
Reason reason,
25+
LocalDate updatedDate
26+
) {
27+
28+
}

0 commit comments

Comments
 (0)