-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from nhkhai/main
SIS-27: Created Endpoints For The Review Entity.
- Loading branch information
Showing
15 changed files
with
268 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
31 changes: 30 additions & 1 deletion
31
src/main/java/sg/com/smartinventory/repositories/CustomerRepository.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 |
---|---|---|
@@ -1,10 +1,39 @@ | ||
package sg.com.smartinventory.repositories; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import sg.com.smartinventory.entities.Customer; | ||
|
||
// CustomerRepository simply extends JpaRepository, giving us a lot of default methods to access db without the hard work. | ||
// CustomerRepository simply extends JpaRepository, giving us a lot of default methods to access the database without the hard work. | ||
// This is a very powerful feature of Spring Data JPA. It will automatically do a property check and traverse the supported nested properties, translating them into the relevant queries. | ||
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism. | ||
public interface CustomerRepository extends JpaRepository<Customer, Long> { | ||
// Custom query to find all customers with a certain ID. | ||
List<Customer> findById(long id); | ||
|
||
// Custom query to find all customers with a certain first name. | ||
List<Customer> findByFirstName(String firstName); | ||
|
||
// Custom query to find all customers with a certain last name. | ||
List<Customer> findByLastName(String lastName); | ||
|
||
// Custom query to find all customers with a certain first name and last name. | ||
List<Customer> findByFirstNameAndLastName(String firstName, String lastName); | ||
|
||
// Custom query to find all customers with a certain country. | ||
List<Customer> findByCountry(String country); | ||
|
||
// Custom query to find all customers with a certain address. | ||
List<Customer> findByAddress(String address); | ||
|
||
// Custom query to find all customers with a certain postal code. | ||
List<Customer> findByPostalCode(int postalCode); | ||
|
||
// Custom query to find all customers with a certain phone number. | ||
List<Customer> findByPhoneNumber(int phoneNumber); | ||
|
||
// Custom query to find all customers with a certain email. | ||
List<Customer> findByEmail(String email); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/sg/com/smartinventory/repositories/ProductRepository.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 |
---|---|---|
@@ -1,9 +1,30 @@ | ||
package sg.com.smartinventory.repositories; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import sg.com.smartinventory.entities.Product; | ||
|
||
// ProductRepository simply extends JpaRepository, giving us a lot of default methods to access the database without the hard work. | ||
// This is a very powerful feature of Spring Data JPA. It will automatically do a property check and traverse the supported nested properties, translating them into the relevant queries. | ||
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism. | ||
public interface ProductRepository extends JpaRepository<Product, Long> { | ||
// Custom query to find all products with a certain ID. | ||
List<Product> findById(long id); | ||
|
||
// Custom query to find all products with a certain category. | ||
List<Product> findByCategory(String category); | ||
|
||
// Custom query to find all products with a certain name. | ||
List<Product> findByName(String name); | ||
|
||
// Custom query to find all products with a certain description. | ||
List<Product> findByDescription(String description); | ||
|
||
// Custom query to find all products with a certain price. | ||
List<Product> findByPrice(double price); | ||
|
||
// Custom query to find all products with a certain stock quantity. | ||
List<Product> findByStockQuantity(int stockQuantity); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/sg/com/smartinventory/repositories/ReviewRepository.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 |
---|---|---|
@@ -1,9 +1,33 @@ | ||
package sg.com.smartinventory.repositories; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import sg.com.smartinventory.entities.Review; | ||
|
||
// ReviewRepository simply extends JpaRepository, giving us a lot of default methods to access the database without the hard work. | ||
// This is a very powerful feature of Spring Data JPA. It will automatically do a property check and traverse the supported nested properties, translating them into the relevant queries. | ||
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism. | ||
public interface ReviewRepository extends JpaRepository<Review, Long> { | ||
// Custom query to find all reviews with a certain ID. | ||
List<Review> findById(long id); | ||
|
||
// Custom query to find all reviews with a certain category. | ||
List<Review> findByCategory(String category); | ||
|
||
// Custom query to find all reviews with a certain review content. | ||
List<Review> findByReviewContent(String reviewContent); | ||
|
||
// Custom query to find all reviews with a certain rating. | ||
List<Review> findByRating(int rating); | ||
|
||
// Custom query to find all reviews with a certain customer ID. | ||
List<Review> findByCustomerId(long customerId); | ||
|
||
// Custom query to find all reviews with a certain product ID. | ||
List<Review> findByProductId(long productId); | ||
|
||
// Custom query to find all reviews with a certain customer ID and product ID. | ||
List<Review> findByCustomerIdAndProductId(long customerId, long productId); | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/java/sg/com/smartinventory/services/CustomerService.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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package sg.com.smartinventory.services; | ||
|
||
import sg.com.smartinventory.entities.Customer; | ||
// import sg.com.smartinventory.entities.Review; | ||
|
||
public interface CustomerService { | ||
Customer createCustomer(Customer customer); | ||
|
||
// Review addReviewToCustomer(long customerId, long productId, Review review); | ||
} |
Oops, something went wrong.