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
906402aa
Commit
906402aa
authored
Sep 13, 2023
by
lemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
55010bb9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
SalesController.java
...om/showcase/synapse/sales/controller/SalesController.java
+3
-2
SalesService.java
...java/com/showcase/synapse/sales/service/SalesService.java
+25
-15
No files found.
src/main/java/com/showcase/synapse/sales/controller/SalesController.java
View file @
906402aa
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.showcase.synapse.sales.dto.ProductSalesDto
;
import
com.showcase.synapse.sales.dto.SalesCreateDto
;
import
com.showcase.synapse.sales.dto.SalesCreateDto
;
import
com.showcase.synapse.sales.entity.ProductEntity
;
import
com.showcase.synapse.sales.entity.ProductEntity
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
import
com.showcase.synapse.sales.entity.SalesEntity
;
...
@@ -31,8 +32,8 @@ public class SalesController {
...
@@ -31,8 +32,8 @@ public class SalesController {
}
}
@GetMapping
(
"/product/"
)
@GetMapping
(
"/product/"
)
public
ResponseEntity
<
List
<
Product
Entity
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
public
ResponseEntity
<
List
<
Product
SalesDto
>>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
Product
Entity
>
productEntities
=
salesService
.
getProducts
();
List
<
Product
SalesDto
>
productEntities
=
salesService
.
getProducts
();
return
ResponseEntity
.
ok
(
productEntities
);
return
ResponseEntity
.
ok
(
productEntities
);
}
}
...
...
src/main/java/com/showcase/synapse/sales/service/SalesService.java
View file @
906402aa
package
com
.
showcase
.
synapse
.
sales
.
service
;
package
com
.
showcase
.
synapse
.
sales
.
service
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.
Iterator
;
import
java.util.
ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
...
@@ -12,6 +12,7 @@ import org.axonframework.queryhandling.QueryGateway;
...
@@ -12,6 +12,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.dto.ProductSalesDto
;
import
com.showcase.synapse.sales.entity.ProductEntity
;
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.GetProductsQuery
;
import
com.showcase.synapse.sales.query.GetProductsQuery
;
...
@@ -45,26 +46,35 @@ public class SalesService {
...
@@ -45,26 +46,35 @@ public class SalesService {
return
returnValue
;
return
returnValue
;
}
}
public
List
<
Product
Entity
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
public
List
<
Product
SalesDto
>
getProducts
()
throws
ExecutionException
,
InterruptedException
{
List
<
ProductEntity
>
product
Inventory
List
=
queryGateway
.
query
(
new
GetProductsQuery
(),
List
<
ProductEntity
>
productList
=
queryGateway
.
query
(
new
GetProductsQuery
(),
ResponseTypes
.
multipleInstancesOf
(
ProductEntity
.
class
)).
get
();
ResponseTypes
.
multipleInstancesOf
(
ProductEntity
.
class
)).
get
();
if
(
productInventoryList
!=
null
&&
productInventoryList
.
size
()
>
0
)
{
List
<
ProductSalesDto
>
productInventoryList
=
null
;
if
(
productList
!=
null
&&
productList
.
size
()
>
0
)
{
productInventoryList
=
new
ArrayList
<
ProductSalesDto
>();
ProductEntity
tempPE
=
null
;
ProductEntity
tempPE
=
null
;
int
size
=
productInventoryList
.
size
();
ProductSalesDto
dto
=
null
;
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
int
size
=
productList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
tempPE
=
productList
.
get
(
i
);
if
(
tempPE
.
getInventory
()
!=
null
&&
tempPE
.
getInventory
().
getWhid
()
!=
null
)
{
dto
=
new
ProductSalesDto
();
dto
.
setProductId
(
tempPE
.
getId
());
dto
.
setProductName
(
tempPE
.
getName
());
dto
.
setProductComment
(
tempPE
.
getComment
());
dto
.
setPrice
(
tempPE
.
getPrice
().
multiply
(
tempPE
.
getChannel
().
getDiscountRate
().
add
(
new
BigDecimal
(
1
))));
dto
.
setSalesChannel
(
tempPE
.
getChannel
().
getName
());
dto
.
setWhId
(
tempPE
.
getInventory
().
getWhid
());
dto
.
setWhName
(
tempPE
.
getInventory
().
getWhName
());
dto
.
setQuantity
(
tempPE
.
getInventory
().
getQuantity
());
productInventoryList
.
add
(
dto
);
}
}
}
}
}
// "productid": "5e75ede3-eb2c-4403-bf41-5f0dbbec07eb",
// "productname": "아이폰15",
// "productcomment": "MSA Product : 아이폰15",
// "price": 30000.00,
// "saleschannel": "company"
// "whid": "494647f8-20b8-4f65-99c9-b28044b270dc",
// "whName": "Busan warehouse",
// "quantity": 5000
return
productInventoryList
;
return
productInventoryList
;
}
}
...
...
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