From f7d0d14a1dbcbdc25e6ffc87bb03955d5cd0448d Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 17 Mar 2024 22:09:22 +0900 Subject: [PATCH] =?UTF-8?q?RAC-325=20fix:=20=EA=B2=B0=EC=A0=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/mapper/AdminMapper.java | 13 ++++++++ .../application/usecase/AdminUseCase.java | 32 +++++++++---------- .../domain/service/MentoringGetService.java | 5 +++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/mapper/AdminMapper.java b/src/main/java/com/postgraduate/domain/admin/application/mapper/AdminMapper.java index 0765dd63..3993d2c9 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/mapper/AdminMapper.java +++ b/src/main/java/com/postgraduate/domain/admin/application/mapper/AdminMapper.java @@ -132,6 +132,19 @@ public static PaymentInfo mapToPaymentInfo(Payment payment, Mentoring mentoring) ); } + public static PaymentInfo mapToPaymentInfo(Payment payment) { + User user = payment.getUser(); + return new PaymentInfo( + payment.getPaymentId(), + null, + user.getNickName(), + user.getPhoneNumber(), + payment.getPaidAt(), + payment.getPay(), + payment.getStatus() + ); + } + public static SalaryInfo mapToSalaryResponse(Senior senior, String accountNumber, Salary salary) { User user = senior.getUser(); return new SalaryInfo( diff --git a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminUseCase.java b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminUseCase.java index 1f41b5b2..8a08d038 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminUseCase.java @@ -4,11 +4,11 @@ import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; import com.postgraduate.domain.admin.application.dto.res.MentoringManageResponse; import com.postgraduate.domain.admin.application.dto.res.MentoringWithPaymentResponse; +import com.postgraduate.domain.admin.application.dto.res.WishResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.adminssr.application.dto.req.Login; import com.postgraduate.domain.adminssr.domain.AuthGetService; -import com.postgraduate.domain.mentoring.application.usecase.MentoringManageUseCase; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; @@ -18,16 +18,13 @@ import com.postgraduate.domain.salary.domain.entity.Salary; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.salary.domain.service.SalaryUpdateService; -import com.postgraduate.domain.salary.exception.SalaryNotFoundException; import com.postgraduate.domain.salary.exception.SalaryNotYetException; -import com.postgraduate.domain.salary.util.SalaryUtil; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.entity.constant.Status; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.senior.domain.service.SeniorUpdateService; import com.postgraduate.domain.senior.exception.SeniorCertificationException; import com.postgraduate.domain.user.domain.entity.User; -import com.postgraduate.domain.admin.application.dto.res.WishResponse; import com.postgraduate.domain.user.domain.service.UserGetService; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.service.WishGetService; @@ -40,6 +37,7 @@ import java.util.List; import java.util.Optional; +import static com.postgraduate.domain.admin.application.mapper.AdminMapper.*; import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.YET; import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.CANCEL; import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.DONE; @@ -74,7 +72,7 @@ public List allSenior() { Salary salary = salaryGetService.bySenior(senior); SalaryStatus salaryStatus = getStatus(salary); Optional wish = wishGetService.byUser(senior.getUser()); - return AdminMapper.mapToSeniorInfo(senior, salaryStatus, wish.isPresent()); + return mapToSeniorInfo(senior, salaryStatus, wish.isPresent()); }) .toList(); } @@ -91,9 +89,9 @@ public List salaryInfos() { return all.stream() .map(salary -> { if (salary.getAccountNumber() == null) - return AdminMapper.mapToSalaryResponse(salary.getSenior(), salary); + return mapToSalaryResponse(salary.getSenior(), salary); String accountNumber = encryptorUtils.decryptData(salary.getAccountNumber()); - return AdminMapper.mapToSalaryResponse(salary.getSenior(), accountNumber, salary); + return mapToSalaryResponse(salary.getSenior(), accountNumber, salary); }) .toList(); } @@ -102,8 +100,10 @@ public List paymentInfos() { List all = paymentGetService.all(); return all.stream() .map(payment -> { - Mentoring mentoring = mentoringGetService.byPayment(payment); - return AdminMapper.mapToPaymentInfo(payment, mentoring); + Mentoring mentoring = mentoringGetService.byPaymentWithNull(payment); + if (mentoring == null) + return mapToPaymentInfo(payment); + return mapToPaymentInfo(payment, mentoring); }) .toList(); } @@ -112,7 +112,7 @@ public CertificationDetailsResponse getCertification(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); if (senior.getStatus() == Status.APPROVE) throw new SeniorCertificationException(); - return AdminMapper.mapToCertificationInfo(senior); + return mapToCertificationInfo(senior); } public void updateNotApprove(Long seniorId) { @@ -131,7 +131,7 @@ public MentoringManageResponse seniorMentorings(Long seniorId) { List mentoringInfos = mentorings.stream() .map(AdminMapper::mapToMentoringInfo) .toList(); - UserMentoringInfo seniorInfo = AdminMapper.mapToUserMentoringInfo(senior); + UserMentoringInfo seniorInfo = mapToUserMentoringInfo(senior); return new MentoringManageResponse(mentoringInfos, seniorInfo); } @@ -142,14 +142,14 @@ public SalaryInfo seniorSalary(Long seniorId) { if (status != YET) throw new SalaryNotYetException(); if (salary.getAccountNumber() == null) - return AdminMapper.mapToSalaryResponse(senior, salary); + return mapToSalaryResponse(senior, salary); String accountNumber = encryptorUtils.decryptData(salary.getAccountNumber()); - return AdminMapper.mapToSalaryResponse(senior, accountNumber, salary); + return mapToSalaryResponse(senior, accountNumber, salary); } public WishResponse wishInfo(Long userId) { Wish wish = wishGetService.byUserId(userId); - return AdminMapper.mapToWishResponse(wish); + return mapToWishResponse(wish); } public MentoringManageResponse userMentoringInfos(Long userId) { @@ -158,14 +158,14 @@ public MentoringManageResponse userMentoringInfos(Long userId) { List mentoringInfos = mentorings.stream() .map(AdminMapper::mapToMentoringInfo) .toList(); - UserMentoringInfo userInfo = AdminMapper.mapToUserMentoringInfo(user); + UserMentoringInfo userInfo = mapToUserMentoringInfo(user); return new MentoringManageResponse(mentoringInfos, userInfo); } public MentoringWithPaymentResponse paymentMentoringInfo(Long paymentId) { Payment payment = paymentGetService.byId(paymentId); Mentoring mentoring = mentoringGetService.byPayment(payment); - return AdminMapper.mapToMentoringWithPaymentResponse(mentoring); + return mapToMentoringWithPaymentResponse(mentoring); } public void wishDone(Long wishId) { diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java index 7fc79db5..d4ecce2c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java @@ -31,6 +31,11 @@ public void checkByPayment(Payment payment) { }); } + public Mentoring byPaymentWithNull(Payment payment) { + return mentoringRepository.findByPayment(payment) + .orElse(null); + } + public Mentoring byPayment(Payment payment) { return mentoringRepository.findByPayment(payment) .orElseThrow(MentoringNotFoundException::new);