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
21d7cea0
Commit
21d7cea0
authored
Sep 12, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
57fe27fb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
InventoryEntity.java
.../com/showcase/synapse/product/entity/InventoryEntity.java
+33
-0
ProductEntity.java
...va/com/showcase/synapse/product/entity/ProductEntity.java
+6
-1
ProductEventHandler.java
...se/synapse/product/event/handler/ProductEventHandler.java
+9
-0
No files found.
src/main/java/com/showcase/synapse/product/entity/InventoryEntity.java
0 → 100644
View file @
21d7cea0
package
com
.
showcase
.
synapse
.
product
.
entity
;
import
java.io.Serializable
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
InventoryEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
6540276275154344203L
;
@Id
@Column
(
name
=
"wh_id"
)
private
String
whid
;
@Column
(
name
=
"ref_product_id"
)
private
String
productid
;
private
String
whName
;
private
Integer
quantity
;
}
src/main/java/com/showcase/synapse/product/entity/ProductEntity.java
View file @
21d7cea0
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import
javax.persistence.CascadeType
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.OneToOne
;
import
javax.persistence.OneToOne
;
...
@@ -30,7 +31,11 @@ public class ProductEntity {
...
@@ -30,7 +31,11 @@ public class ProductEntity {
// @Column(name = "channel", nullable = false)
// @Column(name = "channel", nullable = false)
// private Integer channel;
// private Integer channel;
@OneToOne
(
cascade
=
CascadeType
.
PERSIST
)
@OneToOne
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
PERSIST
)
@JoinColumn
(
name
=
"channel_id"
)
@JoinColumn
(
name
=
"channel_id"
)
private
ChannelEntity
channel
;
private
ChannelEntity
channel
;
@OneToOne
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"ref_product_id"
,
referencedColumnName
=
"ref_product_id"
)
private
InventoryEntity
inventory
;
}
}
src/main/java/com/showcase/synapse/product/event/handler/ProductEventHandler.java
View file @
21d7cea0
package
com
.
showcase
.
synapse
.
product
.
event
.
handler
;
package
com
.
showcase
.
synapse
.
product
.
event
.
handler
;
import
java.util.UUID
;
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.ChannelEntity
;
import
com.showcase.synapse.product.entity.InventoryEntity
;
import
com.showcase.synapse.product.entity.ProductEntity
;
import
com.showcase.synapse.product.entity.ProductEntity
;
import
com.showcase.synapse.product.event.ChannelCreatedEvent
;
import
com.showcase.synapse.product.event.ChannelCreatedEvent
;
import
com.showcase.synapse.product.event.ProductCreatedEvent
;
import
com.showcase.synapse.product.event.ProductCreatedEvent
;
...
@@ -35,6 +38,12 @@ public class ProductEventHandler {
...
@@ -35,6 +38,12 @@ public class ProductEventHandler {
ChannelEntity
ce
=
new
ChannelEntity
();
ChannelEntity
ce
=
new
ChannelEntity
();
ce
.
setId
(
productCreatedEvent
.
getChannel
());
ce
.
setId
(
productCreatedEvent
.
getChannel
());
productEntity
.
setChannel
(
ce
);
productEntity
.
setChannel
(
ce
);
InventoryEntity
ie
=
new
InventoryEntity
();
ie
.
setWhid
(
UUID
.
randomUUID
().
toString
());
ie
.
setProductid
(
productCreatedEvent
.
getProductId
());
ie
.
setWhName
(
"init wh data"
);
ie
.
setQuantity
(
0
);
productEntity
.
setInventory
(
ie
);
productRepository
.
save
(
productEntity
);
productRepository
.
save
(
productEntity
);
...
...
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