Skip to content

Commit

Permalink
Feat(INVT-CPC-1002 ):Ability to set the proper roles to the end points (
Browse files Browse the repository at this point in the history
#578)

JIRA: link to jira ticket
https://champlainsaintlambert.atlassian.net/browse/CPC-1002
## Context:
This ticket is about giving authorizations to certain roles for
Inventory, where the roles were not specified.

## Changes
- Added roles for endpoints that had no roles or user permisions
- My changes affect Inventory and Vets
  • Loading branch information
Abdur-Siddiqui authored Oct 22, 2023
1 parent b7282e2 commit 3b28af8
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ public Mono<ResponseEntity<Void>> processResetPassword(@RequestBody @Valid Mono<

//Start of Inventory Methods
@GetMapping("/inventory/{inventoryId}/products-pagination")
@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER, Roles.VET})
public Flux<ProductResponseDTO> getProductsInInventoryByInventoryIdAndProductFieldPagination(@PathVariable String inventoryId,
@RequestParam(required = false) String productName,
@RequestParam(required = false) Double productPrice,
Expand All @@ -802,6 +803,7 @@ public Flux<ProductResponseDTO> getProductsInInventoryByInventoryIdAndProductFie
}

@GetMapping("/inventory/{inventoryId}/products-count")
@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER,Roles.VET})
public Mono<ResponseEntity<Long>> getTotalNumberOfProductsWithRequestParams(@PathVariable String inventoryId,
@RequestParam(required = false) String productName,
@RequestParam(required = false) Double productPrice,
Expand All @@ -810,6 +812,7 @@ public Mono<ResponseEntity<Long>> getTotalNumberOfProductsWithRequestParams(@Pat
.map(response -> ResponseEntity.status(HttpStatus.OK).body(response));
}
@PostMapping(value = "inventory/{inventoryId}/products")
@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER})
public Mono<ResponseEntity<ProductResponseDTO>> addProductToInventory(@RequestBody ProductRequestDTO model, @PathVariable String inventoryId){
return inventoryServiceClient.addProductToInventory(model, inventoryId)
.map(s -> ResponseEntity.status(HttpStatus.CREATED).body(s))
Expand All @@ -827,7 +830,6 @@ public Mono<ResponseEntity<InventoryResponseDTO>> addInventory(@RequestBody Inve
}

@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER,Roles.VET})

@GetMapping(value ="inventory/{inventoryId}")
public Mono<ResponseEntity<InventoryResponseDTO>> getInventoryById(@PathVariable String inventoryId){
return inventoryServiceClient.getInventoryById(inventoryId)
Expand All @@ -853,7 +855,6 @@ public Mono<ResponseEntity<InventoryResponseDTO>> updateInventory( @RequestBody
}



@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER})
@PutMapping(value = "inventory/{inventoryId}/products/{productId}")
public Mono<ResponseEntity<ProductResponseDTO>> updateProductInInventory(@RequestBody ProductRequestDTO model, @PathVariable String inventoryId, @PathVariable String productId){
Expand Down Expand Up @@ -912,22 +913,19 @@ public Mono<ResponseEntity<Void>> deleteAllInventories() {
.defaultIfEmpty(ResponseEntity.notFound().build());
}


@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER})
@PostMapping(value = "inventory/type")
public Mono<ResponseEntity<InventoryTypeResponseDTO>> addInventoryType(@RequestBody InventoryTypeRequestDTO inventoryTypeRequestDTO){
return inventoryServiceClient.addInventoryType(inventoryTypeRequestDTO)
.map(s -> ResponseEntity.status(HttpStatus.CREATED).body(s))
.defaultIfEmpty(ResponseEntity.badRequest().build());
}

@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER})

@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER, Roles.VET})
@GetMapping(value = "inventory/type")
public Flux<InventoryTypeResponseDTO> getAllInventoryTypes(){
return inventoryServiceClient.getAllInventoryTypes();
}

@SecuredEndpoint(allowedRoles = {Roles.ADMIN,Roles.INVENTORY_MANAGER})
@DeleteMapping(value = "inventory/{inventoryId}")
public Mono<Void> deleteInventoryByInventoryId(@PathVariable String inventoryId) {
return inventoryServiceClient.deleteInventoryByInventoryId(inventoryId);
Expand Down

0 comments on commit 3b28af8

Please sign in to comment.