-
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.
Merge pull request #34 from Digital-Hana-Starbucks/feature/menu
Feat: 카테고리 전체조회 API 작성 (#28)
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/hanaro/starbucks/dto/category/CategoryResDto.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,19 @@ | ||
package com.hanaro.starbucks.dto.category; | ||
|
||
import com.hanaro.starbucks.entity.Category; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class CategoryResDto { | ||
private int categoryIdx; | ||
|
||
private String categoryName; | ||
|
||
public CategoryResDto(Category category) { | ||
this.categoryIdx = category.getCategoryIdx(); | ||
this.categoryName = category.getCategoryName(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hanaro/starbucks/service/CategoryService.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,21 @@ | ||
package com.hanaro.starbucks.service; | ||
|
||
import com.hanaro.starbucks.dto.category.CategoryResDto; | ||
import com.hanaro.starbucks.entity.Category; | ||
import com.hanaro.starbucks.repository.CategoryRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CategoryService { | ||
private final CategoryRepository categoryRepository; | ||
|
||
public List<CategoryResDto> getCategoryList() { | ||
List<Category> categories = categoryRepository.findAll(); | ||
return categories.stream().map(CategoryResDto::new).collect(Collectors.toList()); | ||
} | ||
} |