-
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.
Browse files
Browse the repository at this point in the history
✨ [FEATURE] 특정 판매자 페이지 조회 (#57)
- Loading branch information
Showing
6 changed files
with
136 additions
and
3 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
52 changes: 52 additions & 0 deletions
52
src/main/java/umc/unimade/domain/accounts/dto/SellerPageResponse.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,52 @@ | ||
package umc.unimade.domain.accounts.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import umc.unimade.domain.accounts.entity.Seller; | ||
import umc.unimade.domain.products.entity.Products; | ||
|
||
import java.util.List; | ||
|
||
// TODO - md 찜 수, 상품 찜 수, 접속한 buyer가 해당 seller 찜한 여부, + 설명창,인스타 (?) | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class SellerPageResponse { | ||
private String profileImage; | ||
private String name; | ||
private String phone; | ||
private Page<ProductsResponse> products; | ||
|
||
public static SellerPageResponse of(Seller seller, Page<ProductsResponse> products) { | ||
return SellerPageResponse.builder() | ||
.profileImage(seller.getProfileImage()) | ||
.name(seller.getName()) | ||
.phone(seller.getPhone()) | ||
.products(products) | ||
.build(); | ||
} | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public static class ProductsResponse { | ||
private Long productId; | ||
private String name; | ||
private Long price; | ||
private String imageUrl; | ||
|
||
public static ProductsResponse from(Products product) { | ||
return ProductsResponse.builder() | ||
.productId(product.getId()) | ||
.name(product.getName()) | ||
.price(product.getPrice()) | ||
.imageUrl(product.getProductImages().isEmpty() ? null : product.getProductImages().get(0).getImageUrl()) | ||
.build(); | ||
} | ||
} | ||
} |
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
19 changes: 18 additions & 1 deletion
19
src/main/java/umc/unimade/domain/products/repository/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,14 +1,31 @@ | ||
package umc.unimade.domain.products.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
import umc.unimade.domain.products.entity.ProductStatus; | ||
import umc.unimade.domain.products.entity.Products; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface ProductRepository extends JpaRepository<Products, Long>, ProductsRepositoryCustom { | ||
List<Products> findTop4BySellerIdAndStatusOrderByCreatedAtDesc(Long sellerId, ProductStatus status); | ||
|
||
} | ||
// deadline 지난 selling상품 찾기 | ||
@Query("SELECT p FROM Products p WHERE p.status = :status AND p.deadline < CURRENT_DATE") | ||
List<Products> findExpiredProducts(ProductStatus status); | ||
|
||
// 인기순 | ||
@Query("SELECT p FROM Products p LEFT JOIN p.favoriteProducts f WHERE p.seller.id = :sellerId AND p.status = :status GROUP BY p.id ORDER BY COUNT(f) DESC") | ||
Page<Products> findBySellerIdAndStatusOrderByPopularity(Long sellerId, ProductStatus status, Pageable pageable); | ||
|
||
// 최신순 | ||
Page<Products> findBySellerIdAndStatusOrderByCreatedAtDesc(Long sellerId, ProductStatus status, Pageable pageable); | ||
|
||
// 마감순 | ||
@Query("SELECT p FROM Products p WHERE p.seller.id = :sellerId AND p.status = :status ORDER BY p.deadline ASC") | ||
Page<Products> findBySellerIdAndStatusOrderByDeadline(Long sellerId, ProductStatus status, 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