Skip to content

Commit

Permalink
Refactor | CAKK-82 | 코드 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
YongsHub committed Sep 16, 2024
1 parent 5d6a724 commit d4674e3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public ApiResponse<Void> updateBasicInformation(
@PathVariable Long cakeShopId,
@Valid @RequestBody UpdateShopRequest request
) {
//shopService.updateBasicInformation(request.toParam(user, cakeShopId));
shopService.updateBasicInformation(request.toParam(user, cakeShopId));

return ApiResponse.success();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public record UpdateShopRequest(
String shopDescription
) {

// public CakeShopUpdateParam toParam(User user, Long cakeShopId) {
// return CakeShopUpdateParam.builder()
// .user(user)
// .cakeShopId(cakeShopId)
// .thumbnailUrl(thumbnailUrl())
// .shopName(shopName())
// .shopBio(shopBio())
// .shopDescription(shopDescription())
// .build();
// }
public CakeShopUpdateParam toParam(User user, Long cakeShopId) {
return CakeShopUpdateParam.builder()
.user(user)
.cakeShopId(cakeShopId)
.thumbnailUrl(thumbnailUrl())
.shopName(shopName())
.shopBio(shopBio())
.shopDescription(shopDescription())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ class TagReadFacade(

fun getTagsByTagName(tagNames: List<String>): List<Tag> {
val tags: List<Tag> = tagJpaRepository.findTagsByTagNameIsIn(tagNames)
return tagNames.stream()
.map { tagName: String ->
tags
.stream()
.filter { tag: Tag -> tag.tagName == tagName }
.findAny()
.orElse(tagJpaRepository.save(TagMapper.supplyTagBy(tagName)))
}.toList()
return tagNames.map {
tags.find {
tag: Tag -> tag.tagName == it
} ?: tagJpaRepository.save(TagMapper.supplyTagBy(it))
}.toList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class UserManageFacade(
) {

fun create(user: User): User {
userJpaRepository.findByProviderId(user.providerId) ?: return userJpaRepository.save(user)
throw CakkException(ReturnCode.ALREADY_EXIST_USER)
userJpaRepository.findByProviderId(user.providerId)?.let {
throw CakkException(ReturnCode.ALREADY_EXIST_USER)
} ?: return userJpaRepository.save(user)
}

fun updateProfile(user: User, param: ProfileUpdateParam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class UserReadFacade(
}

fun findByIdWithAll(userId: Long): User {
val user: User = userQueryRepository.searchByIdWithAll(userId)
if (Objects.isNull(user)) {
throw CakkException(ReturnCode.NOT_EXIST_USER)
}
return user
return userQueryRepository.searchByIdWithAll(userId) ?: throw CakkException(ReturnCode.NOT_EXIST_USER)
}

fun findAll(): List<User> {
Expand Down

0 comments on commit d4674e3

Please sign in to comment.