-
Notifications
You must be signed in to change notification settings - Fork 50
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 #19 from d-h-k/BE-Sally
[BE] 카테고리 DTO 생성 및 유틸 패키지 분리
- Loading branch information
Showing
10 changed files
with
220 additions
and
129 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
2 changes: 2 additions & 0 deletions
2
BE/side-dish-backend/src/main/java/com/codesquad/team14/domain/Item.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
48 changes: 0 additions & 48 deletions
48
BE/side-dish-backend/src/main/java/com/codesquad/team14/dto/DetailedItemDto.java
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
BE/side-dish-backend/src/main/java/com/codesquad/team14/dto/ItemDto.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
BE/side-dish-backend/src/main/java/com/codesquad/team14/dto/category/CategoryDto.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,38 @@ | ||
package com.codesquad.team14.dto.category; | ||
|
||
import com.codesquad.team14.domain.Category; | ||
import com.codesquad.team14.dto.item.ItemDto; | ||
|
||
import java.util.List; | ||
|
||
public class CategoryDto { | ||
private Long id; | ||
private String name; | ||
private List<ItemDto> items; | ||
|
||
private CategoryDto(Long id, String name, List<ItemDto> items) { | ||
this.id = id; | ||
this.name = name; | ||
this.items = items; | ||
} | ||
|
||
public static CategoryDto from(Category category) { | ||
return new CategoryDto( | ||
category.getId(), | ||
category.getName(), | ||
category.getItemDtoList() | ||
); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public List<ItemDto> getItems() { | ||
return items; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
BE/side-dish-backend/src/main/java/com/codesquad/team14/dto/item/DetailedItemDto.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,81 @@ | ||
package com.codesquad.team14.dto.item; | ||
|
||
import com.codesquad.team14.domain.Item; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DetailedItemDto { | ||
private final Long id; | ||
private final String topImage; | ||
private final List<String> thumbImages; | ||
private final String description; | ||
private final String deliveryInfo; | ||
private final String deliveryFee; | ||
private final int nPrice; | ||
private final int sPrice; | ||
private final int point; | ||
|
||
public DetailedItemDto(Long id, String topImage, List<String> thumbImages, String description, String deliveryInfo, | ||
String deliveryFee, int nPrice, int sPrice, int point) { | ||
this.id = id; | ||
this.topImage = topImage; | ||
this.thumbImages = thumbImages; | ||
this.description = description; | ||
this.deliveryInfo = deliveryInfo; | ||
this.deliveryFee = deliveryFee; | ||
this.nPrice = nPrice; | ||
this.sPrice = sPrice; | ||
this.point = point; | ||
} | ||
|
||
public static DetailedItemDto from(Item item) { | ||
return new DetailedItemDto( | ||
item.getId(), | ||
item.getImages().split(", ")[0], | ||
Arrays.asList(item.getImages().split(", ")), | ||
item.getDescription(), | ||
item.getDeliveryInfo(), | ||
item.getDeliveryFeePolicy(), | ||
item.getNPrice(), | ||
item.getSPrice(), | ||
item.getSPrice() / 100 | ||
); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTopImage() { | ||
return topImage; | ||
} | ||
|
||
public List<String> getThumbImages() { | ||
return thumbImages; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getDeliveryInfo() { | ||
return deliveryInfo; | ||
} | ||
|
||
public String getDeliveryFee() { | ||
return deliveryFee; | ||
} | ||
|
||
public int getnPrice() { | ||
return nPrice; | ||
} | ||
|
||
public int getsPrice() { | ||
return sPrice; | ||
} | ||
|
||
public int getPoint() { | ||
return point; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
BE/side-dish-backend/src/main/java/com/codesquad/team14/dto/item/ItemDto.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,75 @@ | ||
package com.codesquad.team14.dto.item; | ||
|
||
import com.codesquad.team14.domain.Item; | ||
import com.codesquad.team14.utils.Badge; | ||
|
||
import java.util.List; | ||
|
||
public class ItemDto { | ||
private Long id; | ||
private String topImage; | ||
private String deliveryTypes; | ||
private String title; | ||
private String description; | ||
private int nPrice; | ||
private int sPrice; | ||
private List<Badge> badges; | ||
|
||
private ItemDto(Long id, String image, String deliveryTypes, String title, | ||
String description, int nPrice, int sPrice, List<Badge> badges) { | ||
this.id = id; | ||
this.topImage = image; | ||
this.deliveryTypes = deliveryTypes; | ||
this.title = title; | ||
this.description = description; | ||
this.nPrice = nPrice; | ||
this.sPrice = sPrice; | ||
this.badges = badges; | ||
} | ||
|
||
public static ItemDto from(Item item) { | ||
return new ItemDto( | ||
item.getId(), | ||
item.getImages().split(", ")[0], | ||
item.getDeliveryTypes().toString(), | ||
item.getTitle(), | ||
item.getDescription(), | ||
item.getNPrice(), | ||
item.getSPrice(), | ||
item.getBadges() | ||
); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTopImage() { | ||
return topImage; | ||
} | ||
|
||
public String getDeliveryTypes() { | ||
return deliveryTypes; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public int getnPrice() { | ||
return nPrice; | ||
} | ||
|
||
public int getsPrice() { | ||
return sPrice; | ||
} | ||
|
||
public List<Badge> getBadges() { | ||
return badges; | ||
} | ||
|
||
} |
3 changes: 0 additions & 3 deletions
3
BE/side-dish-backend/src/main/java/com/codesquad/team14/repository/CategoryRepository.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 |
---|---|---|
@@ -1,12 +1,9 @@ | ||
package com.codesquad.team14.repository; | ||
|
||
import com.codesquad.team14.domain.Category; | ||
import com.codesquad.team14.domain.Item; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface CategoryRepository extends CrudRepository<Category, Long> { | ||
} |
Oops, something went wrong.