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
18137b5a
Commit
18137b5a
authored
May 06, 2021
by
Khai Yuan Liew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-58] Work on DEL product endpoint
parent
d6474c5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
7 deletions
+4
-7
ProductController.java
.../nisum/ascend/inventory/controller/ProductController.java
+1
-1
ProductRepository.java
.../nisum/ascend/inventory/repository/ProductRepository.java
+0
-2
ProductService.java
...va/com/nisum/ascend/inventory/service/ProductService.java
+3
-4
No files found.
src/main/java/com/nisum/ascend/inventory/controller/ProductController.java
View file @
18137b5a
...
@@ -16,7 +16,7 @@ public class ProductController {
...
@@ -16,7 +16,7 @@ public class ProductController {
@DeleteMapping
(
value
=
"/{sku}"
)
@DeleteMapping
(
value
=
"/{sku}"
)
public
void
deleteProduct
(
@PathVariable
String
sku
)
{
public
void
deleteProduct
(
@PathVariable
String
sku
)
{
//
productService.removeProductBySku(sku).subscribe();
productService
.
removeProductBySku
(
sku
).
subscribe
();
}
}
}
}
src/main/java/com/nisum/ascend/inventory/repository/ProductRepository.java
View file @
18137b5a
...
@@ -10,6 +10,4 @@ import reactor.core.publisher.Mono;
...
@@ -10,6 +10,4 @@ import reactor.core.publisher.Mono;
public
interface
ProductRepository
extends
ReactiveMongoRepository
<
Product
,
String
>
{
public
interface
ProductRepository
extends
ReactiveMongoRepository
<
Product
,
String
>
{
Mono
<
Product
>
findBySku
(
String
sku
);
Mono
<
Product
>
findBySku
(
String
sku
);
Mono
<
ProductDto
>
deleteProduct
(
ProductDto
prod
);
}
}
src/main/java/com/nisum/ascend/inventory/service/ProductService.java
View file @
18137b5a
...
@@ -17,13 +17,12 @@ public class ProductService {
...
@@ -17,13 +17,12 @@ public class ProductService {
@Autowired
@Autowired
ProductRepository
productRepository
;
ProductRepository
productRepository
;
public
Mono
<
Product
Dto
>
removeProductBySku
(
String
sku
){
public
Mono
<
Product
>
removeProductBySku
(
String
sku
){
return
productRepository
return
productRepository
.
findBySku
(
sku
)
.
findBySku
(
sku
)
.
map
(
ProductDto:
:
generateDtoFromProduct
)
.
flatMap
(
existingProduct
->
productRepository
.
delete
(
existingProduct
)
.
flatMap
(
existingProduct
->
productRepository
.
deleteProduct
(
existingProduct
)
.
then
(
Mono
.
just
(
existingProduct
)))
.
then
(
Mono
.
just
(
existingProduct
)))
.
switchIfEmpty
(
Mono
.
error
(
new
ResourceNotFoundException
(
HttpStatus
.
NOT_FOUND
,
"
product not f
ound"
)));
.
switchIfEmpty
(
Mono
.
error
(
new
ResourceNotFoundException
(
HttpStatus
.
NOT_FOUND
,
"
Product Not F
ound"
)));
}
}
}
}
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