Skip to content

Commit

Permalink
v1.0.1 (#559)
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
Leejin-Yang authored Aug 18, 2023
2 parents db87dd2 + a73b632 commit 0802eb8
Show file tree
Hide file tree
Showing 43 changed files with 442 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public ReviewFavorite(final Member member, final Review review) {
this.review = review;
}

public static ReviewFavorite createReviewFavoriteByMemberAndReview(final Member member, final Review review,
final Boolean favorite) {
public static ReviewFavorite create(final Member member, final Review review, final Boolean favorite) {
final ReviewFavorite reviewFavorite = new ReviewFavorite(member, review);
reviewFavorite.review.getReviewFavorites().add(reviewFavorite);
reviewFavorite.member.getReviewFavorites().add(reviewFavorite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ public interface ProductRepository extends JpaRepository<Product, Long> {

@Query("SELECT p FROM Product p "
+ "WHERE p.name LIKE CONCAT('%', :name, '%') "
+ "ORDER BY CASE "
+ "WHEN p.name LIKE CONCAT(:name, '%') THEN 1 "
+ "ELSE 2 END")
+ "ORDER BY "
+ "(CASE WHEN p.name LIKE CONCAT(:name, '%') THEN 1 ELSE 2 END), "
+ "p.id DESC")
Page<Product> findAllByNameContaining(@Param("name") final String name, final Pageable pageable);

@Query("SELECT new com.funeat.product.dto.ProductReviewCountDto(p, COUNT(r.id)) FROM Product p "
+ "LEFT JOIN Review r ON r.product.id = p.id "
+ "WHERE p.name LIKE CONCAT('%', :name, '%') "
+ "GROUP BY p.id "
+ "ORDER BY CASE "
+ "WHEN p.name LIKE CONCAT(:name, '%') THEN 1 "
+ "ELSE 2 END")
+ "ORDER BY "
+ "(CASE WHEN p.name LIKE CONCAT(:name, '%') THEN 1 ELSE 2 END), p.id DESC")
Page<ProductReviewCountDto> findAllWithReviewCountByNameContaining(@Param("name") final String name, final Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void likeReview(final Long reviewId, final Long memberId, final ReviewFav

private ReviewFavorite saveReviewFavorite(final Member member, final Review review, final Boolean favorite) {
try {
final ReviewFavorite reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review,
final ReviewFavorite reviewFavorite = ReviewFavorite.create(member, review,
favorite);
return reviewFavoriteRepository.save(reviewFavorite);
} catch (final DataIntegrityViolationException e) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/com/funeat/tag/domain/TagType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum TagType {

TASTE, PRICE, ETC
TASTE, QUANTITY, ETC
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,67 @@ class searchProducts_성공_테스트 {
페이지를_검증한다(response, pageDto);
상품_자동_완성_검색_결과를_검증한다(response, expectedProducts);
}

@Test
void 페이지가_넘어가도_중복없이_결과를_조회한다() {
// given
final var category = 카테고리_간편식사_생성();
단일_카테고리_저장(category);

final var product1 = 상품_망고빙수_가격5000원_평점4점_생성(category);
final var product2 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product3 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product4 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product5 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product6 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product7 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product8 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product9 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product10 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product11 = 상품_애플망고_가격3000원_평점5점_생성(category);
복수_상품_저장(product1, product2, product3, product4, product5, product6, product7, product8, product9,
product10, product11);

// when
final var response1 = 상품_자동_완성_검색_요청("망고", 0);
final var response2 = 상품_자동_완성_검색_요청("망고", 1);

// then
결과값이_이전_요청_결과값에_중복되는지_검증(response1, response2);
}

@Test
void 페이지가_넘어가도_시작되는_단어_우선_조회한다() {
// given
final var category = 카테고리_간편식사_생성();
단일_카테고리_저장(category);

final var product1 = 상품_망고빙수_가격5000원_평점4점_생성(category);
final var product2 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product3 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product4 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product5 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product6 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product7 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product8 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product9 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product10 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product11 = 상품_망고빙수_가격5000원_평점4점_생성(category);
복수_상품_저장(product1, product2, product3, product4, product5, product6, product7, product8, product9,
product10, product11);

final var pageDto = new PageDto(11L, 2L, true, false, 0L, PAGE_SIZE);
final var expectedProducts = List.of(product11, product1, product10, product9, product8, product7, product6,
product5, product4, product3);

// when
final var response = 상품_자동_완성_검색_요청("망고", 0);

// then
STATUS_CODE를_검증한다(response, 정상_처리);
페이지를_검증한다(response, pageDto);
상품_자동_완성_검색_결과를_검증한다(response, expectedProducts);
}
}

@Nested
Expand Down Expand Up @@ -684,6 +745,88 @@ class getSearchResults_성공_테스트 {
페이지를_검증한다(response, pageDto);
상품_검색_결과를_검증한다(response, expected);
}

@Test
void 페이지가_넘어가도_중복없이_상품_결과를_조회한다() {
// given
final var category = 카테고리_간편식사_생성();
단일_카테고리_저장(category);

final var product1 = 상품_망고빙수_가격5000원_평점4점_생성(category);
final var product2 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product3 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product4 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product5 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product6 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product7 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product8 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product9 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product10 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product11 = 상품_애플망고_가격3000원_평점5점_생성(category);
복수_상품_저장(product1, product2, product3, product4, product5, product6, product7, product8, product9,
product10, product11);

// when
final var response1 = 상품_검색_결과_조회_요청("망고", 0);
final var response2 = 상품_검색_결과_조회_요청("망고", 1);

// then
결과값이_이전_요청_결과값에_중복되는지_검증(response1, response2);
}

@Test
void 페이지가_넘어가도_시작되는_단어_우선_조회한다() {
// given
final var category = 카테고리_간편식사_생성();
단일_카테고리_저장(category);

final var product1 = 상품_망고빙수_가격5000원_평점4점_생성(category);
final var product2 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product3 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product4 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product5 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product6 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product7 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product8 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product9 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product10 = 상품_애플망고_가격3000원_평점5점_생성(category);
final var product11 = 상품_망고빙수_가격5000원_평점4점_생성(category);
복수_상품_저장(product1, product2, product3, product4, product5, product6, product7, product8, product9,
product10, product11);

final var pageDto = new PageDto(11L, 2L, true, false, 0L, PAGE_SIZE);
final var expectedDto1 = SearchProductResultDto.toDto(product11, 0L);
final var expectedDto2 = SearchProductResultDto.toDto(product1, 0L);
final var expectedDto3 = SearchProductResultDto.toDto(product10, 0L);
final var expectedDto4 = SearchProductResultDto.toDto(product9, 0L);
final var expectedDto5 = SearchProductResultDto.toDto(product8, 0L);
final var expectedDto6 = SearchProductResultDto.toDto(product7, 0L);
final var expectedDto7 = SearchProductResultDto.toDto(product6, 0L);
final var expectedDto8 = SearchProductResultDto.toDto(product5, 0L);
final var expectedDto9 = SearchProductResultDto.toDto(product4, 0L);
final var expectedDto10 = SearchProductResultDto.toDto(product3, 0L);
final var expected = List.of(expectedDto1, expectedDto2, expectedDto3, expectedDto4, expectedDto5,
expectedDto6, expectedDto7, expectedDto8, expectedDto9, expectedDto10);

// when
final var response = 상품_검색_결과_조회_요청("망고", 0);

// then
STATUS_CODE를_검증한다(response, 정상_처리);
페이지를_검증한다(response, pageDto);
상품_검색_결과를_검증한다(response, expected);
}
}

private void 결과값이_이전_요청_결과값에_중복되는지_검증(final ExtractableResponse<Response> response1,
final ExtractableResponse<Response> response2) {
final var lastResponses = response1.jsonPath()
.getList("products", SearchProductResultDto.class);
final var currentResponse = response2.jsonPath()
.getList("products", SearchProductResultDto.class).get(0);

assertThat(lastResponses).usingRecursiveFieldByFieldElementComparator()
.doesNotContain(currentResponse);
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ public class CategoryFixture {
return new Category("EMART24", CategoryType.STORE);
}


public static Category 카테고리_세븐일레븐_생성() {
return new Category("세븐일레븐", CategoryType.STORE);
}
}
6 changes: 3 additions & 3 deletions backend/src/test/java/com/funeat/fixture/TagFixture.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.funeat.fixture;

import static com.funeat.tag.domain.TagType.ETC;
import static com.funeat.tag.domain.TagType.PRICE;
import static com.funeat.tag.domain.TagType.QUANTITY;
import static com.funeat.tag.domain.TagType.TASTE;

import com.funeat.tag.domain.Tag;
Expand All @@ -18,11 +18,11 @@ public class TagFixture {
}

public static Tag 태그_갓성비_PRICE_생성() {
return new Tag("갓성비", PRICE);
return new Tag("갓성비", QUANTITY);
}

public static Tag 태그_푸짐해요_PRICE_생성() {
return new Tag("푸짐해요", PRICE);
return new Tag("푸짐해요", QUANTITY);
}

public static Tag 태그_간식_ETC_생성() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class findByMemberAndReview_성공_테스트 {
final var review = 리뷰_이미지test4_평점4점_재구매O_생성(member, product, 0L);
단일_리뷰_저장(review);

final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, true);
final var reviewFavorite = ReviewFavorite.create(member, review, true);
단일_리뷰_좋아요_저장(reviewFavorite);

final var expected = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, true);
final var expected = ReviewFavorite.create(member, review, true);

// when
final var actual = reviewFavoriteRepository.findByMemberAndReview(member, review).get();
Expand Down Expand Up @@ -95,7 +95,7 @@ class findByMemberAndReview_실패_테스트 {
final var review = 리뷰_이미지test4_평점4점_재구매O_생성(member, product, 0L);
단일_리뷰_저장(review);

final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, true);
final var reviewFavorite = ReviewFavorite.create(member, review, true);
단일_리뷰_좋아요_저장(reviewFavorite);

final var wrongReview = 리뷰_이미지test5_평점5점_재구매O_생성(member, product, 0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class updateChecked_성공_테스트 {

final var member = 멤버_멤버1_생성();
final var review = 리뷰_이미지test1_평점1점_재구매O_생성(member, product, 0L);
final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, true);
final var reviewFavorite = ReviewFavorite.create(member, review, true);

// when
reviewFavorite.updateChecked(false);
Expand All @@ -45,7 +45,7 @@ class updateChecked_성공_테스트 {

final var member = 멤버_멤버1_생성();
final var review = 리뷰_이미지test1_평점1점_재구매O_생성(member, product, 0L);
final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, false);
final var reviewFavorite = ReviewFavorite.create(member, review, false);

// when
reviewFavorite.updateChecked(true);
Expand All @@ -67,7 +67,7 @@ class updateChecked_실패_테스트 {

final var member = 멤버_멤버1_생성();
final var review = 리뷰_이미지test1_평점1점_재구매O_생성(member, product, 0L);
final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, true);
final var reviewFavorite = ReviewFavorite.create(member, review, true);

// when
reviewFavorite.updateChecked(true);
Expand All @@ -85,7 +85,7 @@ class updateChecked_실패_테스트 {

final var member = 멤버_멤버1_생성();
final var review = 리뷰_이미지test1_평점1점_재구매O_생성(member, product, 0L);
final var reviewFavorite = ReviewFavorite.createReviewFavoriteByMemberAndReview(member, review, false);
final var reviewFavorite = ReviewFavorite.create(member, review, false);

// when
reviewFavorite.updateChecked(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.funeat.fixture.CategoryFixture.카테고리_GS25_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_간편식사_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_과자류_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_세븐일레븐_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_식품_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_아이스크림_생성;
import static com.funeat.fixture.CategoryFixture.카테고리_음료_생성;
Expand Down Expand Up @@ -35,7 +36,8 @@ class findAllByType_성공_테스트 {
final var CU = 카테고리_CU_생성();
final var GS25 = 카테고리_GS25_생성();
final var EMART24 = 카테고리_EMART24_생성();
복수_카테고리_저장(간편식사, 즉석조리, 과자류, 아이스크림, 식품, 음료, CU, GS25, EMART24);
final var 세븐일레븐 = 카테고리_세븐일레븐_생성();
복수_카테고리_저장(간편식사, 즉석조리, 과자류, 아이스크림, 식품, 음료, CU, GS25, EMART24, 세븐일레븐);

final var expected = List.of(간편식사, 즉석조리, 과자류, 아이스크림, 식품, 음료);

Expand All @@ -59,9 +61,10 @@ class findAllByType_성공_테스트 {
final var CU = 카테고리_CU_생성();
final var GS25 = 카테고리_GS25_생성();
final var EMART24 = 카테고리_EMART24_생성();
복수_카테고리_저장(간편식사, 즉석조리, 과자류, 아이스크림, 식품, 음료, CU, GS25, EMART24);
final var 세븐일레븐 = 카테고리_세븐일레븐_생성();
복수_카테고리_저장(간편식사, 즉석조리, 과자류, 아이스크림, 식품, 음료, CU, GS25, EMART24, 세븐일레븐);

final var expected = List.of(CU, GS25, EMART24);
final var expected = List.of(CU, GS25, EMART24, 세븐일레븐);

// when
final var actual = categoryRepository.findAllByType(CategoryType.STORE);
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"babel-plugin-styled-components": "^2.1.4",
"copy-webpack-plugin": "^11.0.0",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.44.0",
"eslint-import-resolver-typescript": "^3.5.5",
Expand Down
10 changes: 5 additions & 5 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<meta property="og:url" content="https://funeat.site" />
<meta property="og:site_name" content="펀잇" />
<meta property="og:type" content="website" />
<meta property="og:image" content="assets/og-image.png" />
<meta property="og:image" content="/assets/og-image.png" />
<meta property="og:image:alt" content="펀잇" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="ko" />
<link rel="icon" href="./assets/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32x32.png" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-icon-180x180.png" />
<link rel="icon" href="/assets/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-icon-180x180.png" />
<title>펀잇</title>
</head>
<body>
Expand Down
Loading

0 comments on commit 0802eb8

Please sign in to comment.