-
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
✨ follow user #431
base: be/dev
Are you sure you want to change the base?
✨ follow user #431
Conversation
github-actions
bot
commented
Dec 5, 2024
•
edited by tackyu
Loading
edited by tackyu
- 유저 프로필 조회 시, 팔로잉, 팔로워 수 반환하도록 수정
- 유저 팔로우 구현
- 유저 언팔로우 구현
- 본인 계정의 팔로워 삭제 구현
- 유저 삭제에 따른 UserFollow 정리(팔로우 데이터 삭제, 팔로워, 팔로잉 수 수정)
|
0, | ||
0, | ||
user.getUserFollowerCount(), | ||
user.getUserFolloweeCount(), |
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.
follower과 followee... 하다가 게슈탈트 붕괴현상 일어나지 않았는지 걱정되네요 ㅋㅋㅋㅋ
고생하셨습니닷
몇 가지 의견 남겼어요~~~
@Column(nullable = false) | ||
@ColumnDefault("0") | ||
private long userFollowerCount; | ||
|
||
@Column(nullable = false) | ||
@ColumnDefault("0") | ||
private long userFolloweeCount; |
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.
변수명 앞에 user는 빼도 되지 않을까요???
+) 저희 DB 수정도 필요하겠네요....!!
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"follower_id", "followee_id"})}) |
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.
👍
public UserFollow(User follower, User followee) { | ||
this(0L, follower, followee); | ||
} |
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.
follower
와 followee
가 같은지 확인하지 않아도 될까요?
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.
좋네요. �유니크 키가 있긴 하지만 validate 함수를 만들어 검사하는것이 빠르게 예외를 발생시킬 방법인것 같아요
List<UserFollow> followings = userFollowRepository.findAllByFollowerId(userInfo.getId()); | ||
for (UserFollow userFollow : followings) { | ||
userFollow.getFollowee().decreaseUserFollowerCount(); | ||
userFollowRepository.delete(userFollow); | ||
} | ||
List<UserFollow> followers = userFollowRepository.findAllByFolloweeId(userInfo.getId()); | ||
for (UserFollow userFollow : followers) { | ||
userFollow.getFollower().decreaseUserFolloweeCount(); | ||
userFollowRepository.delete(userFollow); | ||
} |
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.
제가 보기에는 팔로우 수가 줄어드는게 맞는것 같아요. 👍
회의에서 이야기 해봅시다
assertAll( | ||
() -> assertThat(deletedUserFollower).isTrue(), | ||
() -> assertThat(deletedUserFollowee).isTrue() | ||
); |
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.
리뷰가 늦어졌네요.
폰드 고생했습니다.
몇가지 생각해볼것 적어봤습니다.
@Transactional | ||
public UserFollowResponse followUser(long followerId, long followeeId) { | ||
User follower = userRepository.findById(followerId) | ||
.orElseThrow(() -> new NotFoundException("팔로워 정보를 조회할 수 없습니다.")); |
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.
서비스 메서드가 재사용 가능하게 잘 만들어진것 같아요.
public UserFollow(User follower, User followee) { | ||
this(0L, follower, followee); | ||
} |
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.
좋네요. �유니크 키가 있긴 하지만 validate 함수를 만들어 검사하는것이 빠르게 예외를 발생시킬 방법인것 같아요
Optional<UserFollow> findByFollowerIdAndFolloweeId(Long followerId, Long followeeId); | ||
|
||
List<UserFollow> findAllByFollowerId(long followerId); | ||
|
||
List<UserFollow> findAllByFolloweeId(long followeeId); |
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.
UserFollow
도 authorAble을 구현해야 할까요?
사용자가 차단 한 상황에 팔로우 목록에서 보여줄지 고민이 필요할것 같아요.
또는 차단 했을때 팔로우를 지울지도 고민이 필요해보여요. 이 부분은 정책 회의때 이야기 해봐야 할것 같네요.
List<UserFollow> followings = userFollowRepository.findAllByFollowerId(userInfo.getId()); | ||
for (UserFollow userFollow : followings) { | ||
userFollow.getFollowee().decreaseUserFollowerCount(); | ||
userFollowRepository.delete(userFollow); | ||
} | ||
List<UserFollow> followers = userFollowRepository.findAllByFolloweeId(userInfo.getId()); | ||
for (UserFollow userFollow : followers) { | ||
userFollow.getFollower().decreaseUserFolloweeCount(); | ||
userFollowRepository.delete(userFollow); | ||
} |
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.
제가 보기에는 팔로우 수가 줄어드는게 맞는것 같아요. 👍
회의에서 이야기 해봅시다