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

πŸ› Fix: μ΄ˆλŒ€μž₯ μˆ˜λ½μ€ ν–ˆλŠ”λ° Memberκ°€ μ—†λŠ” κ²½μš°λ„ κ³ λ € #140

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import treehouse.server.api.branch.business.BranchService;
import treehouse.server.api.invitation.implement.InvitationCommandAdapter;
import treehouse.server.api.invitation.implement.InvitationQueryAdapter;
import treehouse.server.api.invitation.presentation.dto.InvitationRequestDTO;
Expand All @@ -21,7 +20,6 @@
import treehouse.server.global.entity.treeHouse.TreeHouse;
import treehouse.server.global.exception.GlobalErrorCode;
import treehouse.server.global.exception.ThrowClass.InvitationException;
import treehouse.server.global.exception.ThrowClass.UserException;

import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -50,7 +48,7 @@ public class InvitationService {
@Transactional
public InvitationResponseDTO.getInvitations getInvitations(User user) {

List<Invitation> invitations = invitationQueryAdapter.findAllByPhone(user.getPhone());
List<Invitation> invitations = invitationQueryAdapter.findAllPendingByPhone(user.getPhone());

List<InvitationResponseDTO.getInvitation> invitationDtos = invitations.stream()
.map(invitation -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class InvitationQueryAdapter {

private final InvitationRepository invitationRepository;

public List<Invitation> findAllByPhone(String phone) {
public List<Invitation> findAllPendingByPhone(String phone) {
return invitationRepository.findAllByPhone(phone)
.stream().filter(invitation -> invitation.getStatus().equals(InvitationStatus.PENDING)).toList();
}
Expand All @@ -45,4 +45,8 @@ public Invitation findAcceptedInvitation(User user, TreeHouse treeHouse) {
.filter(invitation -> invitation.getStatus().equals(InvitationStatus.ACCEPTED))
.orElseThrow(() -> new InvitationException(GlobalErrorCode.INVITATION_NOT_FOUND));
}

public List<Invitation> findAllByPhone(String phone) {
return invitationRepository.findAllByPhone(phone);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import treehouse.server.global.entity.redis.RefreshToken;
import treehouse.server.global.exception.GlobalErrorCode;
import treehouse.server.global.exception.ThrowClass.AuthException;
import treehouse.server.global.exception.ThrowClass.GeneralException;
import treehouse.server.global.fcm.service.FcmService;
import treehouse.server.global.redis.service.RedisService;
import treehouse.server.global.security.jwt.dto.TokenDTO;
Expand Down Expand Up @@ -59,7 +58,7 @@ public User findById(Long id){
public UserResponseDTO.registerUser register(UserRequestDTO.registerUser request){
User user = UserMapper.toUser(request.getUserName(), request.getPhoneNumber());
User savedUser = userCommandAdapter.register(user);
List<Invitation> receivedInvitations = invitationQueryAdapter.findAllByPhone(request.getPhoneNumber());
List<Invitation> receivedInvitations = invitationQueryAdapter.findAllPendingByPhone(request.getPhoneNumber());
receivedInvitations.forEach(invitation -> {
invitation.setReceiver(savedUser);
invitationCommandAdapter.saveInvitation(invitation);
Expand Down Expand Up @@ -93,7 +92,7 @@ public UserResponseDTO.reissue reissue(UserRequestDTO.reissue request){
return UserMapper.toReissue(token.getAccessToken(), token.getRefreshToken());
}


@Transactional
public UserResponseDTO.checkUserStatus checkUserStatus(UserRequestDTO.checkUserStatus request) {

Boolean isNewUser = !userQueryAdapter.existByPhoneNumber(request.getPhoneNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Invitation extends BaseDateTimeEntity {

private LocalDateTime expiredAt; //μ΄ˆλŒ€μž₯ 만료일자

@JoinColumn(name = "senderId")
@JoinColumn(name = "senderId", nullable = true)
@ManyToOne(fetch = FetchType.LAZY)
private Member sender;

Expand Down
Loading