Skip to content
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 @@ -9,19 +9,26 @@
import com.team.buddyya.certification.dto.response.TestAccountResponse;
import com.team.buddyya.certification.exception.PhoneAuthenticationException;
import com.team.buddyya.certification.exception.PhoneAuthenticationExceptionType;
import com.team.buddyya.certification.repository.*;
import com.team.buddyya.certification.repository.AdminAccountRepository;
import com.team.buddyya.certification.repository.PhoneInfoRepository;
import com.team.buddyya.certification.repository.RegisteredPhoneRepository;
import com.team.buddyya.certification.repository.StudentIdCardRepository;
import com.team.buddyya.certification.repository.TestAccountRepository;
import com.team.buddyya.point.domain.Point;
import com.team.buddyya.point.service.FindPointService;
import com.team.buddyya.student.domain.MatchingProfile;
import com.team.buddyya.student.domain.Student;
import com.team.buddyya.student.dto.response.UserResponse;
import com.team.buddyya.student.exception.StudentException;
import com.team.buddyya.student.exception.StudentExceptionType;
import com.team.buddyya.student.repository.MatchingProfileRepository;
import com.team.buddyya.student.repository.StudentRepository;
import com.team.buddyya.student.service.InvitationService;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service
@RequiredArgsConstructor
@Transactional
Expand All @@ -37,6 +44,7 @@ public class PhoneAuthenticationService {
private final TestAccountRepository testAccountRepository;
private final FindPointService findPointService;
private final AdminAccountRepository adminAccountRepository;
private final MatchingProfileRepository matchingProfileRepository;
private final InvitationService invitationService;
private final JwtUtils jwtUtils;

Expand Down Expand Up @@ -68,7 +76,9 @@ public UserResponse checkMembership(String phoneNumber) {
student.getAvatar().setLoggedOut(false);
boolean isStudentIdCardRequested = studentIdCardRepository.findByStudent(student).isPresent();
Point point = findPointService.findByStudent(student);
return UserResponse.fromCheckMembership(student, isStudentIdCardRequested, EXISTING_MEMBER, accessToken, refreshToken, point);
MatchingProfile matchingProfile = getMatchingProfile(student);
return UserResponse.fromCheckMembership(student, isStudentIdCardRequested, EXISTING_MEMBER, accessToken,
refreshToken, point, matchingProfile);
}
return UserResponse.fromCheckMembership(NEW_MEMBER);
}
Expand Down Expand Up @@ -106,7 +116,13 @@ private void resetMessageCountIfExists(String udId) {
return;
}
PhoneInfo phoneInfo = phoneInfoRepository.findPhoneInfoByUdId(udId)
.orElseThrow(() -> new PhoneAuthenticationException(PhoneAuthenticationExceptionType.PHONE_INFO_NOT_FOUND));
.orElseThrow(
() -> new PhoneAuthenticationException(PhoneAuthenticationExceptionType.PHONE_INFO_NOT_FOUND));
phoneInfo.resetMessageSendCount();
}

private MatchingProfile getMatchingProfile(Student student) {
return matchingProfileRepository.findByStudent(student)
.orElseThrow(() -> new StudentException(StudentExceptionType.MATCHING_PROFILE_NOT_FOUND));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public static UserResponse fromOnboard(Student student, Boolean isStudentIdCardR
}

public static UserResponse fromCheckMembership(Student student, Boolean isStudentIdCardRequested, String status,
String accessToken, String refreshToken, Point point) {
String accessToken, String refreshToken, Point point,
MatchingProfile matchingProfile) {
return new UserResponse(
student.getId(),
student.getRole().name(),
Expand All @@ -163,9 +164,9 @@ public static UserResponse fromCheckMembership(Student student, Boolean isStuden
null,
accessToken,
refreshToken,
null,
null,
null,
matchingProfile.getIntroduction(),
matchingProfile.getBuddyActivity(),
matchingProfile.isCompleted(),
student.getUniversity().getIsMatchingActive(),
student.getUniversity().getIsFeedActive()
);
Expand Down