-
Notifications
You must be signed in to change notification settings - Fork 5
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 #161 from MoonJongHyeon1095/dev
fix: EC2 정지 현상 문제원인 파악중
- Loading branch information
Showing
19 changed files
with
1,145 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# BE | ||
<br> | ||
<h2><b>tech stack</b></h3> | ||
<p> | ||
<img src="https://img.shields.io/badge/Spring Boot-6DB33F?style=for-the-badge&logo=Spring Boot&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Spring Security-6DB33F?style=for-the-badge&logo=Spring Security&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Web Socket-010101?style=for-the-badge&logo=Web Socket&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Rabbit MQ-FF6600?style=for-the-badge&logo=rabbitmq&logoColor=white"> | ||
<br> | ||
<img src="https://img.shields.io/badge/NginX-009639?style=for-the-badge&logo=NGINX&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=Docker&logoColor=white"> | ||
<img src="https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge&logo=MySQL&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Amazon AWS-FF9900?style=for-the-badge&logo=Amazon AWS&logoColor=white"> | ||
<img src="https://img.shields.io/badge/Github Actions-2088FF?style=for-the-badge&logo=Github Actions&logoColor=white"> | ||
<br> |
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
241 changes: 241 additions & 0 deletions
241
src/main/java/com/github/commerce/repository/product/ProductRepositoryCustom.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,241 @@ | ||
package com.github.commerce.repository.product; | ||
|
||
import com.github.commerce.web.dto.product.GetProductDto; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
import javax.persistence.Query; | ||
import java.util.List; | ||
|
||
@Repository | ||
public class ProductRepositoryCustom { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
public List<GetProductDto> findByProductCategorySortByCreatedAt( | ||
String inputProductCategory, | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
|
||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE p.product_category = :inputProductCategory " + | ||
"AND (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.created_at DESC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputProductCategory", inputProductCategory); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> findByProductCategorySortByPrice( | ||
String inputProductCategory, | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
|
||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE p.product_category = :inputProductCategory " + | ||
"AND (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.price ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputProductCategory", inputProductCategory); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> findByProductCategorySortById( | ||
String inputProductCategory, | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
|
||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE p.product_category = :inputProductCategory " + | ||
"AND (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.id ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputProductCategory", inputProductCategory); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> findAllSortByCreatedAt( | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.created_at DESC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> findAllSortByPrice( | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.price ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> findAllSortById( | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"ORDER BY p.id ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
public List<GetProductDto> searchProductSortByPrice( | ||
String searchToken, | ||
String inputAgeCategory, | ||
String inputGenderCategory, | ||
Pageable pageable) { | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"AND p.name LIKE :searchToken " + | ||
"ORDER BY p.price ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("searchToken", searchToken); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
} | ||
|
||
|
||
public List<GetProductDto> searchProductSortByCreatedAt(String searchToken, String inputAgeCategory, String inputGenderCategory, Pageable pageable) | ||
{ | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"AND p.name LIKE :searchToken " + | ||
"ORDER BY p.created_at DESC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("searchToken", searchToken); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
|
||
} | ||
|
||
public List<GetProductDto> searchProductSortById(String searchToken, String inputAgeCategory, String inputGenderCategory, Pageable pageable) { | ||
String sql = "SELECT p.id, p.name, p.price, p.created_at, " + | ||
"p.product_category, p.age_category, p.gender_category, " + | ||
"p.left_amount, p.thumbnail_url, s.shop_name " + | ||
"FROM commerce.products p LEFT JOIN commerce.sellers s ON p.sellers_id = s.id " + | ||
"WHERE (:inputAgeCategory IS NULL OR p.age_category = :inputAgeCategory) " + | ||
"AND (:inputGenderCategory IS NULL OR p.gender_category = :inputGenderCategory) " + | ||
"AND p.is_deleted = false " + | ||
"AND p.name LIKE :searchToken " + | ||
"ORDER BY p.id ASC"; | ||
|
||
Query query = entityManager.createNativeQuery(sql, "GetProductDtoMapping"); | ||
query.setParameter("searchToken", searchToken); | ||
query.setParameter("inputAgeCategory", inputAgeCategory); | ||
query.setParameter("inputGenderCategory", inputGenderCategory); | ||
query.setFirstResult((int) pageable.getOffset()); | ||
query.setMaxResults(pageable.getPageSize()); | ||
|
||
//noinspection unchecked | ||
return query.getResultList(); | ||
|
||
} | ||
} |
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.