Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] refactor: 상품 랭킹 조회 시 Response에 카테고리 타입 추가 #421

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.funeat.product.domain;

public enum CategoryType {
FOOD, STORE
FOOD, STORE;

public static String convertToLowerCase(final CategoryType type) {
return type.name().toLowerCase();
}
wugawuga marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package com.funeat.product.dto;

import com.funeat.product.domain.CategoryType;
import com.funeat.product.domain.Product;

public class RankingProductDto {

private final Long id;
private final String name;
private final String image;
private final String categoryType;

public RankingProductDto(final Long id, final String name, final String image) {
public RankingProductDto(final Long id, final String name, final String image, final String categoryType) {
this.id = id;
this.name = name;
this.image = image;
this.categoryType = categoryType;
}

public static RankingProductDto toDto(final Product product) {
return new RankingProductDto(product.getId(), product.getName(), product.getImage());
return new RankingProductDto(product.getId(), product.getName(), product.getImage(),
CategoryType.convertToLowerCase(product.getCategory().getType()));
}

public Long getId() {
Expand All @@ -29,4 +33,8 @@ public String getName() {
public String getImage() {
return image;
}

public String getCategoryType() {
return categoryType;
}
}
Loading