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 {
...
@@ -25,31 +25,31 @@ public class WMSAggregate {
@AggregateIdentifier
@AggregateIdentifier
private
String
id
;
private
String
id
;
//
private int quantiy;
private
int
quantiy
;
@CommandHandler
@CommandHandler
public
WMSAggregate
(
CreateInventoryCommand
command
)
{
public
WMSAggregate
(
CreateInventoryCommand
command
)
{
log
.
info
(
"[WMSAggregate(CreateInventoryCommand) > apply new InventoryCreatedEvent]"
);
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
@EventSourcingHandler
public
void
createProduct
(
InventoryCreatedEvent
event
)
{
public
void
createProduct
(
InventoryCreatedEvent
event
)
{
this
.
id
=
event
.
getProductId
();
this
.
id
=
event
.
getProductId
();
//
this.quantiy = event.getQuantity();
this
.
quantiy
=
event
.
getQuantity
();
}
}
@CommandHandler
@CommandHandler
public
void
changeQuantity
(
ChangeInventoryQuantityCommand
command
)
{
public
void
changeQuantity
(
ChangeInventoryQuantityCommand
command
)
{
log
.
info
(
"[@CommandHandler ProductchangeQuantity]"
);
log
.
info
(
"[@CommandHandler ProductchangeQuantity]"
);
//
if(this.quantiy < command.getQuantity()) throw new IllegalArgumentException("tfy ");
if
(
this
.
quantiy
<
command
.
getQuantity
())
throw
new
IllegalArgumentException
(
"tfy "
);
//
apply(new InventoryQuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
apply
(
new
InventoryQuantityChangedEvent
(
command
.
getProductId
(),
this
.
quantiy
-
command
.
getQuantity
()));
}
}
@EventSourcingHandler
@EventSourcingHandler
public
void
changeQuantity
(
InventoryQuantityChangedEvent
event
)
{
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;
...
@@ -11,10 +11,9 @@ import java.math.BigDecimal;
public
class
CreateInventoryCommand
{
public
class
CreateInventoryCommand
{
@TargetAggregateIdentifier
@TargetAggregateIdentifier
private
final
String
id
;
private
final
String
whId
;
private
final
String
name
;
private
final
String
productId
;
private
final
String
comment
;
private
final
String
whName
;
private
final
BigDecimal
price
;
private
final
Integer
quantity
;
// private final Integer quantity;
}
}
src/main/java/com/showcase/synapse/wms/controller/WMSController.java
View file @
dad95263
...
@@ -33,12 +33,11 @@ public class WMSController {
...
@@ -33,12 +33,11 @@ public class WMSController {
@PostMapping
(
"/"
)
@PostMapping
(
"/"
)
public
ResponseEntity
<
Map
<
String
,
String
>>
inventoryCreate
(
@RequestBody
InventoryCreateDto
inventoryCreateDto
)
{
public
ResponseEntity
<
Map
<
String
,
String
>>
inventoryCreate
(
@RequestBody
InventoryCreateDto
inventoryCreateDto
)
{
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
getName
(),
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
getProductId
(),
inventoryCreateDto
.
getWhName
(),
inventoryCreateDto
.
getComment
(),
inventoryCreateDto
.
getQuantity
());
BigDecimal
.
valueOf
(
inventoryCreateDto
.
getPrice
()));
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"inventoryId"
,
inventoryId
);
m
.
put
(
"inventoryId"
,
inventoryId
);
m
.
put
(
"
productName"
,
inventoryCreateDto
.
get
Name
());
m
.
put
(
"
whName"
,
inventoryCreateDto
.
getWh
Name
());
return
ResponseEntity
.
ok
(
m
);
return
ResponseEntity
.
ok
(
m
);
}
}
...
...
src/main/java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
View file @
dad95263
...
@@ -6,8 +6,9 @@ import lombok.Setter;
...
@@ -6,8 +6,9 @@ import lombok.Setter;
@Getter
@Getter
@Setter
@Setter
public
class
InventoryCreateDto
{
public
class
InventoryCreateDto
{
private
String
name
;
// private String whId;
private
String
comment
;
private
String
productId
;
private
int
price
;
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;
...
@@ -16,8 +16,8 @@ import java.math.BigDecimal;
@NoArgsConstructor
@NoArgsConstructor
public
class
InventoryEntity
{
public
class
InventoryEntity
{
@Id
@Id
private
String
i
d
;
private
String
whI
d
;
private
String
name
;
private
String
productId
;
private
String
comment
;
private
String
whName
;
private
BigDecimal
price
;
private
int
quantity
;
}
}
src/main/java/com/showcase/synapse/wms/event/InventoryCreatedEvent.java
View file @
dad95263
...
@@ -8,8 +8,8 @@ import java.math.BigDecimal;
...
@@ -8,8 +8,8 @@ import java.math.BigDecimal;
@AllArgsConstructor
@AllArgsConstructor
@Getter
@Getter
public
class
InventoryCreatedEvent
{
public
class
InventoryCreatedEvent
{
private
String
whId
;
private
String
productId
;
private
String
productId
;
private
String
name
;
private
String
whName
;
private
String
comment
;
private
int
quantity
;
private
BigDecimal
price
;
}
}
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;
...
@@ -15,31 +15,31 @@ import com.showcase.synapse.wms.repository.InventoryRepository;
@Slf4j
@Slf4j
public
class
InventoryEventHandler
{
public
class
InventoryEventHandler
{
private
final
InventoryRepository
product
Repository
;
private
final
InventoryRepository
inventory
Repository
;
@EventHandler
@EventHandler
protected
void
saveProduct
(
InventoryCreatedEvent
product
CreatedEvent
)
{
protected
void
saveProduct
(
InventoryCreatedEvent
inventory
CreatedEvent
)
{
log
.
info
(
"InventoryCreatedEvent 이벤트 받음?"
);
log
.
info
(
"InventoryCreatedEvent 이벤트 받음?"
);
log
.
info
(
"InventoryEventHandler > [InventoryCreatedEvent] productCreatedEvent"
);
log
.
info
(
"InventoryEventHandler > [InventoryCreatedEvent] productCreatedEvent"
);
InventoryEntity
product
Entity
=
new
InventoryEntity
();
InventoryEntity
inventory
Entity
=
new
InventoryEntity
();
productEntity
.
setId
(
product
CreatedEvent
.
getProductId
());
inventoryEntity
.
setProductId
(
inventory
CreatedEvent
.
getProductId
());
productEntity
.
setName
(
productCreatedEvent
.
getName
());
inventoryEntity
.
setWhId
(
inventoryCreatedEvent
.
getWhId
());
productEntity
.
setComment
(
productCreatedEvent
.
getComment
());
inventoryEntity
.
setWhName
(
inventoryCreatedEvent
.
getWhName
());
productEntity
.
setPrice
(
productCreatedEvent
.
getPrice
());
inventoryEntity
.
setQuantity
(
inventoryCreatedEvent
.
getQuantity
());
productRepository
.
save
(
product
Entity
);
inventoryRepository
.
save
(
inventory
Entity
);
}
}
@EventHandler
@EventHandler
protected
void
changeQuantity
(
InventoryQuantityChangedEvent
product
QuantityChangedEvent
)
{
protected
void
changeQuantity
(
InventoryQuantityChangedEvent
inventory
QuantityChangedEvent
)
{
log
.
info
(
"InventoryQuantityChangedEvent 이벤트 받음?"
);
log
.
info
(
"InventoryQuantityChangedEvent 이벤트 받음?"
);
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());
// log.info("[{}] quantity:{}", productEntity.getName(), productEntity.getQuentity());
// productEntity.setQuentity(productQuantityChangedEvent.getQuantity());
// 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;
...
@@ -17,12 +17,12 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Slf4j
public
class
InventoryQueryHandler
{
public
class
InventoryQueryHandler
{
private
final
InventoryRepository
product
Repository
;
private
final
InventoryRepository
inventory
Repository
;
@QueryHandler
@QueryHandler
protected
List
<
InventoryEntity
>
on
(
GetInventoryQuery
query
)
{
protected
List
<
InventoryEntity
>
on
(
GetInventoryQuery
query
)
{
log
.
info
(
"---product 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
;
package
com
.
showcase
.
synapse
.
wms
.
service
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
...
@@ -28,16 +27,16 @@ public class InventoryService {
...
@@ -28,16 +27,16 @@ public class InventoryService {
this
.
queryGateway
=
queryGateway
;
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"
);
log
.
info
(
"[@Service createProduct] new CreateInventoryCommand"
);
// command생성
// command생성
CreateInventoryCommand
create
Product
Command
=
new
CreateInventoryCommand
(
CreateInventoryCommand
create
Inventory
Command
=
new
CreateInventoryCommand
(
UUID
.
randomUUID
().
toString
(),
name
,
comment
,
price
UUID
.
randomUUID
().
toString
(),
productId
,
whName
,
quantity
);
);
System
.
out
.
println
(
"test"
);
// 여기
// 여기
// 생성한 command전송(비동기)
// 생성한 command전송(비동기)
String
returnValue
=
commandGateway
.
sendAndWait
(
createProductCommand
);
log
.
info
(
"[command전송] 비동기"
);
String
returnValue
=
commandGateway
.
sendAndWait
(
createInventoryCommand
);
System
.
out
.
printf
(
"returnValue: %s \n"
,
returnValue
);
System
.
out
.
printf
(
"returnValue: %s \n"
,
returnValue
);
return
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