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