File tree Expand file tree Collapse file tree
src/main/java/life/mosu/mosuserver
domain/examapplication/repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package life .mosu .mosuserver .application .profile ;
22
3+ import life .mosu .mosuserver .domain .examapplication .repository .ExamApplicationJpaRepository ;
34import life .mosu .mosuserver .domain .profile .entity .ProfileJpaEntity ;
45import life .mosu .mosuserver .domain .profile .repository .ProfileJpaRepository ;
56import life .mosu .mosuserver .global .exception .CustomRuntimeException ;
1718public class RecommenderService {
1819
1920 private final ProfileJpaRepository profileJpaRepository ;
21+ private final ExamApplicationJpaRepository examApplicationJpaRepository ;
2022
2123 @ Transactional
2224 public void registerRecommender (Long userId , RecommenderRegistrationRequest request ) {
2325 ProfileJpaEntity profile = profileJpaRepository .findByUserId (userId )
2426 .orElseThrow (() -> new CustomRuntimeException (ErrorCode .PROFILE_NOT_FOUND ));
25- if (profile .getRecommenderPhoneNumber () != null ) {
26- throw new CustomRuntimeException (ErrorCode .ALREADY_REGISTERED_RECOMMENDER );
27- }
28-
2927 profile .registerRecommenderPhoneNumber (request .phoneNumber ());
3028 }
3129
3230 @ Transactional (readOnly = true , propagation = Propagation .NOT_SUPPORTED )
3331 public Boolean verifyRecommender (Long userId ) {
3432 ProfileJpaEntity profile = profileJpaRepository .findByUserId (userId )
3533 .orElseThrow (() -> new CustomRuntimeException (ErrorCode .PROFILE_NOT_FOUND ));
36- return profile .getRecommenderPhoneNumber () != null ;
34+ if (profile .getRecommenderPhoneNumber () == null ) {
35+ return false ;
36+ }
37+
38+ return examApplicationJpaRepository .existsPaymentDoneByUserId (userId );
3739 }
3840
3941}
Original file line number Diff line number Diff line change @@ -143,7 +143,6 @@ Optional<ExamApplicationNotifyProjection> findExamAndPaymentByExamApplicationId(
143143 JOIN PaymentJpaEntity p ON p.examApplicationId = ea.id
144144 WHERE ea.id = :examApplicationId
145145 AND p.paymentStatus = 'DONE'
146- AND p.deleted = false
147146 """ )
148147 Optional <ExamInfoWithExamNumberProjection > findExamInfoWithExamNumber (
149148 @ Param ("examApplicationId" ) Long examApplicationId );
@@ -194,4 +193,17 @@ SELECT COUNT(ea)
194193 AND p.deleted = false
195194 """ )
196195 long countAll ();
196+
197+ @ Query ("""
198+ select exists (
199+ select 1
200+ from ExamApplicationJpaEntity ea
201+ join PaymentJpaEntity p on p.examApplicationId = ea.id
202+ where ea.userId = :userId
203+ and p.paymentStatus = 'DONE'
204+ and p.deleted = false
205+ and ea.deleted = false
206+ )
207+ """ )
208+ boolean existsPaymentDoneByUserId (@ Param ("userId" ) Long userId );
197209}
You can’t perform that action at this time.
0 commit comments