Skip to content

Commit

Permalink
[#17] refactor: Renaming Dish to Item
Browse files Browse the repository at this point in the history
- Mockup API의 네이밍에 맞게 Dish라는 명칭을 Item으로 수정
  • Loading branch information
jihye-woo committed Apr 22, 2021
1 parent 7b99539 commit 971b284
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.team15.sidedish.controller;

import com.team15.sidedish.dto.ItemDTO;
import com.team15.sidedish.service.DishService;
import com.team15.sidedish.service.ItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -11,12 +11,12 @@
import java.util.List;

@RestController
public class DishController {
private final Logger logger = LoggerFactory.getLogger(DishController.class);
private final DishService dishService;
public class ItemController {
private final Logger logger = LoggerFactory.getLogger(ItemController.class);
private final ItemService itemService;

public DishController(DishService dishService) {
this.dishService = dishService;
public ItemController(ItemService itemService) {
this.itemService = itemService;
}

@GetMapping("/dishes")
Expand All @@ -28,13 +28,13 @@ public List<ItemDTO> showDishByHash() {
@GetMapping("/dish/{hash}")
public ItemDTO showSingleDish(@PathVariable String hash) {
logger.info("Show single dish by hash");
return dishService.showSingleDish(hash);
return itemService.showSingleDish(hash);

}

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.Optional;

public interface DishRepository extends CrudRepository<ItemDTO, String> {
public interface ItemRepository extends CrudRepository<ItemDTO, String> {

@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 e.`dish_hash`=:hash")
@Override
Expand Down
28 changes: 0 additions & 28 deletions backend/src/main/java/com/team15/sidedish/service/DishService.java

This file was deleted.

28 changes: 28 additions & 0 deletions backend/src/main/java/com/team15/sidedish/service/ItemService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.team15.sidedish.service;

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

import java.util.List;

@Service
public class ItemService {
private final ItemRepository itemRepository;

public ItemService(ItemRepository itemRepository) {
this.itemRepository = itemRepository;
}

public List<ItemDTO> showDishes() {
return itemRepository.findAll();
}

public ItemDTO showSingleDish(String hash) {
return itemRepository.findById(hash).orElseThrow(IllegalArgumentException::new);
}

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

0 comments on commit 971b284

Please sign in to comment.