-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature 72 product in organization #103
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
832f625
[feature-70-BE-Expose-Organization-destruction] - changes after review
berki0 f90569e
[feature-72-BE-products-in-organization] CRUD
berki0 3281bb8
[feature-72-BE-products-in-organization] add deleting method
berki0 b2af645
[feature-72-BE-products-in-organization] add deleting method
berki0 f6ff5c1
update product, entity fetcher
ignatIgnatov 4f6732e
[feature-72-BE-products-in-organization] add tests
berki0 f42a518
[feature-72-BE-products-in-organization] add tests
berki0 b108aae
[feature-72-BE-products-in-organization] add tests
berki0 76b0db8
[feature-72-BE-products-in-organization] add tests
berki0 3f9fc72
[feature-72-BE-products-in-organization] add tests
berki0 283f2bb
[feature-72-BE-products-in-organization] add tests
berki0 c7df993
[feature-72-BE-products-in-organization] add tests
berki0 9d1a46e
[feature-72-BE-products-in-organization] add tests
berki0 5842c84
[feature-72-BE-products-in-organization] add tests
berki0 34484b6
[feature-72-BE-products-in-organization] add tests
berki0 89c3c5a
[feature-72-BE-products-in-organization] add tests
berki0 851ccf0
[feature-72-BE-products-in-organization] add tests
berki0 2577835
[feature-72-BE-products-in-organization] add tests
berki0 18f7185
[feature-72-BE-products-in-organization] add tests
berki0 6025974
[feature-72-BE-products-in-organization] add tests
berki0 a434678
working create and update integration tests
ignatIgnatov d47aede
refactoring
ignatIgnatov 935639a
working delete integration test
ignatIgnatov 0d9e089
[feature-72-BE-products-in-organization] add tests
berki0 b8d8606
[feature-72-BE-products-in-organization] changes after review
berki0 fb0fb2d
[feature-72-BE-products-in-organization] changes after review
berki0 9e9bbe6
[feature-72-BE-products-in-organization] changes after review
berki0 4346fad
[feature-72-BE-products-in-organization] changes after review
berki0 2063c21
[feature-72-BE-products-in-organization] changes after review
berki0 a43b3d9
fix delete method
berki0 ecc5794
fix delete method
berki0 650aacd
fix delete method
berki0 6cf44ed
[feature-72-BE-products-in-organization] changes after review
berki0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/jewellery/inventory/controller/ProductInOrganizationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package jewellery.inventory.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.validation.Valid; | ||
import java.util.UUID; | ||
import jewellery.inventory.dto.request.ProductRequestDto; | ||
import jewellery.inventory.dto.response.ProductsInOrganizationResponseDto; | ||
import jewellery.inventory.service.ProductInOrganizationService; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/organizations") | ||
@AllArgsConstructor | ||
public class ProductInOrganizationController { | ||
private final ProductInOrganizationService productInOrganizationService; | ||
|
||
@Operation(summary = "Get all products in organization") | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/{organizationId}/products") | ||
public ProductsInOrganizationResponseDto getAllProductsInOrganization( | ||
@PathVariable UUID organizationId) { | ||
return productInOrganizationService.getProductsInOrganization(organizationId); | ||
} | ||
|
||
@Operation(summary = "Create a new product in organization") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@PostMapping("/products") | ||
public ProductsInOrganizationResponseDto createProductInOrganization( | ||
@RequestBody @Valid ProductRequestDto productRequestDto) { | ||
return productInOrganizationService.createProductInOrganization(productRequestDto); | ||
} | ||
|
||
@Operation(summary = "Delete a new product in organization") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@DeleteMapping("/products/{productId}") | ||
public void deleteProductInOrganization( | ||
@PathVariable("productId") UUID productId) { | ||
productInOrganizationService.deleteProductInOrganization(productId); | ||
} | ||
|
||
@Operation(summary = "Update a product in organization") | ||
@ResponseStatus(HttpStatus.OK) | ||
@PutMapping("/products/{productId}") | ||
public ProductsInOrganizationResponseDto updateProduct( | ||
@PathVariable("productId") UUID productId, | ||
@Valid @RequestBody ProductRequestDto productRequestDto) { | ||
return productInOrganizationService.updateProduct(productId, productRequestDto); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/jewellery/inventory/dto/response/ProductsInOrganizationResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package jewellery.inventory.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@SuperBuilder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ProductsInOrganizationResponseDto { | ||
private OrganizationResponseDto organization; | ||
private List<ProductResponseDto> products; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/jewellery/inventory/exception/organization/OrganizationNotOwnerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package jewellery.inventory.exception.organization; | ||
|
||
|
||
import java.util.UUID; | ||
|
||
public class OrganizationNotOwnerException extends RuntimeException { | ||
public OrganizationNotOwnerException(UUID organizationId, UUID productId) { | ||
super("Organization with id " + organizationId + " is not the owner of a product with id " + productId); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...a/jewellery/inventory/exception/organization/ProductIsNotPartOfOrganizationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package jewellery.inventory.exception.organization; | ||
|
||
import java.util.UUID; | ||
|
||
public class ProductIsNotPartOfOrganizationException extends RuntimeException { | ||
public ProductIsNotPartOfOrganizationException(UUID productId) { | ||
super("The Product with id " + productId + "is not owned of Organization"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/jewellery/inventory/mapper/ProductInOrganizationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jewellery.inventory.mapper; | ||
|
||
import jewellery.inventory.dto.response.ProductResponseDto; | ||
import jewellery.inventory.dto.response.ProductsInOrganizationResponseDto; | ||
import jewellery.inventory.model.Organization; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ProductInOrganizationMapper { | ||
private final OrganizationMapper organizationMapper; | ||
|
||
public ProductsInOrganizationResponseDto mapToProductsInOrganizationResponseDto( | ||
Organization organization, List<ProductResponseDto> products) { | ||
ProductsInOrganizationResponseDto productsInOrganizationResponseDto = | ||
new ProductsInOrganizationResponseDto(); | ||
|
||
productsInOrganizationResponseDto.setOrganization(organizationMapper.toResponse(organization)); | ||
productsInOrganizationResponseDto.setProducts(products); | ||
return productsInOrganizationResponseDto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obsolete change?