Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -40,6 +40,8 @@ public AdminItemResDto createItem(AdminItemReqDto reqDto) throws IOException {
path = path.equals("decor_two") ? "decor2" : path;
path = path.equals("decor_one") ? "decor1" : path;

path = path.equals("letter_paper") ? "letter" : path;

// ์ด๋ฏธ์ง€ s3์— ์—…๋กœ๋“œ
String imageUrl = s3ImageService.upload(reqDto.file(),path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public SliceResponse<ShopItemInfoResDto> getItemSlice(Long userId, ItemCategory
*/
return SliceResponse.of(sliceEntity, item -> {
Boolean isPurchased = userItemMap.containsKey(item.getId());
return itemMapper.toShopItemInfoResDto(item, getShopCloudFrontDomain(), getMyCloudFrontDomain(), isPurchased, userItemMap.getOrDefault(item.getId(), false));
return itemMapper.toShopItemInfoResDto(item, getCloudFrontDomainByCategory(item.getCategory()), getMyCloudFrontDomain(), isPurchased, userItemMap.getOrDefault(item.getId(), false));
});
}

Expand Down Expand Up @@ -131,7 +131,7 @@ public ItemInfoResDto purchaseItem(Long userId, PurchaseItemReqDto reqDto){

log.info("[ShopService] purchaseItem End - userId: {}", userId);
// 4. ์•„์ดํ…œ ๊ตฌ๋งค ํ›„, ํ•ด๋‹น ์•„์ดํ…œ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
return userItemMapper.toItemInfoResDto(userItem, item, getShopCloudFrontDomain());
return userItemMapper.toItemInfoResDto(userItem, item, getCloudFrontDomainByCategory(item.getCategory()));
}

/**
Expand All @@ -157,7 +157,8 @@ public ItemInfoResDto equipItem(Long userId, EquipItemReqDto reqDto) {

// 2. ๋ฉฑ๋“ฑ์„ฑ ์ฒดํฌ: ์ด๋ฏธ ์›ํ•˜๋Š” ์ƒํƒœ๋ผ๋ฉด DB ๋ณ€๊ฒฝ ์—†์ด ๋ฐ”๋กœ ๋ฐ˜ํ™˜ (๋ถˆํ•„์š”ํ•œ ์ฟผ๋ฆฌ ๋ฐฉ์ง€)
if (targetUserItem.getIsEquipped() == targetStatus) {
return userItemMapper.toItemInfoResDto(targetUserItem, targetUserItem.getItem(), cloudfrontDomain);
return userItemMapper.toItemInfoResDto(targetUserItem, targetUserItem.getItem(),
getCloudFrontDomainByCategory(targetUserItem.getItem().getCategory()));
}

/*
Expand Down Expand Up @@ -187,7 +188,8 @@ public ItemInfoResDto equipItem(Long userId, EquipItemReqDto reqDto) {

log.info("[ShopService] equipItem End - userId: {}", userId);
// 4. ๋ณ€๊ฒฝ๋œ ์ •๋ณด ๋ฐ˜ํ™˜
return userItemMapper.toItemInfoResDto(targetUserItem, targetUserItem.getItem(), getMyCloudFrontDomain());
return userItemMapper.toItemInfoResDto(targetUserItem, targetUserItem.getItem(),
getCloudFrontDomainByCategory(targetUserItem.getItem().getCategory()));
}

/**
Expand All @@ -202,7 +204,8 @@ public List<ItemInfoResDto> getEquippedItems(Long userId){
log.info("[ShopService] getEquippedItems End - userId: {}", userId);
// 2. ์กฐํšŒํ•ด์˜จ ๊ฐ ์•„์ดํ…œ์„ dto๋กœ ๋ณ€ํ™˜ (Fetch Join ์ผ์œผ๋ฏ€๋กœ N+1 ๋ฐœ์ƒ ์•ˆํ•จ)
return equippedItems.stream()
.map(userItem -> userItemMapper.toItemInfoResDto(userItem, userItem.getItem(), getMyCloudFrontDomain()))
.map(userItem -> userItemMapper.toItemInfoResDto(userItem, userItem.getItem(),
getCloudFrontDomainByCategory(userItem.getItem().getCategory())))
.toList();
}

Expand All @@ -212,4 +215,11 @@ private String getShopCloudFrontDomain(){
private String getMyCloudFrontDomain(){
return cloudfrontDomain+"/my";
}
}

private String getCloudFrontDomainByCategory(ItemCategory category) {
return switch (category) {
case LETTER_PAPER -> cloudfrontDomain + "/letter";
default -> cloudfrontDomain + "/shop";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ItemInitializer implements ApplicationRunner {
String PATH_DECOR_TWO = "decor2";
String PATH_BACKGROUND = "background";

String PATH_LETTER_PAPER = "letter";

@Override
@Transactional
Expand Down Expand Up @@ -170,9 +171,22 @@ private List<Item> getInitItemList(){
items.add(buildBackgroundItem("Blossom.png", 750));
items.add(buildBackgroundItem("Beach.png", 1000));



items.add(buildLetterPaperItem("Blue.png", 150));
items.add(buildLetterPaperItem("Green.png", 100));
items.add(buildLetterPaperItem("Pink.png", 75));
items.add(buildLetterPaperItem("Purple.png", 175));


return items;
}


private Item buildLetterPaperItem(String name, Integer price) {
return buildItem(PATH_LETTER_PAPER, ItemCategory.LETTER_PAPER, name, price);
}

/**
* 1. Back ์•„์ดํ…œ ์ƒ์„ฑ ํ•จ์ˆ˜
*/
Expand Down
Loading