-
Notifications
You must be signed in to change notification settings - Fork 2
feat: is_event값 추가 #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: is_event값 추가 #302
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package in.koreatech.koin.domain.shop.service; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
@@ -30,6 +32,7 @@ | |
| @RequiredArgsConstructor | ||
| public class ShopService { | ||
|
|
||
| private final Clock clock; | ||
| private final MenuRepository menuRepository; | ||
| private final MenuCategoryRepository menuCategoryRepository; | ||
| private final ShopRepository shopRepository; | ||
|
|
@@ -55,7 +58,8 @@ public MenuCategoriesResponse getMenuCategories(Long shopId) { | |
|
|
||
| public ShopResponse getShop(Long shopId) { | ||
| Shop shop = shopRepository.getById(shopId); | ||
| return ShopResponse.from(shop); | ||
| Boolean eventDuration = eventArticleRepository.isEvent(shopId, LocalDate.now(clock)); | ||
| return ShopResponse.from(shop, eventDuration); | ||
|
Comment on lines
+61
to
+62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good |
||
| } | ||
|
|
||
| public ShopMenuResponse getShopMenu(Long shopId) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| package in.koreatech.koin.acceptance; | ||
|
|
||
| import static in.koreatech.koin.domain.user.model.UserType.OWNER; | ||
| import static java.time.format.DateTimeFormatter.ofPattern; | ||
| import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import java.time.ZonedDateTime; | ||
| import java.util.List; | ||
|
|
||
| import org.assertj.core.api.SoftAssertions; | ||
|
|
@@ -43,6 +48,7 @@ | |
| import in.koreatech.koin.domain.user.model.User; | ||
| import in.koreatech.koin.domain.user.model.UserGender; | ||
| import in.koreatech.koin.global.auth.JwtProvider; | ||
| import in.koreatech.koin.support.JsonAssertions; | ||
| import io.restassured.RestAssured; | ||
| import io.restassured.http.ContentType; | ||
| import io.restassured.response.ExtractableResponse; | ||
|
|
@@ -93,6 +99,9 @@ class OwnerShopApiTest extends AcceptanceTest { | |
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| when(clock.instant()).thenReturn( | ||
| ZonedDateTime.parse("2024-02-21 18:00:00 KST", ofPattern("yyyy-MM-dd " + "HH:mm:ss z")).toInstant()); | ||
| when(clock.getZone()).thenReturn(Clock.systemDefaultZone().getZone()); | ||
|
|
||
| OwnerAttachment attachment = OwnerAttachment.builder() | ||
| .url("https://test.com/test.jpg") | ||
|
|
@@ -337,8 +346,8 @@ void getShop() { | |
| .dayOfWeek("FRIDAY") | ||
| .build(); | ||
|
|
||
| ShopOpen newShopOpen1 = shopOpenRepository.save(open1); | ||
| ShopOpen newShopOpen2 = shopOpenRepository.save(open2); | ||
| shopOpenRepository.save(open1); | ||
| shopOpenRepository.save(open2); | ||
|
Comment on lines
+349
to
+350
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다 여기 코드는 왜 인스턴스가 선언되어 있지...???
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 바꾸기 이전에는
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 복붙하면서 미사용코드 선언해둬서 미사용 변수 생략했습니다. |
||
|
|
||
| ShopCategoryMap shopCategoryMap1 = ShopCategoryMap.builder() | ||
| .shop(shop) | ||
|
|
@@ -350,8 +359,8 @@ void getShop() { | |
| .shopCategory(shopCategory2) | ||
| .build(); | ||
|
|
||
| ShopCategoryMap newShopCategoryMap1 = shopCategoryMapRepository.save(shopCategoryMap1); | ||
| ShopCategoryMap newShopCategoryMap2 = shopCategoryMapRepository.save(shopCategoryMap2); | ||
| shopCategoryMapRepository.save(shopCategoryMap1); | ||
| shopCategoryMapRepository.save(shopCategoryMap2); | ||
|
|
||
| ShopImage shopImage1 = ShopImage.builder() | ||
| .imageUrl("https://test.com/test1.jpg") | ||
|
|
@@ -363,14 +372,14 @@ void getShop() { | |
| .shop(shop) | ||
| .build(); | ||
|
|
||
| ShopImage newShopImage1 = shopImageRepository.save(shopImage1); | ||
| ShopImage newShopImage2 = shopImageRepository.save(shopImage2); | ||
| shopImageRepository.save(shopImage1); | ||
| shopImageRepository.save(shopImage2); | ||
|
|
||
| ExtractableResponse<Response> response = RestAssured | ||
| .given() | ||
| .header("Authorization", "Bearer " + token) | ||
| .when() | ||
| .get("/owner/shops/1") | ||
| .get("/owner/shops/{shopId}", shop.getId()) | ||
| .then() | ||
| .statusCode(HttpStatus.OK.value()) | ||
| .extract(); | ||
|
|
@@ -380,27 +389,53 @@ void getShop() { | |
| List<ShopOpen> savedShopOpens = shopOpenRepository.findAllByShopId(shop.getId()); | ||
| List<ShopCategoryMap> savedShopCategoryMaps = shopCategoryMapRepository.findAllByShopId(shop.getId()); | ||
|
|
||
| assertSoftly( | ||
| softly -> { | ||
| softly.assertThat(response.body().jsonPath().getString("address")).isEqualTo(shop.getAddress()); | ||
| softly.assertThat(response.body().jsonPath().getBoolean("delivery")).isEqualTo(shop.getDelivery()); | ||
| softly.assertThat(response.body().jsonPath().getLong("delivery_price")) | ||
| .isEqualTo(shop.getDeliveryPrice()); | ||
| softly.assertThat(response.body().jsonPath().getString("description")).isEqualTo(shop.getDescription()); | ||
| softly.assertThat(response.body().jsonPath().getLong("id")).isEqualTo(shop.getId()); | ||
| softly.assertThat(response.body().jsonPath().getString("name")).isEqualTo(shop.getName()); | ||
| softly.assertThat(response.body().jsonPath().getBoolean("pay_bank")).isEqualTo(shop.getPayBank()); | ||
| softly.assertThat(response.body().jsonPath().getBoolean("pay_card")).isEqualTo(shop.getPayCard()); | ||
| softly.assertThat(response.body().jsonPath().getString("phone")).isEqualTo(shop.getPhone()); | ||
|
|
||
| softly.assertThat(response.body().jsonPath().getList("image_urls")).hasSize(savedShopImages.size()); | ||
| softly.assertThat(response.body().jsonPath().getList("menu_categories")) | ||
| .hasSize(savedMenuCategories.size()); | ||
| softly.assertThat(response.body().jsonPath().getList("open")).hasSize(savedShopOpens.size()); | ||
| softly.assertThat(response.body().jsonPath().getList("shop_categories")) | ||
| .hasSize(savedShopCategoryMaps.size()); | ||
| } | ||
| ); | ||
| JsonAssertions.assertThat(response.asPrettyString()) | ||
| .isEqualTo(String.format(""" | ||
| { | ||
| "address": "대전광역시 유성구 대학로 291", | ||
| "delivery": true, | ||
| "delivery_price": 3000, | ||
| "description": "테스트 상점입니다.", | ||
| "id": 1, | ||
| "image_urls": [ | ||
| "https://test.com/test1.jpg", | ||
| "https://test.com/test2.jpg" | ||
| ], | ||
| "menu_categories": [ | ||
|
|
||
| ], | ||
| "name": "테스트 상점", | ||
| "open": [ | ||
| { | ||
| "day_of_week": "MONDAY", | ||
| "closed": false, | ||
| "open_time": "00:00", | ||
| "close_time": "21:00" | ||
| }, | ||
| { | ||
| "day_of_week": "FRIDAY", | ||
| "closed": false, | ||
| "open_time": "00:00", | ||
| "close_time": "00:00" | ||
| } | ||
| ], | ||
| "pay_bank": true, | ||
| "pay_card": true, | ||
| "phone": "010-1234-5678", | ||
| "shop_categories": [ | ||
| { | ||
| "id": 1, | ||
| "name": "테스트1" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "name": "테스트2" | ||
| } | ||
| ], | ||
| "updated_at": "%s", | ||
| "is_event": false | ||
| } | ||
| """, LocalDateTime.now().format(ofPattern("yyyy-MM-dd")))); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -656,7 +691,7 @@ void ownerCannotQueryOtherStoresWithoutPermission() { | |
| .given() | ||
| .header("Authorization", "Bearer " + otherOwnerToken) | ||
| .when() | ||
| .get("/owner/shops/1") | ||
| .get("/owner/shops/{shopId}", shop.getId()) | ||
| .then() | ||
| .statusCode(HttpStatus.FORBIDDEN.value()) | ||
| .extract(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service에서 clock now로 지금 시간 가져온담에 db의 start/enddate참조해서 그안에 있으면 참을 반환한다는 의민가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네넹