-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 메뉴 카테고리 조회 기능 구현 * refactor: 응답 DTO 생성 로직 수정 * refactor: cascade 처리 방식 변경 refactor: cascade 처리 방식 변경 * test: 테스트 문맥 변경 (cherry picked from commit 1130bfb)
- Loading branch information
1 parent
5e7a842
commit 8d6272d
Showing
6 changed files
with
128 additions
and
5 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
25 changes: 25 additions & 0 deletions
25
src/main/java/in/koreatech/koin/domain/shop/dto/MenuCategoriesResponse.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,25 @@ | ||
package in.koreatech.koin.domain.shop.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import in.koreatech.koin.domain.shop.model.MenuCategory; | ||
|
||
@JsonNaming(value = SnakeCaseStrategy.class) | ||
public record MenuCategoriesResponse(Long count, List<MenuCategoryResponse> menuCategories) { | ||
public static MenuCategoriesResponse from(List<MenuCategory> menuCategories) { | ||
List<MenuCategoryResponse> categories = menuCategories.stream() | ||
.map(menuCategory -> MenuCategoryResponse.of(menuCategory.getId(), menuCategory.getName())) | ||
.toList(); | ||
|
||
return new MenuCategoriesResponse((long)categories.size(), categories); | ||
} | ||
|
||
private record MenuCategoryResponse(Long id, String name) { | ||
public static MenuCategoryResponse of(Long id, String name) { | ||
return new MenuCategoryResponse(id, name); | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/in/koreatech/koin/domain/shop/repository/MenuCategoryRepository.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,13 @@ | ||
package in.koreatech.koin.domain.shop.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.repository.Repository; | ||
|
||
import in.koreatech.koin.domain.shop.model.MenuCategory; | ||
|
||
public interface MenuCategoryRepository extends Repository<MenuCategory, Long> { | ||
List<MenuCategory> findAllByShopId(Long shopId); | ||
|
||
MenuCategory save(MenuCategory menuCategory); | ||
} |
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