forked from nikhiljain1203/ProductService_Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee474e1
commit 30e4cfc
Showing
11 changed files
with
132 additions
and
20 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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/productservice_proxy/models/BaseModel.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
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/example/productservice_proxy/models/Product.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,14 +1,19 @@ | ||
package com.example.productservice_proxy.models; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
public class Product extends BaseModel{ | ||
private String title; | ||
private double price; | ||
private String description; | ||
@ManyToOne(cascade= CascadeType.ALL) | ||
private Categories category; | ||
private String imageUrl; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/productservice_proxy/repostries/ProductRepo.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 com.example.productservice_proxy.repostries; | ||
|
||
import com.example.productservice_proxy.models.Product; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ProductRepo extends JpaRepository<Product, Long> { | ||
Product save(Product product); // (save) is a method of JpaRepository (interface) | ||
} |
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
40 changes: 39 additions & 1 deletion
40
src/main/java/com/example/productservice_proxy/services/SelfProductService.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,4 +1,42 @@ | ||
package com.example.productservice_proxy.services; | ||
|
||
public class SelfProductService { | ||
import com.example.productservice_proxy.models.Product; | ||
import com.example.productservice_proxy.repostries.ProductRepo; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class SelfProductService implements IProductService { | ||
|
||
ProductRepo productRepo; | ||
|
||
public SelfProductService(ProductRepo productRepo) { | ||
this.productRepo = productRepo; | ||
} | ||
@Override | ||
public List<Product> getAllProducts() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Product getSingleProduct(Long productId) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Product addNewProduct(Product product) { | ||
this.productRepo.save(product); | ||
return product; | ||
} | ||
|
||
@Override | ||
public Product updateProduct(Long productId, Product product) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String deleteProduct(Long productId) { | ||
return null; | ||
} | ||
} |
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 +1,6 @@ | ||
|
||
spring.jpa.hibernate.ddl-auto=update | ||
spring.datasource.url=jdbc:mysql://localhost:3306/test | ||
spring.datasource.username=root | ||
spring.datasource.password=password | ||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||
#spring.jpa.show-sql: true |