Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ecom-order
Project
Project
Details
Activity
Releases
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
Ashok Kumar K
ecom-order
Commits
f88fdfe4
Commit
f88fdfe4
authored
Jun 01, 2020
by
Ashok Kumar K
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed OrderLineDto model and updated OrderServiceImpl
parent
4a112bbf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
OrderLineDto.java
...main/java/com/nisum/ecomorder/model/dto/OrderLineDto.java
+0
-5
OrderServiceImpl.java
...va/com/nisum/ecomorder/service/impl/OrderServiceImpl.java
+2
-0
No files found.
src/main/java/com/nisum/ecomorder/model/dto/OrderLineDto.java
View file @
f88fdfe4
...
@@ -4,7 +4,6 @@ import lombok.Data;
...
@@ -4,7 +4,6 @@ import lombok.Data;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
@Data
@Data
public
class
OrderLineDto
{
public
class
OrderLineDto
{
...
@@ -13,8 +12,4 @@ public class OrderLineDto {
...
@@ -13,8 +12,4 @@ public class OrderLineDto {
private
String
productId
;
private
String
productId
;
@Min
(
value
=
1
,
message
=
"quantity must be at least one"
)
@Min
(
value
=
1
,
message
=
"quantity must be at least one"
)
private
int
quantity
;
private
int
quantity
;
private
String
productName
;
@NotNull
(
message
=
"price can't be null"
)
@Min
(
value
=
1
,
message
=
"price can't be negative"
)
private
Double
price
;
}
}
src/main/java/com/nisum/ecomorder/service/impl/OrderServiceImpl.java
View file @
f88fdfe4
...
@@ -47,6 +47,8 @@ public class OrderServiceImpl implements OrderService {
...
@@ -47,6 +47,8 @@ public class OrderServiceImpl implements OrderService {
String
productId
=
orderLine
.
getProductId
();
String
productId
=
orderLine
.
getProductId
();
Product
product
=
productClient
.
getProductById
(
productId
);
Product
product
=
productClient
.
getProductById
(
productId
);
if
(
product
.
getId
()
==
null
)
throw
new
NotFoundException
(
"product not found with ID: "
+
productId
);
if
(
product
.
getId
()
==
null
)
throw
new
NotFoundException
(
"product not found with ID: "
+
productId
);
orderLine
.
setProductName
(
product
.
getName
());
orderLine
.
setPrice
(
product
.
getPrice
());
orderLine
.
setSubTotal
(
product
.
getPrice
()
*
orderLine
.
getQuantity
());
orderLine
.
setSubTotal
(
product
.
getPrice
()
*
orderLine
.
getQuantity
());
});
});
order
.
setOrderTotal
(
order
.
getLineItems
().
stream
().
mapToDouble
(
OrderLine:
:
getSubTotal
).
sum
());
order
.
setOrderTotal
(
order
.
getLineItems
().
stream
().
mapToDouble
(
OrderLine:
:
getSubTotal
).
sum
());
...
...
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