Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inventory-service
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
Ascend
inventory-service
Commits
d6474c5a
Commit
d6474c5a
authored
May 06, 2021
by
Khai Yuan Liew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-58] Work on DELETE product controller
parent
391f5a10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
ResourceNotFoundException.java
...ascend/inventory/exception/ResourceNotFoundException.java
+14
-0
ProductService.java
...va/com/nisum/ascend/inventory/service/ProductService.java
+4
-1
No files found.
src/main/java/com/nisum/ascend/inventory/exception/ResourceNotFoundException.java
0 → 100644
View file @
d6474c5a
package
com
.
nisum
.
ascend
.
inventory
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@ResponseStatus
(
value
=
HttpStatus
.
NOT_FOUND
)
public
class
ResourceNotFoundException
extends
Exception
{
HttpStatus
status
;
public
ResourceNotFoundException
(
HttpStatus
status
,
String
message
)
{
super
(
message
);
this
.
status
=
status
;
}
}
src/main/java/com/nisum/ascend/inventory/service/ProductService.java
View file @
d6474c5a
package
com
.
nisum
.
ascend
.
inventory
.
service
;
package
com
.
nisum
.
ascend
.
inventory
.
service
;
import
com.nisum.ascend.inventory.dto.ProductDto
;
import
com.nisum.ascend.inventory.dto.ProductDto
;
import
com.nisum.ascend.inventory.exception.ResourceNotFoundException
;
import
com.nisum.ascend.inventory.model.Product
;
import
com.nisum.ascend.inventory.model.Product
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Flux
;
import
com.nisum.ascend.inventory.repository.ProductRepository
;
import
com.nisum.ascend.inventory.repository.ProductRepository
;
...
@@ -20,7 +22,8 @@ public class ProductService {
...
@@ -20,7 +22,8 @@ public class ProductService {
.
findBySku
(
sku
)
.
findBySku
(
sku
)
.
map
(
ProductDto:
:
generateDtoFromProduct
)
.
map
(
ProductDto:
:
generateDtoFromProduct
)
.
flatMap
(
existingProduct
->
productRepository
.
deleteProduct
(
existingProduct
)
.
flatMap
(
existingProduct
->
productRepository
.
deleteProduct
(
existingProduct
)
.
then
(
Mono
.
just
(
existingProduct
)));
//Insert Exception Handling after AFP-56 merge
.
then
(
Mono
.
just
(
existingProduct
)))
.
switchIfEmpty
(
Mono
.
error
(
new
ResourceNotFoundException
(
HttpStatus
.
NOT_FOUND
,
"product not found"
)));
}
}
}
}
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