-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
187 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ build/ | |
|
||
### yml | ||
**/application-infra-rdb.yml | ||
**/application-security.yml | ||
|
||
### STS ### | ||
.apt_generated | ||
|
116 changes: 0 additions & 116 deletions
116
api/src/main/java/com/mm/api/Item/service/ItemService.java
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
...m/api/Item/controller/ItemController.java → ...m/api/item/controller/ItemController.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
2 changes: 1 addition & 1 deletion
2
...i/Item/dto/request/ItemCreateRequest.java → ...i/item/dto/request/ItemCreateRequest.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
2 changes: 1 addition & 1 deletion
2
...i/Item/dto/request/ItemUpdateRequest.java → ...i/item/dto/request/ItemUpdateRequest.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,4 +1,4 @@ | ||
package com.mm.api.Item.dto.request; | ||
package com.mm.api.item.dto.request; | ||
|
||
import java.util.List; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...Item/dto/response/ItemDetailResponse.java → ...item/dto/response/ItemDetailResponse.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
6 changes: 1 addition & 5 deletions
6
...m/api/Item/dto/response/ItemResponse.java → ...m/api/item/dto/response/ItemResponse.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
122 changes: 122 additions & 0 deletions
122
api/src/main/java/com/mm/api/item/service/ItemService.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,122 @@ | ||
package com.mm.api.item.service; | ||
|
||
import static com.mm.api.exception.ErrorCode.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.mm.api.exception.CustomException; | ||
import com.mm.api.item.dto.request.ItemCreateRequest; | ||
import com.mm.api.item.dto.request.ItemUpdateRequest; | ||
import com.mm.api.item.dto.response.ItemDetailResponse; | ||
import com.mm.api.item.dto.response.ItemResponse; | ||
import com.mm.coredomain.domain.Item; | ||
import com.mm.coredomain.domain.ItemCategoryType; | ||
import com.mm.coredomain.domain.ItemImage; | ||
import com.mm.coredomain.domain.ItemUpdate; | ||
import com.mm.coredomain.domain.ItemVideo; | ||
import com.mm.coredomain.repository.ItemRepository; | ||
import com.mm.coreinfraqdsl.repository.ItemCustomRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class ItemService { | ||
private final ItemRepository itemRepository; | ||
private final ItemCustomRepository itemCustomRepository; | ||
|
||
public ItemResponse createItem(ItemCreateRequest request) { | ||
Item item = request.toEntity(); | ||
|
||
List<ItemImage> itemImages = getItemImages(request.imageUrls(), item); | ||
List<ItemVideo> itemVideos = getItemVideos(request.videoUrls(), item); | ||
|
||
item.setItemImages(itemImages); | ||
item.setItemVideos(itemVideos); | ||
|
||
Item savedItem = itemRepository.save(item); | ||
return ItemResponse.of(savedItem); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<ItemResponse> getItems(Integer page) { | ||
List<Item> items = itemCustomRepository.getItemsByPage(page); | ||
|
||
return items.stream() | ||
.map(ItemResponse::of) | ||
.toList(); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public ItemDetailResponse getItemDetail(Long id) { | ||
Item item = itemRepository.findById(id) | ||
.orElseThrow(() -> new CustomException(ITEM_NOT_FOUND)); | ||
|
||
List<String> images = item.getItemImages().stream() | ||
.map(ItemImage::getUrl) | ||
.toList(); | ||
List<String> videos = item.getItemVideos().stream() | ||
.map(ItemVideo::getUrl) | ||
.toList(); | ||
|
||
return ItemDetailResponse.of(item, images, videos); | ||
} | ||
|
||
public ItemResponse updateItem(Long id, ItemUpdateRequest request) { | ||
Item item = itemRepository.findById(id) | ||
.orElseThrow(() -> new CustomException(ITEM_NOT_FOUND)); | ||
|
||
ItemUpdate itemUpdate = getItemUpdate(request); | ||
item.updateItem(itemUpdate); | ||
|
||
List<ItemImage> itemImages = getItemImages(request.imageUrls(), item); | ||
List<ItemVideo> itemVideos = getItemVideos(request.videoUrls(), item); | ||
|
||
item.setItemImages(itemImages); | ||
item.setItemVideos(itemVideos); | ||
|
||
return ItemResponse.of(item); | ||
} | ||
|
||
public void deleteItem(Long id) { | ||
itemRepository.deleteById(id); | ||
} | ||
|
||
private ItemUpdate getItemUpdate(ItemUpdateRequest request) { | ||
return ItemUpdate.builder() | ||
.detail(request.detail()) | ||
.redirectUrl(request.redirectUrl()) | ||
.categoryType(ItemCategoryType.of(request.categoryType())) | ||
.price(request.price()) | ||
.refund(request.refund()) | ||
.rating(request.rating()) | ||
.thumbnailUrl(request.thumbnailUrl()) | ||
.build(); | ||
} | ||
|
||
private List<ItemVideo> getItemVideos(List<String> videoUrls, Item item) { | ||
return videoUrls | ||
.stream() | ||
.map(url -> | ||
ItemVideo.builder() | ||
.url(url) | ||
.item(item) | ||
.build()) | ||
.toList(); | ||
} | ||
|
||
private List<ItemImage> getItemImages(List<String> imageUrls, Item item) { | ||
return imageUrls | ||
.stream() | ||
.map(url -> | ||
ItemImage.builder() | ||
.url(url) | ||
.item(item) | ||
.build()) | ||
.toList(); | ||
} | ||
} |
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
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,17 @@ | ||
// 실행가능한 jar로 생성하는 옵션, main이 없는 라이브러리에서는 false로 비활성화함 | ||
// 스프링 부트 2.0 이상이라면 bootRepackage.enabled를 사용해야 함 | ||
bootJar { enabled = false } | ||
|
||
// 외부에서 의존하기 위한 jar로 생성하는 옵션, main이 없는 라이브러리에서는 true로 비활성화함 | ||
jar { enabled = true } | ||
|
||
dependencies { | ||
implementation project(':core:core-domain'); | ||
|
||
// security | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' | ||
implementation 'io.jsonwebtoken:jjwt-api:0.12.3' | ||
implementation 'io.jsonwebtoken:jjwt-impl:0.12.3' | ||
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.3' | ||
} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
13 changes: 13 additions & 0 deletions
13
core/core-security/src/main/java/com/example/coresecurity/CoreSecurityApplication.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,13 @@ | ||
package com.example.coresecurity; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class CoreSecurityApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(CoreSecurityApplication.class, args); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
core/core-security/src/test/java/com/example/coresecurity/CoreSecurityApplicationTests.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,13 @@ | ||
package com.example.coresecurity; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class CoreSecurityApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
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