Skip to content

Commit

Permalink
๐Ÿ› Fix: ์ดˆ๋Œ€์žฅ ์ˆ˜๋ฝ์€ ํ–ˆ๋Š”๋ฐ Member๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ๋„ ๊ณ ๋ ค
Browse files Browse the repository at this point in the history
  • Loading branch information
koojun99 committed Oct 10, 2024
1 parent 7667ee5 commit e75d0b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
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

0 comments on commit e75d0b5

Please sign in to comment.