Skip to content

Commit

Permalink
[refac] apply code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Parkjyun committed Jul 13, 2024
1 parent bd1b60c commit e2c4971
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class StoreController {
private final HeartCommandService heartCommandService;

@GetMapping("/stores/{id}")
public HankkiResponse<StoreGetResponse> getStore(@PathVariable Long id) {
public HankkiResponse<StoreGetResponse> getStore(@PathVariable final Long id) {
return HankkiResponse.success(CommonSuccessCode.OK, storeQueryService.getStoreInformation(id));
}

@GetMapping("/stores/{id}/thumbnail")
public HankkiResponse<StoreThumbnailResponse> getStoreThumbnail(@PathVariable Long id) {
public HankkiResponse<StoreThumbnailResponse> getStoreThumbnail(@PathVariable final Long id) {
return HankkiResponse.success(CommonSuccessCode.OK, storeQueryService.getStoreThumbnail(id));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public Store getStoreReference(final Long id) {
return storeRepository.getReferenceById(id);
}

protected Store findByIdWhereDeletedIsFalse(Long id) {
protected Store findByIdWhereDeletedIsFalse(final Long id) {
return storeRepository.findByIdAndIsDeletedIsFalse(id)
.orElseThrow(() -> new NotFoundException(StoreErrorCode.STORE_NOT_FOUND));
}

protected Store findByIdWithHeartAndIsDeletedFalse(Long id) {
protected Store findByIdWithHeartAndIsDeletedFalse(final Long id) {
return storeRepository.findByIdWithHeartAndIsDeletedFalse(id)
.orElseThrow(() -> new NotFoundException(StoreErrorCode.STORE_NOT_FOUND));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.hankki.hankkiserver.api.store.service.response.*;
import org.hankki.hankkiserver.domain.store.model.Store;
import org.hankki.hankkiserver.domain.store.model.StoreCategory;
import org.hankki.hankkiserver.domain.store.model.StoreImage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -22,12 +23,12 @@ public class StoreQueryService {
private final MenuFinder menuFinder;

@Transactional(readOnly = true)
public StoreThumbnailResponse getStoreThumbnail(Long id) {
public StoreThumbnailResponse getStoreThumbnail(final Long id) {
return StoreThumbnailResponse.of(storeFinder.findByIdWhereDeletedIsFalse(id));
}

@Transactional(readOnly = true)
public StoreGetResponse getStoreInformation(Long id) {
public StoreGetResponse getStoreInformation(final Long id) {

Store store = storeFinder.findByIdWithHeartAndIsDeletedFalse(id);

Expand Down Expand Up @@ -55,17 +56,17 @@ public PriceCategoriesResponse getPriceCategories() {
.toList());
}

private List<String> getImageUrlsFromStore(Store store) {
private List<String> getImageUrlsFromStore(final Store store) {
return store.getImages().stream()
.map(storeImage -> storeImage.getImageUrl())
.map(StoreImage::getImageUrl)
.toList();
}

private List<MenuResponse> getMenus(Store store) {
private List<MenuResponse> getMenus(final Store store) {
return menuFinder.findAllByStore(store).stream().map(MenuResponse::of).toList();
}

private boolean isLiked(Long id, Store store) {
private boolean isLiked(final Long id, final Store store) {
return store.getHearts().stream().anyMatch(heart -> heart.getUser().getId().equals(id));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public record StoreGetResponse(
List<String> imageUrls,
List<MenuResponse> menus
) {
public static StoreGetResponse of(Store store, boolean isLiked, List<String> imageUrls, List<MenuResponse> menus) {
public static StoreGetResponse of(final Store store, final boolean isLiked, final List<String> imageUrls, final List<MenuResponse> menus) {
return new StoreGetResponse(store.getName(),
store.getCategory().getName(),
store.getHeartCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public record StoreThumbnailResponse(
int lowestPrice,
int heartCount
) {
public static StoreThumbnailResponse of(Store store) {
public static StoreThumbnailResponse of(final Store store) {
return new StoreThumbnailResponse(
store.getId(),
store.getName(),
Expand Down

0 comments on commit e2c4971

Please sign in to comment.