Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.showcase.synapse.wms
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com.showcase.synapse
com.showcase.synapse.wms
Commits
dad95263
Commit
dad95263
authored
Sep 12, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
b7e54815
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
44 deletions
+42
-44
WMSAggregate.java
...java/com/showcase/synapse/wms/aggregate/WMSAggregate.java
+6
-6
CreateInventoryCommand.java
.../showcase/synapse/wms/command/CreateInventoryCommand.java
+4
-5
WMSController.java
...va/com/showcase/synapse/wms/controller/WMSController.java
+3
-4
InventoryCreateDto.java
...java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
+4
-3
InventoryEntity.java
...java/com/showcase/synapse/wms/entity/InventoryEntity.java
+4
-4
InventoryCreatedEvent.java
...com/showcase/synapse/wms/event/InventoryCreatedEvent.java
+3
-3
InventoryEventHandler.java
...case/synapse/wms/event/handler/InventoryEventHandler.java
+11
-11
InventoryQueryHandler.java
...case/synapse/wms/query/handler/InventoryQueryHandler.java
+2
-2
InventoryService.java
...va/com/showcase/synapse/wms/service/InventoryService.java
+5
-6
No files found.
src/main/java/com/showcase/synapse/wms/aggregate/WMSAggregate.java
View file @
dad95263
...
...
@@ -25,31 +25,31 @@ public class WMSAggregate {
@AggregateIdentifier
private
String
id
;
//
private int quantiy;
private
int
quantiy
;
@CommandHandler
public
WMSAggregate
(
CreateInventoryCommand
command
)
{
log
.
info
(
"[WMSAggregate(CreateInventoryCommand) > apply new InventoryCreatedEvent]"
);
apply
(
new
InventoryCreatedEvent
(
command
.
get
Id
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()));
apply
(
new
InventoryCreatedEvent
(
command
.
get
WhId
(),
command
.
getProductId
(),
command
.
getWhName
(),
command
.
getQuantity
()));
}
@EventSourcingHandler
public
void
createProduct
(
InventoryCreatedEvent
event
)
{
this
.
id
=
event
.
getProductId
();
//
this.quantiy = event.getQuantity();
this
.
quantiy
=
event
.
getQuantity
();
}
@CommandHandler
public
void
changeQuantity
(
ChangeInventoryQuantityCommand
command
)
{
log
.
info
(
"[@CommandHandler ProductchangeQuantity]"
);
//
if(this.quantiy < command.getQuantity()) throw new IllegalArgumentException("tfy ");
//
apply(new InventoryQuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
if
(
this
.
quantiy
<
command
.
getQuantity
())
throw
new
IllegalArgumentException
(
"tfy "
);
apply
(
new
InventoryQuantityChangedEvent
(
command
.
getProductId
(),
this
.
quantiy
-
command
.
getQuantity
()));
}
@EventSourcingHandler
public
void
changeQuantity
(
InventoryQuantityChangedEvent
event
)
{
//
this.quantiy = event.getQuantity();
this
.
quantiy
=
event
.
getQuantity
();
}
}
src/main/java/com/showcase/synapse/wms/command/CreateInventoryCommand.java
View file @
dad95263
...
...
@@ -11,10 +11,9 @@ import java.math.BigDecimal;
public
class
CreateInventoryCommand
{
@TargetAggregateIdentifier
private
final
String
id
;
private
final
String
name
;
private
final
String
comment
;
private
final
BigDecimal
price
;
// private final Integer quantity;
private
final
String
whId
;
private
final
String
productId
;
private
final
String
whName
;
private
final
Integer
quantity
;
}
src/main/java/com/showcase/synapse/wms/controller/WMSController.java
View file @
dad95263
...
...
@@ -33,12 +33,11 @@ public class WMSController {
@PostMapping
(
"/"
)
public
ResponseEntity
<
Map
<
String
,
String
>>
inventoryCreate
(
@RequestBody
InventoryCreateDto
inventoryCreateDto
)
{
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
getName
(),
inventoryCreateDto
.
getComment
(),
BigDecimal
.
valueOf
(
inventoryCreateDto
.
getPrice
()));
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
getProductId
(),
inventoryCreateDto
.
getWhName
(),
inventoryCreateDto
.
getQuantity
());
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"inventoryId"
,
inventoryId
);
m
.
put
(
"
productName"
,
inventoryCreateDto
.
get
Name
());
m
.
put
(
"
whName"
,
inventoryCreateDto
.
getWh
Name
());
return
ResponseEntity
.
ok
(
m
);
}
...
...
src/main/java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
View file @
dad95263
...
...
@@ -6,8 +6,9 @@ import lombok.Setter;
@Getter
@Setter
public
class
InventoryCreateDto
{
private
String
name
;
private
String
comment
;
private
int
price
;
// private String whId;
private
String
productId
;
private
String
whName
;
private
Integer
quantity
;
}
src/main/java/com/showcase/synapse/wms/entity/InventoryEntity.java
View file @
dad95263
...
...
@@ -16,8 +16,8 @@ import java.math.BigDecimal;
@NoArgsConstructor
public
class
InventoryEntity
{
@Id
private
String
i
d
;
private
String
name
;
private
String
comment
;
private
BigDecimal
price
;
private
String
whI
d
;
private
String
productId
;
private
String
whName
;
private
int
quantity
;
}
src/main/java/com/showcase/synapse/wms/event/InventoryCreatedEvent.java
View file @
dad95263
...
...
@@ -8,8 +8,8 @@ import java.math.BigDecimal;
@AllArgsConstructor
@Getter
public
class
InventoryCreatedEvent
{
private
String
whId
;
private
String
productId
;
private
String
name
;
private
String
comment
;
private
BigDecimal
price
;
private
String
whName
;
private
int
quantity
;
}
src/main/java/com/showcase/synapse/wms/event/handler/InventoryEventHandler.java
View file @
dad95263
...
...
@@ -15,31 +15,31 @@ import com.showcase.synapse.wms.repository.InventoryRepository;
@Slf4j
public
class
InventoryEventHandler
{
private
final
InventoryRepository
product
Repository
;
private
final
InventoryRepository
inventory
Repository
;
@EventHandler
protected
void
saveProduct
(
InventoryCreatedEvent
product
CreatedEvent
)
{
protected
void
saveProduct
(
InventoryCreatedEvent
inventory
CreatedEvent
)
{
log
.
info
(
"InventoryCreatedEvent 이벤트 받음?"
);
log
.
info
(
"InventoryEventHandler > [InventoryCreatedEvent] productCreatedEvent"
);
InventoryEntity
product
Entity
=
new
InventoryEntity
();
productEntity
.
setId
(
product
CreatedEvent
.
getProductId
());
productEntity
.
setName
(
productCreatedEvent
.
getName
());
productEntity
.
setComment
(
productCreatedEvent
.
getComment
());
productEntity
.
setPrice
(
productCreatedEvent
.
getPrice
());
InventoryEntity
inventory
Entity
=
new
InventoryEntity
();
inventoryEntity
.
setProductId
(
inventory
CreatedEvent
.
getProductId
());
inventoryEntity
.
setWhId
(
inventoryCreatedEvent
.
getWhId
());
inventoryEntity
.
setWhName
(
inventoryCreatedEvent
.
getWhName
());
inventoryEntity
.
setQuantity
(
inventoryCreatedEvent
.
getQuantity
());
productRepository
.
save
(
product
Entity
);
inventoryRepository
.
save
(
inventory
Entity
);
}
@EventHandler
protected
void
changeQuantity
(
InventoryQuantityChangedEvent
product
QuantityChangedEvent
)
{
protected
void
changeQuantity
(
InventoryQuantityChangedEvent
inventory
QuantityChangedEvent
)
{
log
.
info
(
"InventoryQuantityChangedEvent 이벤트 받음?"
);
log
.
info
(
"[InventoryQuantityChangedEvent]"
);
InventoryEntity
productEntity
=
productRepository
.
findById
(
product
QuantityChangedEvent
.
getProductId
()).
get
();
InventoryEntity
inventoryEntity
=
inventoryRepository
.
findById
(
inventory
QuantityChangedEvent
.
getProductId
()).
get
();
// log.info("[{}] quantity:{}", productEntity.getName(), productEntity.getQuentity());
// productEntity.setQuentity(productQuantityChangedEvent.getQuantity());
productRepository
.
save
(
product
Entity
);
inventoryRepository
.
save
(
inventory
Entity
);
}
}
src/main/java/com/showcase/synapse/wms/query/handler/InventoryQueryHandler.java
View file @
dad95263
...
...
@@ -17,12 +17,12 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public
class
InventoryQueryHandler
{
private
final
InventoryRepository
product
Repository
;
private
final
InventoryRepository
inventory
Repository
;
@QueryHandler
protected
List
<
InventoryEntity
>
on
(
GetInventoryQuery
query
)
{
log
.
info
(
"---product query---"
);
return
product
Repository
.
findAll
();
return
inventory
Repository
.
findAll
();
}
}
src/main/java/com/showcase/synapse/wms/service/InventoryService.java
View file @
dad95263
package
com
.
showcase
.
synapse
.
wms
.
service
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.concurrent.ExecutionException
;
...
...
@@ -28,16 +27,16 @@ public class InventoryService {
this
.
queryGateway
=
queryGateway
;
}
public
String
createInventory
(
String
name
,
String
comment
,
BigDecimal
price
)
{
public
String
createInventory
(
String
productId
,
String
whName
,
int
quantity
)
{
log
.
info
(
"[@Service createProduct] new CreateInventoryCommand"
);
// command생성
CreateInventoryCommand
create
Product
Command
=
new
CreateInventoryCommand
(
UUID
.
randomUUID
().
toString
(),
name
,
comment
,
price
CreateInventoryCommand
create
Inventory
Command
=
new
CreateInventoryCommand
(
UUID
.
randomUUID
().
toString
(),
productId
,
whName
,
quantity
);
System
.
out
.
println
(
"test"
);
// 여기
// 생성한 command전송(비동기)
String
returnValue
=
commandGateway
.
sendAndWait
(
createProductCommand
);
log
.
info
(
"[command전송] 비동기"
);
String
returnValue
=
commandGateway
.
sendAndWait
(
createInventoryCommand
);
System
.
out
.
printf
(
"returnValue: %s \n"
,
returnValue
);
return
returnValue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment