Commit ccd97c03 authored by lemin's avatar lemin

ccc

parent 49c6287c
package com.showcase.synapse.common.command;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.axonframework.modelling.command.TargetAggregateIdentifier;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@AllArgsConstructor
@Getter
public class CancleSalesCommand implements Serializable{
private static final long serialVersionUID = 1L;
@TargetAggregateIdentifier
private final String salesOrderId;
private final Integer orderQuantity;
}
package com.showcase.synapse.wms.command; package com.showcase.synapse.common.command;
import java.io.Serializable;
import org.axonframework.modelling.command.TargetAggregateIdentifier; import org.axonframework.modelling.command.TargetAggregateIdentifier;
...@@ -7,9 +9,13 @@ import lombok.Getter; ...@@ -7,9 +9,13 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public class ChangeInventoryQuantityCommand { public class ChangeInventoryQuantityCommand implements Serializable{
private static final long serialVersionUID = 1L;
@TargetAggregateIdentifier @TargetAggregateIdentifier
private String productId; private String whId;
private int quantity; private String salesOrderId;
private String orderComment;
private Integer orderQuantity;
} }
package com.showcase.synapse.wms.command; package com.showcase.synapse.common.command;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import org.axonframework.modelling.command.TargetAggregateIdentifier; import org.axonframework.modelling.command.TargetAggregateIdentifier;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public class CreateInventoryCommand { public class CreateInventoryCommand implements Serializable{
private static final long serialVersionUID = 1L;
@TargetAggregateIdentifier @TargetAggregateIdentifier
private final String whId; private final String whId;
......
package com.showcase.synapse.wms;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.thoughtworks.xstream.XStream;
@Configuration
public class AxonConfig {
@Bean
public XStream xStream() {
XStream xStream = new XStream();
xStream.allowTypesByWildcard(new String[] {
"com.showcase.synapse.**"
});
return xStream;
}
}
\ No newline at end of file
...@@ -2,8 +2,10 @@ package com.showcase.synapse.wms; ...@@ -2,8 +2,10 @@ package com.showcase.synapse.wms;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@SpringBootApplication @SpringBootApplication
@Import({ AxonConfig.class })
public class MsaWMSApplication { public class MsaWMSApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -8,8 +8,8 @@ import org.axonframework.eventsourcing.EventSourcingHandler; ...@@ -8,8 +8,8 @@ import org.axonframework.eventsourcing.EventSourcingHandler;
import org.axonframework.modelling.command.AggregateIdentifier; import org.axonframework.modelling.command.AggregateIdentifier;
import org.axonframework.spring.stereotype.Aggregate; import org.axonframework.spring.stereotype.Aggregate;
import com.showcase.synapse.wms.command.ChangeInventoryQuantityCommand; import com.showcase.synapse.common.command.ChangeInventoryQuantityCommand;
import com.showcase.synapse.wms.command.CreateInventoryCommand; import com.showcase.synapse.common.command.CreateInventoryCommand;
import com.showcase.synapse.wms.event.InventoryCreatedEvent; import com.showcase.synapse.wms.event.InventoryCreatedEvent;
import com.showcase.synapse.wms.event.InventoryQuantityChangedEvent; import com.showcase.synapse.wms.event.InventoryQuantityChangedEvent;
import com.showcase.synapse.wms.saga.InventorySaga; import com.showcase.synapse.wms.saga.InventorySaga;
...@@ -42,9 +42,9 @@ public class WMSAggregate { ...@@ -42,9 +42,9 @@ public class WMSAggregate {
@CommandHandler @CommandHandler
public void changeInventoryQuantity(ChangeInventoryQuantityCommand command) { public void changeInventoryQuantity(ChangeInventoryQuantityCommand command) {
log.info("[@CommandHandler ProductchangeQuantity]"); log.info("[@CommandHandler changeInventoryQuantity ChangeInventoryQuantityCommand]");
if(this.quantiy < command.getQuantity()) throw new IllegalArgumentException("tfy "); if(this.quantiy < command.getOrderQuantity()) throw new IllegalArgumentException("tfy ");
apply(new InventoryQuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity())); apply(new InventoryQuantityChangedEvent(command.getWhId(), this.quantiy - command.getOrderQuantity()));
} }
@EventSourcingHandler @EventSourcingHandler
......
...@@ -6,6 +6,6 @@ import lombok.Getter; ...@@ -6,6 +6,6 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public class InventoryQuantityChangedEvent { public class InventoryQuantityChangedEvent {
private String productId; private String whId;
private int quantity; private int quantity;
} }
...@@ -45,9 +45,9 @@ public class InventoryEventHandler { ...@@ -45,9 +45,9 @@ public class InventoryEventHandler {
protected void changeInventoryQuantity(InventoryQuantityChangedEvent inventoryQuantityChangedEvent) { protected void changeInventoryQuantity(InventoryQuantityChangedEvent inventoryQuantityChangedEvent) {
log.info("InventoryQuantityChangedEvent 이벤트 받음?"); log.info("InventoryQuantityChangedEvent 이벤트 받음?");
log.info("[InventoryQuantityChangedEvent]"); log.info("[InventoryQuantityChangedEvent]");
InventoryEntity inventoryEntity = inventoryRepository.findById(inventoryQuantityChangedEvent.getProductId()).get(); InventoryEntity inventoryEntity = inventoryRepository.findById(inventoryQuantityChangedEvent.getWhId()).get();
// log.info("[{}] quantity:{}", productEntity.getName(), productEntity.getQuentity()); log.info("[{}] quantity:{}", inventoryQuantityChangedEvent.getWhId(), inventoryQuantityChangedEvent.getQuantity());
// productEntity.setQuentity(productQuantityChangedEvent.getQuantity()); inventoryEntity.setQuantity(inventoryQuantityChangedEvent.getQuantity());
inventoryRepository.save(inventoryEntity); inventoryRepository.save(inventoryEntity);
} }
......
...@@ -9,7 +9,7 @@ import org.axonframework.messaging.responsetypes.ResponseTypes; ...@@ -9,7 +9,7 @@ import org.axonframework.messaging.responsetypes.ResponseTypes;
import org.axonframework.queryhandling.QueryGateway; import org.axonframework.queryhandling.QueryGateway;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.showcase.synapse.wms.command.CreateInventoryCommand; import com.showcase.synapse.common.command.CreateInventoryCommand;
import com.showcase.synapse.wms.entity.InventoryEntity; import com.showcase.synapse.wms.entity.InventoryEntity;
import com.showcase.synapse.wms.query.GetInventoryQuery; import com.showcase.synapse.wms.query.GetInventoryQuery;
......
#axon:
# serializer:
# general: jackson
# events: jackson
# messages: jackson
axon: axon:
serializer: serializer:
general: xstream general: xstream
......
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