Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.showcase.synapse.delivery
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.delivery
Commits
802a3849
Commit
802a3849
authored
Sep 11, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delivery commit
parent
1e7782a2
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
100 additions
and
47 deletions
+100
-47
DeliveryAggregate.java
...howcase/synapse/delivery/aggregate/DeliveryAggregate.java
+13
-13
ChangeDeliveryStatusCommand.java
...synapse/delivery/command/ChangeDeliveryStatusCommand.java
+1
-1
CreateDeliveryCommand.java
...wcase/synapse/delivery/command/CreateDeliveryCommand.java
+1
-1
DeliveryController.java
...wcase/synapse/delivery/controller/DeliveryController.java
+9
-9
DeliveryCreateDto.java
.../com/showcase/synapse/delivery/dto/DeliveryCreateDto.java
+1
-1
DeliveryEntity.java
.../com/showcase/synapse/delivery/entity/DeliveryEntity.java
+1
-1
DeliveryStatus.java
...a/com/showcase/synapse/delivery/enums/DeliveryStatus.java
+1
-1
DeliveryCreatedEvent.java
...showcase/synapse/delivery/event/DeliveryCreatedEvent.java
+1
-1
DeliveryQuantityChangedEvent.java
.../synapse/delivery/event/DeliveryQuantityChangedEvent.java
+1
-1
DeliveryEventHandler.java
.../synapse/delivery/event/handler/DeliveryEventHandler.java
+45
-0
GetDeliveryQuery.java
...com/showcase/synapse/delivery/query/GetDeliveryQuery.java
+1
-1
DeliveryQueryHandler.java
.../synapse/delivery/query/handler/DeliveryQueryHandler.java
+6
-6
DeliveryRepository.java
...wcase/synapse/delivery/repository/DeliveryRepository.java
+8
-0
DeliverySaga.java
...java/com/showcase/synapse/delivery/saga/DeliverySaga.java
+1
-1
DeliveryService.java
...om/showcase/synapse/delivery/service/DeliveryService.java
+10
-10
No files found.
src/main/java/com/showcase/synapse/delivery/aggregate/
Product
Aggregate.java
→
src/main/java/com/showcase/synapse/delivery/aggregate/
Delivery
Aggregate.java
View file @
802a3849
...
...
@@ -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.delivery.command.Change
Quantity
Command
;
import
com.showcase.synapse.delivery.command.Create
Product
Command
;
import
com.showcase.synapse.delivery.event.
Product
CreatedEvent
;
import
com.showcase.synapse.delivery.event.
Product
QuantityChangedEvent
;
import
com.showcase.synapse.delivery.saga.
Product
Saga
;
import
com.showcase.synapse.delivery.command.Change
DeliveryStatus
Command
;
import
com.showcase.synapse.delivery.command.Create
Delivery
Command
;
import
com.showcase.synapse.delivery.event.
Delivery
CreatedEvent
;
import
com.showcase.synapse.delivery.event.
Delivery
QuantityChangedEvent
;
import
com.showcase.synapse.delivery.saga.
Delivery
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
Delivery
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
DeliveryAggregate
(
CreateDelivery
Command
command
)
{
log
.
info
(
"[
DeliveryAggregate(CreateDeliveryCommand) > apply new Delivery
CreatedEvent]"
);
apply
(
new
Delivery
CreatedEvent
(
command
.
getId
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()));
}
@EventSourcingHandler
public
void
createProduct
(
Product
CreatedEvent
event
)
{
public
void
createProduct
(
Delivery
CreatedEvent
event
)
{
this
.
id
=
event
.
getProductId
();
// this.quantiy = event.getQuantity();
}
@CommandHandler
public
void
changeQuantity
(
Change
Quantity
Command
command
)
{
public
void
changeQuantity
(
Change
DeliveryStatus
Command
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
Delivery
QuantityChangedEvent(command.getProductId(), this.quantiy - command.getQuantity()));
}
@EventSourcingHandler
public
void
changeQuantity
(
Product
QuantityChangedEvent
event
)
{
public
void
changeQuantity
(
Delivery
QuantityChangedEvent
event
)
{
// this.quantiy = event.getQuantity();
}
...
...
src/main/java/com/showcase/synapse/delivery/command/Change
Quantity
Command.java
→
src/main/java/com/showcase/synapse/delivery/command/Change
DeliveryStatus
Command.java
View file @
802a3849
...
...
@@ -7,7 +7,7 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
class
Change
Quantity
Command
{
public
class
Change
DeliveryStatus
Command
{
@TargetAggregateIdentifier
private
String
productId
;
...
...
src/main/java/com/showcase/synapse/delivery/command/Create
Product
Command.java
→
src/main/java/com/showcase/synapse/delivery/command/Create
Delivery
Command.java
View file @
802a3849
...
...
@@ -8,7 +8,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@Getter
public
class
Create
Product
Command
{
public
class
Create
Delivery
Command
{
@TargetAggregateIdentifier
private
final
String
id
;
...
...
src/main/java/com/showcase/synapse/delivery/controller/
Product
Controller.java
→
src/main/java/com/showcase/synapse/delivery/controller/
Delivery
Controller.java
View file @
802a3849
...
...
@@ -3,9 +3,9 @@ package com.showcase.synapse.delivery.controller;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
com.showcase.synapse.delivery.dto.
Product
CreateDto
;
import
com.showcase.synapse.delivery.entity.
Product
Entity
;
import
com.showcase.synapse.delivery.service.
Product
Service
;
import
com.showcase.synapse.delivery.dto.
Delivery
CreateDto
;
import
com.showcase.synapse.delivery.entity.
Delivery
Entity
;
import
com.showcase.synapse.delivery.service.
Delivery
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
Delivery
Controller
{
final
Product
Service
productService
;
final
Delivery
Service
productService
;
public
ProductController
(
Product
Service
productService
)
{
public
DeliveryController
(
Delivery
Service
productService
)
{
this
.
productService
=
productService
;
}
@GetMapping
(
"/"
)
public
ResponseEntity
<
List
<
Product
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
Product
Entity
>
productEntities
=
productService
.
getProducts
();
public
ResponseEntity
<
List
<
Delivery
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
Delivery
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
Delivery
CreateDto
productCreateDto
)
{
String
productId
=
productService
.
createProduct
(
productCreateDto
.
getName
(),
productCreateDto
.
getComment
(),
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()));
...
...
src/main/java/com/showcase/synapse/delivery/dto/
Product
CreateDto.java
→
src/main/java/com/showcase/synapse/delivery/dto/
Delivery
CreateDto.java
View file @
802a3849
...
...
@@ -5,7 +5,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
Product
CreateDto
{
public
class
Delivery
CreateDto
{
private
String
name
;
private
String
comment
;
private
int
price
;
...
...
src/main/java/com/showcase/synapse/delivery/entity/
Product
Entity.java
→
src/main/java/com/showcase/synapse/delivery/entity/
Delivery
Entity.java
View file @
802a3849
...
...
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
Product
Entity
{
public
class
Delivery
Entity
{
@Id
private
String
id
;
private
String
name
;
...
...
src/main/java/com/showcase/synapse/delivery/enums/
Order
Status.java
→
src/main/java/com/showcase/synapse/delivery/enums/
Delivery
Status.java
View file @
802a3849
package
com
.
showcase
.
synapse
.
delivery
.
enums
;
public
enum
Order
Status
{
public
enum
Delivery
Status
{
CREATED
,
CANCELED
}
src/main/java/com/showcase/synapse/delivery/event/
Product
CreatedEvent.java
→
src/main/java/com/showcase/synapse/delivery/event/
Delivery
CreatedEvent.java
View file @
802a3849
...
...
@@ -7,7 +7,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@Getter
public
class
Product
CreatedEvent
{
public
class
Delivery
CreatedEvent
{
private
String
productId
;
private
String
name
;
private
String
comment
;
...
...
src/main/java/com/showcase/synapse/delivery/event/
Product
QuantityChangedEvent.java
→
src/main/java/com/showcase/synapse/delivery/event/
Delivery
QuantityChangedEvent.java
View file @
802a3849
...
...
@@ -5,7 +5,7 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
class
Product
QuantityChangedEvent
{
public
class
Delivery
QuantityChangedEvent
{
private
String
productId
;
private
int
quantity
;
}
src/main/java/com/showcase/synapse/delivery/event/handler/
Product
EventHandler.java
→
src/main/java/com/showcase/synapse/delivery/event/handler/
Delivery
EventHandler.java
View file @
802a3849
...
...
@@ -5,24 +5,24 @@ import lombok.extern.slf4j.Slf4j;
import
org.axonframework.eventhandling.EventHandler
;
import
org.springframework.stereotype.Component
;
import
com.showcase.synapse.delivery.entity.
Product
Entity
;
import
com.showcase.synapse.delivery.event.
Product
CreatedEvent
;
import
com.showcase.synapse.delivery.event.
Product
QuantityChangedEvent
;
import
com.showcase.synapse.delivery.repository.
Product
Repository
;
import
com.showcase.synapse.delivery.entity.
Delivery
Entity
;
import
com.showcase.synapse.delivery.event.
Delivery
CreatedEvent
;
import
com.showcase.synapse.delivery.event.
Delivery
QuantityChangedEvent
;
import
com.showcase.synapse.delivery.repository.
Delivery
Repository
;
@Component
@AllArgsConstructor
@Slf4j
public
class
Product
EventHandler
{
public
class
Delivery
EventHandler
{
private
final
Product
Repository
productRepository
;
private
final
Delivery
Repository
productRepository
;
@EventHandler
protected
void
saveProduct
(
Product
CreatedEvent
productCreatedEvent
)
{
protected
void
saveProduct
(
Delivery
CreatedEvent
productCreatedEvent
)
{
log
.
info
(
"
Product
CreatedEvent 이벤트 받음?"
);
log
.
info
(
"
ProductEventHandler > [Product
CreatedEvent] productCreatedEvent"
);
ProductEntity
productEntity
=
new
Product
Entity
();
log
.
info
(
"
Delivery
CreatedEvent 이벤트 받음?"
);
log
.
info
(
"
DeliveryEventHandler > [Delivery
CreatedEvent] productCreatedEvent"
);
DeliveryEntity
productEntity
=
new
Delivery
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
(
Delivery
QuantityChangedEvent
productQuantityChangedEvent
)
{
log
.
info
(
"
Delivery
QuantityChangedEvent 이벤트 받음?"
);
log
.
info
(
"[
Delivery
QuantityChangedEvent]"
);
Delivery
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/delivery/query/Get
Products
Query.java
→
src/main/java/com/showcase/synapse/delivery/query/Get
Delivery
Query.java
View file @
802a3849
package
com
.
showcase
.
synapse
.
delivery
.
query
;
public
class
Get
Products
Query
{
public
class
Get
Delivery
Query
{
}
src/main/java/com/showcase/synapse/delivery/query/handler/
Product
QueryHandler.java
→
src/main/java/com/showcase/synapse/delivery/query/handler/
Delivery
QueryHandler.java
View file @
802a3849
...
...
@@ -5,9 +5,9 @@ import java.util.List;
import
org.axonframework.queryhandling.QueryHandler
;
import
org.springframework.stereotype.Component
;
import
com.showcase.synapse.delivery.entity.
Product
Entity
;
import
com.showcase.synapse.delivery.query.Get
Products
Query
;
import
com.showcase.synapse.delivery.repository.
Product
Repository
;
import
com.showcase.synapse.delivery.entity.
Delivery
Entity
;
import
com.showcase.synapse.delivery.query.Get
Delivery
Query
;
import
com.showcase.synapse.delivery.repository.
Delivery
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
Delivery
QueryHandler
{
private
final
Product
Repository
productRepository
;
private
final
Delivery
Repository
productRepository
;
@QueryHandler
protected
List
<
ProductEntity
>
on
(
GetProducts
Query
query
)
{
protected
List
<
DeliveryEntity
>
on
(
GetDelivery
Query
query
)
{
log
.
info
(
"---product query---"
);
return
productRepository
.
findAll
();
}
...
...
src/main/java/com/showcase/synapse/delivery/repository/
Product
Repository.java
→
src/main/java/com/showcase/synapse/delivery/repository/
Delivery
Repository.java
View file @
802a3849
package
com
.
showcase
.
synapse
.
delivery
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
com.showcase.synapse.delivery.entity.
Product
Entity
;
import
com.showcase.synapse.delivery.entity.
Delivery
Entity
;
public
interface
ProductRepository
extends
JpaRepository
<
Product
Entity
,
String
>
{
public
interface
DeliveryRepository
extends
JpaRepository
<
Delivery
Entity
,
String
>
{
}
src/main/java/com/showcase/synapse/delivery/saga/
Product
Saga.java
→
src/main/java/com/showcase/synapse/delivery/saga/
Delivery
Saga.java
View file @
802a3849
...
...
@@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j;
//@Saga
@Slf4j
public
class
Product
Saga
{
public
class
Delivery
Saga
{
@Autowired
private
transient
CommandGateway
commandGateway
;
...
...
src/main/java/com/showcase/synapse/delivery/service/
Product
Service.java
→
src/main/java/com/showcase/synapse/delivery/service/
Delivery
Service.java
View file @
802a3849
...
...
@@ -10,28 +10,28 @@ import org.axonframework.messaging.responsetypes.ResponseTypes;
import
org.axonframework.queryhandling.QueryGateway
;
import
org.springframework.stereotype.Service
;
import
com.showcase.synapse.delivery.command.Create
Product
Command
;
import
com.showcase.synapse.delivery.entity.
Product
Entity
;
import
com.showcase.synapse.delivery.query.Get
Products
Query
;
import
com.showcase.synapse.delivery.command.Create
Delivery
Command
;
import
com.showcase.synapse.delivery.entity.
Delivery
Entity
;
import
com.showcase.synapse.delivery.query.Get
Delivery
Query
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Service
public
class
Product
Service
{
public
class
Delivery
Service
{
private
final
CommandGateway
commandGateway
;
private
final
QueryGateway
queryGateway
;
public
Product
Service
(
CommandGateway
commandGateway
,
QueryGateway
queryGateway
)
{
public
Delivery
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
Delivery
Command"
);
// command생성
Create
ProductCommand
createProductCommand
=
new
CreateProduct
Command
(
Create
DeliveryCommand
createProductCommand
=
new
CreateDelivery
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
<
Delivery
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
return
queryGateway
.
query
(
new
Get
Delivery
Query
(),
ResponseTypes
.
multipleInstancesOf
(
Delivery
Entity
.
class
)).
get
();
}
}
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