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
c0eed78e
Commit
c0eed78e
authored
Sep 11, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wms commit
parent
cb3dcae4
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
101 additions
and
48 deletions
+101
-48
WMSAggregate.java
...java/com/showcase/synapse/wms/aggregate/WMSAggregate.java
+13
-13
ChangeInventoryQuantityCommand.java
...e/synapse/wms/command/ChangeInventoryQuantityCommand.java
+1
-1
CreateInventoryCommand.java
.../showcase/synapse/wms/command/CreateInventoryCommand.java
+1
-1
WMSController.java
...va/com/showcase/synapse/wms/controller/WMSController.java
+9
-9
InventoryCreateDto.java
...java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
+1
-1
InventoryEntity.java
...java/com/showcase/synapse/wms/entity/InventoryEntity.java
+1
-1
InventoryStatus.java
.../java/com/showcase/synapse/wms/enums/InventoryStatus.java
+1
-1
InventoryCreatedEvent.java
...com/showcase/synapse/wms/event/InventoryCreatedEvent.java
+1
-1
InventoryQuantityChangedEvent.java
...case/synapse/wms/event/InventoryQuantityChangedEvent.java
+1
-1
InventoryEventHandler.java
...case/synapse/wms/event/handler/InventoryEventHandler.java
+45
-0
GetInventoryQuery.java
...ava/com/showcase/synapse/wms/query/GetInventoryQuery.java
+1
-1
InventoryQueryHandler.java
...case/synapse/wms/query/handler/InventoryQueryHandler.java
+6
-6
InventoryRepository.java
.../showcase/synapse/wms/repository/InventoryRepository.java
+8
-0
InventorySaga.java
...ain/java/com/showcase/synapse/wms/saga/InventorySaga.java
+1
-1
InventoryService.java
...va/com/showcase/synapse/wms/service/InventoryService.java
+10
-10
application.yml
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/com/showcase/synapse/wms/aggregate/
Product
Aggregate.java
→
src/main/java/com/showcase/synapse/wms/aggregate/
WMS
Aggregate.java
View file @
c0eed78e
...
...
@@ -8,11 +8,11 @@ import org.axonframework.eventsourcing.EventSourcingHandler;
import
org.axonframework.modelling.command.AggregateIdentifier
;
import
org.axonframework.spring.stereotype.Aggregate
;
import
com.showcase.synapse.wms.command.ChangeQuantityCommand
;
import
com.showcase.synapse.wms.command.Create
Product
Command
;
import
com.showcase.synapse.wms.event.
Product
CreatedEvent
;
import
com.showcase.synapse.wms.event.
Product
QuantityChangedEvent
;
import
com.showcase.synapse.wms.saga.
Product
Saga
;
import
com.showcase.synapse.wms.command.Change
Inventory
QuantityCommand
;
import
com.showcase.synapse.wms.command.Create
Inventory
Command
;
import
com.showcase.synapse.wms.event.
Inventory
CreatedEvent
;
import
com.showcase.synapse.wms.event.
Inventory
QuantityChangedEvent
;
import
com.showcase.synapse.wms.saga.
Inventory
Saga
;
import
java.math.BigDecimal
;
...
...
@@ -21,7 +21,7 @@ import static org.axonframework.modelling.command.AggregateLifecycle.apply;
@Aggregate
@NoArgsConstructor
@Slf4j
public
class
Product
Aggregate
{
public
class
WMS
Aggregate
{
@AggregateIdentifier
private
String
id
;
...
...
@@ -29,26 +29,26 @@ public class ProductAggregate {
@CommandHandler
public
ProductAggregate
(
CreateProduct
Command
command
)
{
log
.
info
(
"[
ProductAggregate(CreateProductCommand) > apply new Product
CreatedEvent]"
);
apply
(
new
Product
CreatedEvent
(
command
.
getId
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()));
public
WMSAggregate
(
CreateInventory
Command
command
)
{
log
.
info
(
"[
WMSAggregate(CreateInventoryCommand) > apply new Inventory
CreatedEvent]"
);
apply
(
new
Inventory
CreatedEvent
(
command
.
getId
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()));
}
@EventSourcingHandler
public
void
createProduct
(
Product
CreatedEvent
event
)
{
public
void
createProduct
(
Inventory
CreatedEvent
event
)
{
this
.
id
=
event
.
getProductId
();
// this.quantiy = event.getQuantity();
}
@CommandHandler
public
void
changeQuantity
(
ChangeQuantityCommand
command
)
{
public
void
changeQuantity
(
Change
Inventory
QuantityCommand
command
)
{
log
.
info
(
"[@CommandHandler ProductchangeQuantity]"
);
// if(this.quantiy < command.getQuantity()) throw new IllegalArgumentException("tfy ");
// apply(new
Product
QuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
// apply(new
Inventory
QuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
}
@EventSourcingHandler
public
void
changeQuantity
(
Product
QuantityChangedEvent
event
)
{
public
void
changeQuantity
(
Inventory
QuantityChangedEvent
event
)
{
// this.quantiy = event.getQuantity();
}
...
...
src/main/java/com/showcase/synapse/wms/command/ChangeQuantityCommand.java
→
src/main/java/com/showcase/synapse/wms/command/Change
Inventory
QuantityCommand.java
View file @
c0eed78e
...
...
@@ -7,7 +7,7 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
class
ChangeQuantityCommand
{
public
class
Change
Inventory
QuantityCommand
{
@TargetAggregateIdentifier
private
String
productId
;
...
...
src/main/java/com/showcase/synapse/wms/command/Create
Product
Command.java
→
src/main/java/com/showcase/synapse/wms/command/Create
Inventory
Command.java
View file @
c0eed78e
...
...
@@ -8,7 +8,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@Getter
public
class
Create
Product
Command
{
public
class
Create
Inventory
Command
{
@TargetAggregateIdentifier
private
final
String
id
;
...
...
src/main/java/com/showcase/synapse/wms/controller/
Product
Controller.java
→
src/main/java/com/showcase/synapse/wms/controller/
WMS
Controller.java
View file @
c0eed78e
...
...
@@ -3,9 +3,9 @@ package com.showcase.synapse.wms.controller;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
com.showcase.synapse.wms.dto.
Product
CreateDto
;
import
com.showcase.synapse.wms.entity.
Product
Entity
;
import
com.showcase.synapse.wms.service.
Product
Service
;
import
com.showcase.synapse.wms.dto.
Inventory
CreateDto
;
import
com.showcase.synapse.wms.entity.
Inventory
Entity
;
import
com.showcase.synapse.wms.service.
Inventory
Service
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
...
...
@@ -16,23 +16,23 @@ import java.util.concurrent.ExecutionException;
@RestController
@RequestMapping
(
"/api/msa/product"
)
@CrossOrigin
(
origins
=
"*"
)
public
class
Product
Controller
{
public
class
WMS
Controller
{
final
Product
Service
productService
;
final
Inventory
Service
productService
;
public
ProductController
(
Product
Service
productService
)
{
public
WMSController
(
Inventory
Service
productService
)
{
this
.
productService
=
productService
;
}
@GetMapping
(
"/"
)
public
ResponseEntity
<
List
<
Product
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
Product
Entity
>
productEntities
=
productService
.
getProducts
();
public
ResponseEntity
<
List
<
Inventory
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
Inventory
Entity
>
productEntities
=
productService
.
getProducts
();
return
ResponseEntity
.
ok
(
productEntities
);
}
@PostMapping
(
"/"
)
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
Product
CreateDto
productCreateDto
)
{
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
Inventory
CreateDto
productCreateDto
)
{
String
productId
=
productService
.
createProduct
(
productCreateDto
.
getName
(),
productCreateDto
.
getComment
(),
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()));
...
...
src/main/java/com/showcase/synapse/wms/dto/
Product
CreateDto.java
→
src/main/java/com/showcase/synapse/wms/dto/
Inventory
CreateDto.java
View file @
c0eed78e
...
...
@@ -5,7 +5,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
Product
CreateDto
{
public
class
Inventory
CreateDto
{
private
String
name
;
private
String
comment
;
private
int
price
;
...
...
src/main/java/com/showcase/synapse/wms/entity/
Product
Entity.java
→
src/main/java/com/showcase/synapse/wms/entity/
Inventory
Entity.java
View file @
c0eed78e
...
...
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
Product
Entity
{
public
class
Inventory
Entity
{
@Id
private
String
id
;
private
String
name
;
...
...
src/main/java/com/showcase/synapse/wms/enums/
Order
Status.java
→
src/main/java/com/showcase/synapse/wms/enums/
Inventory
Status.java
View file @
c0eed78e
package
com
.
showcase
.
synapse
.
wms
.
enums
;
public
enum
Order
Status
{
public
enum
Inventory
Status
{
CREATED
,
CANCELED
}
src/main/java/com/showcase/synapse/wms/event/
Product
CreatedEvent.java
→
src/main/java/com/showcase/synapse/wms/event/
Inventory
CreatedEvent.java
View file @
c0eed78e
...
...
@@ -7,7 +7,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@Getter
public
class
Product
CreatedEvent
{
public
class
Inventory
CreatedEvent
{
private
String
productId
;
private
String
name
;
private
String
comment
;
...
...
src/main/java/com/showcase/synapse/wms/event/
Product
QuantityChangedEvent.java
→
src/main/java/com/showcase/synapse/wms/event/
Inventory
QuantityChangedEvent.java
View file @
c0eed78e
...
...
@@ -5,7 +5,7 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
class
Product
QuantityChangedEvent
{
public
class
Inventory
QuantityChangedEvent
{
private
String
productId
;
private
int
quantity
;
}
src/main/java/com/showcase/synapse/wms/event/handler/
Product
EventHandler.java
→
src/main/java/com/showcase/synapse/wms/event/handler/
Inventory
EventHandler.java
View file @
c0eed78e
...
...
@@ -5,24 +5,24 @@ import lombok.extern.slf4j.Slf4j;
import
org.axonframework.eventhandling.EventHandler
;
import
org.springframework.stereotype.Component
;
import
com.showcase.synapse.wms.entity.
Product
Entity
;
import
com.showcase.synapse.wms.event.
Product
CreatedEvent
;
import
com.showcase.synapse.wms.event.
Product
QuantityChangedEvent
;
import
com.showcase.synapse.wms.repository.
Product
Repository
;
import
com.showcase.synapse.wms.entity.
Inventory
Entity
;
import
com.showcase.synapse.wms.event.
Inventory
CreatedEvent
;
import
com.showcase.synapse.wms.event.
Inventory
QuantityChangedEvent
;
import
com.showcase.synapse.wms.repository.
Inventory
Repository
;
@Component
@AllArgsConstructor
@Slf4j
public
class
Product
EventHandler
{
public
class
Inventory
EventHandler
{
private
final
Product
Repository
productRepository
;
private
final
Inventory
Repository
productRepository
;
@EventHandler
protected
void
saveProduct
(
Product
CreatedEvent
productCreatedEvent
)
{
protected
void
saveProduct
(
Inventory
CreatedEvent
productCreatedEvent
)
{
log
.
info
(
"
Product
CreatedEvent 이벤트 받음?"
);
log
.
info
(
"
ProductEventHandler > [Product
CreatedEvent] productCreatedEvent"
);
ProductEntity
productEntity
=
new
Product
Entity
();
log
.
info
(
"
Inventory
CreatedEvent 이벤트 받음?"
);
log
.
info
(
"
InventoryEventHandler > [Inventory
CreatedEvent] productCreatedEvent"
);
InventoryEntity
productEntity
=
new
Inventory
Entity
();
productEntity
.
setId
(
productCreatedEvent
.
getProductId
());
productEntity
.
setName
(
productCreatedEvent
.
getName
());
productEntity
.
setComment
(
productCreatedEvent
.
getComment
());
...
...
@@ -33,10 +33,10 @@ public class ProductEventHandler {
}
@EventHandler
protected
void
changeQuantity
(
Product
QuantityChangedEvent
productQuantityChangedEvent
)
{
log
.
info
(
"
Product
QuantityChangedEvent 이벤트 받음?"
);
log
.
info
(
"[
Product
QuantityChangedEvent]"
);
Product
Entity
productEntity
=
productRepository
.
findById
(
productQuantityChangedEvent
.
getProductId
()).
get
();
protected
void
changeQuantity
(
Inventory
QuantityChangedEvent
productQuantityChangedEvent
)
{
log
.
info
(
"
Inventory
QuantityChangedEvent 이벤트 받음?"
);
log
.
info
(
"[
Inventory
QuantityChangedEvent]"
);
Inventory
Entity
productEntity
=
productRepository
.
findById
(
productQuantityChangedEvent
.
getProductId
()).
get
();
// log.info("[{}] quantity:{}", productEntity.getName(), productEntity.getQuentity());
// productEntity.setQuentity(productQuantityChangedEvent.getQuantity());
productRepository
.
save
(
productEntity
);
...
...
src/main/java/com/showcase/synapse/wms/query/Get
Products
Query.java
→
src/main/java/com/showcase/synapse/wms/query/Get
Inventory
Query.java
View file @
c0eed78e
package
com
.
showcase
.
synapse
.
wms
.
query
;
public
class
Get
Products
Query
{
public
class
Get
Inventory
Query
{
}
src/main/java/com/showcase/synapse/wms/query/handler/
Product
QueryHandler.java
→
src/main/java/com/showcase/synapse/wms/query/handler/
Inventory
QueryHandler.java
View file @
c0eed78e
...
...
@@ -5,9 +5,9 @@ import java.util.List;
import
org.axonframework.queryhandling.QueryHandler
;
import
org.springframework.stereotype.Component
;
import
com.showcase.synapse.wms.entity.
Product
Entity
;
import
com.showcase.synapse.wms.query.Get
Products
Query
;
import
com.showcase.synapse.wms.repository.
Product
Repository
;
import
com.showcase.synapse.wms.entity.
Inventory
Entity
;
import
com.showcase.synapse.wms.query.Get
Inventory
Query
;
import
com.showcase.synapse.wms.repository.
Inventory
Repository
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -15,12 +15,12 @@ import lombok.extern.slf4j.Slf4j;
@Component
@RequiredArgsConstructor
@Slf4j
public
class
Product
QueryHandler
{
public
class
Inventory
QueryHandler
{
private
final
Product
Repository
productRepository
;
private
final
Inventory
Repository
productRepository
;
@QueryHandler
protected
List
<
ProductEntity
>
on
(
GetProducts
Query
query
)
{
protected
List
<
InventoryEntity
>
on
(
GetInventory
Query
query
)
{
log
.
info
(
"---product query---"
);
return
productRepository
.
findAll
();
}
...
...
src/main/java/com/showcase/synapse/wms/repository/
Product
Repository.java
→
src/main/java/com/showcase/synapse/wms/repository/
Inventory
Repository.java
View file @
c0eed78e
package
com
.
showcase
.
synapse
.
wms
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
com.showcase.synapse.wms.entity.
Product
Entity
;
import
com.showcase.synapse.wms.entity.
Inventory
Entity
;
public
interface
ProductRepository
extends
JpaRepository
<
Product
Entity
,
String
>
{
public
interface
InventoryRepository
extends
JpaRepository
<
Inventory
Entity
,
String
>
{
}
src/main/java/com/showcase/synapse/wms/saga/
Product
Saga.java
→
src/main/java/com/showcase/synapse/wms/saga/
Inventory
Saga.java
View file @
c0eed78e
...
...
@@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j;
//@Saga
@Slf4j
public
class
Product
Saga
{
public
class
Inventory
Saga
{
@Autowired
private
transient
CommandGateway
commandGateway
;
...
...
src/main/java/com/showcase/synapse/wms/service/
Product
Service.java
→
src/main/java/com/showcase/synapse/wms/service/
Inventory
Service.java
View file @
c0eed78e
...
...
@@ -10,28 +10,28 @@ import org.axonframework.messaging.responsetypes.ResponseTypes;
import
org.axonframework.queryhandling.QueryGateway
;
import
org.springframework.stereotype.Service
;
import
com.showcase.synapse.wms.command.Create
Product
Command
;
import
com.showcase.synapse.wms.entity.
Product
Entity
;
import
com.showcase.synapse.wms.query.Get
Products
Query
;
import
com.showcase.synapse.wms.command.Create
Inventory
Command
;
import
com.showcase.synapse.wms.entity.
Inventory
Entity
;
import
com.showcase.synapse.wms.query.Get
Inventory
Query
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Service
public
class
Product
Service
{
public
class
Inventory
Service
{
private
final
CommandGateway
commandGateway
;
private
final
QueryGateway
queryGateway
;
public
Product
Service
(
CommandGateway
commandGateway
,
QueryGateway
queryGateway
)
{
public
Inventory
Service
(
CommandGateway
commandGateway
,
QueryGateway
queryGateway
)
{
this
.
commandGateway
=
commandGateway
;
this
.
queryGateway
=
queryGateway
;
}
public
String
createProduct
(
String
name
,
String
comment
,
BigDecimal
price
)
{
log
.
info
(
"[@Service createProduct] new Create
Product
Command"
);
log
.
info
(
"[@Service createProduct] new Create
Inventory
Command"
);
// command생성
Create
ProductCommand
createProductCommand
=
new
CreateProduct
Command
(
Create
InventoryCommand
createProductCommand
=
new
CreateInventory
Command
(
UUID
.
randomUUID
().
toString
(),
name
,
comment
,
price
);
System
.
out
.
println
(
"test"
);
...
...
@@ -42,9 +42,9 @@ public class ProductService {
return
returnValue
;
}
public
List
<
Product
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
return
queryGateway
.
query
(
new
Get
Products
Query
(),
ResponseTypes
.
multipleInstancesOf
(
Product
Entity
.
class
)).
get
();
public
List
<
Inventory
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
return
queryGateway
.
query
(
new
Get
Inventory
Query
(),
ResponseTypes
.
multipleInstancesOf
(
Inventory
Entity
.
class
)).
get
();
}
}
src/main/resources/application.yml
View file @
c0eed78e
...
...
@@ -5,7 +5,7 @@ axon:
servers
:
localhost:8124
server
:
port
:
909
0
port
:
909
4
spring
:
datasource
:
...
...
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