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
49c6287c
Commit
49c6287c
authored
Sep 12, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JPA JPA !!!!1
parent
69b7b1a4
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
19 deletions
+106
-19
WMSController.java
...va/com/showcase/synapse/wms/controller/WMSController.java
+1
-1
InventoryCreateDto.java
...java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
+1
-1
ChannelEntity.java
...n/java/com/showcase/synapse/wms/entity/ChannelEntity.java
+32
-0
InventoryEntity.java
...java/com/showcase/synapse/wms/entity/InventoryEntity.java
+13
-8
ProductEntity.java
...n/java/com/showcase/synapse/wms/entity/ProductEntity.java
+41
-0
InventoryEventHandler.java
...case/synapse/wms/event/handler/InventoryEventHandler.java
+16
-7
InventoryService.java
...va/com/showcase/synapse/wms/service/InventoryService.java
+2
-2
No files found.
src/main/java/com/showcase/synapse/wms/controller/WMSController.java
View file @
49c6287c
...
...
@@ -33,7 +33,7 @@ public class WMSController {
@PostMapping
(
"/"
)
public
ResponseEntity
<
Map
<
String
,
String
>>
inventoryCreate
(
@RequestBody
InventoryCreateDto
inventoryCreateDto
)
{
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
getProductId
(),
inventoryCreateDto
.
getWhName
(),
String
inventoryId
=
inventoryService
.
createInventory
(
inventoryCreateDto
.
get
WhId
(),
inventoryCreateDto
.
get
ProductId
(),
inventoryCreateDto
.
getWhName
(),
inventoryCreateDto
.
getQuantity
());
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"inventoryId"
,
inventoryId
);
...
...
src/main/java/com/showcase/synapse/wms/dto/InventoryCreateDto.java
View file @
49c6287c
...
...
@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
InventoryCreateDto
{
//
private String whId;
private
String
whId
;
private
String
productId
;
private
String
whName
;
private
Integer
quantity
;
...
...
src/main/java/com/showcase/synapse/wms/entity/ChannelEntity.java
0 → 100644
View file @
49c6287c
package
com
.
showcase
.
synapse
.
wms
.
entity
;
import
java.math.BigDecimal
;
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
@Column
(
name
=
"channel_id"
)
private
Integer
id
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"discount_rate"
)
private
BigDecimal
discountRate
;
}
src/main/java/com/showcase/synapse/wms/entity/InventoryEntity.java
View file @
49c6287c
package
com
.
showcase
.
synapse
.
wms
.
entity
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
java.math.BigDecimal
;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
InventoryEntity
{
@Id
private
String
whId
;
private
String
productId
;
@Column
(
name
=
"wh_id"
)
private
String
whid
;
@Column
(
name
=
"ref_product_id"
)
private
String
productid
;
private
String
whName
;
private
int
quantity
;
private
Integer
quantity
;
}
src/main/java/com/showcase/synapse/wms/entity/ProductEntity.java
0 → 100644
View file @
49c6287c
package
com
.
showcase
.
synapse
.
wms
.
entity
;
import
java.math.BigDecimal
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.OneToOne
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
ProductEntity
{
@Id
private
String
id
;
private
String
name
;
private
String
comment
;
private
BigDecimal
price
;
// @Column(name = "channel", nullable = false)
// private Integer channel;
@OneToOne
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
PERSIST
)
@JoinColumn
(
name
=
"channel_id"
)
private
ChannelEntity
channel
;
@OneToOne
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"ref_product_id"
)
private
InventoryEntity
inventory
;
}
src/main/java/com/showcase/synapse/wms/event/handler/InventoryEventHandler.java
View file @
49c6287c
...
...
@@ -2,6 +2,9 @@ package com.showcase.synapse.wms.event.handler;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Optional
;
import
org.axonframework.eventhandling.EventHandler
;
import
org.springframework.stereotype.Component
;
...
...
@@ -22,13 +25,19 @@ public class InventoryEventHandler {
log
.
info
(
"InventoryCreatedEvent 이벤트 받음?"
);
log
.
info
(
"InventoryEventHandler > [InventoryCreatedEvent] productCreatedEvent"
);
InventoryEntity
inventoryEntity
=
new
InventoryEntity
();
inventoryEntity
.
setProductId
(
inventoryCreatedEvent
.
getProductId
());
inventoryEntity
.
setWhId
(
inventoryCreatedEvent
.
getWhId
());
Optional
<
InventoryEntity
>
optional
=
inventoryRepository
.
findById
(
inventoryCreatedEvent
.
getWhId
());
if
(
optional
.
isPresent
())
{
InventoryEntity
inventoryEntity
=
optional
.
get
();
// InventoryEntity inventoryEntity = new InventoryEntity();
inventoryEntity
.
setProductid
(
inventoryCreatedEvent
.
getProductId
());
inventoryEntity
.
setWhid
(
inventoryCreatedEvent
.
getWhId
());
inventoryEntity
.
setWhName
(
inventoryCreatedEvent
.
getWhName
());
inventoryEntity
.
setQuantity
(
inventoryCreatedEvent
.
getQuantity
());
inventoryRepository
.
save
(
inventoryEntity
);
}
// inventoryRepository.save(inventoryEntity);
}
...
...
src/main/java/com/showcase/synapse/wms/service/InventoryService.java
View file @
49c6287c
...
...
@@ -27,11 +27,11 @@ public class InventoryService {
this
.
queryGateway
=
queryGateway
;
}
public
String
createInventory
(
String
productId
,
String
whName
,
int
quantity
)
{
public
String
createInventory
(
String
whId
,
String
productId
,
String
whName
,
int
quantity
)
{
log
.
info
(
"[@Service createProduct] new CreateInventoryCommand"
);
// command생성
CreateInventoryCommand
createInventoryCommand
=
new
CreateInventoryCommand
(
UUID
.
randomUUID
().
toString
()
,
productId
,
whName
,
quantity
whId
,
productId
,
whName
,
quantity
);
// 여기
// 생성한 command전송(비동기)
...
...
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