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

✨ follow user #431

Open
wants to merge 10 commits into
base: be/dev
Choose a base branch
from
Open

✨ follow user #431

wants to merge 10 commits into from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 5, 2024

  1. 유저 프로필 조회 시, 팔로잉, 팔로워 수 반환하도록 수정
  2. 유저 팔로우 구현
  3. 유저 언팔로우 구현
  4. 본인 계정의 팔로워 삭제 구현
  5. 유저 삭제에 따른 UserFollow 정리(팔로우 데이터 삭제, 팔로워, 팔로잉 수 수정)

@github-actions github-actions bot added ✨ feature new feature BE Backend labels Dec 5, 2024
Copy link
Contributor Author

Overall Project 89.94% -0.57% 🍏
Files changed 89.82% 🍏

File Coverage
UserController.java 100% 🍏
UserFollowResponse.java 100% 🍏
UserFollowRequest.java 100% 🍏
ProfileResponse.java 100% 🍏
User.java 96.41% 🍏
UserService.java 90.04% -5.53% 🍏
UserFollow.java 90% -10% 🍏

Comment on lines -27 to +28
0,
0,
user.getUserFollowerCount(),
user.getUserFolloweeCount(),
Copy link
Contributor

Choose a reason for hiding this comment

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

팔로우 여부를 필드로 추가해야 하겠어요!

Copy link
Contributor

@hyxrxn hyxrxn left a comment

Choose a reason for hiding this comment

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

follower과 followee... 하다가 게슈탈트 붕괴현상 일어나지 않았는지 걱정되네요 ㅋㅋㅋㅋ
고생하셨습니닷
몇 가지 의견 남겼어요~~~

Comment on lines +43 to +49
@Column(nullable = false)
@ColumnDefault("0")
private long userFollowerCount;

@Column(nullable = false)
@ColumnDefault("0")
private long userFolloweeCount;
Copy link
Contributor

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"})})
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +35 to +37
public UserFollow(User follower, User followee) {
this(0L, follower, followee);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

followerfollowee가 같은지 확인하지 않아도 될까요?

Choose a reason for hiding this comment

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

좋네요. �유니크 키가 있긴 하지만 validate 함수를 만들어 검사하는것이 빠르게 예외를 발생시킬 방법인것 같아요

Comment on lines +139 to +148
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);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

생각해보니 유저가 탈퇴했을 때 좋아요 개수는 변하지 않지만 팔로우 개수는 변하는군요...!!!
다음 회의 때 이야기해보면 좋을 것 같아요

Choose a reason for hiding this comment

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

제가 보기에는 팔로우 수가 줄어드는게 맞는것 같아요. 👍
회의에서 이야기 해봅시다

Comment on lines +304 to +307
assertAll(
() -> assertThat(deletedUserFollower).isTrue(),
() -> assertThat(deletedUserFollowee).isTrue()
);
Copy link
Contributor

Choose a reason for hiding this comment

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

위 코멘트랑 관련있는데 삭제시 팔로워/팔로이의 숫자가 변하는게 정책이라면 이를 함께 확인하지 않아도 될까요?

Copy link

@HaiSeong HaiSeong 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 +152 to +155
@Transactional
public UserFollowResponse followUser(long followerId, long followeeId) {
User follower = userRepository.findById(followerId)
.orElseThrow(() -> new NotFoundException("팔로워 정보를 조회할 수 없습니다."));

Choose a reason for hiding this comment

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

서비스 메서드가 재사용 가능하게 잘 만들어진것 같아요.

Comment on lines +35 to +37
public UserFollow(User follower, User followee) {
this(0L, follower, followee);
}

Choose a reason for hiding this comment

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

좋네요. �유니크 키가 있긴 하지만 validate 함수를 만들어 검사하는것이 빠르게 예외를 발생시킬 방법인것 같아요

Comment on lines +10 to +14
Optional<UserFollow> findByFollowerIdAndFolloweeId(Long followerId, Long followeeId);

List<UserFollow> findAllByFollowerId(long followerId);

List<UserFollow> findAllByFolloweeId(long followeeId);

Choose a reason for hiding this comment

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

UserFollow 도 authorAble을 구현해야 할까요?
사용자가 차단 한 상황에 팔로우 목록에서 보여줄지 고민이 필요할것 같아요.

또는 차단 했을때 팔로우를 지울지도 고민이 필요해보여요. 이 부분은 정책 회의때 이야기 해봐야 할것 같네요.

Comment on lines +139 to +148
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);
}

Choose a reason for hiding this comment

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

제가 보기에는 팔로우 수가 줄어드는게 맞는것 같아요. 👍
회의에서 이야기 해봅시다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Backend ✨ feature new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants