Skip to content

Commit

Permalink
Refactor: ProductMealTypeResponse -> ProductBasicTypeResponse 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ku-kim committed Apr 25, 2022
1 parent b11552c commit 5810e2e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import sidedish.com.controller.model.ProductDetailTypeResponse;
import sidedish.com.controller.model.ProductMealTypeResponse;
import sidedish.com.controller.model.ProductBasicTypeResponse;
import sidedish.com.service.ProductsService;

@RestController
Expand All @@ -24,7 +24,7 @@ public ProductsController(ProductsService productsService) {
}

@GetMapping
public List<ProductMealTypeResponse> findProductsMealType(
public List<ProductBasicTypeResponse> findProductsMealType(
@RequestParam @NotEmpty String meal) {
return productsService.findByMealType(meal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
import java.util.stream.Collectors;
import org.springframework.stereotype.Component;
import sidedish.com.controller.model.ProductDetailTypeResponse;
import sidedish.com.controller.model.ProductMealTypeResponse;
import sidedish.com.controller.model.ProductBasicTypeResponse;
import sidedish.com.domain.Product;

@Component
public class ProductsDtoMapper {

public List<ProductMealTypeResponse> toProductsMealTypeResponseFromDomain(
public List<ProductBasicTypeResponse> toProductsMealTypeResponseFromDomain(
List<Product> products) {
return products.stream()
.map(this::toProductMealTypeResponseFromDomain)
.collect(Collectors.toList());
}

private ProductMealTypeResponse toProductMealTypeResponseFromDomain(
private ProductBasicTypeResponse toProductMealTypeResponseFromDomain(
Product product) {
return new ProductMealTypeResponse(
return new ProductBasicTypeResponse(
product.getId(),
product.getImages().get(0).getImageUrl(),
product.getProductName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Getter
@AllArgsConstructor
public class ProductMealTypeResponse {
public class ProductBasicTypeResponse {

private Long id;
private String image;
Expand Down
4 changes: 2 additions & 2 deletions BE/src/main/java/sidedish/com/service/ProductsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.stereotype.Service;
import sidedish.com.controller.ProductsDtoMapper;
import sidedish.com.controller.model.ProductDetailTypeResponse;
import sidedish.com.controller.model.ProductMealTypeResponse;
import sidedish.com.controller.model.ProductBasicTypeResponse;
import sidedish.com.domain.Product;
import sidedish.com.exception.NoSuchProductsException;
import sidedish.com.repository.DeliveryPolicyRepository;
Expand Down Expand Up @@ -36,7 +36,7 @@ public ProductsService(ProductsRepository productsRepository,
this.domainEntityMapper = domainEntityMapper;
}

public List<ProductMealTypeResponse> findByMealType(String meal) {
public List<ProductBasicTypeResponse> findByMealType(String meal) {
List<Product> products = domainEntityMapper.toDomainFromProductsEntity(
productsRepository.findByMealType(meal),
discountPolicyRepository.findAll(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import sidedish.com.controller.model.ProductDetailTypeResponse;
import sidedish.com.controller.model.ProductMealTypeResponse;
import sidedish.com.controller.model.ProductBasicTypeResponse;
import sidedish.com.domain.DeliveryPolicy;
import sidedish.com.domain.DiscountPolicy;
import sidedish.com.domain.Image;
Expand Down Expand Up @@ -62,7 +62,7 @@ class ProductsControllerTest {
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}

private List<ProductMealTypeResponse> createProductsMealTypeResponse() {
private List<ProductBasicTypeResponse> createProductsMealTypeResponse() {
List<Product> products = new ArrayList<>();

DiscountPolicy discountPolicy = new DiscountPolicy("이벤트특가", 20);
Expand Down

0 comments on commit 5810e2e

Please sign in to comment.