Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.showcase.synapse.product
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.product
Commits
548c2768
Commit
548c2768
authored
Sep 07, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
e20a73c3
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
11 deletions
+58
-11
ProductAggregate.java
.../showcase/synapse/product/aggregate/ProductAggregate.java
+1
-1
CreateProductCommand.java
...howcase/synapse/product/command/CreateProductCommand.java
+1
-1
ProductController.java
...howcase/synapse/product/controller/ProductController.java
+2
-1
ProductCreateDto.java
...va/com/showcase/synapse/product/dto/ProductCreateDto.java
+1
-0
ChannelEntity.java
...va/com/showcase/synapse/product/entity/ChannelEntity.java
+27
-0
ProductEntity.java
...va/com/showcase/synapse/product/entity/ProductEntity.java
+19
-6
ProductCreatedEvent.java
...m/showcase/synapse/product/event/ProductCreatedEvent.java
+1
-0
ProductEventHandler.java
...se/synapse/product/event/handler/ProductEventHandler.java
+4
-0
ProductService.java
.../com/showcase/synapse/product/service/ProductService.java
+2
-2
No files found.
src/main/java/com/showcase/synapse/product/aggregate/ProductAggregate.java
View file @
548c2768
...
@@ -31,7 +31,7 @@ public class ProductAggregate {
...
@@ -31,7 +31,7 @@ public class ProductAggregate {
@CommandHandler
@CommandHandler
public
ProductAggregate
(
CreateProductCommand
command
)
{
public
ProductAggregate
(
CreateProductCommand
command
)
{
log
.
info
(
"[ProductAggregate(CreateProductCommand) > apply new ProductCreatedEvent]"
);
log
.
info
(
"[ProductAggregate(CreateProductCommand) > apply new ProductCreatedEvent]"
);
apply
(
new
ProductCreatedEvent
(
command
.
getId
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()));
apply
(
new
ProductCreatedEvent
(
command
.
getId
(),
command
.
getName
(),
command
.
getComment
(),
command
.
getPrice
()
,
command
.
getChannel
()
));
}
}
@EventSourcingHandler
@EventSourcingHandler
...
...
src/main/java/com/showcase/synapse/product/command/CreateProductCommand.java
View file @
548c2768
...
@@ -15,6 +15,6 @@ public class CreateProductCommand {
...
@@ -15,6 +15,6 @@ public class CreateProductCommand {
private
final
String
name
;
private
final
String
name
;
private
final
String
comment
;
private
final
String
comment
;
private
final
BigDecimal
price
;
private
final
BigDecimal
price
;
// private final Integer quantity
;
private
final
Integer
channel
;
}
}
src/main/java/com/showcase/synapse/product/controller/ProductController.java
View file @
548c2768
...
@@ -35,7 +35,8 @@ public class ProductController {
...
@@ -35,7 +35,8 @@ public class ProductController {
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
ProductCreateDto
productCreateDto
)
{
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
ProductCreateDto
productCreateDto
)
{
String
productId
=
productService
.
createProduct
(
productCreateDto
.
getName
(),
String
productId
=
productService
.
createProduct
(
productCreateDto
.
getName
(),
productCreateDto
.
getComment
(),
productCreateDto
.
getComment
(),
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()));
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()),
productCreateDto
.
getChannel
());
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"productId"
,
productId
);
m
.
put
(
"productId"
,
productId
);
m
.
put
(
"productName"
,
productCreateDto
.
getName
());
m
.
put
(
"productName"
,
productCreateDto
.
getName
());
...
...
src/main/java/com/showcase/synapse/product/dto/ProductCreateDto.java
View file @
548c2768
...
@@ -9,5 +9,6 @@ public class ProductCreateDto {
...
@@ -9,5 +9,6 @@ public class ProductCreateDto {
private
String
name
;
private
String
name
;
private
String
comment
;
private
String
comment
;
private
int
price
;
private
int
price
;
private
int
channel
;
}
}
src/main/java/com/showcase/synapse/product/entity/ChannelEntity.java
0 → 100644
View file @
548c2768
package
com
.
showcase
.
synapse
.
product
.
entity
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
ChannelEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"channel_id"
)
private
Integer
id
;
@Column
(
name
=
"name"
)
private
String
name
;
}
src/main/java/com/showcase/synapse/product/entity/ProductEntity.java
View file @
548c2768
package
com
.
showcase
.
synapse
.
product
.
entity
;
package
com
.
showcase
.
synapse
.
product
.
entity
;
import
java.math.BigDecimal
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.OneToOne
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.Setter
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
java.math.BigDecimal
;
@Entity
@Entity
@Getter
@Getter
@Setter
@Setter
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
public
class
ProductEntity
{
public
class
ProductEntity
{
@Id
@Id
private
String
id
;
private
String
id
;
private
String
name
;
private
String
name
;
private
String
comment
;
private
String
comment
;
private
BigDecimal
price
;
private
BigDecimal
price
;
// @Column(name = "channel", nullable = false)
// private Integer channel;
@OneToOne
(
cascade
=
CascadeType
.
PERSIST
)
@JoinColumn
(
name
=
"channel_id"
)
private
ChannelEntity
channel
;
}
}
src/main/java/com/showcase/synapse/product/event/ProductCreatedEvent.java
View file @
548c2768
...
@@ -12,4 +12,5 @@ public class ProductCreatedEvent {
...
@@ -12,4 +12,5 @@ public class ProductCreatedEvent {
private
String
name
;
private
String
name
;
private
String
comment
;
private
String
comment
;
private
BigDecimal
price
;
private
BigDecimal
price
;
private
Integer
channel
;
}
}
src/main/java/com/showcase/synapse/product/event/handler/ProductEventHandler.java
View file @
548c2768
...
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.axonframework.eventhandling.EventHandler
;
import
org.axonframework.eventhandling.EventHandler
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.showcase.synapse.product.entity.ChannelEntity
;
import
com.showcase.synapse.product.entity.ProductEntity
;
import
com.showcase.synapse.product.entity.ProductEntity
;
import
com.showcase.synapse.product.event.ProductCreatedEvent
;
import
com.showcase.synapse.product.event.ProductCreatedEvent
;
import
com.showcase.synapse.product.event.ProductQuantityChangedEvent
;
import
com.showcase.synapse.product.event.ProductQuantityChangedEvent
;
...
@@ -27,6 +28,9 @@ public class ProductEventHandler {
...
@@ -27,6 +28,9 @@ public class ProductEventHandler {
productEntity
.
setName
(
productCreatedEvent
.
getName
());
productEntity
.
setName
(
productCreatedEvent
.
getName
());
productEntity
.
setComment
(
productCreatedEvent
.
getComment
());
productEntity
.
setComment
(
productCreatedEvent
.
getComment
());
productEntity
.
setPrice
(
productCreatedEvent
.
getPrice
());
productEntity
.
setPrice
(
productCreatedEvent
.
getPrice
());
ChannelEntity
ce
=
new
ChannelEntity
();
ce
.
setId
(
productCreatedEvent
.
getChannel
());
productEntity
.
setChannel
(
ce
);
productRepository
.
save
(
productEntity
);
productRepository
.
save
(
productEntity
);
...
...
src/main/java/com/showcase/synapse/product/service/ProductService.java
View file @
548c2768
...
@@ -28,11 +28,11 @@ public class ProductService {
...
@@ -28,11 +28,11 @@ public class ProductService {
this
.
queryGateway
=
queryGateway
;
this
.
queryGateway
=
queryGateway
;
}
}
public
String
createProduct
(
String
name
,
String
comment
,
BigDecimal
price
)
{
public
String
createProduct
(
String
name
,
String
comment
,
BigDecimal
price
,
int
channel
)
{
log
.
info
(
"[@Service createProduct] new CreateProductCommand"
);
log
.
info
(
"[@Service createProduct] new CreateProductCommand"
);
// command생성
// command생성
CreateProductCommand
createProductCommand
=
new
CreateProductCommand
(
CreateProductCommand
createProductCommand
=
new
CreateProductCommand
(
UUID
.
randomUUID
().
toString
(),
name
,
comment
,
price
UUID
.
randomUUID
().
toString
(),
name
,
comment
,
price
,
channel
);
);
System
.
out
.
println
(
"test"
);
System
.
out
.
println
(
"test"
);
// 여기
// 여기
...
...
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