-
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
Showing
13 changed files
with
115 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) | ||
|
||
Fix: |
17 changes: 9 additions & 8 deletions
17
java-backend/demo/src/main/java/com/example/demo/CategoryRepo.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,11 @@ | ||
package com.example.demo; | ||
// package com.example.demo; | ||
|
||
import org.springframework.stereotype.Repository; | ||
import org.springframework.data.jpa.repository.*; | ||
// import org.springframework.stereotype.Repository; | ||
// import org.springframework.data.jpa.repository.*; | ||
|
||
@Repository | ||
public interface CategoryRepo extends JpaRepository<Category, Integer> { | ||
@Query(value = "INSERT INTO category (categoryName, description, picture) VALUES ('Seafood', 'tasty', null)") | ||
void insertCategory(); | ||
} | ||
// @Repository | ||
// public interface CategoryRepo extends JpaRepository<Category, Integer> { | ||
// @Query(value = "INSERT INTO category (categoryName, description, picture) | ||
// VALUES ('Seafood', 'tasty', null)") | ||
// void insertCategory(); | ||
// } |
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
10 changes: 7 additions & 3 deletions
10
java-backend/demo/src/main/java/com/example/demo/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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package com.example.demo; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface ProductRepo extends JpaRepository<Product, Long> { | ||
public interface ProductRepo extends JpaRepository<Product, Integer> { | ||
|
||
// @Modifying | ||
// @Query(value = "UPDATE product SET productName = 'Product 1' WHERE productId | ||
// = 55", nativeQuery = true) | ||
// String updateProduct(); | ||
|
||
@Query(value = "UPDATE product SET productName = 'Product 1' WHERE productId = 55") | ||
void updateProduct(); | ||
} |
6 changes: 3 additions & 3 deletions
6
java-backend/demo/src/main/java/com/example/demo/SalesOrder.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,5 +1,5 @@ | ||
package com.example.demo; | ||
// package com.example.demo; | ||
|
||
public class SalesOrder { | ||
// public class SalesOrder { | ||
|
||
} | ||
// } |
14 changes: 7 additions & 7 deletions
14
java-backend/demo/src/main/java/com/example/demo/SalesRepo.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,9 @@ | ||
package com.example.demo; | ||
// package com.example.demo; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
// import org.springframework.data.jpa.repository.JpaRepository; | ||
// import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface SalesRepo extends JpaRepository<SalesOrder, Long> { | ||
@Query(value = "DELETE from salesorder ORDER BY orderId DESC limit 1") | ||
void deleteByOrderIdDescLimitOne(); | ||
} | ||
// public interface SalesRepo extends JpaRepository<SalesOrder, Long> { | ||
// @Query(value = "DELETE from salesorder ORDER BY orderId DESC limit 1") | ||
// void deleteByOrderIdDescLimitOne(); | ||
// } |
32 changes: 32 additions & 0 deletions
32
java-backend/demo/src/main/java/com/example/demo/UpdateProductService.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,32 @@ | ||
package com.example.demo; | ||
|
||
import com.example.demo.Product; | ||
import com.example.demo.ProductRepo; | ||
import org.springframework.beans.factory.annotation.*; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
@RequestMapping | ||
@CrossOrigin | ||
public class UpdateProductService { | ||
|
||
@Autowired | ||
private ProductRepo productRepo; | ||
|
||
public Product updateProduct() { | ||
Optional<Product> optionalProduct = productRepo.findById(55); | ||
if (optionalProduct.isPresent()) { | ||
Product product = optionalProduct.get(); | ||
product.setProductName("Product 1"); | ||
|
||
return productRepo.save(product); | ||
} | ||
return null; // or throw an exception | ||
} | ||
|
||
} |
Binary file not shown.
File renamed without changes.
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