Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,23 @@

@JsonNaming(value = SnakeCaseStrategy.class)
public record OwnerShopsResponse(
Long count,
Integer count,
List<InnerShopResponse> shops
) {

public static OwnerShopsResponse from(List<Shop> shops) {
return new OwnerShopsResponse(
(long) shops.size(),
shops.stream()
.map(InnerShopResponse::from)
.toList()
);
public static OwnerShopsResponse from(List<InnerShopResponse> shops) {
return new OwnerShopsResponse(shops.size(), shops);
}

@JsonNaming(value = SnakeCaseStrategy.class)
private record InnerShopResponse(
public record InnerShopResponse(
Long id,
String name
String name,
boolean isEvent
) {

public static InnerShopResponse from(Shop shop) {
return new InnerShopResponse(shop.getId(), shop.getName());
public static InnerShopResponse from(Shop shop, boolean isEvent) {
return new InnerShopResponse(shop.getId(), shop.getName(), isEvent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import in.koreatech.koin.domain.owner.repository.OwnerRepository;
import in.koreatech.koin.domain.ownershop.dto.OwnerShopsRequest;
import in.koreatech.koin.domain.ownershop.dto.OwnerShopsResponse;
import in.koreatech.koin.domain.ownershop.dto.OwnerShopsResponse.InnerShopResponse;
import in.koreatech.koin.domain.shop.dto.CreateCategoryRequest;
import in.koreatech.koin.domain.shop.dto.CreateMenuRequest;
import in.koreatech.koin.domain.shop.dto.MenuCategoriesResponse;
Expand Down Expand Up @@ -68,7 +69,12 @@ public class OwnerShopService {

public OwnerShopsResponse getOwnerShops(Long ownerId) {
List<Shop> shops = shopRepository.findAllByOwnerId(ownerId);
return OwnerShopsResponse.from(shops);
var innerShopResponses = shops.stream().map(shop -> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사기 자료형 ..발..

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦶

Boolean eventDuration = eventArticleRepository.isEvent(shop.getId(), LocalDate.now(clock));
return InnerShopResponse.from(shop, eventDuration);
})
.toList();
return OwnerShopsResponse.from(innerShopResponses);
}

@Transactional
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/in/koreatech/koin/domain/shop/dto/ShopsResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ public record ShopsResponse(
@Schema(description = "상점 정보")
List<InnerShopResponse> shops
) {
public static ShopsResponse from(List<Shop> shops) {
return new ShopsResponse(
shops.size(),
shops.stream().map(InnerShopResponse::from).toList()
);

public static ShopsResponse from(List<InnerShopResponse> shops) {
return new ShopsResponse(shops.size(), shops);
}

@JsonNaming(value = SnakeCaseStrategy.class)
private record InnerShopResponse(
public record InnerShopResponse(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service에서 InnerShop을 호출하기 위해 바꿨군요 Good~

@Schema(example = "0", description = " 속해있는 상점 카테고리들의 고유 id 리스트")
List<Long> categoryIds,

Expand All @@ -49,9 +47,13 @@ private record InnerShopResponse(
boolean payCard,

@Schema(example = "041-000-0000", description = "전화번호")
String phone
String phone,

@Schema(example = "true", description = "삭제 여부")
boolean isEvent
) {
public static InnerShopResponse from(Shop shop) {

public static InnerShopResponse from(Shop shop, boolean isEvent) {
return new InnerShopResponse(
shop.getShopCategories().stream().map(shopCategoryMap ->
shopCategoryMap.getShopCategory().getId()
Expand All @@ -62,7 +64,8 @@ public static InnerShopResponse from(Shop shop) {
shop.getShopOpens().stream().map(InnerShopOpen::from).toList(),
shop.getPayBank(),
shop.getPayCard(),
shop.getPhone()
shop.getPhone(),
isEvent
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import in.koreatech.koin.domain.shop.dto.ShopMenuResponse;
import in.koreatech.koin.domain.shop.dto.ShopResponse;
import in.koreatech.koin.domain.shop.dto.ShopsResponse;
import in.koreatech.koin.domain.shop.dto.ShopsResponse.InnerShopResponse;
import in.koreatech.koin.domain.shop.model.EventArticle;
import in.koreatech.koin.domain.shop.model.Menu;
import in.koreatech.koin.domain.shop.model.MenuCategory;
Expand Down Expand Up @@ -70,7 +71,12 @@ public ShopMenuResponse getShopMenus(Long shopId) {

public ShopsResponse getShops() {
List<Shop> shops = shopRepository.findAll();
return ShopsResponse.from(shops);
var innerShopResponses = shops.stream().map(shop -> {
Boolean eventDuration = eventArticleRepository.isEvent(shop.getId(), LocalDate.now(clock));
return InnerShopResponse.from(shop, eventDuration);
})
Comment on lines +74 to +77

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

람다식 Good

.toList();
return ShopsResponse.from(innerShopResponses);
}

public ShopCategoriesResponse getShopsCategories() {
Expand Down