-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor | CAKK-57 | 케이크 도메인 로직 리팩토링 #203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ public CakeShopByMineResponse getMyBusinessId(final User user) { | |
return ShopMapper.supplyCakeShopByMineResponseBy(result); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
@Transactional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. readOnly를 제거한 이유는 뭘까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인증 정책을 통해 BusinessOwner인증 요청을 보내다보니 엔티티 변경 감지로 Update될 수 있기 때문입니다 |
||
public void requestCertificationBusinessOwner(final CertificationParam param) { | ||
final BusinessInformation businessInformation = cakeShopReader.findBusinessInformationByCakeShopId(param.cakeShopId()); | ||
final CertificationEvent certificationEvent = verificationPolicy | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.cakk.domain.mysql.facade.cake; | ||
|
||
import java.util.List; | ||
|
||
import com.cakk.domain.mysql.annotation.DomainFacade; | ||
import com.cakk.domain.mysql.entity.cake.Cake; | ||
import com.cakk.domain.mysql.entity.cake.CakeCategory; | ||
import com.cakk.domain.mysql.entity.cake.Tag; | ||
import com.cakk.domain.mysql.entity.shop.CakeShop; | ||
|
||
@DomainFacade | ||
public class CakeManagerFacade { | ||
|
||
public void createCake(CakeShop cakeShop, Cake cake, List<Tag> tags, List<CakeCategory> cakeCategories) { | ||
cake.registerTags(tags); | ||
cake.registerCategories(cakeCategories); | ||
cakeShop.registerCake(cake); | ||
} | ||
|
||
public void updateCake(Cake cake, String cakeImageUrl, List<Tag> tags, List<CakeCategory> cakeCategories) { | ||
cake.updateCakeImageUrl(cakeImageUrl); | ||
cake.updateCakeCategories(cakeCategories); | ||
cake.updateCakeTags(tags); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package com.cakk.domain.mysql.repository.reader; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import com.cakk.domain.mysql.annotation.Reader; | ||
import com.cakk.domain.mysql.entity.cake.Tag; | ||
import com.cakk.domain.mysql.mapper.TagMapper; | ||
import com.cakk.domain.mysql.repository.jpa.TagJpaRepository; | ||
|
||
@Reader | ||
|
@@ -17,4 +19,16 @@ public class TagReader { | |
public Optional<Tag> findByTagName(final String tagName) { | ||
return tagJpaRepository.findTagByTagName(tagName); | ||
} | ||
|
||
public List<Tag> getTagsByTagName(final List<String> tagNames) { | ||
List<Tag> tags = tagJpaRepository.findTagsByTagNameIsIn(tagNames); | ||
|
||
return tagNames.stream() | ||
.map(tagName -> tags | ||
.stream() | ||
.filter(tag -> tag.getTagName().equals(tagName)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tag에 대한 equals와 hashcode를 overriding 하여 비교하는건 어떨까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영하겠습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lcomment 근데 이 부분은 tagName:String 타입과 tag: Tag 타입 때문에 흠,, 해야 하는 이유가 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 제가 잘못 봤네요 ! 필요 없을 것 같습니다 |
||
.findAny() | ||
.orElse(tagJpaRepository.save(TagMapper.supplyTagBy(tagName)))) | ||
.toList(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 로직을 삭제한 이유는 뭘까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orphanremoval 옵션이 작동하고 있기 때문에 필요 없는 로직이 되었습니다