From d143c29ebd8f4f49424317fd898fde638bd48482 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 14:25:59 +0900 Subject: [PATCH 01/47] =?UTF-8?q?RAC-186=20fix:=20=EC=8B=A0=EC=B2=AD=20?= =?UTF-8?q?=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=83=81=EC=84=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EC=97=90=20`term`=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/AppliedMentoringDetailResponse.java | 1 + .../domain/mentoring/application/mapper/MentoringMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java index b3bf2c92..bc00f1f0 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java @@ -14,6 +14,7 @@ public class AppliedMentoringDetailResponse { private String postgradu; private String major; private String lab; + private int term; private String topic; private String question; private String[] dates; diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index ce35fcc5..f2b7b3c1 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -64,6 +64,7 @@ public static AppliedMentoringDetailResponse mapToAppliedDetailInfo(Mentoring me .postgradu(senior.getInfo().getPostgradu()) .major(senior.getInfo().getMajor()) .lab(senior.getInfo().getLab()) + .term(senior.getProfile().getTerm()) .topic(mentoring.getTopic()) .question(mentoring.getQuestion()) .dates(dates) From bd2832ec97199359bbb22093dac69cad56265358 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 16:51:44 +0900 Subject: [PATCH 02/47] =?UTF-8?q?RAC-186=20feat:=20`Wish`=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wish/domain/repository/WishRepository.java | 4 ++++ .../domain/wish/exception/WishException.java | 10 ++++++++++ .../wish/exception/WishNotFoundException.java | 12 ++++++++++++ .../presentation/constant/WishResponseCode.java | 16 ++++++++++++++++ .../constant/WishResponseMessage.java | 15 +++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/wish/exception/WishException.java create mode 100644 src/main/java/com/postgraduate/domain/wish/exception/WishNotFoundException.java create mode 100644 src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseCode.java create mode 100644 src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java diff --git a/src/main/java/com/postgraduate/domain/wish/domain/repository/WishRepository.java b/src/main/java/com/postgraduate/domain/wish/domain/repository/WishRepository.java index edc9982e..fe7de291 100644 --- a/src/main/java/com/postgraduate/domain/wish/domain/repository/WishRepository.java +++ b/src/main/java/com/postgraduate/domain/wish/domain/repository/WishRepository.java @@ -1,7 +1,11 @@ package com.postgraduate.domain.wish.domain.repository; +import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.wish.domain.entity.Wish; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface WishRepository extends JpaRepository { + Optional findByUser(User user); } diff --git a/src/main/java/com/postgraduate/domain/wish/exception/WishException.java b/src/main/java/com/postgraduate/domain/wish/exception/WishException.java new file mode 100644 index 00000000..a1bd3987 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/exception/WishException.java @@ -0,0 +1,10 @@ +package com.postgraduate.domain.wish.exception; + +import com.postgraduate.global.exception.ApplicationException; + +public class WishException extends ApplicationException { + + protected WishException(String message, String errorCode) { + super(message, errorCode); + } +} diff --git a/src/main/java/com/postgraduate/domain/wish/exception/WishNotFoundException.java b/src/main/java/com/postgraduate/domain/wish/exception/WishNotFoundException.java new file mode 100644 index 00000000..03a2dcd4 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/exception/WishNotFoundException.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.wish.exception; + +import com.postgraduate.domain.salary.exception.SalaryException; + +import static com.postgraduate.domain.wish.presentation.constant.WishResponseCode.WISH_NOT_FOUND; +import static com.postgraduate.domain.wish.presentation.constant.WishResponseMessage.NOT_FOUND_WISH; + +public class WishNotFoundException extends SalaryException { + public WishNotFoundException() { + super(NOT_FOUND_WISH.getMessage(), WISH_NOT_FOUND.getCode()); + } +} diff --git a/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseCode.java b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseCode.java new file mode 100644 index 00000000..4fbafb54 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseCode.java @@ -0,0 +1,16 @@ +package com.postgraduate.domain.wish.presentation.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum WishResponseCode { + WISH_FIND("WSH200"), + WISH_UPDATE("WSH201"), + WISH_CREATE("WSH202"), + WISH_DELETE("WSH203"), + + WISH_NOT_FOUND("EX200"); + private final String code; +} diff --git a/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java new file mode 100644 index 00000000..8d84b338 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java @@ -0,0 +1,15 @@ +package com.postgraduate.domain.wish.presentation.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum WishResponseMessage { + GET_WISH_INFO("희망 정보 조회에 성공하였습니다"), + GET_WISH_LIST_INFO("희망 리스트 조회에 성공하였습니다."), + + NOT_FOUND_WISH("희망을 찾을 수 없습니다."); + + private final String message; +} From 8018681c9da00c4cbe2e5d09e200211c908c4517 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 16:53:06 +0900 Subject: [PATCH 03/47] =?UTF-8?q?RAC-186=20fix:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/UserResponse.java | 5 +++ .../admin/application/mapper/AdminMapper.java | 24 ++++++++------ .../usecase/UserManageByAdminUseCase.java | 33 +++++++++---------- .../admin/presentation/AdminController.java | 12 +++---- .../domain/user/domain/entity/User.java | 1 - 5 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java index d2eeb13b..415efd3c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.admin.application.dto.res; +import com.postgraduate.domain.user.domain.entity.constant.Role; import lombok.Getter; import lombok.experimental.SuperBuilder; @@ -10,7 +11,11 @@ public class UserResponse { private Long userId; private String nickName; + private String phoneNumber; private LocalDate createdAt; private Boolean marketingReceive; private Boolean matchingReceive; + private Long wishId; + private Role role; + // 매칭 지원 완료 여부 } 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 a23d5d76..247399e9 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 @@ -7,6 +7,7 @@ import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; +import com.postgraduate.domain.wish.domain.entity.Wish; public class AdminMapper { @@ -36,16 +37,19 @@ public static CertificationResponse mapToCertification(Senior senior) { .build(); } -// public static UserResponse mapToUserResponse(User user) { -// return UserResponse.builder() -// .userId(user.getUserId()) -// .nickName(user.getNickName()) -// .marketingReceive(user.getMarketingReceive()) -// .matchingReceive(user.getHope().getMatchingReceive()) -// .createdAt(user.getCreatedAt()) -// .build(); -// } - + public static UserResponse mapToUserResponse(User user, Wish wish) { + return UserResponse.builder() + .userId(user.getUserId()) + .nickName(user.getNickName()) + .phoneNumber(user.getPhoneNumber()) + .createdAt(user.getCreatedAt()) + .marketingReceive(user.getMarketingReceive()) + .matchingReceive(wish.getMatchingReceive()) + .wishId(wish.getWishId()) + .role(user.getRole()) + .build(); + } +// // public static UserWithSeniorResponse mapToUserWithSeniorResponse(User user, Long seniorId) { // return UserWithSeniorResponse.builder() // .userId(user.getUserId()) diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java index 2440aed3..8e711ccc 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java @@ -2,34 +2,33 @@ import com.postgraduate.domain.admin.application.dto.res.UserResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; -import com.postgraduate.domain.senior.domain.entity.Senior; -import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; -import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.service.UserGetService; +import com.postgraduate.domain.wish.domain.entity.Wish; +import com.postgraduate.domain.wish.domain.repository.WishRepository; +import com.postgraduate.domain.wish.exception.WishNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; +import static com.postgraduate.domain.user.domain.entity.constant.Role.ADMIN; + @Service @Transactional @RequiredArgsConstructor public class UserManageByAdminUseCase { private final UserGetService userGetService; - private final SeniorGetService seniorGetService; -// public List getUsers() { -// List users = userGetService.all(); -// List userResponses = new ArrayList<>(); -// users.forEach(user -> { -// if (user.getRole() == Role.SENIOR) { -// Senior senior = seniorGetService.byUser(user); -// userResponses.add(AdminMapper.mapToUserWithSeniorResponse(user, senior.getSeniorId())); -// } -// userResponses.add(AdminMapper.mapToUserResponse(user)); -// }); -// return userResponses; -// } + private final WishRepository wishRepository; + public List getUsers() { + List users = userGetService.all(); + return users.stream() + .filter(user -> user.getRole() != ADMIN) + .map(user -> { + Wish wish = wishRepository.findByUser(user).orElseThrow(WishNotFoundException::new); + return AdminMapper.mapToUserResponse(user, wish); + }) + .toList(); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 0bec2988..d57c7679 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -56,12 +56,12 @@ public ResponseDto updateSeniorStatus(@PathVariable Long seniorId, @RequestBody return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_STATUS.getMessage()); } -// @GetMapping("/users") -// @Operation(summary = "[관리자] 후배 정보 목록", description = "대학생 후배 정보 목록을 조회합니다.") -// public ResponseDto> getUsers() { -// List users = userManageUseCase.getUsers(); -// return ResponseDto.create(USER_FIND.getCode(), GET_USER_LIST_INFO.getMessage(), users); -// } + @GetMapping("/users") + @Operation(summary = "[관리자] 후배 정보 목록", description = "대학생 후배 정보 목록을 조회합니다.") + public ResponseDto> getUsers() { + List users = userManageUseCase.getUsers(); + return ResponseDto.create(USER_FIND.getCode(), GET_USER_LIST_INFO.getMessage(), users); + } @GetMapping("/seniors") @Operation(summary = "[관리자] 선배 정보 목록", description = "대학원생 선배 정보 목록을 조회합니다.") diff --git a/src/main/java/com/postgraduate/domain/user/domain/entity/User.java b/src/main/java/com/postgraduate/domain/user/domain/entity/User.java index 3f13f1f4..01aa72e1 100644 --- a/src/main/java/com/postgraduate/domain/user/domain/entity/User.java +++ b/src/main/java/com/postgraduate/domain/user/domain/entity/User.java @@ -1,6 +1,5 @@ package com.postgraduate.domain.user.domain.entity; -import com.postgraduate.domain.senior.application.dto.req.SeniorMyPageUserAccountRequest; import com.postgraduate.domain.user.domain.entity.constant.Role; import jakarta.persistence.*; import lombok.AllArgsConstructor; From f5121828fbb2463c7ace342a71df05fe229fe69e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 16:55:02 +0900 Subject: [PATCH 04/47] =?UTF-8?q?RAC-186=20refactor:=20`SalaryUtil`?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=A0=95=EC=82=B0=EC=9D=BC=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/SalaryInfoUseCase.java | 10 ++-------- .../domain/salary/util/MonthFormat.java | 9 --------- .../domain/salary/util/SalaryUtil.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/salary/util/MonthFormat.java create mode 100644 src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java diff --git a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java index 804c17b3..d55c1c30 100644 --- a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java @@ -15,11 +15,12 @@ import java.time.LocalDate; import java.util.List; +import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; + @Service @Transactional @RequiredArgsConstructor public class SalaryInfoUseCase { - private static final int SALARY_DATE = 10; private final SeniorGetService seniorGetService; private final SalaryGetService salaryGetService; @@ -31,13 +32,6 @@ public SalaryInfoResponse getSalary(User user) { return new SalaryInfoResponse(salaryDate, amount); //TODO 수수료 } - private LocalDate getSalaryDate() { - LocalDate now = LocalDate.now(); - return now.getDayOfMonth() <= SALARY_DATE - ? now.withDayOfMonth(SALARY_DATE) - : now.plusMonths(1).withDayOfMonth(SALARY_DATE); - } - private int getAmount(List salaries) { return salaries.stream() .map(salary -> salary.getMentoring().getPay()) diff --git a/src/main/java/com/postgraduate/domain/salary/util/MonthFormat.java b/src/main/java/com/postgraduate/domain/salary/util/MonthFormat.java deleted file mode 100644 index e1caede6..00000000 --- a/src/main/java/com/postgraduate/domain/salary/util/MonthFormat.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.postgraduate.domain.salary.util; - -import java.time.format.DateTimeFormatter; - -public class MonthFormat { - public static DateTimeFormatter getMonthFormat() { - return DateTimeFormatter.ofPattern("yyyy-MM"); - } -} diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java new file mode 100644 index 00000000..02d5b181 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -0,0 +1,18 @@ +package com.postgraduate.domain.salary.util; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class SalaryUtil { + private static final int SALARY_DATE = 10; + public static LocalDate getSalaryDate() { + LocalDate now = LocalDate.now(); + return now.getDayOfMonth() <= SALARY_DATE + ? now.withDayOfMonth(SALARY_DATE) + : now.plusMonths(1).withDayOfMonth(SALARY_DATE); + } + + public static DateTimeFormatter getMonthFormat() { + return DateTimeFormatter.ofPattern("yyyy-MM"); + } +} From ab1a380fb63dda9af8ba8c4c9876ef250660e398 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 16:58:18 +0900 Subject: [PATCH 05/47] =?UTF-8?q?RAC-186=20fix:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/SeniorResponse.java | 9 ++++-- .../admin/application/mapper/AdminMapper.java | 10 +++++-- .../usecase/SeniorManageByAdminUseCase.java | 29 +++++++++++++++++-- .../domain/service/SeniorGetService.java | 4 +++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java index 7d86a26d..0c39f268 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java @@ -1,14 +1,17 @@ package com.postgraduate.domain.admin.application.dto.res; +import com.postgraduate.domain.senior.domain.entity.constant.Status; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Builder @Getter public class SeniorResponse { private Long seniorId; private String nickName; - private LocalDate createdAt; + private String phoneNumber; + private Status status; + private String salaryStatus; + private Boolean marketingReceive; + // 후배 회원 가입 } 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 247399e9..d8248a0f 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 @@ -61,11 +61,15 @@ public static UserResponse mapToUserResponse(User user, Wish wish) { // .build(); // } - public static SeniorResponse mapToSeniorResponse(Senior senior) { + public static SeniorResponse mapToSeniorResponse(Senior senior, String salaryStatus) { + User user = senior.getUser(); return SeniorResponse.builder() .seniorId(senior.getSeniorId()) - .nickName(senior.getUser().getNickName()) - .createdAt(senior.getCreatedAt()) + .nickName(user.getNickName()) + .phoneNumber(user.getPhoneNumber()) + .status(senior.getStatus()) + .salaryStatus(salaryStatus) + .marketingReceive(user.getMarketingReceive()) .build(); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 3a08d0b9..388f4cbc 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -8,6 +8,8 @@ import com.postgraduate.domain.admin.application.dto.res.SeniorResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; +import com.postgraduate.domain.salary.domain.entity.Salary; +import com.postgraduate.domain.salary.domain.service.SalaryGetService; 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; @@ -20,12 +22,15 @@ import java.util.List; +import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; + @Service @Transactional @RequiredArgsConstructor public class SeniorManageByAdminUseCase { private final SeniorGetService seniorGetService; private final UserUpdateService userUpdateService; + private final SalaryGetService salaryGetService; public CertificationDetailsResponse getCertificationDetails(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); @@ -55,7 +60,27 @@ public void updateSeniorStatus(Long seniorId, SeniorStatusRequest request) { } public List getSeniors() { - List seniors = seniorGetService.byStatus(Status.APPROVE); - return seniors.stream().map(AdminMapper::mapToSeniorResponse).toList(); + List seniors = seniorGetService.getAll(); + return seniors.stream() + .map(senior -> { + List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); + String salaryStatus = getSalaryStatus(salaries); + return AdminMapper.mapToSeniorResponse(senior, salaryStatus); + }) + .toList(); + } + + private String getSalaryStatus(List salaries) { + long count = salaries.stream() + .filter(Salary::getStatus) + .count(); + + if (count == salaries.size()) { + return "O"; + } + if (count == 0) { + return "X"; + } + return "-"; } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java index 7c8adfa0..79afa349 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java @@ -37,6 +37,10 @@ public List byStatus(Status status) { return seniorRepository.findAllByStatus(status); } + public List getAll() { + return seniorRepository.findAll(); + } + public Page bySearch(String search, Integer page, String sort) { if (page == null) page = 1; From 690b7fab55c7c7959f2b3421e45fa119bd50f519 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 30 Nov 2023 18:52:45 +0900 Subject: [PATCH 06/47] =?UTF-8?q?RAC-186=20feat:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 12 ++++++++ .../wish/application/mapper/WishMapper.java | 8 ++++++ .../mapper/dto/res/WishResponse.java | 28 +++++++++++++++++++ .../application/usecase/WishInfoUseCase.java | 19 +++++++++++++ .../wish/domain/service/WishGetService.java | 17 +++++++++++ 5 files changed, 84 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java create mode 100644 src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java create mode 100644 src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index d57c7679..aeda3bb1 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -6,6 +6,8 @@ import com.postgraduate.domain.admin.application.usecase.PaymentManageByAdminUseCase; import com.postgraduate.domain.admin.application.usecase.SeniorManageByAdminUseCase; import com.postgraduate.domain.admin.application.usecase.UserManageByAdminUseCase; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; +import com.postgraduate.domain.wish.application.usecase.WishInfoUseCase; import com.postgraduate.global.dto.ResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -23,6 +25,8 @@ import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; import static com.postgraduate.domain.user.presentation.constant.UserResponseCode.USER_FIND; import static com.postgraduate.domain.user.presentation.constant.UserResponseMessage.GET_USER_LIST_INFO; +import static com.postgraduate.domain.wish.presentation.constant.WishResponseCode.WISH_FIND; +import static com.postgraduate.domain.wish.presentation.constant.WishResponseMessage.*; @RestController @@ -34,6 +38,7 @@ public class AdminController { private final UserManageByAdminUseCase userManageUseCase; private final MentoringManageByAdminUseCase mentoringManageUseCase; private final PaymentManageByAdminUseCase paymentManageUseCase; + private final WishInfoUseCase wishInfoUseCase; @GetMapping("/certification/{seniorId}") @Operation(summary = "[관리자] 선배 프로필 승인 요청 조회", description = "선배 신청 시 작성한 사전 작성정보 및 첨부사진을 조회합니다.") @@ -63,6 +68,13 @@ public ResponseDto> getUsers() { return ResponseDto.create(USER_FIND.getCode(), GET_USER_LIST_INFO.getMessage(), users); } + @GetMapping("/wish/{wishId}") + @Operation(summary = "[관리자] 후배 매칭 지원 정보", description = "대학생 후배 매칭 지원 정보를 상세 조회합니다.") + public ResponseDto getWish(@PathVariable Long wishId) { + WishResponse wish = wishInfoUseCase.getWish(wishId); + return ResponseDto.create(WISH_FIND.getCode(), GET_WISH_INFO.getMessage(), wish); + } + @GetMapping("/seniors") @Operation(summary = "[관리자] 선배 정보 목록", description = "대학원생 선배 정보 목록을 조회합니다.") public ResponseDto> getSeniors() { diff --git a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java index d0e3cf9f..332c908d 100644 --- a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java +++ b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java @@ -2,6 +2,7 @@ import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; import com.postgraduate.domain.user.domain.entity.User; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; import com.postgraduate.domain.wish.domain.entity.Wish; public class WishMapper { @@ -13,4 +14,11 @@ public static Wish mapToWish(User user, SignUpRequest request) { .matchingReceive(request.getMatchingReceive()) .build(); } + + public static WishResponse mapToWish(Wish wish) { + User user = wish.getUser(); + String[] field = wish.getField().split(","); + return new WishResponse(user.getNickName(), user.getPhoneNumber(), user.getCreatedAt(), user.getMarketingReceive(), + wish.getMatchingReceive(), wish.getMajor(), field); + } } diff --git a/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java b/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java new file mode 100644 index 00000000..7db5cb63 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java @@ -0,0 +1,28 @@ +package com.postgraduate.domain.wish.application.mapper.dto.res; + +import jakarta.validation.constraints.NotNull; + +import java.time.LocalDate; + +public record WishResponse( + @NotNull + String nickName, + + @NotNull + String phoneNumber, + + @NotNull + LocalDate createAt, + + @NotNull + Boolean marketingReceive, + + @NotNull + Boolean matchingReceive, + + @NotNull + String major, + + @NotNull + String[] field +) {} diff --git a/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java b/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java new file mode 100644 index 00000000..aa6966dc --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java @@ -0,0 +1,19 @@ +package com.postgraduate.domain.wish.application.usecase; + +import com.postgraduate.domain.wish.application.mapper.WishMapper; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; +import com.postgraduate.domain.wish.domain.entity.Wish; +import com.postgraduate.domain.wish.domain.service.WishGetService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class WishInfoUseCase { + private final WishGetService wishGetService; + + public WishResponse getWish(Long wishId) { + Wish wish = wishGetService.byWishId(wishId); + return WishMapper.mapToWish(wish); + } +} diff --git a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java new file mode 100644 index 00000000..80029ca5 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java @@ -0,0 +1,17 @@ +package com.postgraduate.domain.wish.domain.service; + +import com.postgraduate.domain.wish.application.mapper.WishMapper; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; +import com.postgraduate.domain.wish.domain.entity.Wish; +import com.postgraduate.domain.wish.domain.repository.WishRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class WishGetService { + private final WishRepository wishRepository; + public Wish byWishId(Long wishId) { + return wishRepository.findById(wishId).orElseThrow(); + } +} From fa9f9c0c92cd60f5580b2568a859906219fa0cb8 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 2 Dec 2023 14:55:41 +0900 Subject: [PATCH 07/47] =?UTF-8?q?RAC-186=20fix:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/MentoringResponse.java | 5 ++--- .../admin/application/mapper/AdminMapper.java | 11 ++++++----- .../MentoringManageByAdminUseCase.java | 12 ++++++++---- .../admin/presentation/AdminController.java | 19 +++++++++++++------ .../repository/MentoringRepository.java | 2 ++ .../domain/service/MentoringGetService.java | 8 ++++++++ 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java index 0482d08f..3d94c918 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java @@ -14,8 +14,7 @@ public class MentoringResponse { private Long mentoringId; private Status status; private String userNickName; - private Long seniorId; + private String userPhoneNumber; private String seniorNickName; - private LocalDate createdAt; - private String date; + private String seniorPhoneNumber; } 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 d8248a0f..300d7b22 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 @@ -74,14 +74,15 @@ public static SeniorResponse mapToSeniorResponse(Senior senior, String salarySta } public static MentoringResponse mapToMentoringResponse(Mentoring mentoring) { + User user = mentoring.getUser(); + Senior senior = mentoring.getSenior(); return MentoringResponse.builder() .mentoringId(mentoring.getMentoringId()) .status(mentoring.getStatus()) - .userNickName(mentoring.getUser().getNickName()) - .seniorId(mentoring.getSenior().getSeniorId()) - .seniorNickName(mentoring.getSenior().getUser().getNickName()) - .createdAt(mentoring.getCreatedAt()) - .date(mentoring.getDate()) + .userNickName(user.getNickName()) + .userPhoneNumber(user.getPhoneNumber()) + .seniorNickName(senior.getUser().getNickName()) + .seniorPhoneNumber(senior.getUser().getPhoneNumber()) .build(); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index 824e4805..de33f14a 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -15,8 +15,12 @@ @RequiredArgsConstructor public class MentoringManageByAdminUseCase { private final MentoringGetService mentoringGetService; -// public List getMentorings() { -// List mentorings = mentoringGetService.all(); -// return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); -// } + public List getUserMentorings(Long userId) { + List mentorings = mentoringGetService.byUserId(userId); + return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); + } + public List getSeniorMentorings(Long seniorId) { + List mentorings = mentoringGetService.bySeniorId(seniorId); + return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index aeda3bb1..c5de2aba 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -82,12 +82,19 @@ public ResponseDto> getSeniors() { return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), seniors); } -// @GetMapping("/mentorings") -// @Operation(summary = "[관리자] 매칭 정보 목록", description = "매칭 정보 목록을 조회합니다.") -// public ResponseDto> getMentorings() { -// List mentorings = mentoringManageUseCase.getMentorings(); -// return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); -// } + @GetMapping("/user/{userId}/mentoring") + @Operation(summary = "[관리자] 유저 멘토링 조회", description = "유저의 멘토링 목록을 조회합니다.") + public ResponseDto> getUserMentorings(@PathVariable Long userId) { + List mentorings = mentoringManageUseCase.getUserMentorings(userId); + return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); + } + + @GetMapping("/senior/{seniorId}/mentoring") + @Operation(summary = "[관리자] 유저 멘토링 조회", description = "유저의 멘토링 목록을 조회합니다.") + public ResponseDto> getSeniorMentorings(@PathVariable Long seniorId) { + List mentorings = mentoringManageUseCase.getSeniorMentorings(seniorId); + return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); + } @GetMapping("/payments") @Operation(summary = "[관리자] 결제 정보 목록", description = "결제 정보 목록을 조회합니다.") diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java b/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java index cb976080..c4433db4 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java @@ -15,4 +15,6 @@ public interface MentoringRepository extends JpaRepository { List findAllByUserAndStatus(User user, Status status); List findAllBySeniorAndStatus(Senior senior, Status status); List findAllByStatusAndCreatedAtIsBefore(Status status, LocalDate now); + List findAllByUser_UserId(Long userId); + List findAllBySenior_SeniorId(Long seniorId); } 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 b8992125..c1316cf5 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 @@ -32,4 +32,12 @@ public Mentoring byMentoringId(Long mentoringId) { public List byStatusAndCreatedAt(Status status, LocalDate now) { return mentoringRepository.findAllByStatusAndCreatedAtIsBefore(status, now); } + + public List byUserId(Long userId) { + return mentoringRepository.findAllByUser_UserId(userId); + } + + public List bySeniorId(Long seniorId) { + return mentoringRepository.findAllBySenior_SeniorId(seniorId); + } } From 00f826c95cdcf7529123dbc9931f2725073a9a49 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 4 Dec 2023 21:40:24 +0900 Subject: [PATCH 08/47] =?UTF-8?q?RAC-186=20feat:=20Account=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EB=B0=8F=20=EC=9D=91=EB=8B=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/exception/AccountException.java | 10 +++++++ .../exception/AccountNotFoundException.java | 10 +++++++ .../constant/AccountResponseCode.java | 16 ++++++++++ .../constant/AccountResponseMessage.java | 15 ++++++++++ .../admin/presentation/AdminController.java | 29 ++++++++++++------- 5 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/account/exception/AccountException.java create mode 100644 src/main/java/com/postgraduate/domain/account/exception/AccountNotFoundException.java create mode 100644 src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java create mode 100644 src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseMessage.java diff --git a/src/main/java/com/postgraduate/domain/account/exception/AccountException.java b/src/main/java/com/postgraduate/domain/account/exception/AccountException.java new file mode 100644 index 00000000..bf4e4e93 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/account/exception/AccountException.java @@ -0,0 +1,10 @@ +package com.postgraduate.domain.account.exception; + +import com.postgraduate.global.exception.ApplicationException; + +public class AccountException extends ApplicationException { + + protected AccountException(String message, String errorCode) { + super(message, errorCode); + } +} diff --git a/src/main/java/com/postgraduate/domain/account/exception/AccountNotFoundException.java b/src/main/java/com/postgraduate/domain/account/exception/AccountNotFoundException.java new file mode 100644 index 00000000..c57e9302 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/account/exception/AccountNotFoundException.java @@ -0,0 +1,10 @@ +package com.postgraduate.domain.account.exception; + +import static com.postgraduate.domain.account.presentation.constant.AccountResponseCode.ACCOUNT_NOT_FOUND; +import static com.postgraduate.domain.account.presentation.constant.AccountResponseMessage.NOT_FOUND_ACCOUNT; + +public class AccountNotFoundException extends AccountException { + public AccountNotFoundException() { + super(NOT_FOUND_ACCOUNT.getMessage(), ACCOUNT_NOT_FOUND.getCode()); + } +} diff --git a/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java new file mode 100644 index 00000000..2311ce3a --- /dev/null +++ b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java @@ -0,0 +1,16 @@ +package com.postgraduate.domain.account.presentation.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum AccountResponseCode { + ACCOUNT_FIND("ACT200"), + ACCOUNT_UPDATE("ACT201"), + ACCOUNT_CREATE("ACT202"), + ACCOUNT_DELETE("ACT203"), + + ACCOUNT_NOT_FOUND("AE400"); + private final String code; +} diff --git a/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseMessage.java b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseMessage.java new file mode 100644 index 00000000..9dbf27e9 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseMessage.java @@ -0,0 +1,15 @@ +package com.postgraduate.domain.account.presentation.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum AccountResponseMessage { + GET_ACCOUNT_INFO("계좌 정보 조회에 성공하였습니다"), + GET_ACCOUNT_LIST_INFO("계좌 리스트 조회에 성공하였습니다."), + + NOT_FOUND_ACCOUNT("계좌를 찾을 수 없습니다."); + + private final String message; +} diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index c5de2aba..adf9d4ff 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -2,10 +2,7 @@ import com.postgraduate.domain.admin.application.dto.req.SeniorStatusRequest; import com.postgraduate.domain.admin.application.dto.res.*; -import com.postgraduate.domain.admin.application.usecase.MentoringManageByAdminUseCase; -import com.postgraduate.domain.admin.application.usecase.PaymentManageByAdminUseCase; -import com.postgraduate.domain.admin.application.usecase.SeniorManageByAdminUseCase; -import com.postgraduate.domain.admin.application.usecase.UserManageByAdminUseCase; +import com.postgraduate.domain.admin.application.usecase.*; import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; import com.postgraduate.domain.wish.application.usecase.WishInfoUseCase; import com.postgraduate.global.dto.ResponseDto; @@ -20,13 +17,15 @@ import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_LIST_INFO; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.PAYMENT_FIND; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.GET_PAYMENT_LIST_INFO; +import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseCode.SALARY_FIND; +import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseMessage.GET_SALARY_INFO; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_FIND; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_UPDATE; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; import static com.postgraduate.domain.user.presentation.constant.UserResponseCode.USER_FIND; import static com.postgraduate.domain.user.presentation.constant.UserResponseMessage.GET_USER_LIST_INFO; import static com.postgraduate.domain.wish.presentation.constant.WishResponseCode.WISH_FIND; -import static com.postgraduate.domain.wish.presentation.constant.WishResponseMessage.*; +import static com.postgraduate.domain.wish.presentation.constant.WishResponseMessage.GET_WISH_INFO; @RestController @@ -39,6 +38,7 @@ public class AdminController { private final MentoringManageByAdminUseCase mentoringManageUseCase; private final PaymentManageByAdminUseCase paymentManageUseCase; private final WishInfoUseCase wishInfoUseCase; + private final SalaryManageByAdminUseCase salaryManageUseCase; @GetMapping("/certification/{seniorId}") @Operation(summary = "[관리자] 선배 프로필 승인 요청 조회", description = "선배 신청 시 작성한 사전 작성정보 및 첨부사진을 조회합니다.") @@ -47,12 +47,12 @@ public ResponseDto getCertificationDetails(@PathVa return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_PROFILE.getMessage(), certification); } - @GetMapping("/certification") - @Operation(summary = "[관리자] 선배 프로필 승인 대기 목록", description = "선배 프로필 승인 신청한 유저 목록을 조회합니다.") - public ResponseDto> getCertifications() { - List certifications = seniorManageUseCase.getCertifications(); - return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), certifications); - } +// @GetMapping("/certification") +// @Operation(summary = "[관리자] 선배 프로필 승인 대기 목록", description = "선배 프로필 승인 신청한 유저 목록을 조회합니다.") +// public ResponseDto> getCertifications() { +// List certifications = seniorManageUseCase.getCertifications(); +// return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), certifications); +// } @PatchMapping("/certification/{seniorId}") @Operation(summary = "[관리자] 선배 프로필 승인 요청 응답", description = "선배 승인 신청한 유저를 승인 또는 거부합니다.") @@ -82,6 +82,13 @@ public ResponseDto> getSeniors() { return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), seniors); } + @GetMapping("/salary/{seniorId}") + @Operation(summary = "[관리자] 선배 정산 상세 정보", description = "대학원생 선배 정산 상세 정보를 조회합니다.") + public ResponseDto getSalary(@PathVariable Long seniorId) { + SalaryResponse salary = salaryManageUseCase.getSalary(seniorId); + return ResponseDto.create(SALARY_FIND.getCode(), GET_SALARY_INFO.getMessage(), salary); + } + @GetMapping("/user/{userId}/mentoring") @Operation(summary = "[관리자] 유저 멘토링 조회", description = "유저의 멘토링 목록을 조회합니다.") public ResponseDto> getUserMentorings(@PathVariable Long userId) { From 9358e99a10fc802c8ceb2e652be7ba1bcaca9d55 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 4 Dec 2023 21:44:22 +0900 Subject: [PATCH 09/47] =?UTF-8?q?RAC-186=20feat:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/SalaryResponse.java | 13 +++++++ .../application/dto/res/SeniorResponse.java | 2 +- .../admin/application/mapper/AdminMapper.java | 17 +++++++++- .../usecase/SalaryManageByAdminUseCase.java | 34 +++++++++++++++++++ .../usecase/SeniorManageByAdminUseCase.java | 16 +-------- .../usecase/SalaryInfoUseCase.java | 8 +---- .../domain/salary/util/SalaryUtil.java | 23 +++++++++++++ 7 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java create mode 100644 src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java new file mode 100644 index 00000000..2206b1d1 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java @@ -0,0 +1,13 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import jakarta.annotation.Nullable; + +public record SalaryResponse( + @Nullable String nickName, + @Nullable String phoneNumber, + @Nullable Integer totalAmount, + @Nullable String accountHolder, + @Nullable String bank, + @Nullable String accountNumber, + @Nullable Boolean status +) {} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java index 0c39f268..f59da10a 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java @@ -11,7 +11,7 @@ public class SeniorResponse { private String nickName; private String phoneNumber; private Status status; - private String salaryStatus; + private Boolean salaryStatus; private Boolean marketingReceive; // 후배 회원 가입 } 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 300d7b22..971fc7f8 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 @@ -1,5 +1,6 @@ package com.postgraduate.domain.admin.application.mapper; +import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.admin.application.dto.CertificationInfo; import com.postgraduate.domain.admin.application.dto.CertificationProfile; import com.postgraduate.domain.admin.application.dto.res.*; @@ -61,7 +62,7 @@ public static UserResponse mapToUserResponse(User user, Wish wish) { // .build(); // } - public static SeniorResponse mapToSeniorResponse(Senior senior, String salaryStatus) { + public static SeniorResponse mapToSeniorResponse(Senior senior, Boolean salaryStatus) { User user = senior.getUser(); return SeniorResponse.builder() .seniorId(senior.getSeniorId()) @@ -96,4 +97,18 @@ public static PaymentResponse mapToPaymentResponse(Payment payment) { .pay(payment.getMentoring().getPay()) .build(); } + + public static SalaryResponse mapToSalaryResponse(Account account, int totalAmount, Boolean status) { + Senior senior = account.getSenior(); + User user = senior.getUser(); + return new SalaryResponse( + user.getNickName(), + user.getPhoneNumber(), + totalAmount, + account.getAccountHolder(), + account.getBank(), + account.getAccountNumber(), + status + ); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java new file mode 100644 index 00000000..2fdfd805 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -0,0 +1,34 @@ +package com.postgraduate.domain.admin.application.usecase; + +import com.postgraduate.domain.account.domain.entity.Account; +import com.postgraduate.domain.account.domain.service.AccountGetService; +import com.postgraduate.domain.account.exception.AccountNotFoundException; +import com.postgraduate.domain.admin.application.dto.res.SalaryResponse; +import com.postgraduate.domain.admin.application.mapper.AdminMapper; +import com.postgraduate.domain.salary.domain.entity.Salary; +import com.postgraduate.domain.salary.domain.service.SalaryGetService; +import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.service.SeniorGetService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static com.postgraduate.domain.salary.util.SalaryUtil.*; + +@Service +@RequiredArgsConstructor +public class SalaryManageByAdminUseCase { + private final SeniorGetService seniorGetService; + private final AccountGetService accountGetService; + private final SalaryGetService salaryGetService; + + public SalaryResponse getSalary(Long seniorId) { + Senior senior = seniorGetService.bySeniorId(seniorId); + Account account = accountGetService.bySenior(senior).orElseThrow(AccountNotFoundException::new); + List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); + int totalAmount = getAmount(salaries); + Boolean status = getStatus(salaries); + return AdminMapper.mapToSalaryResponse(account, totalAmount, status); + } +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 388f4cbc..63b3c1e0 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -64,23 +64,9 @@ public List getSeniors() { return seniors.stream() .map(senior -> { List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); - String salaryStatus = getSalaryStatus(salaries); + Boolean salaryStatus = getStatus(salaries); return AdminMapper.mapToSeniorResponse(senior, salaryStatus); }) .toList(); } - - private String getSalaryStatus(List salaries) { - long count = salaries.stream() - .filter(Salary::getStatus) - .count(); - - if (count == salaries.size()) { - return "O"; - } - if (count == 0) { - return "X"; - } - return "-"; - } } diff --git a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java index d55c1c30..5b89426d 100644 --- a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java @@ -15,6 +15,7 @@ import java.time.LocalDate; import java.util.List; +import static com.postgraduate.domain.salary.util.SalaryUtil.getAmount; import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; @Service @@ -32,13 +33,6 @@ public SalaryInfoResponse getSalary(User user) { return new SalaryInfoResponse(salaryDate, amount); //TODO 수수료 } - private int getAmount(List salaries) { - return salaries.stream() - .map(salary -> salary.getMentoring().getPay()) - .mapToInt(Integer::intValue) - .sum(); - } - public List getSalaryDetail(User user, Boolean status) { Senior senior = seniorGetService.byUser(user); List salaries = salaryGetService.bySeniorAndStatus(senior, status); diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index 02d5b181..11ae693f 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -1,7 +1,10 @@ package com.postgraduate.domain.salary.util; +import com.postgraduate.domain.salary.domain.entity.Salary; + import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.List; public class SalaryUtil { private static final int SALARY_DATE = 10; @@ -15,4 +18,24 @@ public static LocalDate getSalaryDate() { public static DateTimeFormatter getMonthFormat() { return DateTimeFormatter.ofPattern("yyyy-MM"); } + + public static int getAmount(List salaries) { + return salaries.stream() + .map(salary -> salary.getMentoring().getPay()) + .mapToInt(Integer::intValue) + .sum(); + } + + public static Boolean getStatus(List salaries) { + long count = salaries.stream() + .filter(Salary::getStatus) + .count(); + if (count == salaries.size()) { + return true; + } + if (count != salaries.size()) { + return false; + } + return null; + } } From 9840f4106dcbe9e40dc2e7606875e32f458e7cfa Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 4 Dec 2023 21:46:15 +0900 Subject: [PATCH 10/47] =?UTF-8?q?RAC-186=20fix:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=8A=B9=EC=9D=B8=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20dto=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/dto/CertificationInfo.java | 7 ++++++- .../dto/res/CertificationDetailsResponse.java | 12 ++---------- .../admin/application/mapper/AdminMapper.java | 15 +++++++++++---- .../usecase/SeniorManageByAdminUseCase.java | 8 ++------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java index 38560097..5f4d9f3d 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java @@ -8,9 +8,14 @@ @Getter @AllArgsConstructor public class CertificationInfo { - private String nickName; private String certification; + private String nickName; + private String phoneNumber; + //인증 신청 날짜 private String postgradu; + private String major; private String field; + private String lab; private String professor; + private String keyword; } diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java index 6bcd71f1..59c1ab63 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java @@ -1,15 +1,7 @@ package com.postgraduate.domain.admin.application.dto.res; import com.postgraduate.domain.admin.application.dto.CertificationInfo; -import com.postgraduate.domain.admin.application.dto.CertificationProfile; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; +import jakarta.annotation.Nullable; -@Builder -@Getter -@AllArgsConstructor -public class CertificationDetailsResponse { - private CertificationInfo certificationInfo; - private CertificationProfile certificationProfile; +public record CertificationDetailsResponse(@Nullable CertificationInfo certificationInfo) { } 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 971fc7f8..327b9f94 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 @@ -6,6 +6,7 @@ import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; +import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.wish.domain.entity.Wish; @@ -13,12 +14,18 @@ public class AdminMapper { public static CertificationInfo mapToCertificationInfo(Senior senior) { + User user = senior.getUser(); + Info info = senior.getInfo(); return CertificationInfo.builder() .certification(senior.getCertification()) - .nickName(senior.getUser().getNickName()) - .postgradu(senior.getInfo().getPostgradu()) - .field(senior.getInfo().getField()) - .professor(senior.getInfo().getProfessor()) + .nickName(user.getNickName()) + .phoneNumber(user.getPhoneNumber()) + .postgradu(info.getPostgradu()) + .major(info.getMajor()) + .field(info.getField()) + .lab(info.getLab()) + .professor(info.getProfessor()) + .keyword(info.getKeyword()) .build(); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 63b3c1e0..f919a7e1 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -1,7 +1,6 @@ package com.postgraduate.domain.admin.application.usecase; import com.postgraduate.domain.admin.application.dto.CertificationInfo; -import com.postgraduate.domain.admin.application.dto.CertificationProfile; import com.postgraduate.domain.admin.application.dto.req.SeniorStatusRequest; import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; import com.postgraduate.domain.admin.application.dto.res.CertificationResponse; @@ -23,6 +22,7 @@ import java.util.List; import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; +import static com.postgraduate.domain.salary.util.SalaryUtil.getStatus; @Service @Transactional @@ -37,12 +37,8 @@ public CertificationDetailsResponse getCertificationDetails(Long seniorId) { if (senior.getStatus() != Status.WAITING) { throw new SeniorNotWaitingException(); } - CertificationProfile certificationProfile = null; - if (senior.getProfile() != null) { - certificationProfile = AdminMapper.mapToCertificationProfile(senior); - } CertificationInfo certificationInfo = AdminMapper.mapToCertificationInfo(senior); - return new CertificationDetailsResponse(certificationInfo, certificationProfile); + return new CertificationDetailsResponse(certificationInfo); } public List getCertifications() { From 4265bea7266a7550f571195496c075b4dfe67a78 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 4 Dec 2023 22:14:20 +0900 Subject: [PATCH 11/47] =?UTF-8?q?RAC-186=20fix:=20=EA=B3=84=EC=A2=8C?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EB=B3=B5=ED=98=B8=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/application/mapper/AdminMapper.java | 4 ++-- .../application/usecase/SalaryManageByAdminUseCase.java | 5 ++++- 2 files changed, 6 insertions(+), 3 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 327b9f94..f1e7ff37 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 @@ -105,7 +105,7 @@ public static PaymentResponse mapToPaymentResponse(Payment payment) { .build(); } - public static SalaryResponse mapToSalaryResponse(Account account, int totalAmount, Boolean status) { + public static SalaryResponse mapToSalaryResponse(Account account, String accountNumber, int totalAmount, Boolean status) { Senior senior = account.getSenior(); User user = senior.getUser(); return new SalaryResponse( @@ -114,7 +114,7 @@ public static SalaryResponse mapToSalaryResponse(Account account, int totalAmoun totalAmount, account.getAccountHolder(), account.getBank(), - account.getAccountNumber(), + accountNumber, status ); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 2fdfd805..6dff05f4 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -9,6 +9,7 @@ import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; +import com.postgraduate.global.config.security.util.EncryptorUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -22,13 +23,15 @@ public class SalaryManageByAdminUseCase { private final SeniorGetService seniorGetService; private final AccountGetService accountGetService; private final SalaryGetService salaryGetService; + private final EncryptorUtils encryptorUtils; public SalaryResponse getSalary(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); Account account = accountGetService.bySenior(senior).orElseThrow(AccountNotFoundException::new); + String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); int totalAmount = getAmount(salaries); Boolean status = getStatus(salaries); - return AdminMapper.mapToSalaryResponse(account, totalAmount, status); + return AdminMapper.mapToSalaryResponse(account, accountNumber, totalAmount, status); } } From 62a09f6260db1b5095587f088fed75791a2d57a5 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 4 Dec 2023 22:15:15 +0900 Subject: [PATCH 12/47] =?UTF-8?q?RAC-186=20feat:=20=ED=9B=84=EB=B0=B0=20?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=ED=9B=84=EB=B0=B0=EB=A7=8C=20=EA=B0=80=EC=A7=80=EB=8A=94=20`wi?= =?UTF-8?q?sh`=EB=A1=9C=20=ED=8C=90=EB=8B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/application/dto/res/SeniorResponse.java | 2 +- .../domain/admin/application/mapper/AdminMapper.java | 3 ++- .../application/usecase/SeniorManageByAdminUseCase.java | 7 ++++++- .../domain/wish/application/mapper/WishMapper.java | 3 +-- .../wish/application/mapper/dto/res/WishResponse.java | 8 +------- .../domain/wish/domain/service/WishGetService.java | 9 +++++++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java index f59da10a..9a9f69e4 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java @@ -13,5 +13,5 @@ public class SeniorResponse { private Status status; private Boolean salaryStatus; private Boolean marketingReceive; - // 후배 회원 가입 + private Boolean isUser; } 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 f1e7ff37..baad7d35 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 @@ -69,7 +69,7 @@ public static UserResponse mapToUserResponse(User user, Wish wish) { // .build(); // } - public static SeniorResponse mapToSeniorResponse(Senior senior, Boolean salaryStatus) { + public static SeniorResponse mapToSeniorResponse(Senior senior, Boolean salaryStatus, Boolean isUser) { User user = senior.getUser(); return SeniorResponse.builder() .seniorId(senior.getSeniorId()) @@ -78,6 +78,7 @@ public static SeniorResponse mapToSeniorResponse(Senior senior, Boolean salarySt .status(senior.getStatus()) .salaryStatus(salaryStatus) .marketingReceive(user.getMarketingReceive()) + .isUser(isUser) .build(); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index f919a7e1..c4b026a0 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -15,11 +15,14 @@ import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.service.UserUpdateService; +import com.postgraduate.domain.wish.domain.entity.Wish; +import com.postgraduate.domain.wish.domain.service.WishGetService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Optional; import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; import static com.postgraduate.domain.salary.util.SalaryUtil.getStatus; @@ -31,6 +34,7 @@ public class SeniorManageByAdminUseCase { private final SeniorGetService seniorGetService; private final UserUpdateService userUpdateService; private final SalaryGetService salaryGetService; + private final WishGetService wishGetService; public CertificationDetailsResponse getCertificationDetails(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); @@ -61,7 +65,8 @@ public List getSeniors() { .map(senior -> { List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); Boolean salaryStatus = getStatus(salaries); - return AdminMapper.mapToSeniorResponse(senior, salaryStatus); + Optional wish = wishGetService.byUser(senior.getUser()); + return AdminMapper.mapToSeniorResponse(senior, salaryStatus, wish.isPresent()); }) .toList(); } diff --git a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java index 332c908d..20653963 100644 --- a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java +++ b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java @@ -17,8 +17,7 @@ public static Wish mapToWish(User user, SignUpRequest request) { public static WishResponse mapToWish(Wish wish) { User user = wish.getUser(); - String[] field = wish.getField().split(","); return new WishResponse(user.getNickName(), user.getPhoneNumber(), user.getCreatedAt(), user.getMarketingReceive(), - wish.getMatchingReceive(), wish.getMajor(), field); + wish.getMatchingReceive(), wish.getMajor(), wish.getField()); } } diff --git a/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java b/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java index 7db5cb63..5ffa2719 100644 --- a/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java +++ b/src/main/java/com/postgraduate/domain/wish/application/mapper/dto/res/WishResponse.java @@ -7,22 +7,16 @@ public record WishResponse( @NotNull String nickName, - @NotNull String phoneNumber, - @NotNull LocalDate createAt, - @NotNull Boolean marketingReceive, - @NotNull Boolean matchingReceive, - @NotNull String major, - @NotNull - String[] field + String field ) {} diff --git a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java index 80029ca5..89b9dc0f 100644 --- a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java +++ b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java @@ -1,12 +1,13 @@ package com.postgraduate.domain.wish.domain.service; -import com.postgraduate.domain.wish.application.mapper.WishMapper; -import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; +import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.repository.WishRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor public class WishGetService { @@ -14,4 +15,8 @@ public class WishGetService { public Wish byWishId(Long wishId) { return wishRepository.findById(wishId).orElseThrow(); } + + public Optional byUser(User user) { + return wishRepository.findByUser(user); + } } From 40b45a7fb2ad9db4ee46c679c35000cb7898dfaa Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:31:46 +0900 Subject: [PATCH 13/47] =?UTF-8?q?RAC-186=20fix:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/CertificationDetailsResponse.java | 4 ++-- .../dto/res/SalaryDetailsResponse.java | 21 +++++++++++++++++++ .../application/dto/res/SalaryResponse.java | 13 ------------ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java index 59c1ab63..ccf4cbad 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.admin.application.dto.res; import com.postgraduate.domain.admin.application.dto.CertificationInfo; -import jakarta.annotation.Nullable; +import jakarta.validation.constraints.NotNull; -public record CertificationDetailsResponse(@Nullable CertificationInfo certificationInfo) { +public record CertificationDetailsResponse(@NotNull CertificationInfo certificationInfo) { } diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java new file mode 100644 index 00000000..f265b06c --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java @@ -0,0 +1,21 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import jakarta.validation.constraints.NotNull; + +public record SalaryDetailsResponse( + @NotNull + String nickName, + @NotNull + String phoneNumber, + @NotNull + Integer totalAmount, + @NotNull + String accountHolder, + @NotNull + String bank, + @NotNull + String accountNumber, + @NotNull + SalaryStatus status +) {} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java deleted file mode 100644 index 2206b1d1..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import jakarta.annotation.Nullable; - -public record SalaryResponse( - @Nullable String nickName, - @Nullable String phoneNumber, - @Nullable Integer totalAmount, - @Nullable String accountHolder, - @Nullable String bank, - @Nullable String accountNumber, - @Nullable Boolean status -) {} From 5b5c5555843a779c380b60122af71c160f161d67 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:35:45 +0900 Subject: [PATCH 14/47] =?UTF-8?q?RAC-186=20fix:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20dto=20Enum=EC=9C=BC=EB=A1=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/dto/res/SeniorResponse.java | 3 ++- .../admin/application/mapper/AdminMapper.java | 6 +++--- .../usecase/SeniorManageByAdminUseCase.java | 3 ++- .../salary/domain/entity/constant/SalaryStatus.java | 10 ++++++++++ .../postgraduate/domain/salary/util/SalaryUtil.java | 13 +++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java index 9a9f69e4..baad7fcd 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.admin.application.dto.res; +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import com.postgraduate.domain.senior.domain.entity.constant.Status; import lombok.Builder; import lombok.Getter; @@ -11,7 +12,7 @@ public class SeniorResponse { private String nickName; private String phoneNumber; private Status status; - private Boolean salaryStatus; + private SalaryStatus salaryStatus; private Boolean marketingReceive; private Boolean isUser; } 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 baad7d35..ad12a59a 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 @@ -6,6 +6,7 @@ import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; @@ -69,7 +70,7 @@ public static UserResponse mapToUserResponse(User user, Wish wish) { // .build(); // } - public static SeniorResponse mapToSeniorResponse(Senior senior, Boolean salaryStatus, Boolean isUser) { + public static SeniorResponse mapToSeniorResponse(Senior senior, SalaryStatus salaryStatus, Boolean isUser) { User user = senior.getUser(); return SeniorResponse.builder() .seniorId(senior.getSeniorId()) @@ -106,8 +107,7 @@ public static PaymentResponse mapToPaymentResponse(Payment payment) { .build(); } - public static SalaryResponse mapToSalaryResponse(Account account, String accountNumber, int totalAmount, Boolean status) { - Senior senior = account.getSenior(); + public static SalariesResponse mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, LocalDateTime salaryDoneDate) { User user = senior.getUser(); return new SalaryResponse( user.getNickName(), diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index c4b026a0..759f411f 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -8,6 +8,7 @@ import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; import com.postgraduate.domain.salary.domain.entity.Salary; +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.entity.constant.Status; @@ -64,7 +65,7 @@ public List getSeniors() { return seniors.stream() .map(senior -> { List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); - Boolean salaryStatus = getStatus(salaries); + SalaryStatus salaryStatus = getStatus(salaries); Optional wish = wishGetService.byUser(senior.getUser()); return AdminMapper.mapToSeniorResponse(senior, salaryStatus, wish.isPresent()); }) diff --git a/src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java b/src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java new file mode 100644 index 00000000..a4f58e62 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java @@ -0,0 +1,10 @@ +package com.postgraduate.domain.salary.domain.entity.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum SalaryStatus { + DONE, YET, NONE +} diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index 11ae693f..e12b7375 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.salary.util; import com.postgraduate.domain.salary.domain.entity.Salary; +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import java.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -26,16 +27,16 @@ public static int getAmount(List salaries) { .sum(); } - public static Boolean getStatus(List salaries) { + public static SalaryStatus getStatus(List salaries) { long count = salaries.stream() .filter(Salary::getStatus) .count(); - if (count == salaries.size()) { - return true; + if (count == 0) { + return SalaryStatus.NONE; } - if (count != salaries.size()) { - return false; + if (count == salaries.size()) { + return SalaryStatus.DONE; } - return null; + return SalaryStatus.YET; } } From cc7f8dffa3b63d0898aed05072410cabf0495eb7 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:39:07 +0900 Subject: [PATCH 15/47] =?UTF-8?q?RAC-186=20feat:=20=EA=B0=80=EC=A7=9C=20?= =?UTF-8?q?=EA=B3=84=EC=A2=8C=20=EC=A0=95=EB=B3=B4=20Util?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/account/util/AccountUtil.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/account/util/AccountUtil.java diff --git a/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java b/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java new file mode 100644 index 00000000..90b295a1 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java @@ -0,0 +1,19 @@ +package com.postgraduate.domain.account.util; + +import com.postgraduate.domain.account.domain.entity.Account; +import com.postgraduate.global.config.security.util.EncryptorUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class AccountUtil { + private final EncryptorUtils encryptorUtils; + public Account createDummyAccount() { + return Account.builder() + .accountNumber(encryptorUtils.encryptData("dummyAccountNumber")) + .bank("dummyBank") + .accountHolder("dummyAccountHolder") + .build(); + } +} From b93a6c6acdbdfe0740c2be2863e175a5b69b972c Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:41:50 +0900 Subject: [PATCH 16/47] =?UTF-8?q?RAC-186=20feat:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/mapper/AdminMapper.java | 13 +++++++++++++ .../usecase/SalaryManageByAdminUseCase.java | 16 ++++++++++------ .../admin/presentation/AdminController.java | 4 ++-- 3 files changed, 25 insertions(+), 8 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 ad12a59a..17f4dc90 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 @@ -119,4 +119,17 @@ public static SalariesResponse mapToSalaryResponse(Senior senior, Account accoun status ); } + + public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, SalaryStatus status) { + User user = senior.getUser(); + return new SalaryDetailsResponse( + user.getNickName(), + user.getPhoneNumber(), + totalAmount, + account.getAccountHolder(), + account.getBank(), + accountNumber, + status + ); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 6dff05f4..c4792f7c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -2,10 +2,13 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.account.domain.service.AccountGetService; -import com.postgraduate.domain.account.exception.AccountNotFoundException; -import com.postgraduate.domain.admin.application.dto.res.SalaryResponse; +import com.postgraduate.domain.account.util.AccountUtil; +import com.postgraduate.domain.admin.application.dto.res.AllSalariesResponse; +import com.postgraduate.domain.admin.application.dto.res.SalariesResponse; +import com.postgraduate.domain.admin.application.dto.res.SalaryDetailsResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.salary.domain.entity.Salary; +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; @@ -24,14 +27,15 @@ public class SalaryManageByAdminUseCase { private final AccountGetService accountGetService; private final SalaryGetService salaryGetService; private final EncryptorUtils encryptorUtils; + private final AccountUtil accountUtil; - public SalaryResponse getSalary(Long seniorId) { + public SalaryDetailsResponse getSalary(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); - Account account = accountGetService.bySenior(senior).orElseThrow(AccountNotFoundException::new); + Account account = accountGetService.bySenior(senior).orElse(accountUtil.createDummyAccount()); String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); int totalAmount = getAmount(salaries); - Boolean status = getStatus(salaries); - return AdminMapper.mapToSalaryResponse(account, accountNumber, totalAmount, status); + SalaryStatus status = getStatus(salaries); + return AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, status); } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index adf9d4ff..b83dc7f5 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -84,8 +84,8 @@ public ResponseDto> getSeniors() { @GetMapping("/salary/{seniorId}") @Operation(summary = "[관리자] 선배 정산 상세 정보", description = "대학원생 선배 정산 상세 정보를 조회합니다.") - public ResponseDto getSalary(@PathVariable Long seniorId) { - SalaryResponse salary = salaryManageUseCase.getSalary(seniorId); + public ResponseDto getSalary(@PathVariable Long seniorId) { + SalaryDetailsResponse salary = salaryManageUseCase.getSalary(seniorId); return ResponseDto.create(SALARY_FIND.getCode(), GET_SALARY_INFO.getMessage(), salary); } From 2461ba866c8b0fd0867ea74fd15ed3ff027db1e1 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:42:42 +0900 Subject: [PATCH 17/47] =?UTF-8?q?RAC-186=20feat:=20=EC=A0=95=EC=82=B0?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EC=9D=BC=20=ED=95=84=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20salaryDate(=EC=A0=95=EC=82=B0=EC=98=88=EC=A0=95?= =?UTF-8?q?=EC=9D=BC),=20salaryDoneDate(=EC=A0=95=EC=82=B0=EC=99=84?= =?UTF-8?q?=EB=A3=8C=EC=9D=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/postgraduate/domain/salary/domain/entity/Salary.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java b/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java index 5cd06686..b9f5b903 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java @@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; import java.time.LocalDate; +import java.time.LocalDateTime; @Entity @Builder @@ -32,4 +33,7 @@ public class Salary { @Column(nullable = false) private LocalDate salaryDate; + + @Column + private LocalDateTime salaryDoneDate; } From d7bf76035f89672a0c7dff420ce9b2c083602d61 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:43:06 +0900 Subject: [PATCH 18/47] =?UTF-8?q?RAC-186=20feat:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/AllSalariesResponse.java | 8 +++++++ .../application/dto/res/SalariesResponse.java | 22 +++++++++++++++++++ .../admin/application/mapper/AdminMapper.java | 6 +++-- .../usecase/SalaryManageByAdminUseCase.java | 21 ++++++++++++++++++ .../admin/presentation/AdminController.java | 7 ++++++ .../domain/repository/SalaryRepository.java | 1 + .../domain/service/SalaryGetService.java | 4 ++++ .../domain/salary/util/SalaryUtil.java | 5 +++++ 8 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java new file mode 100644 index 00000000..4b84d337 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java @@ -0,0 +1,8 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record AllSalariesResponse(@NotNull List salariesResponses) { +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java new file mode 100644 index 00000000..610cd519 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java @@ -0,0 +1,22 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import jakarta.validation.constraints.NotNull; + +import java.time.LocalDateTime; + +public record SalariesResponse( + @NotNull + String nickName, + @NotNull + String phoneNumber, + @NotNull + Integer totalAmount, + @NotNull + String accountHolder, + @NotNull + String bank, + @NotNull + String accountNumber, + @NotNull + LocalDateTime salaryDoneDate +) {} 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 17f4dc90..d79f7617 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 @@ -12,6 +12,8 @@ import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.wish.domain.entity.Wish; +import java.time.LocalDateTime; + public class AdminMapper { public static CertificationInfo mapToCertificationInfo(Senior senior) { @@ -109,14 +111,14 @@ public static PaymentResponse mapToPaymentResponse(Payment payment) { public static SalariesResponse mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, LocalDateTime salaryDoneDate) { User user = senior.getUser(); - return new SalaryResponse( + return new SalariesResponse( user.getNickName(), user.getPhoneNumber(), totalAmount, account.getAccountHolder(), account.getBank(), accountNumber, - status + salaryDoneDate ); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index c4792f7c..55aadd59 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -16,8 +16,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; +import static com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus.DONE; import static com.postgraduate.domain.salary.util.SalaryUtil.*; @Service @@ -38,4 +41,22 @@ public SalaryDetailsResponse getSalary(Long seniorId) { SalaryStatus status = getStatus(salaries); return AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, status); } + + public AllSalariesResponse getSalaries() { + List responses = new ArrayList<>(); + List seniors = seniorGetService.getAll(); + for (Senior senior : seniors) { + List salaries = salaryGetService.bySeniorAndSalaryDateAndStatus(senior, getSalaryDate(), true); + if (getStatus(salaries) != DONE) { + continue; + } + Account account = accountGetService.bySenior(senior).orElse(accountUtil.createDummyAccount()); + String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); + int totalAmount = getAmount(salaries); + LocalDateTime salaryDoneDate = getDoneDate(salaries); + SalariesResponse response = AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, salaryDoneDate); + responses.add(response); + } + return new AllSalariesResponse(responses); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index b83dc7f5..1e2944d4 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -82,6 +82,13 @@ public ResponseDto> getSeniors() { return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), seniors); } + @GetMapping("/salary") + @Operation(summary = "[관리자] 정산 목록 조회", description = "한 달 기준으로 정산 목록을 조회합니다. 기준일은 [11일 ~ 내월 10일]입니다.") + public ResponseDto getSalaries() { + AllSalariesResponse salaries = salaryManageUseCase.getSalaries(); + return ResponseDto.create(SALARY_FIND.getCode(), GET_SALARY_INFO.getMessage(), salaries); + } + @GetMapping("/salary/{seniorId}") @Operation(summary = "[관리자] 선배 정산 상세 정보", description = "대학원생 선배 정산 상세 정보를 조회합니다.") public ResponseDto getSalary(@PathVariable Long seniorId) { diff --git a/src/main/java/com/postgraduate/domain/salary/domain/repository/SalaryRepository.java b/src/main/java/com/postgraduate/domain/salary/domain/repository/SalaryRepository.java index 17d9dd84..e47c7ff7 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/repository/SalaryRepository.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/repository/SalaryRepository.java @@ -11,6 +11,7 @@ public interface SalaryRepository extends JpaRepository { List findAllBySeniorAndSalaryDate(Senior senior, LocalDate salaryDate); + List findAllBySeniorAndSalaryDateAndStatus(Senior senior, LocalDate salaryDate, Boolean status); List findAllBySeniorAndStatusOrderBySalaryDateDesc(Senior senior, Boolean status); Optional findByMentoring(Mentoring mentoring); } diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java index cd1616ae..f77f992a 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java @@ -24,6 +24,10 @@ public List bySeniorAndSalaryDate(Senior senior, LocalDate salaryDate) { return salaryRepository.findAllBySeniorAndSalaryDate(senior, salaryDate); } + public List bySeniorAndSalaryDateAndStatus(Senior senior, LocalDate salaryDate, Boolean status) { + return salaryRepository.findAllBySeniorAndSalaryDateAndStatus(senior, salaryDate, status); + } + public Salary byMentoring(Mentoring mentoring) { return salaryRepository.findByMentoring(mentoring).orElseThrow(SalaryNotFoundException::new); } diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index e12b7375..7bfd1b81 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -4,6 +4,7 @@ import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; @@ -39,4 +40,8 @@ public static SalaryStatus getStatus(List salaries) { } return SalaryStatus.YET; } + + public static LocalDateTime getDoneDate(List salaries) { + return salaries.get(0).getSalaryDoneDate(); + } } From 48f9140cb7452e8bb2bcbeb4599d8470f57ecf71 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:52:37 +0900 Subject: [PATCH 19/47] =?UTF-8?q?RAC-186=20fix:=20`WishNotFoundException`?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/application/mapper/AdminMapper.java | 9 ++++++--- .../application/usecase/UserManageByAdminUseCase.java | 4 ++-- 2 files changed, 8 insertions(+), 5 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 d79f7617..62c4b085 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 @@ -13,6 +13,7 @@ import com.postgraduate.domain.wish.domain.entity.Wish; import java.time.LocalDateTime; +import java.util.Optional; public class AdminMapper { @@ -48,15 +49,17 @@ public static CertificationResponse mapToCertification(Senior senior) { .build(); } - public static UserResponse mapToUserResponse(User user, Wish wish) { + public static UserResponse mapToUserResponse(User user, Optional wish) { + Long wishId = wish.map(Wish::getWishId).orElse(null); + Boolean matchingReceive = wish.map(Wish::getMatchingReceive).orElse(null); return UserResponse.builder() .userId(user.getUserId()) .nickName(user.getNickName()) .phoneNumber(user.getPhoneNumber()) .createdAt(user.getCreatedAt()) .marketingReceive(user.getMarketingReceive()) - .matchingReceive(wish.getMatchingReceive()) - .wishId(wish.getWishId()) + .matchingReceive(matchingReceive) + .wishId(wishId) .role(user.getRole()) .build(); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java index 8e711ccc..78edfb33 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java @@ -6,12 +6,12 @@ import com.postgraduate.domain.user.domain.service.UserGetService; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.repository.WishRepository; -import com.postgraduate.domain.wish.exception.WishNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Optional; import static com.postgraduate.domain.user.domain.entity.constant.Role.ADMIN; @@ -26,7 +26,7 @@ public List getUsers() { return users.stream() .filter(user -> user.getRole() != ADMIN) .map(user -> { - Wish wish = wishRepository.findByUser(user).orElseThrow(WishNotFoundException::new); + Optional wish = wishRepository.findByUser(user); return AdminMapper.mapToUserResponse(user, wish); }) .toList(); From c9bb102e487cedf0657abecd35f394b3431e63b5 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 16:54:34 +0900 Subject: [PATCH 20/47] =?UTF-8?q?RAC-186=20fix:=20swagger=20description=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/presentation/AdminController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 1e2944d4..337ad669 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -97,14 +97,14 @@ public ResponseDto getSalary(@PathVariable Long seniorId) } @GetMapping("/user/{userId}/mentoring") - @Operation(summary = "[관리자] 유저 멘토링 조회", description = "유저의 멘토링 목록을 조회합니다.") + @Operation(summary = "[관리자] 후배 멘토링 조회", description = "후배의 멘토링 목록을 조회합니다.") public ResponseDto> getUserMentorings(@PathVariable Long userId) { List mentorings = mentoringManageUseCase.getUserMentorings(userId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); } @GetMapping("/senior/{seniorId}/mentoring") - @Operation(summary = "[관리자] 유저 멘토링 조회", description = "유저의 멘토링 목록을 조회합니다.") + @Operation(summary = "[관리자] 선배 멘토링 조회", description = "선배의 멘토링 목록을 조회합니다.") public ResponseDto> getSeniorMentorings(@PathVariable Long seniorId) { List mentorings = mentoringManageUseCase.getSeniorMentorings(seniorId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); From 04b438f14a38bd25cf411734cf8d18003137a9c8 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 17:25:35 +0900 Subject: [PATCH 21/47] =?UTF-8?q?RAC-186=20feat:=20Payment=20=EC=98=88?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/payment/exception/PaymentException.java | 9 +++++++++ .../payment/exception/PaymentNotFoundException.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/payment/exception/PaymentException.java create mode 100644 src/main/java/com/postgraduate/domain/payment/exception/PaymentNotFoundException.java diff --git a/src/main/java/com/postgraduate/domain/payment/exception/PaymentException.java b/src/main/java/com/postgraduate/domain/payment/exception/PaymentException.java new file mode 100644 index 00000000..bbaf244a --- /dev/null +++ b/src/main/java/com/postgraduate/domain/payment/exception/PaymentException.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.payment.exception; + +import com.postgraduate.global.exception.ApplicationException; + +public class PaymentException extends ApplicationException { + protected PaymentException(String message, String errorCode) { + super(message, errorCode); + } +} diff --git a/src/main/java/com/postgraduate/domain/payment/exception/PaymentNotFoundException.java b/src/main/java/com/postgraduate/domain/payment/exception/PaymentNotFoundException.java new file mode 100644 index 00000000..f9718942 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/payment/exception/PaymentNotFoundException.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.payment.exception; + +import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.PAYMENT_NOT_FOUND; +import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.NOT_FOUND_PAYMENT; + + +public class PaymentNotFoundException extends PaymentException { + + public PaymentNotFoundException() { + super(NOT_FOUND_PAYMENT.getMessage(), PAYMENT_NOT_FOUND.getCode()); + } +} From 418abf594e756f86ca4a294c046a4ef3e1345dd9 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 17:25:56 +0900 Subject: [PATCH 22/47] =?UTF-8?q?RAC-186=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B2=B0=EC=A0=9C=20=EC=A0=95=EB=B3=B4=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/MentoringWithPaymentResponse.java | 20 +++++++++++++++++++ .../admin/application/mapper/AdminMapper.java | 15 ++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java new file mode 100644 index 00000000..14e86dc1 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java @@ -0,0 +1,20 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import jakarta.validation.constraints.NotNull; + +public record MentoringWithPaymentResponse( + @NotNull + String userNickname, + @NotNull + String userPhoneNumber, + @NotNull + String seniorNickname, + @NotNull + String seniorPhoneNumber, + @NotNull + String date, + @NotNull + int term, + int pay, + int charge +) { } 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 62c4b085..2b564f20 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 @@ -137,4 +137,19 @@ public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account a status ); } + + public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Mentoring mentoring) { + User user = mentoring.getUser(); + Senior senior = mentoring.getSenior(); + return new MentoringWithPaymentResponse( + user.getNickName(), + user.getPhoneNumber(), + senior.getUser().getNickName(), + senior.getUser().getPhoneNumber(), + mentoring.getDate(), + senior.getProfile().getTerm(), + (int) (mentoring.getPay() * 1.2), + (int) (mentoring.getPay() * 0.2) + ); + } } From 5fee6d069ff3d6fba09892ad0cf2bd8da5b25589 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 17:26:28 +0900 Subject: [PATCH 23/47] =?UTF-8?q?RAC-186=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B2=B0=EC=A0=9C=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/MentoringManageByAdminUseCase.java | 13 +++++++++++++ .../domain/admin/presentation/AdminController.java | 8 ++++++++ .../domain/repository/PaymentRepository.java | 2 ++ .../payment/domain/service/PaymentGetService.java | 5 +++++ .../presentation/constant/PaymentResponseCode.java | 4 +++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index de33f14a..31d1bb0c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -1,9 +1,12 @@ package com.postgraduate.domain.admin.application.usecase; import com.postgraduate.domain.admin.application.dto.res.MentoringResponse; +import com.postgraduate.domain.admin.application.dto.res.MentoringWithPaymentResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; +import com.postgraduate.domain.payment.domain.service.PaymentGetService; +import com.postgraduate.domain.payment.exception.PaymentNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,12 +18,22 @@ @RequiredArgsConstructor public class MentoringManageByAdminUseCase { private final MentoringGetService mentoringGetService; + private final PaymentGetService paymentGetService; public List getUserMentorings(Long userId) { List mentorings = mentoringGetService.byUserId(userId); return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); } + public List getSeniorMentorings(Long seniorId) { List mentorings = mentoringGetService.bySeniorId(seniorId); return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); } + + public MentoringWithPaymentResponse getMentoringWithPayment(Long mentoringId) { + Mentoring mentoring = mentoringGetService.byMentoringId(mentoringId); + if (!paymentGetService.existsByMentoring(mentoring)) { + throw new PaymentNotFoundException(); + } + return AdminMapper.mapToMentoringWithPaymentResponse(mentoring); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 337ad669..67979469 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -14,6 +14,7 @@ import java.util.List; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_FIND; +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.*; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_LIST_INFO; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.PAYMENT_FIND; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.GET_PAYMENT_LIST_INFO; @@ -116,4 +117,11 @@ public ResponseDto> getPayments() { List payments = paymentManageUseCase.getPayments(); return ResponseDto.create(PAYMENT_FIND.getCode(), GET_PAYMENT_LIST_INFO.getMessage(), payments); } + + @GetMapping("/payments/{mentoringId}") + @Operation(summary = "[관리자] 결제된 멘토링 정보", description = "결제된 멘토링 정보를 조회합니다.") + public ResponseDto getPayments(@PathVariable Long mentoringId) { + MentoringWithPaymentResponse mentoringWithPayment = mentoringManageUseCase.getMentoringWithPayment(mentoringId); + return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), mentoringWithPayment); + } } diff --git a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java index 6d4364b6..89ec3909 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java @@ -1,7 +1,9 @@ package com.postgraduate.domain.payment.domain.repository; +import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; import org.springframework.data.jpa.repository.JpaRepository; public interface PaymentRepository extends JpaRepository { + Boolean existsByMentoring(Mentoring mentoring); } diff --git a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java index f7b8956c..6cb1103e 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.payment.domain.service; +import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.repository.PaymentRepository; import lombok.RequiredArgsConstructor; @@ -14,4 +15,8 @@ public class PaymentGetService { public List all() { return paymentRepository.findAll(); } + + public Boolean existsByMentoring(Mentoring mentoring) { + return paymentRepository.existsByMentoring(mentoring); + } } diff --git a/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java b/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java index 494bd7b1..c13ee4ee 100644 --- a/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java +++ b/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java @@ -9,6 +9,8 @@ public enum PaymentResponseCode { PAYMENT_FIND("PM200"), PAYMENT_UPDATE("PM201"), PAYMENT_CREATE("PM202"), - PAYMENT_DELETE("PM203"); + PAYMENT_DELETE("PM203"), + + PAYMENT_NOT_FOUND("EX600"); private final String code; } From 0ed93385da9e9260e7697feb5b730742d737bc3e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 22:11:20 +0900 Subject: [PATCH 24/47] =?UTF-8?q?RAC-186=20fix:=20salary=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20util=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/postgraduate/domain/salary/util/SalaryUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index 7bfd1b81..1875a337 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -32,7 +32,7 @@ public static SalaryStatus getStatus(List salaries) { long count = salaries.stream() .filter(Salary::getStatus) .count(); - if (count == 0) { + if (salaries.size() == 0) { return SalaryStatus.NONE; } if (count == salaries.size()) { From 2b5c94a27c643ccfabfa8793ca404bb013134bea Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 22:16:06 +0900 Subject: [PATCH 25/47] =?UTF-8?q?RAC-186=20fix:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=8A=B9=EC=9D=B8=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/CertificationDetailsResponse.java | 24 ++++++++++++++++--- .../admin/application/mapper/AdminMapper.java | 24 +++++++++---------- .../usecase/SeniorManageByAdminUseCase.java | 10 +------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java index ccf4cbad..7d6de468 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java @@ -1,7 +1,25 @@ package com.postgraduate.domain.admin.application.dto.res; -import com.postgraduate.domain.admin.application.dto.CertificationInfo; import jakarta.validation.constraints.NotNull; -public record CertificationDetailsResponse(@NotNull CertificationInfo certificationInfo) { -} +public record CertificationDetailsResponse( + @NotNull + String certification, + @NotNull + String nickName, + @NotNull + String phoneNumber, + //인증 신청 날짜 + @NotNull + String postgradu, + @NotNull + String major, + @NotNull + String field, + @NotNull + String lab, + @NotNull + String professor, + @NotNull + String keyword +) { } 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 2b564f20..349e9cc5 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 @@ -17,20 +17,20 @@ public class AdminMapper { - public static CertificationInfo mapToCertificationInfo(Senior senior) { + public static CertificationDetailsResponse mapToCertificationInfo(Senior senior) { User user = senior.getUser(); Info info = senior.getInfo(); - return CertificationInfo.builder() - .certification(senior.getCertification()) - .nickName(user.getNickName()) - .phoneNumber(user.getPhoneNumber()) - .postgradu(info.getPostgradu()) - .major(info.getMajor()) - .field(info.getField()) - .lab(info.getLab()) - .professor(info.getProfessor()) - .keyword(info.getKeyword()) - .build(); + return new CertificationDetailsResponse( + senior.getCertification(), + user.getNickName(), + user.getPhoneNumber(), + info.getPostgradu(), + info.getMajor(), + info.getField(), + info.getLab(), + info.getProfessor(), + info.getKeyword() + ); } public static CertificationProfile mapToCertificationProfile(Senior senior) { diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 759f411f..2cf66558 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -1,9 +1,7 @@ package com.postgraduate.domain.admin.application.usecase; -import com.postgraduate.domain.admin.application.dto.CertificationInfo; import com.postgraduate.domain.admin.application.dto.req.SeniorStatusRequest; import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; -import com.postgraduate.domain.admin.application.dto.res.CertificationResponse; import com.postgraduate.domain.admin.application.dto.res.SeniorResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; @@ -42,13 +40,7 @@ public CertificationDetailsResponse getCertificationDetails(Long seniorId) { if (senior.getStatus() != Status.WAITING) { throw new SeniorNotWaitingException(); } - CertificationInfo certificationInfo = AdminMapper.mapToCertificationInfo(senior); - return new CertificationDetailsResponse(certificationInfo); - } - - public List getCertifications() { - List seniors = seniorGetService.byStatus(Status.WAITING); - return seniors.stream().map(AdminMapper::mapToCertification).toList(); + return AdminMapper.mapToCertificationInfo(senior); } public void updateSeniorStatus(Long seniorId, SeniorStatusRequest request) { From 574762fa1a9020592208f7fa29ad2a2838f2b894 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 22:17:53 +0900 Subject: [PATCH 26/47] =?UTF-8?q?RAC-186=20feat:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EC=A0=95=EC=82=B0=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/application/mapper/AdminMapper.java | 1 - .../usecase/SalaryManageByAdminUseCase.java | 10 ++++++++++ .../domain/admin/presentation/AdminController.java | 9 +++++++++ .../domain/salary/domain/entity/Salary.java | 5 +++++ .../salary/domain/service/SalaryUpdateService.java | 7 +++++++ .../presentation/constant/SalaryResponseMessage.java | 1 + 6 files changed, 32 insertions(+), 1 deletion(-) 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 349e9cc5..ba3d0eab 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 @@ -1,7 +1,6 @@ package com.postgraduate.domain.admin.application.mapper; import com.postgraduate.domain.account.domain.entity.Account; -import com.postgraduate.domain.admin.application.dto.CertificationInfo; import com.postgraduate.domain.admin.application.dto.CertificationProfile; import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 55aadd59..38beb9c3 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -10,6 +10,7 @@ import com.postgraduate.domain.salary.domain.entity.Salary; import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.service.SalaryGetService; +import com.postgraduate.domain.salary.domain.service.SalaryUpdateService; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.global.config.security.util.EncryptorUtils; @@ -31,6 +32,7 @@ public class SalaryManageByAdminUseCase { private final SalaryGetService salaryGetService; private final EncryptorUtils encryptorUtils; private final AccountUtil accountUtil; + private final SalaryUpdateService salaryUpdateService; public SalaryDetailsResponse getSalary(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); @@ -59,4 +61,12 @@ public AllSalariesResponse getSalaries() { } return new AllSalariesResponse(responses); } + + public void updateSalaryStatus(Long seniorId, Boolean status) { + Senior senior = seniorGetService.bySeniorId(seniorId); + List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); + for (Salary salary : salaries) { + salaryUpdateService.updateStatus(salary, status); + } + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 67979469..930dd8d6 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -19,7 +19,9 @@ import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.PAYMENT_FIND; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.GET_PAYMENT_LIST_INFO; import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseCode.SALARY_FIND; +import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseCode.SALARY_UPDATE; import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseMessage.GET_SALARY_INFO; +import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseMessage.UPDATE_SALARY_STATUS; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_FIND; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_UPDATE; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; @@ -97,6 +99,13 @@ public ResponseDto getSalary(@PathVariable Long seniorId) return ResponseDto.create(SALARY_FIND.getCode(), GET_SALARY_INFO.getMessage(), salary); } + @PatchMapping("/salary/{seniorId}") + @Operation(summary = "[관리자] 정산 상태 변경", description = "대학원생 선배 정산 상태를 변경합니다.") + public ResponseDto updateSalaryStatus(@PathVariable Long seniorId, @RequestParam Boolean status) { + salaryManageUseCase.updateSalaryStatus(seniorId, status); + return ResponseDto.create(SALARY_UPDATE.getCode(), UPDATE_SALARY_STATUS.getMessage()); + } + @GetMapping("/user/{userId}/mentoring") @Operation(summary = "[관리자] 후배 멘토링 조회", description = "후배의 멘토링 목록을 조회합니다.") public ResponseDto> getUserMentorings(@PathVariable Long userId) { diff --git a/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java b/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java index b9f5b903..cd958b11 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/entity/Salary.java @@ -36,4 +36,9 @@ public class Salary { @Column private LocalDateTime salaryDoneDate; + + public void updateStatus(Boolean status) { + this.status = status; + this.salaryDoneDate = LocalDateTime.now(); + } } diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java index b6664824..cd01695b 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java @@ -1,9 +1,16 @@ package com.postgraduate.domain.salary.domain.service; +import com.postgraduate.domain.salary.domain.entity.Salary; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional @RequiredArgsConstructor public class SalaryUpdateService { + + public void updateStatus(Salary salary, Boolean status) { + salary.updateStatus(status); + } } diff --git a/src/main/java/com/postgraduate/domain/salary/presentation/constant/SalaryResponseMessage.java b/src/main/java/com/postgraduate/domain/salary/presentation/constant/SalaryResponseMessage.java index ca378fa1..9d906847 100644 --- a/src/main/java/com/postgraduate/domain/salary/presentation/constant/SalaryResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/salary/presentation/constant/SalaryResponseMessage.java @@ -8,6 +8,7 @@ public enum SalaryResponseMessage { GET_SALARY_INFO("정산 정보 조회에 성공하였습니다"), GET_SALARY_LIST_INFO("정산 리스트 조회에 성공하였습니다."), + UPDATE_SALARY_STATUS("정산 상태 수정에 성공하였습니다."), NOT_FOUND_SALARY("정산을 찾을 수 없습니다."); From 00e4913408145715621ddce50eecc145e0b6adf9 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 22:34:00 +0900 Subject: [PATCH 27/47] =?UTF-8?q?RAC-186=20feat:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/payment/domain/repository/PaymentRepository.java | 1 + .../domain/payment/domain/service/PaymentGetService.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java index 89ec3909..6d811f2a 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java @@ -6,4 +6,5 @@ public interface PaymentRepository extends JpaRepository { Boolean existsByMentoring(Mentoring mentoring); + Payment findByMentoring(Mentoring mentoring); } diff --git a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java index 6cb1103e..d82f4d03 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java @@ -19,4 +19,8 @@ public List all() { public Boolean existsByMentoring(Mentoring mentoring) { return paymentRepository.existsByMentoring(mentoring); } + + public Payment byMentoring(Mentoring mentoring) { + return paymentRepository.findByMentoring(mentoring); + } } From 552cdafca3de4dee769b34f9489cdc8e8de51d40 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Tue, 5 Dec 2023 22:34:35 +0900 Subject: [PATCH 28/47] =?UTF-8?q?RAC-186=20feat:=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=EB=90=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20response=EC=97=90=20p?= =?UTF-8?q?aymentId=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/MentoringWithPaymentResponse.java | 2 ++ .../domain/admin/application/mapper/AdminMapper.java | 3 ++- .../application/usecase/MentoringManageByAdminUseCase.java | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java index 14e86dc1..ed46b873 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java @@ -3,6 +3,8 @@ import jakarta.validation.constraints.NotNull; public record MentoringWithPaymentResponse( + @NotNull + Long paymentId, @NotNull String userNickname, @NotNull 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 ba3d0eab..01efe45e 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 @@ -137,10 +137,11 @@ public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account a ); } - public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Mentoring mentoring) { + public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Long paymentId, Mentoring mentoring) { User user = mentoring.getUser(); Senior senior = mentoring.getSenior(); return new MentoringWithPaymentResponse( + paymentId, user.getNickName(), user.getPhoneNumber(), senior.getUser().getNickName(), diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index 31d1bb0c..6bd2503c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -5,6 +5,7 @@ import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; +import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.service.PaymentGetService; import com.postgraduate.domain.payment.exception.PaymentNotFoundException; import lombok.RequiredArgsConstructor; @@ -34,6 +35,7 @@ public MentoringWithPaymentResponse getMentoringWithPayment(Long mentoringId) { if (!paymentGetService.existsByMentoring(mentoring)) { throw new PaymentNotFoundException(); } - return AdminMapper.mapToMentoringWithPaymentResponse(mentoring); + Payment payment = paymentGetService.byMentoring(mentoring); + return AdminMapper.mapToMentoringWithPaymentResponse(payment.getPaymentId(), mentoring); } } From 46d6b3eeacd975804b9787a3bd38eb6d4853821a Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 8 Dec 2023 16:36:26 +0900 Subject: [PATCH 29/47] =?UTF-8?q?RAC-186=20fix:=20=ED=9B=84=EB=B0=B0=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=AA=A8=EB=93=A0=20wish=20=EC=A1=B0=ED=9A=8C=ED=95=98?= =?UTF-8?q?=EC=97=AC=20user=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/MentoringResponse.java | 23 ++++++---------- .../application/dto/res/UserResponse.java | 25 +++++++---------- .../admin/application/mapper/AdminMapper.java | 27 +++++++++---------- .../usecase/UserManageByAdminUseCase.java | 21 +++++---------- .../wish/domain/service/WishGetService.java | 5 ++++ 5 files changed, 42 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java index 3d94c918..ac7b1a91 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java @@ -1,20 +1,13 @@ package com.postgraduate.domain.admin.application.dto.res; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import java.time.LocalDate; - -@Builder -@Getter -@AllArgsConstructor -public class MentoringResponse { - private Long mentoringId; - private Status status; - private String userNickName; - private String userPhoneNumber; - private String seniorNickName; - private String seniorPhoneNumber; +public record MentoringResponse( + Long mentoringId, + Status status, + String userNickName, + String userPhoneNumber, + String seniorNickName, + String seniorPhoneNumber +) { } diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java index 415efd3c..6d0bbe1c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java @@ -1,21 +1,16 @@ package com.postgraduate.domain.admin.application.dto.res; import com.postgraduate.domain.user.domain.entity.constant.Role; -import lombok.Getter; -import lombok.experimental.SuperBuilder; import java.time.LocalDate; -@Getter -@SuperBuilder -public class UserResponse { - private Long userId; - private String nickName; - private String phoneNumber; - private LocalDate createdAt; - private Boolean marketingReceive; - private Boolean matchingReceive; - private Long wishId; - private Role role; - // 매칭 지원 완료 여부 -} +public record UserResponse( + Long userId, + String nickName, + String phoneNumber, + LocalDate createdAt, + Boolean marketingReceive, + Boolean matchingReceive, + Long wishId, + Role role +) { } 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 01efe45e..ba6c6c73 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 @@ -12,7 +12,6 @@ import com.postgraduate.domain.wish.domain.entity.Wish; import java.time.LocalDateTime; -import java.util.Optional; public class AdminMapper { @@ -48,20 +47,20 @@ public static CertificationResponse mapToCertification(Senior senior) { .build(); } - public static UserResponse mapToUserResponse(User user, Optional wish) { - Long wishId = wish.map(Wish::getWishId).orElse(null); - Boolean matchingReceive = wish.map(Wish::getMatchingReceive).orElse(null); - return UserResponse.builder() - .userId(user.getUserId()) - .nickName(user.getNickName()) - .phoneNumber(user.getPhoneNumber()) - .createdAt(user.getCreatedAt()) - .marketingReceive(user.getMarketingReceive()) - .matchingReceive(matchingReceive) - .wishId(wishId) - .role(user.getRole()) - .build(); + public static UserResponse mapToUserResponse(Wish wish) { + User user = wish.getUser(); + return new UserResponse( + user.getUserId(), + user.getNickName(), + user.getPhoneNumber(), + user.getCreatedAt(), + user.getMarketingReceive(), + wish.getMatchingReceive(), + wish.getWishId(), + user.getRole() + ); } + // // public static UserWithSeniorResponse mapToUserWithSeniorResponse(User user, Long seniorId) { // return UserWithSeniorResponse.builder() diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java index 78edfb33..3614ac5d 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java @@ -2,33 +2,24 @@ import com.postgraduate.domain.admin.application.dto.res.UserResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; -import com.postgraduate.domain.user.domain.entity.User; -import com.postgraduate.domain.user.domain.service.UserGetService; import com.postgraduate.domain.wish.domain.entity.Wish; -import com.postgraduate.domain.wish.domain.repository.WishRepository; +import com.postgraduate.domain.wish.domain.service.WishGetService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.Optional; - -import static com.postgraduate.domain.user.domain.entity.constant.Role.ADMIN; @Service @Transactional @RequiredArgsConstructor public class UserManageByAdminUseCase { - private final UserGetService userGetService; - private final WishRepository wishRepository; + private final WishGetService wishGetService; public List getUsers() { - List users = userGetService.all(); - return users.stream() - .filter(user -> user.getRole() != ADMIN) - .map(user -> { - Optional wish = wishRepository.findByUser(user); - return AdminMapper.mapToUserResponse(user, wish); - }) + List wishes = wishGetService.all(); + + return wishes.stream() + .map(AdminMapper::mapToUserResponse) .toList(); } } diff --git a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java index 89b9dc0f..c8eb2074 100644 --- a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java +++ b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java @@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Optional; @Service @@ -19,4 +20,8 @@ public Wish byWishId(Long wishId) { public Optional byUser(User user) { return wishRepository.findByUser(user); } + + public List all() { + return wishRepository.findAll(); + } } From b97f3edb51d4f707ad142fdf4c6ce4f4ea3ef6d4 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 8 Dec 2023 16:57:04 +0900 Subject: [PATCH 30/47] =?UTF-8?q?RAC-186=20fix:=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=EB=90=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20exists=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=97=86=EC=9D=B4=20findBy=20=EC=97=90=EC=84=9C=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=20=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/MentoringWithPaymentResponse.java | 2 ++ .../domain/admin/application/mapper/AdminMapper.java | 4 ++-- .../application/usecase/MentoringManageByAdminUseCase.java | 6 +----- .../payment/domain/repository/PaymentRepository.java | 5 +++-- .../domain/payment/domain/service/PaymentGetService.java | 7 ++----- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java index ed46b873..c92ddef4 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringWithPaymentResponse.java @@ -17,6 +17,8 @@ public record MentoringWithPaymentResponse( String date, @NotNull int term, + @NotNull int pay, + @NotNull int charge ) { } 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 ba6c6c73..41cb0c75 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 @@ -136,11 +136,11 @@ public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account a ); } - public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Long paymentId, Mentoring mentoring) { + public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Payment payment, Mentoring mentoring) { User user = mentoring.getUser(); Senior senior = mentoring.getSenior(); return new MentoringWithPaymentResponse( - paymentId, + payment.getPaymentId(), user.getNickName(), user.getPhoneNumber(), senior.getUser().getNickName(), diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index 6bd2503c..c2795494 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -7,7 +7,6 @@ import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.service.PaymentGetService; -import com.postgraduate.domain.payment.exception.PaymentNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,10 +31,7 @@ public List getSeniorMentorings(Long seniorId) { public MentoringWithPaymentResponse getMentoringWithPayment(Long mentoringId) { Mentoring mentoring = mentoringGetService.byMentoringId(mentoringId); - if (!paymentGetService.existsByMentoring(mentoring)) { - throw new PaymentNotFoundException(); - } Payment payment = paymentGetService.byMentoring(mentoring); - return AdminMapper.mapToMentoringWithPaymentResponse(payment.getPaymentId(), mentoring); + return AdminMapper.mapToMentoringWithPaymentResponse(payment, mentoring); } } diff --git a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java index 6d811f2a..55de2ef8 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/repository/PaymentRepository.java @@ -4,7 +4,8 @@ import com.postgraduate.domain.payment.domain.entity.Payment; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface PaymentRepository extends JpaRepository { - Boolean existsByMentoring(Mentoring mentoring); - Payment findByMentoring(Mentoring mentoring); + Optional findByMentoring(Mentoring mentoring); } diff --git a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java index d82f4d03..9331ea7d 100644 --- a/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java +++ b/src/main/java/com/postgraduate/domain/payment/domain/service/PaymentGetService.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.repository.PaymentRepository; +import com.postgraduate.domain.payment.exception.PaymentNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -16,11 +17,7 @@ public List all() { return paymentRepository.findAll(); } - public Boolean existsByMentoring(Mentoring mentoring) { - return paymentRepository.existsByMentoring(mentoring); - } - public Payment byMentoring(Mentoring mentoring) { - return paymentRepository.findByMentoring(mentoring); + return paymentRepository.findByMentoring(mentoring).orElseThrow(PaymentNotFoundException::new); } } From d73ec20ea820d34851e1d4bb00bdb3ed3f9d8470 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 8 Dec 2023 17:28:06 +0900 Subject: [PATCH 31/47] =?UTF-8?q?RAC-186=20fix:=20=EC=A0=95=EC=82=B0?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=97=90=EC=84=9C=20=EA=B3=84=EC=A2=8C=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20dummyAccount=20?= =?UTF-8?q?=EB=8C=80=EC=8B=A0=20null=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/account/util/AccountUtil.java | 19 ----------- .../admin/application/mapper/AdminMapper.java | 28 +++++++++++++++- .../usecase/SalaryManageByAdminUseCase.java | 33 +++++++++++++------ 3 files changed, 50 insertions(+), 30 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/account/util/AccountUtil.java diff --git a/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java b/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java deleted file mode 100644 index 90b295a1..00000000 --- a/src/main/java/com/postgraduate/domain/account/util/AccountUtil.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.postgraduate.domain.account.util; - -import com.postgraduate.domain.account.domain.entity.Account; -import com.postgraduate.global.config.security.util.EncryptorUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class AccountUtil { - private final EncryptorUtils encryptorUtils; - public Account createDummyAccount() { - return Account.builder() - .accountNumber(encryptorUtils.encryptData("dummyAccountNumber")) - .bank("dummyBank") - .accountHolder("dummyAccountHolder") - .build(); - } -} 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 41cb0c75..b38cccf3 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 @@ -123,7 +123,20 @@ public static SalariesResponse mapToSalaryResponse(Senior senior, Account accoun ); } - public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, SalaryStatus status) { + public static SalariesResponse mapToSalaryResponse(Senior senior, int totalAmount, LocalDateTime salaryDoneDate) { + User user = senior.getUser(); + return new SalariesResponse( + user.getNickName(), + user.getPhoneNumber(), + totalAmount, + null, + null, + null, + salaryDoneDate + ); + } + + public static SalaryDetailsResponse mapToSalaryDetailsResponse(Senior senior, Account account, String accountNumber, int totalAmount, SalaryStatus status) { User user = senior.getUser(); return new SalaryDetailsResponse( user.getNickName(), @@ -136,6 +149,19 @@ public static SalaryDetailsResponse mapToSalaryResponse(Senior senior, Account a ); } + public static SalaryDetailsResponse mapToSalaryDetailsResponse(Senior senior, int totalAmount, SalaryStatus status) { + User user = senior.getUser(); + return new SalaryDetailsResponse( + user.getNickName(), + user.getPhoneNumber(), + totalAmount, + null, + null, + null, + status + ); + } + public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Payment payment, Mentoring mentoring) { User user = mentoring.getUser(); Senior senior = mentoring.getSenior(); diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 38beb9c3..8ee2b5f4 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -2,7 +2,6 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.account.domain.service.AccountGetService; -import com.postgraduate.domain.account.util.AccountUtil; import com.postgraduate.domain.admin.application.dto.res.AllSalariesResponse; import com.postgraduate.domain.admin.application.dto.res.SalariesResponse; import com.postgraduate.domain.admin.application.dto.res.SalaryDetailsResponse; @@ -20,6 +19,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import static com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus.DONE; import static com.postgraduate.domain.salary.util.SalaryUtil.*; @@ -31,17 +31,21 @@ public class SalaryManageByAdminUseCase { private final AccountGetService accountGetService; private final SalaryGetService salaryGetService; private final EncryptorUtils encryptorUtils; - private final AccountUtil accountUtil; private final SalaryUpdateService salaryUpdateService; public SalaryDetailsResponse getSalary(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); - Account account = accountGetService.bySenior(senior).orElse(accountUtil.createDummyAccount()); - String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); int totalAmount = getAmount(salaries); SalaryStatus status = getStatus(salaries); - return AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, status); + + Optional optionalAccount = accountGetService.bySenior(senior); + if (optionalAccount.isPresent()) { + Account account = optionalAccount.get(); + String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); + return AdminMapper.mapToSalaryDetailsResponse(senior, optionalAccount.get(), accountNumber, totalAmount, status); + } + return AdminMapper.mapToSalaryDetailsResponse(senior, totalAmount, status); } public AllSalariesResponse getSalaries() { @@ -52,16 +56,25 @@ public AllSalariesResponse getSalaries() { if (getStatus(salaries) != DONE) { continue; } - Account account = accountGetService.bySenior(senior).orElse(accountUtil.createDummyAccount()); - String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); - int totalAmount = getAmount(salaries); - LocalDateTime salaryDoneDate = getDoneDate(salaries); - SalariesResponse response = AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, salaryDoneDate); + SalariesResponse response = getSalariesResponse(senior, salaries); responses.add(response); } return new AllSalariesResponse(responses); } + private SalariesResponse getSalariesResponse(Senior senior, List salaries) { + int totalAmount = getAmount(salaries); + LocalDateTime salaryDoneDate = getDoneDate(salaries); + + Optional optionalAccount = accountGetService.bySenior(senior); + if (optionalAccount.isPresent()) { + Account account = optionalAccount.get(); + String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); + return AdminMapper.mapToSalaryResponse(senior, account, accountNumber, totalAmount, salaryDoneDate); + } + return AdminMapper.mapToSalaryResponse(senior, totalAmount, salaryDoneDate); + } + public void updateSalaryStatus(Long seniorId, Boolean status) { Senior senior = seniorGetService.bySeniorId(seniorId); List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); From 48963347c05e949a1bd581430e091ca75aaefb12 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 8 Dec 2023 17:48:20 +0900 Subject: [PATCH 32/47] =?UTF-8?q?RAC-186=20fix:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EB=AA=A9=EB=A1=9D=20List=20=EB=8C=80=EC=8B=A0=20?= =?UTF-8?q?=ED=95=98=EB=82=98=EC=9D=98=20record=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...toringResponse.java => MentoringInfo.java} | 4 ++-- .../dto/res/MentoringManageResponse.java | 9 +++++++++ .../admin/application/mapper/AdminMapper.java | 19 ++++++++++--------- .../MentoringManageByAdminUseCase.java | 17 ++++++++++++----- .../admin/presentation/AdminController.java | 8 ++++---- 5 files changed, 37 insertions(+), 20 deletions(-) rename src/main/java/com/postgraduate/domain/admin/application/dto/{res/MentoringResponse.java => MentoringInfo.java} (73%) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringManageResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/MentoringInfo.java similarity index 73% rename from src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java rename to src/main/java/com/postgraduate/domain/admin/application/dto/MentoringInfo.java index ac7b1a91..19c99388 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/MentoringInfo.java @@ -1,8 +1,8 @@ -package com.postgraduate.domain.admin.application.dto.res; +package com.postgraduate.domain.admin.application.dto; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; -public record MentoringResponse( +public record MentoringInfo( Long mentoringId, Status status, String userNickName, diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringManageResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringManageResponse.java new file mode 100644 index 00000000..74efcb2a --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/MentoringManageResponse.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.admin.application.dto.MentoringInfo; +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record MentoringManageResponse(@NotNull List mentoringInfo) { +} 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 b38cccf3..b03d22a9 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 @@ -2,6 +2,7 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.admin.application.dto.CertificationProfile; +import com.postgraduate.domain.admin.application.dto.MentoringInfo; import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; @@ -86,17 +87,17 @@ public static SeniorResponse mapToSeniorResponse(Senior senior, SalaryStatus sal .build(); } - public static MentoringResponse mapToMentoringResponse(Mentoring mentoring) { + public static MentoringInfo mapToMentoringResponse(Mentoring mentoring) { User user = mentoring.getUser(); Senior senior = mentoring.getSenior(); - return MentoringResponse.builder() - .mentoringId(mentoring.getMentoringId()) - .status(mentoring.getStatus()) - .userNickName(user.getNickName()) - .userPhoneNumber(user.getPhoneNumber()) - .seniorNickName(senior.getUser().getNickName()) - .seniorPhoneNumber(senior.getUser().getPhoneNumber()) - .build(); + return new MentoringInfo( + mentoring.getMentoringId(), + mentoring.getStatus(), + user.getNickName(), + user.getPhoneNumber(), + senior.getUser().getNickName(), + senior.getUser().getPhoneNumber() + ); } public static PaymentResponse mapToPaymentResponse(Payment payment) { diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index c2795494..6fed96dc 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.admin.application.usecase; -import com.postgraduate.domain.admin.application.dto.res.MentoringResponse; +import com.postgraduate.domain.admin.application.dto.MentoringInfo; +import com.postgraduate.domain.admin.application.dto.res.MentoringManageResponse; import com.postgraduate.domain.admin.application.dto.res.MentoringWithPaymentResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; @@ -19,14 +20,20 @@ public class MentoringManageByAdminUseCase { private final MentoringGetService mentoringGetService; private final PaymentGetService paymentGetService; - public List getUserMentorings(Long userId) { + public MentoringManageResponse getUserMentorings(Long userId) { List mentorings = mentoringGetService.byUserId(userId); - return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); + List mentoringInfos = mentorings.stream() + .map(AdminMapper::mapToMentoringResponse) + .toList(); + return new MentoringManageResponse(mentoringInfos); } - public List getSeniorMentorings(Long seniorId) { + public MentoringManageResponse getSeniorMentorings(Long seniorId) { List mentorings = mentoringGetService.bySeniorId(seniorId); - return mentorings.stream().map(AdminMapper::mapToMentoringResponse).toList(); + List mentoringInfos = mentorings.stream() + .map(AdminMapper::mapToMentoringResponse) + .toList(); + return new MentoringManageResponse(mentoringInfos); } public MentoringWithPaymentResponse getMentoringWithPayment(Long mentoringId) { diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 930dd8d6..246dfa80 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -108,15 +108,15 @@ public ResponseDto updateSalaryStatus(@PathVariable Long seniorId, @RequestParam @GetMapping("/user/{userId}/mentoring") @Operation(summary = "[관리자] 후배 멘토링 조회", description = "후배의 멘토링 목록을 조회합니다.") - public ResponseDto> getUserMentorings(@PathVariable Long userId) { - List mentorings = mentoringManageUseCase.getUserMentorings(userId); + public ResponseDto getUserMentorings(@PathVariable Long userId) { + MentoringManageResponse mentorings = mentoringManageUseCase.getUserMentorings(userId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); } @GetMapping("/senior/{seniorId}/mentoring") @Operation(summary = "[관리자] 선배 멘토링 조회", description = "선배의 멘토링 목록을 조회합니다.") - public ResponseDto> getSeniorMentorings(@PathVariable Long seniorId) { - List mentorings = mentoringManageUseCase.getSeniorMentorings(seniorId); + public ResponseDto getSeniorMentorings(@PathVariable Long seniorId) { + MentoringManageResponse mentorings = mentoringManageUseCase.getSeniorMentorings(seniorId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentorings); } From 4a0ec78ba4dba17634eff92939b7df892e4d5b69 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 8 Dec 2023 20:05:22 +0900 Subject: [PATCH 33/47] =?UTF-8?q?RAC-186=20fix:=20=ED=9B=84=EB=B0=B0,=20?= =?UTF-8?q?=EC=84=A0=EB=B0=B0=20=EB=AA=A9=EB=A1=9D=20List=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0=20=ED=95=98=EB=82=98=EC=9D=98=20record=20=EB=B0=98?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/dto/SeniorInfo.java | 23 +++++++++++++++ .../{res/UserResponse.java => UserInfo.java} | 13 +++++++-- .../dto/res/SeniorManageResponse.java | 9 ++++++ .../application/dto/res/SeniorResponse.java | 18 ------------ .../dto/res/UserManageResponse.java | 9 ++++++ .../dto/res/UserWithSeniorResponse.java | 10 ------- .../admin/application/mapper/AdminMapper.java | 28 ++++++++++--------- .../MentoringManageByAdminUseCase.java | 4 +-- .../usecase/SeniorManageByAdminUseCase.java | 10 ++++--- .../usecase/UserManageByAdminUseCase.java | 11 ++++---- .../admin/presentation/AdminController.java | 10 +++---- 11 files changed, 86 insertions(+), 59 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java rename src/main/java/com/postgraduate/domain/admin/application/dto/{res/UserResponse.java => UserInfo.java} (54%) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorManageResponse.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/UserManageResponse.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/UserWithSeniorResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java new file mode 100644 index 00000000..ef01e028 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java @@ -0,0 +1,23 @@ +package com.postgraduate.domain.admin.application.dto; + +import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.senior.domain.entity.constant.Status; +import jakarta.validation.constraints.NotNull; + +public record SeniorInfo( + @NotNull + Long seniorId, + @NotNull + String nickName, + @NotNull + String phoneNumber, + @NotNull + Status status, + @NotNull + SalaryStatus salaryStatus, + @NotNull + Boolean marketingReceive, + @NotNull + Boolean isUser +) { +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/UserInfo.java similarity index 54% rename from src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java rename to src/main/java/com/postgraduate/domain/admin/application/dto/UserInfo.java index 6d0bbe1c..efeea9b5 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/UserInfo.java @@ -1,16 +1,25 @@ -package com.postgraduate.domain.admin.application.dto.res; +package com.postgraduate.domain.admin.application.dto; import com.postgraduate.domain.user.domain.entity.constant.Role; +import jakarta.validation.constraints.NotNull; import java.time.LocalDate; -public record UserResponse( +public record UserInfo( + @NotNull Long userId, + @NotNull String nickName, + @NotNull String phoneNumber, + @NotNull LocalDate createdAt, + @NotNull Boolean marketingReceive, + @NotNull Boolean matchingReceive, + @NotNull Long wishId, + @NotNull Role role ) { } diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorManageResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorManageResponse.java new file mode 100644 index 00000000..524f7211 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorManageResponse.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.admin.application.dto.SeniorInfo; +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record SeniorManageResponse(@NotNull List seniorInfo) { +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java deleted file mode 100644 index baad7fcd..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SeniorResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; -import com.postgraduate.domain.senior.domain.entity.constant.Status; -import lombok.Builder; -import lombok.Getter; - -@Builder -@Getter -public class SeniorResponse { - private Long seniorId; - private String nickName; - private String phoneNumber; - private Status status; - private SalaryStatus salaryStatus; - private Boolean marketingReceive; - private Boolean isUser; -} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserManageResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserManageResponse.java new file mode 100644 index 00000000..f63a9afe --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserManageResponse.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.admin.application.dto.UserInfo; +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record UserManageResponse(@NotNull List userInfo) { +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserWithSeniorResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserWithSeniorResponse.java deleted file mode 100644 index cf128b2a..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/UserWithSeniorResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import lombok.Getter; -import lombok.experimental.SuperBuilder; - -@SuperBuilder -@Getter -public class UserWithSeniorResponse extends UserResponse { - private Long seniorId; -} 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 b03d22a9..db3c284d 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 @@ -3,6 +3,8 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.admin.application.dto.CertificationProfile; import com.postgraduate.domain.admin.application.dto.MentoringInfo; +import com.postgraduate.domain.admin.application.dto.SeniorInfo; +import com.postgraduate.domain.admin.application.dto.UserInfo; import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; @@ -48,9 +50,9 @@ public static CertificationResponse mapToCertification(Senior senior) { .build(); } - public static UserResponse mapToUserResponse(Wish wish) { + public static UserInfo mapToUserInfo(Wish wish) { User user = wish.getUser(); - return new UserResponse( + return new UserInfo( user.getUserId(), user.getNickName(), user.getPhoneNumber(), @@ -74,20 +76,20 @@ public static UserResponse mapToUserResponse(Wish wish) { // .build(); // } - public static SeniorResponse mapToSeniorResponse(Senior senior, SalaryStatus salaryStatus, Boolean isUser) { + public static SeniorInfo mapToSeniorInfo(Senior senior, SalaryStatus salaryStatus, Boolean isUser) { User user = senior.getUser(); - return SeniorResponse.builder() - .seniorId(senior.getSeniorId()) - .nickName(user.getNickName()) - .phoneNumber(user.getPhoneNumber()) - .status(senior.getStatus()) - .salaryStatus(salaryStatus) - .marketingReceive(user.getMarketingReceive()) - .isUser(isUser) - .build(); + return new SeniorInfo( + senior.getSeniorId(), + user.getNickName(), + user.getPhoneNumber(), + senior.getStatus(), + salaryStatus, + user.getMarketingReceive(), + isUser + ); } - public static MentoringInfo mapToMentoringResponse(Mentoring mentoring) { + public static MentoringInfo mapToMentoringInfo(Mentoring mentoring) { User user = mentoring.getUser(); Senior senior = mentoring.getSenior(); return new MentoringInfo( diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java index 6fed96dc..b387ef1a 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/MentoringManageByAdminUseCase.java @@ -23,7 +23,7 @@ public class MentoringManageByAdminUseCase { public MentoringManageResponse getUserMentorings(Long userId) { List mentorings = mentoringGetService.byUserId(userId); List mentoringInfos = mentorings.stream() - .map(AdminMapper::mapToMentoringResponse) + .map(AdminMapper::mapToMentoringInfo) .toList(); return new MentoringManageResponse(mentoringInfos); } @@ -31,7 +31,7 @@ public MentoringManageResponse getUserMentorings(Long userId) { public MentoringManageResponse getSeniorMentorings(Long seniorId) { List mentorings = mentoringGetService.bySeniorId(seniorId); List mentoringInfos = mentorings.stream() - .map(AdminMapper::mapToMentoringResponse) + .map(AdminMapper::mapToMentoringInfo) .toList(); return new MentoringManageResponse(mentoringInfos); } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 2cf66558..a4d90c0c 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -2,7 +2,8 @@ import com.postgraduate.domain.admin.application.dto.req.SeniorStatusRequest; import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; -import com.postgraduate.domain.admin.application.dto.res.SeniorResponse; +import com.postgraduate.domain.admin.application.dto.SeniorInfo; +import com.postgraduate.domain.admin.application.dto.res.SeniorManageResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; import com.postgraduate.domain.salary.domain.entity.Salary; @@ -52,15 +53,16 @@ public void updateSeniorStatus(Long seniorId, SeniorStatusRequest request) { } } - public List getSeniors() { + public SeniorManageResponse getSeniors() { List seniors = seniorGetService.getAll(); - return seniors.stream() + List seniorInfos = seniors.stream() .map(senior -> { List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); SalaryStatus salaryStatus = getStatus(salaries); Optional wish = wishGetService.byUser(senior.getUser()); - return AdminMapper.mapToSeniorResponse(senior, salaryStatus, wish.isPresent()); + return AdminMapper.mapToSeniorInfo(senior, salaryStatus, wish.isPresent()); }) .toList(); + return new SeniorManageResponse(seniorInfos); } } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java index 3614ac5d..5977c43e 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.admin.application.usecase; -import com.postgraduate.domain.admin.application.dto.res.UserResponse; +import com.postgraduate.domain.admin.application.dto.UserInfo; +import com.postgraduate.domain.admin.application.dto.res.UserManageResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.service.WishGetService; @@ -15,11 +16,11 @@ @RequiredArgsConstructor public class UserManageByAdminUseCase { private final WishGetService wishGetService; - public List getUsers() { + public UserManageResponse getUsers() { List wishes = wishGetService.all(); - - return wishes.stream() - .map(AdminMapper::mapToUserResponse) + List userInfos = wishes.stream() + .map(AdminMapper::mapToUserInfo) .toList(); + return new UserManageResponse(userInfos); } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 246dfa80..e81dbf98 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -14,7 +14,7 @@ import java.util.List; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_FIND; -import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.*; +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_DETAIL_INFO; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_LIST_INFO; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.PAYMENT_FIND; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.GET_PAYMENT_LIST_INFO; @@ -66,8 +66,8 @@ public ResponseDto updateSeniorStatus(@PathVariable Long seniorId, @RequestBody @GetMapping("/users") @Operation(summary = "[관리자] 후배 정보 목록", description = "대학생 후배 정보 목록을 조회합니다.") - public ResponseDto> getUsers() { - List users = userManageUseCase.getUsers(); + public ResponseDto getUsers() { + UserManageResponse users = userManageUseCase.getUsers(); return ResponseDto.create(USER_FIND.getCode(), GET_USER_LIST_INFO.getMessage(), users); } @@ -80,8 +80,8 @@ public ResponseDto getWish(@PathVariable Long wishId) { @GetMapping("/seniors") @Operation(summary = "[관리자] 선배 정보 목록", description = "대학원생 선배 정보 목록을 조회합니다.") - public ResponseDto> getSeniors() { - List seniors = seniorManageUseCase.getSeniors(); + public ResponseDto getSeniors() { + SeniorManageResponse seniors = seniorManageUseCase.getSeniors(); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), seniors); } From cf7444f00b6c8951aa76f928c7c6fa1984233517 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 01:13:18 +0900 Subject: [PATCH 34/47] =?UTF-8?q?RAC-186=20fix:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EB=B3=80=EC=88=98=EB=AA=85=20`certificati?= =?UTF-8?q?onStatus`=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../postgraduate/domain/admin/application/dto/SeniorInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java index ef01e028..b8835b94 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java @@ -12,7 +12,7 @@ public record SeniorInfo( @NotNull String phoneNumber, @NotNull - Status status, + Status certificationStatus, @NotNull SalaryStatus salaryStatus, @NotNull From 3ee763ed7b8d51db4762a091ac9c485e2b6885d6 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 01:24:47 +0900 Subject: [PATCH 35/47] =?UTF-8?q?RAC-186=20fix:=20list=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EC=A7=80=EC=96=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/dto/PaymentInfo.java | 20 ++++++++++++ .../SalariesResponse.java => SalaryInfo.java} | 4 +-- .../dto/res/AllSalariesResponse.java | 8 ----- .../dto/res/PaymentManageResponse.java | 9 ++++++ .../application/dto/res/PaymentResponse.java | 19 ----------- .../dto/res/SalaryManageResponse.java | 9 ++++++ .../admin/application/mapper/AdminMapper.java | 32 +++++++++---------- .../usecase/PaymentManageByAdminUseCase.java | 10 ++++-- .../usecase/SalaryManageByAdminUseCase.java | 14 ++++---- .../admin/presentation/AdminController.java | 10 +++--- .../usecase/SalaryInfoUseCase.java | 4 ++- 11 files changed, 76 insertions(+), 63 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/PaymentInfo.java rename src/main/java/com/postgraduate/domain/admin/application/dto/{res/SalariesResponse.java => SalaryInfo.java} (81%) delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentManageResponse.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentResponse.java create mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryManageResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/PaymentInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/PaymentInfo.java new file mode 100644 index 00000000..4c037f8a --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/PaymentInfo.java @@ -0,0 +1,20 @@ +package com.postgraduate.domain.admin.application.dto; + +import jakarta.validation.constraints.NotNull; + +import java.time.LocalDate; + +public record PaymentInfo( + @NotNull + Long paymentId, + @NotNull + Long mentoringId, + @NotNull + String userNickName, + @NotNull + String seniorNickName, + @NotNull + LocalDate createdAt, + @NotNull + Integer pay +) { } diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/SalaryInfo.java similarity index 81% rename from src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java rename to src/main/java/com/postgraduate/domain/admin/application/dto/SalaryInfo.java index 610cd519..e8e2ebd6 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalariesResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/SalaryInfo.java @@ -1,10 +1,10 @@ -package com.postgraduate.domain.admin.application.dto.res; +package com.postgraduate.domain.admin.application.dto; import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; -public record SalariesResponse( +public record SalaryInfo( @NotNull String nickName, @NotNull diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java deleted file mode 100644 index 4b84d337..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/AllSalariesResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import jakarta.validation.constraints.NotNull; - -import java.util.List; - -public record AllSalariesResponse(@NotNull List salariesResponses) { -} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentManageResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentManageResponse.java new file mode 100644 index 00000000..c32c1b44 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentManageResponse.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.admin.application.dto.PaymentInfo; +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record PaymentManageResponse(@NotNull List paymentInfo) { +} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentResponse.java deleted file mode 100644 index e93a7e68..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/PaymentResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.time.LocalDate; - -@Builder -@Getter -@AllArgsConstructor -public class PaymentResponse { - private Long paymentId; - private Long mentoringId; - private String userNickName; - private String seniorNickName; - private LocalDate createdAt; - private Integer pay; -} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryManageResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryManageResponse.java new file mode 100644 index 00000000..5b27e479 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryManageResponse.java @@ -0,0 +1,9 @@ +package com.postgraduate.domain.admin.application.dto.res; + +import com.postgraduate.domain.admin.application.dto.SalaryInfo; +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record SalaryManageResponse(@NotNull List salaryInfos) { +} 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 db3c284d..b6f228fb 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 @@ -1,10 +1,7 @@ package com.postgraduate.domain.admin.application.mapper; import com.postgraduate.domain.account.domain.entity.Account; -import com.postgraduate.domain.admin.application.dto.CertificationProfile; -import com.postgraduate.domain.admin.application.dto.MentoringInfo; -import com.postgraduate.domain.admin.application.dto.SeniorInfo; -import com.postgraduate.domain.admin.application.dto.UserInfo; +import com.postgraduate.domain.admin.application.dto.*; import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; @@ -102,20 +99,21 @@ public static MentoringInfo mapToMentoringInfo(Mentoring mentoring) { ); } - public static PaymentResponse mapToPaymentResponse(Payment payment) { - return PaymentResponse.builder() - .paymentId(payment.getPaymentId()) - .mentoringId(payment.getMentoring().getMentoringId()) - .userNickName(payment.getMentoring().getUser().getNickName()) - .seniorNickName(payment.getMentoring().getSenior().getUser().getNickName()) - .createdAt(payment.getCreatedAt()) - .pay(payment.getMentoring().getPay()) - .build(); + public static PaymentInfo mapToPaymentInfo(Payment payment) { + Mentoring mentoring = payment.getMentoring(); + return new PaymentInfo( + payment.getPaymentId(), + mentoring.getMentoringId(), + mentoring.getUser().getNickName(), + mentoring.getSenior().getUser().getNickName(), + payment.getCreatedAt(), + mentoring.getPay() + ); } - public static SalariesResponse mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, LocalDateTime salaryDoneDate) { + public static SalaryInfo mapToSalaryResponse(Senior senior, Account account, String accountNumber, int totalAmount, LocalDateTime salaryDoneDate) { User user = senior.getUser(); - return new SalariesResponse( + return new SalaryInfo( user.getNickName(), user.getPhoneNumber(), totalAmount, @@ -126,9 +124,9 @@ public static SalariesResponse mapToSalaryResponse(Senior senior, Account accoun ); } - public static SalariesResponse mapToSalaryResponse(Senior senior, int totalAmount, LocalDateTime salaryDoneDate) { + public static SalaryInfo mapToSalaryResponse(Senior senior, int totalAmount, LocalDateTime salaryDoneDate) { User user = senior.getUser(); - return new SalariesResponse( + return new SalaryInfo( user.getNickName(), user.getPhoneNumber(), totalAmount, diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/PaymentManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/PaymentManageByAdminUseCase.java index 6a274a96..8dc36e63 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/PaymentManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/PaymentManageByAdminUseCase.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.admin.application.usecase; -import com.postgraduate.domain.admin.application.dto.res.PaymentResponse; +import com.postgraduate.domain.admin.application.dto.PaymentInfo; +import com.postgraduate.domain.admin.application.dto.res.PaymentManageResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.service.PaymentGetService; @@ -15,8 +16,11 @@ @RequiredArgsConstructor public class PaymentManageByAdminUseCase { private final PaymentGetService paymentGetService; - public List getPayments() { + public PaymentManageResponse getPayments() { List payments = paymentGetService.all(); - return payments.stream().map(AdminMapper::mapToPaymentResponse).toList(); + List paymentInfos = payments.stream() + .map(AdminMapper::mapToPaymentInfo) + .toList(); + return new PaymentManageResponse(paymentInfos); } } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 8ee2b5f4..d0858e69 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -2,8 +2,8 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.account.domain.service.AccountGetService; -import com.postgraduate.domain.admin.application.dto.res.AllSalariesResponse; -import com.postgraduate.domain.admin.application.dto.res.SalariesResponse; +import com.postgraduate.domain.admin.application.dto.res.SalaryManageResponse; +import com.postgraduate.domain.admin.application.dto.SalaryInfo; import com.postgraduate.domain.admin.application.dto.res.SalaryDetailsResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.salary.domain.entity.Salary; @@ -48,21 +48,21 @@ public SalaryDetailsResponse getSalary(Long seniorId) { return AdminMapper.mapToSalaryDetailsResponse(senior, totalAmount, status); } - public AllSalariesResponse getSalaries() { - List responses = new ArrayList<>(); + public SalaryManageResponse getSalaries() { + List responses = new ArrayList<>(); List seniors = seniorGetService.getAll(); for (Senior senior : seniors) { List salaries = salaryGetService.bySeniorAndSalaryDateAndStatus(senior, getSalaryDate(), true); if (getStatus(salaries) != DONE) { continue; } - SalariesResponse response = getSalariesResponse(senior, salaries); + SalaryInfo response = getSalariesResponse(senior, salaries); responses.add(response); } - return new AllSalariesResponse(responses); + return new SalaryManageResponse(responses); } - private SalariesResponse getSalariesResponse(Senior senior, List salaries) { + private SalaryInfo getSalariesResponse(Senior senior, List salaries) { int totalAmount = getAmount(salaries); LocalDateTime salaryDoneDate = getDoneDate(salaries); diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index e81dbf98..49dcb53f 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -11,8 +11,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import java.util.List; - import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_FIND; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_DETAIL_INFO; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.GET_MENTORING_LIST_INFO; @@ -87,8 +85,8 @@ public ResponseDto getSeniors() { @GetMapping("/salary") @Operation(summary = "[관리자] 정산 목록 조회", description = "한 달 기준으로 정산 목록을 조회합니다. 기준일은 [11일 ~ 내월 10일]입니다.") - public ResponseDto getSalaries() { - AllSalariesResponse salaries = salaryManageUseCase.getSalaries(); + public ResponseDto getSalaries() { + SalaryManageResponse salaries = salaryManageUseCase.getSalaries(); return ResponseDto.create(SALARY_FIND.getCode(), GET_SALARY_INFO.getMessage(), salaries); } @@ -122,8 +120,8 @@ public ResponseDto getSeniorMentorings(@PathVariable Lo @GetMapping("/payments") @Operation(summary = "[관리자] 결제 정보 목록", description = "결제 정보 목록을 조회합니다.") - public ResponseDto> getPayments() { - List payments = paymentManageUseCase.getPayments(); + public ResponseDto getPayments() { + PaymentManageResponse payments = paymentManageUseCase.getPayments(); return ResponseDto.create(PAYMENT_FIND.getCode(), GET_PAYMENT_LIST_INFO.getMessage(), payments); } diff --git a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java index 5b89426d..309b3441 100644 --- a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryInfoUseCase.java @@ -36,6 +36,8 @@ public SalaryInfoResponse getSalary(User user) { public List getSalaryDetail(User user, Boolean status) { Senior senior = seniorGetService.byUser(user); List salaries = salaryGetService.bySeniorAndStatus(senior, status); - return salaries.stream().map(SalaryMapper::mapToSalaryDetail).toList(); + return salaries.stream() + .map(SalaryMapper::mapToSalaryDetail) + .toList(); } } From 0f0172dac2ac3f2cc5977b3431d878355bd63cca Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 01:35:50 +0900 Subject: [PATCH 36/47] =?UTF-8?q?RAC-186=20fix:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/SeniorManageByAdminUseCase.java | 14 ++++---------- .../senior/domain/service/SeniorUpdateService.java | 7 ++++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index a4d90c0c..0882e864 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -1,8 +1,8 @@ package com.postgraduate.domain.admin.application.usecase; +import com.postgraduate.domain.admin.application.dto.SeniorInfo; import com.postgraduate.domain.admin.application.dto.req.SeniorStatusRequest; import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; -import com.postgraduate.domain.admin.application.dto.SeniorInfo; import com.postgraduate.domain.admin.application.dto.res.SeniorManageResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; @@ -12,9 +12,7 @@ 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.user.domain.entity.User; -import com.postgraduate.domain.user.domain.entity.constant.Role; -import com.postgraduate.domain.user.domain.service.UserUpdateService; +import com.postgraduate.domain.senior.domain.service.SeniorUpdateService; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.service.WishGetService; import lombok.RequiredArgsConstructor; @@ -32,7 +30,7 @@ @RequiredArgsConstructor public class SeniorManageByAdminUseCase { private final SeniorGetService seniorGetService; - private final UserUpdateService userUpdateService; + private final SeniorUpdateService seniorUpdateService; private final SalaryGetService salaryGetService; private final WishGetService wishGetService; @@ -46,11 +44,7 @@ public CertificationDetailsResponse getCertificationDetails(Long seniorId) { public void updateSeniorStatus(Long seniorId, SeniorStatusRequest request) { Senior senior = seniorGetService.bySeniorId(seniorId); - senior.updateStatus(request.getStatus()); - if (request.getStatus() == Status.APPROVE) { - User user = senior.getUser(); - userUpdateService.updateRole(user.getUserId(), Role.SENIOR); - } + seniorUpdateService.updateCertificationStatus(senior, request.getStatus()); } public SeniorManageResponse getSeniors() { diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java index 42b82a15..455042d3 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java @@ -3,11 +3,12 @@ import com.postgraduate.domain.senior.application.dto.req.SeniorMyPageProfileRequest; import com.postgraduate.domain.senior.domain.entity.Profile; import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.entity.constant.Status; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -@RequiredArgsConstructor @Service +@RequiredArgsConstructor public class SeniorUpdateService { public void signUpSeniorProfile(Senior senior, Profile profile) { senior.updateProfile(profile); @@ -25,4 +26,8 @@ public void updateMyPageProfile(Senior senior, SeniorMyPageProfileRequest myPage public void updateHit(Senior senior) { senior.updateHit(); } + + public void updateCertificationStatus(Senior senior, Status status) { + senior.updateStatus(status); + } } From 472323c77d0d262c7c6dcd0b39830974e6cd2a88 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 12:50:32 +0900 Subject: [PATCH 37/47] =?UTF-8?q?RAC-186=20fix:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=20=EC=A0=95=EB=B3=B4=20`UserManageByAdminUse?= =?UTF-8?q?Case`=EC=97=90=EC=84=9C=20=EA=B4=80=EB=A6=AC=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/mapper/AdminMapper.java | 13 +++++++++++++ .../usecase/UserManageByAdminUseCase.java | 7 +++++++ .../admin/presentation/AdminController.java | 4 +--- .../wish/application/mapper/WishMapper.java | 7 ------- .../application/usecase/WishInfoUseCase.java | 19 ------------------- .../wish/domain/service/WishGetService.java | 3 ++- 6 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java 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 b6f228fb..5990358e 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 @@ -9,6 +9,7 @@ import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; import com.postgraduate.domain.wish.domain.entity.Wish; import java.time.LocalDateTime; @@ -178,4 +179,16 @@ public static MentoringWithPaymentResponse mapToMentoringWithPaymentResponse(Pay (int) (mentoring.getPay() * 0.2) ); } + + public static WishResponse mapToWishResponse(Wish wish) { + User user = wish.getUser(); + return new WishResponse( + user.getNickName(), + user.getPhoneNumber(), + user.getCreatedAt(), + user.getMarketingReceive(), + wish.getMatchingReceive(), + wish.getMajor(), + wish.getField()); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java index 5977c43e..7e8989a3 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/UserManageByAdminUseCase.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.admin.application.dto.UserInfo; import com.postgraduate.domain.admin.application.dto.res.UserManageResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; +import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.service.WishGetService; import lombok.RequiredArgsConstructor; @@ -16,6 +17,7 @@ @RequiredArgsConstructor public class UserManageByAdminUseCase { private final WishGetService wishGetService; + public UserManageResponse getUsers() { List wishes = wishGetService.all(); List userInfos = wishes.stream() @@ -23,4 +25,9 @@ public UserManageResponse getUsers() { .toList(); return new UserManageResponse(userInfos); } + + public WishResponse getWish(Long wishId) { + Wish wish = wishGetService.byWishId(wishId); + return AdminMapper.mapToWishResponse(wish); + } } diff --git a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java index 49dcb53f..fccbbb6f 100644 --- a/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/AdminController.java @@ -4,7 +4,6 @@ import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.admin.application.usecase.*; import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; -import com.postgraduate.domain.wish.application.usecase.WishInfoUseCase; import com.postgraduate.global.dto.ResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -38,7 +37,6 @@ public class AdminController { private final UserManageByAdminUseCase userManageUseCase; private final MentoringManageByAdminUseCase mentoringManageUseCase; private final PaymentManageByAdminUseCase paymentManageUseCase; - private final WishInfoUseCase wishInfoUseCase; private final SalaryManageByAdminUseCase salaryManageUseCase; @GetMapping("/certification/{seniorId}") @@ -72,7 +70,7 @@ public ResponseDto getUsers() { @GetMapping("/wish/{wishId}") @Operation(summary = "[관리자] 후배 매칭 지원 정보", description = "대학생 후배 매칭 지원 정보를 상세 조회합니다.") public ResponseDto getWish(@PathVariable Long wishId) { - WishResponse wish = wishInfoUseCase.getWish(wishId); + WishResponse wish = userManageUseCase.getWish(wishId); return ResponseDto.create(WISH_FIND.getCode(), GET_WISH_INFO.getMessage(), wish); } diff --git a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java index 20653963..d0e3cf9f 100644 --- a/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java +++ b/src/main/java/com/postgraduate/domain/wish/application/mapper/WishMapper.java @@ -2,7 +2,6 @@ import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; import com.postgraduate.domain.user.domain.entity.User; -import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; import com.postgraduate.domain.wish.domain.entity.Wish; public class WishMapper { @@ -14,10 +13,4 @@ public static Wish mapToWish(User user, SignUpRequest request) { .matchingReceive(request.getMatchingReceive()) .build(); } - - public static WishResponse mapToWish(Wish wish) { - User user = wish.getUser(); - return new WishResponse(user.getNickName(), user.getPhoneNumber(), user.getCreatedAt(), user.getMarketingReceive(), - wish.getMatchingReceive(), wish.getMajor(), wish.getField()); - } } diff --git a/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java b/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java deleted file mode 100644 index aa6966dc..00000000 --- a/src/main/java/com/postgraduate/domain/wish/application/usecase/WishInfoUseCase.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.postgraduate.domain.wish.application.usecase; - -import com.postgraduate.domain.wish.application.mapper.WishMapper; -import com.postgraduate.domain.wish.application.mapper.dto.res.WishResponse; -import com.postgraduate.domain.wish.domain.entity.Wish; -import com.postgraduate.domain.wish.domain.service.WishGetService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class WishInfoUseCase { - private final WishGetService wishGetService; - - public WishResponse getWish(Long wishId) { - Wish wish = wishGetService.byWishId(wishId); - return WishMapper.mapToWish(wish); - } -} diff --git a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java index c8eb2074..ba83ddef 100644 --- a/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java +++ b/src/main/java/com/postgraduate/domain/wish/domain/service/WishGetService.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.wish.domain.entity.Wish; import com.postgraduate.domain.wish.domain.repository.WishRepository; +import com.postgraduate.domain.wish.exception.WishNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -14,7 +15,7 @@ public class WishGetService { private final WishRepository wishRepository; public Wish byWishId(Long wishId) { - return wishRepository.findById(wishId).orElseThrow(); + return wishRepository.findById(wishId).orElseThrow(WishNotFoundException::new); } public Optional byUser(User user) { From 74fcd63737741775e14f9c8843f9dffc3ba1a645 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 12:51:03 +0900 Subject: [PATCH 38/47] =?UTF-8?q?RAC-186=20fix:=20`@Transactional`=20useca?= =?UTF-8?q?se=20=EB=8B=A8=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/SalaryManageByAdminUseCase.java | 8 +++++--- .../domain/salary/domain/service/SalaryUpdateService.java | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index d0858e69..27746ae4 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -15,6 +15,7 @@ import com.postgraduate.global.config.security.util.EncryptorUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; @@ -25,6 +26,7 @@ import static com.postgraduate.domain.salary.util.SalaryUtil.*; @Service +@Transactional @RequiredArgsConstructor public class SalaryManageByAdminUseCase { private final SeniorGetService seniorGetService; @@ -43,7 +45,7 @@ public SalaryDetailsResponse getSalary(Long seniorId) { if (optionalAccount.isPresent()) { Account account = optionalAccount.get(); String accountNumber = encryptorUtils.decryptData(account.getAccountNumber()); - return AdminMapper.mapToSalaryDetailsResponse(senior, optionalAccount.get(), accountNumber, totalAmount, status); + return AdminMapper.mapToSalaryDetailsResponse(senior, account, accountNumber, totalAmount, status); } return AdminMapper.mapToSalaryDetailsResponse(senior, totalAmount, status); } @@ -56,13 +58,13 @@ public SalaryManageResponse getSalaries() { if (getStatus(salaries) != DONE) { continue; } - SalaryInfo response = getSalariesResponse(senior, salaries); + SalaryInfo response = getSalaryInfo(senior, salaries); responses.add(response); } return new SalaryManageResponse(responses); } - private SalaryInfo getSalariesResponse(Senior senior, List salaries) { + private SalaryInfo getSalaryInfo(Senior senior, List salaries) { int totalAmount = getAmount(salaries); LocalDateTime salaryDoneDate = getDoneDate(salaries); diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java index cd01695b..f7d71f4e 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryUpdateService.java @@ -3,10 +3,8 @@ import com.postgraduate.domain.salary.domain.entity.Salary; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service -@Transactional @RequiredArgsConstructor public class SalaryUpdateService { From 48c544c6b1e53455dadda7e252586d1103b4201c Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:26:18 +0900 Subject: [PATCH 39/47] =?UTF-8?q?RAC-186=20fix:=20`SalaryStatus`=20admin?= =?UTF-8?q?=20=ED=8C=A8=ED=82=A4=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/application/dto/SeniorInfo.java | 2 +- .../application/dto/res/SalaryDetailsResponse.java | 2 +- .../domain/admin/application/mapper/AdminMapper.java | 2 +- .../usecase/SalaryManageByAdminUseCase.java | 4 ++-- .../usecase/SeniorManageByAdminUseCase.java | 2 +- .../presentation}/constant/SalaryStatus.java | 4 ++-- .../postgraduate/domain/salary/util/SalaryUtil.java | 10 ++++++---- 7 files changed, 14 insertions(+), 12 deletions(-) rename src/main/java/com/postgraduate/domain/{salary/domain/entity => admin/presentation}/constant/SalaryStatus.java (69%) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java index b8835b94..a0aac8c6 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/SeniorInfo.java @@ -1,6 +1,6 @@ package com.postgraduate.domain.admin.application.dto; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.senior.domain.entity.constant.Status; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java index f265b06c..84d5e038 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/SalaryDetailsResponse.java @@ -1,6 +1,6 @@ package com.postgraduate.domain.admin.application.dto.res; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import jakarta.validation.constraints.NotNull; public record SalaryDetailsResponse( 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 5990358e..24f2ecdb 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 @@ -5,7 +5,7 @@ import com.postgraduate.domain.admin.application.dto.res.*; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.payment.domain.entity.Payment; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 27746ae4..73cd4ece 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -7,7 +7,7 @@ import com.postgraduate.domain.admin.application.dto.res.SalaryDetailsResponse; import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.salary.domain.entity.Salary; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.salary.domain.service.SalaryUpdateService; import com.postgraduate.domain.senior.domain.entity.Senior; @@ -22,7 +22,7 @@ import java.util.List; import java.util.Optional; -import static com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus.DONE; +import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.DONE; import static com.postgraduate.domain.salary.util.SalaryUtil.*; @Service diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 0882e864..92ca0d50 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -7,7 +7,7 @@ import com.postgraduate.domain.admin.application.mapper.AdminMapper; import com.postgraduate.domain.admin.exception.SeniorNotWaitingException; import com.postgraduate.domain.salary.domain.entity.Salary; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.entity.constant.Status; diff --git a/src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java b/src/main/java/com/postgraduate/domain/admin/presentation/constant/SalaryStatus.java similarity index 69% rename from src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java rename to src/main/java/com/postgraduate/domain/admin/presentation/constant/SalaryStatus.java index a4f58e62..efc67d51 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/entity/constant/SalaryStatus.java +++ b/src/main/java/com/postgraduate/domain/admin/presentation/constant/SalaryStatus.java @@ -1,10 +1,10 @@ -package com.postgraduate.domain.salary.domain.entity.constant; +package com.postgraduate.domain.admin.presentation.constant; import lombok.Getter; import lombok.RequiredArgsConstructor; -@RequiredArgsConstructor @Getter +@RequiredArgsConstructor public enum SalaryStatus { DONE, YET, NONE } diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index 1875a337..a920f289 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -1,13 +1,15 @@ package com.postgraduate.domain.salary.util; import com.postgraduate.domain.salary.domain.entity.Salary; -import com.postgraduate.domain.salary.domain.entity.constant.SalaryStatus; +import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.*; + public class SalaryUtil { private static final int SALARY_DATE = 10; public static LocalDate getSalaryDate() { @@ -33,12 +35,12 @@ public static SalaryStatus getStatus(List salaries) { .filter(Salary::getStatus) .count(); if (salaries.size() == 0) { - return SalaryStatus.NONE; + return NONE; } if (count == salaries.size()) { - return SalaryStatus.DONE; + return DONE; } - return SalaryStatus.YET; + return YET; } public static LocalDateTime getDoneDate(List salaries) { From 230c5c176c6f21e40f989ce7661160ab313cd23e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:27:35 +0900 Subject: [PATCH 40/47] =?UTF-8?q?RAC-186=20fix:=20findAll()=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=ED=95=98=EB=8A=94=EB=A9=94=EC=84=9C=EB=93=9C=20`all()?= =?UTF-8?q?`=EB=A1=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/usecase/SalaryManageByAdminUseCase.java | 2 +- .../admin/application/usecase/SeniorManageByAdminUseCase.java | 2 +- .../domain/senior/domain/service/SeniorGetService.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java index 73cd4ece..d14bf21e 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SalaryManageByAdminUseCase.java @@ -52,7 +52,7 @@ public SalaryDetailsResponse getSalary(Long seniorId) { public SalaryManageResponse getSalaries() { List responses = new ArrayList<>(); - List seniors = seniorGetService.getAll(); + List seniors = seniorGetService.all(); for (Senior senior : seniors) { List salaries = salaryGetService.bySeniorAndSalaryDateAndStatus(senior, getSalaryDate(), true); if (getStatus(salaries) != DONE) { diff --git a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java index 92ca0d50..29a3edea 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java +++ b/src/main/java/com/postgraduate/domain/admin/application/usecase/SeniorManageByAdminUseCase.java @@ -48,7 +48,7 @@ public void updateSeniorStatus(Long seniorId, SeniorStatusRequest request) { } public SeniorManageResponse getSeniors() { - List seniors = seniorGetService.getAll(); + List seniors = seniorGetService.all(); List seniorInfos = seniors.stream() .map(senior -> { List salaries = salaryGetService.bySeniorAndSalaryDate(senior, getSalaryDate()); diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java index a41c6eee..8aa457c5 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java @@ -37,7 +37,7 @@ public List byStatus(Status status) { return seniorRepository.findAllByStatus(status); } - public List getAll() { + public List all() { return seniorRepository.findAll(); } From 17d22a1a49582cab9f3fdc4a86cd759894aaddf4 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:27:57 +0900 Subject: [PATCH 41/47] =?UTF-8?q?RAC-186=20fix:=20`AppliedMentoringDetailR?= =?UTF-8?q?esponse`=20record=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/AppliedMentoringDetailResponse.java | 29 +++++++------------ .../application/mapper/MentoringMapper.java | 23 +++++++-------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java index bc00f1f0..971139bc 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringDetailResponse.java @@ -1,21 +1,14 @@ package com.postgraduate.domain.mentoring.application.dto.res; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -@AllArgsConstructor -public class AppliedMentoringDetailResponse { - private Long seniorId; - private String profile; - private String nickName; - private String postgradu; - private String major; - private String lab; - private int term; - private String topic; - private String question; - private String[] dates; +public record AppliedMentoringDetailResponse( + Long seniorId, + String profile, + String nickName, + String postgradu, + String major, + String lab, + String topic, + String question, + String[] dates +) { } diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index f2b7b3c1..1f6b544c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -57,18 +57,17 @@ public static WaitingMentoringInfo mapToWaitingInfo(Mentoring mentoring) { public static AppliedMentoringDetailResponse mapToAppliedDetailInfo(Mentoring mentoring) { Senior senior = mentoring.getSenior(); String[] dates = mentoring.getDate().split(","); - return AppliedMentoringDetailResponse.builder() - .seniorId(senior.getSeniorId()) - .profile(senior.getUser().getProfile()) - .nickName(senior.getUser().getNickName()) - .postgradu(senior.getInfo().getPostgradu()) - .major(senior.getInfo().getMajor()) - .lab(senior.getInfo().getLab()) - .term(senior.getProfile().getTerm()) - .topic(mentoring.getTopic()) - .question(mentoring.getQuestion()) - .dates(dates) - .build(); + return new AppliedMentoringDetailResponse( + senior.getSeniorId(), + senior.getUser().getProfile(), + senior.getUser().getNickName(), + senior.getInfo().getPostgradu(), + senior.getInfo().getMajor(), + senior.getInfo().getLab(), + mentoring.getTopic(), + mentoring.getQuestion(), + dates + ); } public static Mentoring mapToMentoring(User user, Senior senior, MentoringApplyRequest request) { From d4bd3f7fa7470e2998c52f3c860941b360c5731d Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:45:26 +0900 Subject: [PATCH 42/47] =?UTF-8?q?RAC-186=20fix:=20SalaryUtil=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringManageUseCase.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index 00008b7e..34b19d57 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -15,6 +15,7 @@ import com.postgraduate.domain.salary.application.mapper.SalaryMapper; import com.postgraduate.domain.salary.domain.entity.Salary; import com.postgraduate.domain.salary.domain.service.SalarySaveService; +import com.postgraduate.domain.salary.util.SalaryUtil; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; @@ -33,7 +34,6 @@ @Transactional @RequiredArgsConstructor public class MentoringManageUseCase { - private static final int SALARY_DATE = 10; private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; private final MentoringUpdateService mentoringUpdateService; private final MentoringGetService mentoringGetService; @@ -57,10 +57,7 @@ public void updateDone(User user, Long mentoringId) { } private void createSalary(Mentoring mentoring) { - LocalDate now = LocalDate.now(); - LocalDate salaryDate = now.getDayOfMonth() < SALARY_DATE - ? now.withDayOfMonth(SALARY_DATE) - : now.plusMonths(1).withDayOfMonth(SALARY_DATE); + LocalDate salaryDate = SalaryUtil.getSalaryDate(); Salary salary = SalaryMapper.mapToSalary(mentoring, salaryDate); salarySaveService.saveSalary(salary); } From 9a6e8fa05947de44a0aa66e69cd8e28e1692075f Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:47:04 +0900 Subject: [PATCH 43/47] =?UTF-8?q?RAC-186=20fix:=20=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=9D=BC=EC=8B=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/res/CertificationDetailsResponse.java | 5 ++++- .../domain/admin/application/mapper/AdminMapper.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java index 7d6de468..fc2a6f1d 100644 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java +++ b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationDetailsResponse.java @@ -2,6 +2,8 @@ import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; + public record CertificationDetailsResponse( @NotNull String certification, @@ -9,7 +11,8 @@ public record CertificationDetailsResponse( String nickName, @NotNull String phoneNumber, - //인증 신청 날짜 + @NotNull + LocalDate createdAt, @NotNull String postgradu, @NotNull 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 24f2ecdb..936fdd36 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 @@ -23,6 +23,7 @@ public static CertificationDetailsResponse mapToCertificationInfo(Senior senior) senior.getCertification(), user.getNickName(), user.getPhoneNumber(), + senior.getCreatedAt(), info.getPostgradu(), info.getMajor(), info.getField(), From c43b9f01f3c9b75aa70923cd5829ae76b838e6b7 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 13:47:17 +0900 Subject: [PATCH 44/47] =?UTF-8?q?RAC-186=20chore:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/CertificationInfo.java | 21 -------------- .../application/dto/CertificationProfile.java | 15 ---------- .../dto/res/CertificationResponse.java | 16 ----------- .../admin/application/mapper/AdminMapper.java | 28 ------------------- 4 files changed, 80 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/CertificationProfile.java delete mode 100644 src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationResponse.java diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java b/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java deleted file mode 100644 index 5f4d9f3d..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.postgraduate.domain.admin.application.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Builder -@Getter -@AllArgsConstructor -public class CertificationInfo { - private String certification; - private String nickName; - private String phoneNumber; - //인증 신청 날짜 - private String postgradu; - private String major; - private String field; - private String lab; - private String professor; - private String keyword; -} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationProfile.java b/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationProfile.java deleted file mode 100644 index 2bbc7096..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/CertificationProfile.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.postgraduate.domain.admin.application.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Builder -@Getter -@AllArgsConstructor -public class CertificationProfile { - private Integer term; - private String time; - private String info; - //연구실 대표 키워드 -} diff --git a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationResponse.java b/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationResponse.java deleted file mode 100644 index 7fa4b992..00000000 --- a/src/main/java/com/postgraduate/domain/admin/application/dto/res/CertificationResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.postgraduate.domain.admin.application.dto.res; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.time.LocalDate; - -@Builder -@Getter -@AllArgsConstructor -public class CertificationResponse { - private Long seniorId; - private String nickName; - private LocalDate createdAt; -} 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 936fdd36..298ff5b1 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 @@ -33,22 +33,6 @@ public static CertificationDetailsResponse mapToCertificationInfo(Senior senior) ); } - public static CertificationProfile mapToCertificationProfile(Senior senior) { - return CertificationProfile.builder() - .time(senior.getProfile().getTime()) - .term(senior.getProfile().getTerm()) - .info(senior.getProfile().getInfo()) - .build(); - } - - public static CertificationResponse mapToCertification(Senior senior) { - return CertificationResponse.builder() - .seniorId(senior.getSeniorId()) - .nickName(senior.getUser().getNickName()) - .createdAt(senior.getCreatedAt()) - .build(); - } - public static UserInfo mapToUserInfo(Wish wish) { User user = wish.getUser(); return new UserInfo( @@ -63,18 +47,6 @@ public static UserInfo mapToUserInfo(Wish wish) { ); } -// -// public static UserWithSeniorResponse mapToUserWithSeniorResponse(User user, Long seniorId) { -// return UserWithSeniorResponse.builder() -// .userId(user.getUserId()) -// .nickName(user.getNickName()) -// .marketingReceive(user.getMarketingReceive()) -// .matchingReceive(user.getHope().getMatchingReceive()) -// .createdAt(user.getCreatedAt()) -// .seniorId(seniorId) -// .build(); -// } - public static SeniorInfo mapToSeniorInfo(Senior senior, SalaryStatus salaryStatus, Boolean isUser) { User user = senior.getUser(); return new SeniorInfo( From 26e399c79ff9387266699eeb3ceaa91f4cc34b6d Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 18:45:19 +0900 Subject: [PATCH 45/47] =?UTF-8?q?RAC-186=20fix:=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/presentation/constant/AccountResponseCode.java | 2 +- .../wish/presentation/constant/WishResponseMessage.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java index 2311ce3a..11283951 100644 --- a/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java +++ b/src/main/java/com/postgraduate/domain/account/presentation/constant/AccountResponseCode.java @@ -11,6 +11,6 @@ public enum AccountResponseCode { ACCOUNT_CREATE("ACT202"), ACCOUNT_DELETE("ACT203"), - ACCOUNT_NOT_FOUND("AE400"); + ACCOUNT_NOT_FOUND("EX1000"); private final String code; } diff --git a/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java index 8d84b338..4e805d1a 100644 --- a/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/wish/presentation/constant/WishResponseMessage.java @@ -6,10 +6,10 @@ @Getter @RequiredArgsConstructor public enum WishResponseMessage { - GET_WISH_INFO("희망 정보 조회에 성공하였습니다"), - GET_WISH_LIST_INFO("희망 리스트 조회에 성공하였습니다."), + GET_WISH_INFO("지원 정보 조회에 성공하였습니다"), + GET_WISH_LIST_INFO("지원 리스트 조회에 성공하였습니다."), - NOT_FOUND_WISH("희망을 찾을 수 없습니다."); + NOT_FOUND_WISH("지원을 찾을 수 없습니다."); private final String message; } From ea5f617e7d3ae912b25f29ac76aebd2c3ad22234 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 23:22:22 +0900 Subject: [PATCH 46/47] =?UTF-8?q?RAC-186=20feat:=20=EC=8A=B9=EC=9D=B8?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=20=EC=95=84=EB=8B=8C=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/exception/SeniorNotWaitingException.java | 7 +++---- .../senior/presentation/constant/SeniorResponseCode.java | 3 ++- .../presentation/constant/SeniorResponseMessage.java | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java b/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java index 5d8c763d..785a28e6 100644 --- a/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java +++ b/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java @@ -1,11 +1,10 @@ package com.postgraduate.domain.admin.exception; -import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_NOT_WAITING; -import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.NOT_WAITING_MENTORING; +import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.NONE_SENIOR; +import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.NOT_WAITING_STATUS; public class SeniorNotWaitingException extends SeniorException{ public SeniorNotWaitingException() { - super(NOT_WAITING_MENTORING.getMessage(), MENTORING_NOT_WAITING.getCode()); - //TODO: 메시지, 코드 변경 + super(NOT_WAITING_STATUS.getMessage(), NONE_SENIOR.getCode()); } } diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseCode.java b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseCode.java index 99e4bffd..e62a8c21 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseCode.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseCode.java @@ -12,6 +12,7 @@ public enum SeniorResponseCode { SENIOR_DELETE("SNR203"), NONE_SENIOR("EX400"), - NONE_ACCOUNT("EX401"); + NONE_ACCOUNT("EX401"), + NOT_WAITING_STATUS("EX402"); private final String code; } diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java index 6647e3cc..c2c88cae 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java @@ -21,7 +21,8 @@ public enum SeniorResponseMessage { UPDATE_STATUS("대학원생 승인 요청 응답에 성공하였습니다"), NONE_SENIOR("등록된 멘토가 없습니다."), - NONE_ACCOUNT("등록된 계좌가 없습니다."); + NONE_ACCOUNT("등록된 계좌가 없습니다."), + NOT_WAITING_STATUS("승인대기 상태의 선배가 아닙니다."); private final String message; } From d2c6bb38cdc7943a08d86445313ab04d9a9e41d3 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 9 Dec 2023 23:26:44 +0900 Subject: [PATCH 47/47] =?UTF-8?q?RAC-186=20feat:=20=EC=8A=B9=EC=9D=B8?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=20=EC=95=84=EB=8B=8C=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=EC=BD=94=EB=93=9C=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/exception/SeniorNotWaitingException.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java b/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java index 785a28e6..3d7cc781 100644 --- a/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java +++ b/src/main/java/com/postgraduate/domain/admin/exception/SeniorNotWaitingException.java @@ -1,10 +1,10 @@ package com.postgraduate.domain.admin.exception; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.NONE_SENIOR; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.NOT_WAITING_STATUS; +import com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode; +import com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage; public class SeniorNotWaitingException extends SeniorException{ public SeniorNotWaitingException() { - super(NOT_WAITING_STATUS.getMessage(), NONE_SENIOR.getCode()); + super(SeniorResponseMessage.NOT_WAITING_STATUS.getMessage(), SeniorResponseCode.NOT_WAITING_STATUS.getCode()); } }