-
Notifications
You must be signed in to change notification settings - Fork 1
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
fd0cfc0
commit 155b87a
Showing
17 changed files
with
134 additions
and
24 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
Binary file not shown.
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/hoangtien2k3/shopappbackend/repositories/ProductSearchRepository.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,11 @@ | ||
//package com.hoangtien2k3.shopappbackend.repositories; | ||
// | ||
//import com.hoangtien2k3.shopappbackend.models.Product; | ||
//import org.springframework.context.annotation.Primary; | ||
//import org.springframework.data.domain.Page; | ||
//import org.springframework.data.domain.Pageable; | ||
//import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
// | ||
//public interface ProductSearchRepository extends ElasticsearchRepository<Product, Long> { | ||
// Page<Product> findByNameContainingOrDescriptionContaining(String name, String description, Pageable pageable); | ||
//} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/hoangtien2k3/shopappbackend/utils/ConfixSql.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,43 @@ | ||
package com.hoangtien2k3.shopappbackend.utils; | ||
|
||
public class ConfixSql { | ||
|
||
public interface Product { | ||
// Tìm kiếm sản phẩm theo từ khóa và id danh mục | ||
String SEARCH_PRODUCT_BY_KEYWORD = "SELECT p FROM Product p WHERE " + | ||
"(:categoryId IS NULL OR :categoryId = 0 OR p.category.id = :categoryId) " + | ||
"AND (:keyword IS NULL OR :keyword = '' OR LOWER(p.name) LIKE LOWER(CONCAT('%', :keyword, '%')) " + | ||
"OR LOWER(p.description) LIKE LOWER(CONCAT('%', :keyword, '%')))"; | ||
|
||
// lấy ra chi tiết sản phẩm theo id | ||
String GET_DETAIL_PRODUCT = "SELECT p FROM Product p LEFT JOIN FETCH p.productImages where p.id = :productId"; | ||
|
||
// tìm kiếm sản phẩm theo danh sách id | ||
String FIND_PRODUCT_BY_IDS = "SELECT p FROM Product p where p.id IN :productIds"; | ||
} | ||
|
||
public interface Category { | ||
// lấy ra tất cả danh mục sản phẩm | ||
String GET_ALL_CATEGORY = "SELECT c FROM Category c WHERE c.active = true"; | ||
|
||
// lấy ra danh mục sản phẩm theo id | ||
String GET_CATEGORY_BY_ID = "SELECT c FROM Category c WHERE c.id = :categoryId"; | ||
} | ||
|
||
public interface User { | ||
// lấy ra tất cả user (ngoại trừ admin) với truyền admin | ||
String GET_ALL_USER = "SELECT o FROM User o WHERE o.active = true AND (:keyword IS NULL OR :keyword = '' " + | ||
"OR o.fullName LIKE %:keyword% " + | ||
"OR o.address LIKE %:keyword% " + | ||
"OR o.phoneNumber LIKE %:keyword%) " + | ||
"AND LOWER(o.role.name) = 'user'"; | ||
} | ||
|
||
public interface Order { | ||
// lẩy ra tất cả các order | ||
String GET_ALL_ORDER = "SELECT o FROM Order o WHERE " + | ||
"(:keyword IS NULL OR :keyword = '' OR o.fullName LIKE %:keyword% OR o.address LIKE %:keyword% " + | ||
"OR o.note LIKE %:keyword%)"; | ||
} | ||
|
||
} |
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