Skip to content
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

[feat] 관심 목록 변경 API #76

Merged
merged 7 commits into from
Aug 7, 2023
Merged

Conversation

chaerlo127
Copy link
Collaborator

🌱 이슈 번호

close #60


💬 기타 사항

  • 아래 커멘트 확인 부탁!
  • 바람니다

@chaerlo127 chaerlo127 added 🔮 feat 기능을 생성해요 ! 🐣 chae-eun 채은이가 만든 기능이에요 ! 👩🏻‍💻 users 사용자 도메인 기능이에요 ! labels Aug 6, 2023
@chaerlo127 chaerlo127 self-assigned this Aug 6, 2023
@@ -28,7 +28,7 @@ class ProductService(
var interestCategoryList: MutableList<Category> = ArrayList()
if(category.isEmpty()) {
// 유저의 관심목록
val userInterestList = userInterestRepository.findByUser(user);
val userInterestList = userInterestRepository.findByUserAndStatus(user, ACTIVE_STATUS);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 status 확인이 필요한 것 같아서 userInterestRepository method 변경하는 김에 한번에 변경해뒀슴니당
@sojungpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고맘머(하트

Comment on lines +219 to +236
// 사용자 관심 목록에 최근 추가한 리스트(REQUEST) 관심 목록이 없다면? => 저장
reqLists.stream()
.forEach { interest ->
if(!categoryLists.contains(interest)) {
// 과거에 삭제했던 경우 / 새롭게 생성하는 경우
val interestE = userInterestRepository.findByUserAndCategory(user, interest)?: userAssembler.toInterestEntity(user, interest)
interestE.status = ACTIVE_STATUS
userInterestRepository.save(interestE)
}
}

// 최근 추가한 리스트(REQUEST)에 사용자 관심 목록이 없다면? => 삭제
userWatchLists.stream()
.forEach { interest ->
// todo: cascade 적용 후 모두 삭제 되었는지 확인 필요
if(!reqLists.contains(interest.category)) userInterestRepository.delete(interest)
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스크린샷 2023-08-07 오전 2 24 56

다음과 같이 리스트 확인 후 수정하는 로직을 구상해보았슴니당

출처 클릭

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 깔끔하게 가능하군요!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋다줍줍

@@ -80,6 +81,7 @@ class UserService(
}

// 로그인
@Transactional
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가하지 못했던 Transactional 추가,, 🌞

Copy link
Member

@psyeon1120 psyeon1120 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤗

Comment on lines +219 to +236
// 사용자 관심 목록에 최근 추가한 리스트(REQUEST) 관심 목록이 없다면? => 저장
reqLists.stream()
.forEach { interest ->
if(!categoryLists.contains(interest)) {
// 과거에 삭제했던 경우 / 새롭게 생성하는 경우
val interestE = userInterestRepository.findByUserAndCategory(user, interest)?: userAssembler.toInterestEntity(user, interest)
interestE.status = ACTIVE_STATUS
userInterestRepository.save(interestE)
}
}

// 최근 추가한 리스트(REQUEST)에 사용자 관심 목록이 없다면? => 삭제
userWatchLists.stream()
.forEach { interest ->
// todo: cascade 적용 후 모두 삭제 되었는지 확인 필요
if(!reqLists.contains(interest.category)) userInterestRepository.delete(interest)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 깔끔하게 가능하군요!!

Copy link
Member

@sojungpp sojungpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨슴니단 !!!!!!

@chaerlo127 chaerlo127 merged commit 7cf5949 into develop Aug 7, 2023
1 check passed
@chaerlo127 chaerlo127 deleted the feat/#60-patchWatchLists branch August 17, 2023 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐣 chae-eun 채은이가 만든 기능이에요 ! 🔮 feat 기능을 생성해요 ! 👩🏻‍💻 users 사용자 도메인 기능이에요 !
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 관심 목록 변경 API
3 participants