Skip to content

Commit

Permalink
[#17] feature: Add showDishsBySection method
Browse files Browse the repository at this point in the history
- 특정 section에 속한 dish 데이터를 가져오는 기능 구현
  - DishController::showDishsBySection 메소드 구현
  - DishService::showDishsBySection 메소드 구현
  - DishRepository::findAllBySection 구현 및 커스텀 쿼리 추가
  • Loading branch information
jihye-woo committed Apr 22, 2021
1 parent d1532bc commit 7b99539
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public ItemDTO showSingleDish(@PathVariable String hash) {

}

// @GetMapping("/dish/{sectionName}")
// public List<Dish> showDishesBySectionName(@PathVariable String sectionName) {
// return dishService.showDishesBySectionName(sectionName);
// }
@GetMapping("/{section}")
public List<ItemDTO> showDishsBySection(@PathVariable String section){
return dishService.showDishsBySection(section);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public interface DishRepository extends CrudRepository<ItemDTO, String> {
@Override
List<ItemDTO> findAll();

@Query("select di.`hash` AS `detail_hash`, di.`top_image` AS `image`, di.`title` AS `alt`, de.`delivery_type`, di.`title`, di.`description`, di.`n_price`, di.`s_price`, e.`badge` from dish di JOIN delivery de on di.`hash` = de.`dish_hash` LEFT OUTER JOIN `event` e on e.`dish_hash` = di.`hash` where di.`section_name` LIKE CONCAT('%', :section, '%')")
List<ItemDTO> findAllBySection(String section);

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.team15.sidedish.dto;

import com.team15.sidedish.domain.Dish;

import java.util.Set;

public class BestResponseDTO {
Expand All @@ -28,7 +26,4 @@ public String getName() {
public Set<ItemDTO> getDishes() {
return dishes;
}



}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.team15.sidedish.service;

import com.team15.sidedish.domain.Dish;
import com.team15.sidedish.domain.DishRepository;
import com.team15.sidedish.dto.ItemDTO;
import org.springframework.stereotype.Service;

import java.security.PublicKey;
import java.util.List;

@Service
Expand All @@ -24,8 +22,7 @@ public ItemDTO showSingleDish(String hash) {
return dishRepository.findById(hash).orElseThrow(IllegalArgumentException::new);
}

// public List<Dish> showDishesBySectionName(String sectionName) {
// return dishRepository.findAllBySectionName(sectionName);
// }

public List<ItemDTO> showDishsBySection(String section) {
return dishRepository.findAllBySection(section);
}
}

0 comments on commit 7b99539

Please sign in to comment.