Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.showcase.synapse.sales
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.sales
Commits
2cb2a4a1
Commit
2cb2a4a1
authored
Sep 13, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
5459bcbe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
18 deletions
+141
-18
SalesController.java
...om/showcase/synapse/sales/controller/SalesController.java
+27
-16
ChannelEntity.java
...java/com/showcase/synapse/sales/entity/ChannelEntity.java
+32
-0
InventoryEntity.java
...va/com/showcase/synapse/sales/entity/InventoryEntity.java
+33
-0
ProductEntity.java
...java/com/showcase/synapse/sales/entity/ProductEntity.java
+41
-0
SalesService.java
...java/com/showcase/synapse/sales/service/SalesService.java
+8
-2
No files found.
src/main/java/com/showcase/synapse/sales/controller/SalesController.java
View file @
2cb2a4a1
package
com
.
showcase
.
synapse
.
sales
.
controller
;
package
com
.
showcase
.
synapse
.
sales
.
controller
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
com.showcase.synapse.sales.dto.SalesCreateDto
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
import
com.showcase.synapse.sales.service.SalesService
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.showcase.synapse.sales.dto.SalesCreateDto
;
import
com.showcase.synapse.sales.entity.ProductEntity
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
import
com.showcase.synapse.sales.service.SalesService
;
@RestController
@RestController
@RequestMapping
(
"/api/msa/
product
"
)
@RequestMapping
(
"/api/msa/
sales
"
)
@CrossOrigin
(
origins
=
"*"
)
@CrossOrigin
(
origins
=
"*"
)
public
class
SalesController
{
public
class
SalesController
{
final
SalesService
product
Service
;
final
SalesService
sales
Service
;
public
SalesController
(
SalesService
product
Service
)
{
public
SalesController
(
SalesService
sales
Service
)
{
this
.
productService
=
product
Service
;
this
.
salesService
=
sales
Service
;
}
}
@GetMapping
(
"/"
)
@GetMapping
(
"/
product/
"
)
public
ResponseEntity
<
List
<
Sales
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
public
ResponseEntity
<
List
<
Product
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
SalesEntity
>
productEntities
=
product
Service
.
getProducts
();
List
<
ProductEntity
>
productEntities
=
sales
Service
.
getProducts
();
return
ResponseEntity
.
ok
(
productEntities
);
return
ResponseEntity
.
ok
(
productEntities
);
}
@GetMapping
(
"/"
)
public
ResponseEntity
<
List
<
SalesEntity
>>
getSalesList
()
throws
ExecutionException
,
InterruptedException
{
List
<
SalesEntity
>
salesList
=
salesService
.
getSalesList
();
return
ResponseEntity
.
ok
(
salesList
);
}
}
@PostMapping
(
"/"
)
@PostMapping
(
"/"
)
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
SalesCreateDto
productCreateDto
)
{
public
ResponseEntity
<
Map
<
String
,
String
>>
productCreate
(
@RequestBody
SalesCreateDto
productCreateDto
)
{
String
productId
=
product
Service
.
createProduct
(
productCreateDto
.
getName
(),
String
productId
=
sales
Service
.
createProduct
(
productCreateDto
.
getName
(),
productCreateDto
.
getComment
(),
productCreateDto
.
getComment
(),
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()));
BigDecimal
.
valueOf
(
productCreateDto
.
getPrice
()));
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
HashMap
<
String
,
String
>
m
=
new
HashMap
<>();
...
...
src/main/java/com/showcase/synapse/sales/entity/ChannelEntity.java
0 → 100644
View file @
2cb2a4a1
package
com
.
showcase
.
synapse
.
sales
.
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/sales/entity/InventoryEntity.java
0 → 100644
View file @
2cb2a4a1
package
com
.
showcase
.
synapse
.
sales
.
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/sales/entity/ProductEntity.java
0 → 100644
View file @
2cb2a4a1
package
com
.
showcase
.
synapse
.
sales
.
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"
,
referencedColumnName
=
"ref_product_id"
)
private
InventoryEntity
inventory
;
}
src/main/java/com/showcase/synapse/sales/service/SalesService.java
View file @
2cb2a4a1
...
@@ -11,6 +11,7 @@ import org.axonframework.queryhandling.QueryGateway;
...
@@ -11,6 +11,7 @@ import org.axonframework.queryhandling.QueryGateway;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.showcase.synapse.sales.command.CreateSalesCommand
;
import
com.showcase.synapse.sales.command.CreateSalesCommand
;
import
com.showcase.synapse.sales.entity.ProductEntity
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
import
com.showcase.synapse.sales.query.GetSalesQuery
;
import
com.showcase.synapse.sales.query.GetSalesQuery
;
...
@@ -42,9 +43,14 @@ public class SalesService {
...
@@ -42,9 +43,14 @@ public class SalesService {
return
returnValue
;
return
returnValue
;
}
}
public
List
<
Sales
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
public
List
<
Product
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
return
queryGateway
.
query
(
new
GetSalesQuery
(),
return
queryGateway
.
query
(
new
GetSalesQuery
(),
ResponseTypes
.
multipleInstancesOf
(
SalesEntity
.
class
)).
get
();
ResponseTypes
.
multipleInstancesOf
(
ProductEntity
.
class
)).
get
();
}
public
List
<
SalesEntity
>
getSalesList
()
throws
ExecutionException
,
InterruptedException
{
return
queryGateway
.
query
(
new
GetSalesQuery
(),
ResponseTypes
.
multipleInstancesOf
(
SalesEntity
.
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