Commit 69b7b1a4 authored by lemin's avatar lemin

commit

parent dad95263
......@@ -24,7 +24,7 @@ import static org.axonframework.modelling.command.AggregateLifecycle.apply;
public class WMSAggregate {
@AggregateIdentifier
private String id;
private String whId;
private int quantiy;
......@@ -35,20 +35,20 @@ public class WMSAggregate {
}
@EventSourcingHandler
public void createProduct(InventoryCreatedEvent event) {
this.id = event.getProductId();
public void createInventory(InventoryCreatedEvent event) {
this.whId = event.getWhId();
this.quantiy = event.getQuantity();
}
@CommandHandler
public void changeQuantity(ChangeInventoryQuantityCommand command) {
public void changeInventoryQuantity(ChangeInventoryQuantityCommand command) {
log.info("[@CommandHandler ProductchangeQuantity]");
if(this.quantiy < command.getQuantity()) throw new IllegalArgumentException("tfy ");
apply(new InventoryQuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
}
@EventSourcingHandler
public void changeQuantity(InventoryQuantityChangedEvent event) {
public void changeInventoryQuantity(InventoryQuantityChangedEvent event) {
this.quantiy = event.getQuantity();
}
......
......@@ -11,5 +11,5 @@ public class InventoryCreatedEvent {
private String whId;
private String productId;
private String whName;
private int quantity;
private Integer quantity;
}
......@@ -18,7 +18,7 @@ public class InventoryEventHandler {
private final InventoryRepository inventoryRepository;
@EventHandler
protected void saveProduct(InventoryCreatedEvent inventoryCreatedEvent) {
protected void saveInventory(InventoryCreatedEvent inventoryCreatedEvent) {
log.info("InventoryCreatedEvent 이벤트 받음?");
log.info("InventoryEventHandler > [InventoryCreatedEvent] productCreatedEvent");
......@@ -33,7 +33,7 @@ public class InventoryEventHandler {
}
@EventHandler
protected void changeQuantity(InventoryQuantityChangedEvent inventoryQuantityChangedEvent) {
protected void changeInventoryQuantity(InventoryQuantityChangedEvent inventoryQuantityChangedEvent) {
log.info("InventoryQuantityChangedEvent 이벤트 받음?");
log.info("[InventoryQuantityChangedEvent]");
InventoryEntity inventoryEntity = inventoryRepository.findById(inventoryQuantityChangedEvent.getProductId()).get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment