Skip to content

Commit

Permalink
Merge pull request #228 from WE-ARE-RACCOONS/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
ywj9811 authored Apr 14, 2024
2 parents 2a619e6 + 314668e commit 17e619e
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 70 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.DoneMentoringInfo;

import java.util.List;

public record DoneMentoringResponse(List<DoneMentoringInfo> mentoringInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.DoneSeniorMentoringInfo;

import java.util.List;

public record DoneSeniorMentoringResponse(List<DoneSeniorMentoringInfo> seniorMentoringInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.ExpectedMentoringInfo;

import java.util.List;

public record ExpectedMentoringResponse(List<ExpectedMentoringInfo> mentoringInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.ExpectedSeniorMentoringInfo;

import java.util.List;

public record ExpectedSeniorMentoringResponse(List<ExpectedSeniorMentoringInfo> seniorMentoringInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.WaitingMentoringInfo;

import java.util.List;

public record WaitingMentoringResponse(List<WaitingMentoringInfo> mentoringInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.postgraduate.domain.mentoring.application.dto.res;

import com.postgraduate.domain.mentoring.application.dto.WaitingSeniorMentoringInfo;

import java.util.List;

public record WaitingSeniorMentoringResponse(List<WaitingSeniorMentoringInfo> seniorMentoringInfos) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import com.postgraduate.domain.mentoring.application.dto.DoneSeniorMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.ExpectedSeniorMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.WaitingSeniorMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse;
import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.*;
import com.postgraduate.domain.mentoring.application.mapper.MentoringMapper;
import com.postgraduate.domain.mentoring.domain.entity.Mentoring;
import com.postgraduate.domain.mentoring.domain.service.MentoringGetService;
Expand Down Expand Up @@ -35,7 +34,7 @@ public SeniorMentoringDetailResponse getSeniorMentoringDetail(User user, Long me
return mapToSeniorMentoringDetail(mentoring);
}

public SeniorMentoringResponse getSeniorWaiting(User user) {
public WaitingSeniorMentoringResponse getSeniorWaiting(User user) {
Senior senior = seniorGetService.byUser(user);
List<Mentoring> mentorings = mentoringGetService.bySeniorWaiting(senior);
List<WaitingSeniorMentoringInfo> waitingMentoringInfos = mentorings.stream()
Expand All @@ -49,10 +48,10 @@ public SeniorMentoringResponse getSeniorWaiting(User user) {
return mapToSeniorWaitingInfo(mentoring, remain);
})
.toList();
return new SeniorMentoringResponse(waitingMentoringInfos);
return new WaitingSeniorMentoringResponse(waitingMentoringInfos);
}

public SeniorMentoringResponse getSeniorExpected(User user) {
public ExpectedSeniorMentoringResponse getSeniorExpected(User user) {
Senior senior = seniorGetService.byUser(user);
List<Mentoring> mentorings = mentoringGetService.bySeniorExpected(senior);
List<ExpectedSeniorMentoringInfo> expectedMentoringInfos = mentorings.stream()
Expand All @@ -63,15 +62,15 @@ public SeniorMentoringResponse getSeniorExpected(User user) {
return mapToSeniorExpectedInfo(mentoring, dDay);
})
.toList();
return new SeniorMentoringResponse(expectedMentoringInfos);
return new ExpectedSeniorMentoringResponse(expectedMentoringInfos);
}

public SeniorMentoringResponse getSeniorDone(User user) {
public DoneSeniorMentoringResponse getSeniorDone(User user) {
Senior senior = seniorGetService.byUser(user);
List<Mentoring> mentorings = mentoringGetService.bySeniorDone(senior);
List<DoneSeniorMentoringInfo> doneSeniorMentoringInfos = mentorings.stream()
.map(MentoringMapper::mapToSeniorDoneInfo)
.toList();
return new SeniorMentoringResponse(doneSeniorMentoringInfos);
return new DoneSeniorMentoringResponse(doneSeniorMentoringInfos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import com.postgraduate.domain.mentoring.application.dto.DoneMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.ExpectedMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.WaitingMentoringInfo;
import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse;
import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.*;
import com.postgraduate.domain.mentoring.application.mapper.MentoringMapper;
import com.postgraduate.domain.mentoring.domain.entity.Mentoring;
import com.postgraduate.domain.mentoring.domain.service.MentoringGetService;
Expand All @@ -28,27 +27,27 @@ public AppliedMentoringDetailResponse getMentoringDetail(User user, Long mentori
return mapToAppliedDetailInfo(mentoring);
}

public AppliedMentoringResponse getWaiting(User user) {
public WaitingMentoringResponse getWaiting(User user) {
List<Mentoring> mentorings = mentoringGetService.byUserWaiting(user);
List<WaitingMentoringInfo> waitingMentoringInfos = mentorings.stream()
.map(MentoringMapper::mapToWaitingInfo)
.toList();
return new AppliedMentoringResponse(waitingMentoringInfos);
return new WaitingMentoringResponse(waitingMentoringInfos);
}

public AppliedMentoringResponse getExpected(User user) {
public ExpectedMentoringResponse getExpected(User user) {
List<Mentoring> mentorings = mentoringGetService.byUserExpected(user);
List<ExpectedMentoringInfo> expectedMentoringInfos = mentorings.stream()
.map(MentoringMapper::mapToExpectedInfo)
.toList();
return new AppliedMentoringResponse(expectedMentoringInfos);
return new ExpectedMentoringResponse(expectedMentoringInfos);
}

public AppliedMentoringResponse getDone(User user) {
public DoneMentoringResponse getDone(User user) {
List<Mentoring> mentorings = mentoringGetService.byUserDone(user);
List<DoneMentoringInfo> doneMentoringInfos = mentorings.stream()
.map(MentoringMapper::mapToDoneInfo)
.toList();
return new AppliedMentoringResponse(doneMentoringInfos);
return new DoneMentoringResponse(doneMentoringInfos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public List<Mentoring> findAllBySeniorAndSalaryStatus(Senior senior, Boolean sta
mentoring.status.eq(Status.DONE),
mentoring.salary.status.eq(status)
)
.leftJoin(mentoring.payment, payment)
.fetchJoin()
.leftJoin(mentoring.salary, salary)
.fetchJoin()
.leftJoin(mentoring.user, user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ public class MentoringController {

@GetMapping("/me/waiting")
@Operation(summary = "[대학생] 신청한 멘토링 목록 조회", description = "대학생이 신청한 멘토링 목록을 조회합니다.")
public ResponseDto<AppliedMentoringResponse> getWaitingMentorings(@AuthenticationPrincipal User user) {
AppliedMentoringResponse mentoringResponse = userInfoUseCase.getWaiting(user);
public ResponseDto<WaitingMentoringResponse> getWaitingMentorings(@AuthenticationPrincipal User user) {
WaitingMentoringResponse mentoringResponse = userInfoUseCase.getWaiting(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

@GetMapping("/me/expected")
@Operation(summary = "[대학생] 예정된 멘토링 목록 조회", description = "대학생이 예정된 멘토링 목록을 조회합니다.")
public ResponseDto<AppliedMentoringResponse> getExpectedMentorings(@AuthenticationPrincipal User user) {
AppliedMentoringResponse mentoringResponse = userInfoUseCase.getExpected(user);
public ResponseDto<ExpectedMentoringResponse> getExpectedMentorings(@AuthenticationPrincipal User user) {
ExpectedMentoringResponse mentoringResponse = userInfoUseCase.getExpected(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

@GetMapping("/me/done")
@Operation(summary = "[대학생] 완료한 멘토링 목록 조회", description = "대학생이 완료한 멘토링 목록을 조회합니다.")
public ResponseDto<AppliedMentoringResponse> getDoneMentorings(@AuthenticationPrincipal User user) {
AppliedMentoringResponse mentoringResponse = userInfoUseCase.getDone(user);
public ResponseDto<DoneMentoringResponse> getDoneMentorings(@AuthenticationPrincipal User user) {
DoneMentoringResponse mentoringResponse = userInfoUseCase.getDone(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

Expand Down Expand Up @@ -81,22 +81,22 @@ public ResponseDto<Void> updateMentoringCancel(@AuthenticationPrincipal User use

@GetMapping("/senior/me/waiting")
@Operation(summary = "[대학원생] 신청받은 확정대기 멘토링 목록 조회", description = "대학원생이 신청받은 확정대기 상태의 멘토링 목록을 조회합니다.")
public ResponseDto<SeniorMentoringResponse> getSeniorWaitingMentorings(@AuthenticationPrincipal User user) {
SeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorWaiting(user);
public ResponseDto<WaitingSeniorMentoringResponse> getSeniorWaitingMentorings(@AuthenticationPrincipal User user) {
WaitingSeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorWaiting(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

@GetMapping("/senior/me/expected")
@Operation(summary = "[대학원생] 신청받은 예정된 멘토링 목록 조회", description = "대학원생이 신청받은 예정 상태의 멘토링 목록을 조회합니다.")
public ResponseDto<SeniorMentoringResponse> getSeniorExpectedMentorings(@AuthenticationPrincipal User user) {
SeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorExpected(user);
public ResponseDto<ExpectedSeniorMentoringResponse> getSeniorExpectedMentorings(@AuthenticationPrincipal User user) {
ExpectedSeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorExpected(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

@GetMapping("/senior/me/done")
@Operation(summary = "[대학원생] 신청받은 완료된 멘토링 목록 조회", description = "대학원생이 신청받은 완료 상태의 멘토링 목록을 조회합니다.")
public ResponseDto<SeniorMentoringResponse> getSeniorDoneMentorings(@AuthenticationPrincipal User user) {
SeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorDone(user);
public ResponseDto<DoneSeniorMentoringResponse> getSeniorDoneMentorings(@AuthenticationPrincipal User user) {
DoneSeniorMentoringResponse mentoringResponse = seniorInfoUseCase.getSeniorDone(user);
return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), mentoringResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.time.LocalDate;

public class SalaryMapper {
private static final int AMOUNT = 20000;

private SalaryMapper() {
throw new IllegalArgumentException();
}
Expand Down Expand Up @@ -43,7 +41,7 @@ public static SalaryDetails mapToSalaryDetail(Mentoring mentoring) {
user.getNickName(),
mentoring.getDate(),
mentoring.getTerm(),
AMOUNT,
mentoring.calculateForSenior(),
salary.getSalaryDate()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.postgraduate.domain.senior.domain.entity.Senior;
import com.postgraduate.domain.senior.domain.entity.constant.Status;
import com.postgraduate.domain.senior.domain.service.SeniorGetService;
import com.postgraduate.domain.senior.exception.NoneProfileException;
import com.postgraduate.domain.user.domain.entity.User;
import com.postgraduate.domain.wish.domain.entity.Wish;
import com.postgraduate.domain.wish.domain.service.WishGetService;
Expand Down Expand Up @@ -51,7 +50,7 @@ public SeniorMyPageResponse getSeniorInfo(User user) {
public SeniorMyPageProfileResponse getSeniorMyPageProfile(User user) {
Senior senior = seniorGetService.byUser(user);
if (senior.getProfile() == null) {
throw new NoneProfileException();
return mapToMyPageProfile(senior);
}
List<Available> availables = availableGetService.byMine(senior);
List<AvailableTimeResponse> times = availables.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.postgraduate.domain.mentoring.application.usecase;

import com.postgraduate.domain.account.domain.entity.Account;
import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.DoneSeniorMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.ExpectedSeniorMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.WaitingSeniorMentoringResponse;
import com.postgraduate.domain.mentoring.domain.entity.Mentoring;
import com.postgraduate.domain.mentoring.domain.service.MentoringGetService;
import com.postgraduate.domain.mentoring.exception.MentoringNotFoundException;
import com.postgraduate.domain.payment.domain.entity.Payment;
import com.postgraduate.domain.payment.domain.entity.constant.Status;
import com.postgraduate.domain.salary.domain.entity.Salary;
import com.postgraduate.domain.salary.domain.service.SalaryGetService;
import com.postgraduate.domain.senior.domain.entity.Info;
import com.postgraduate.domain.senior.domain.entity.Profile;
import com.postgraduate.domain.senior.domain.entity.Senior;
Expand All @@ -26,7 +26,7 @@
import java.time.LocalDateTime;
import java.util.List;

import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.*;
import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.WAITING;
import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE;
import static com.postgraduate.domain.user.domain.entity.constant.Role.SENIOR;
import static com.postgraduate.domain.user.domain.entity.constant.Role.USER;
Expand Down Expand Up @@ -115,7 +115,7 @@ void getSeniorWaiting() {
given(mentoringGetService.bySeniorWaiting(senior))
.willReturn(mentorings);

SeniorMentoringResponse seniorWaiting = mentoringSeniorInfoUseCase.getSeniorWaiting(user);
WaitingSeniorMentoringResponse seniorWaiting = mentoringSeniorInfoUseCase.getSeniorWaiting(user);

assertThat(seniorWaiting.seniorMentoringInfos())
.hasSameSizeAs(mentorings);
Expand All @@ -138,7 +138,7 @@ void getSeniorExpected() {
given(mentoringGetService.bySeniorExpected(senior))
.willReturn(mentorings);

SeniorMentoringResponse seniorExpected = mentoringSeniorInfoUseCase.getSeniorExpected(user);
ExpectedSeniorMentoringResponse seniorExpected = mentoringSeniorInfoUseCase.getSeniorExpected(user);

assertThat(seniorExpected.seniorMentoringInfos())
.hasSameSizeAs(mentorings);
Expand All @@ -165,7 +165,7 @@ void getSeniorDone() {
given(mentoringGetService.bySeniorDone(senior))
.willReturn(mentorings);

SeniorMentoringResponse seniorDone = mentoringSeniorInfoUseCase.getSeniorDone(user);
DoneSeniorMentoringResponse seniorDone = mentoringSeniorInfoUseCase.getSeniorDone(user);

assertThat(seniorDone.seniorMentoringInfos())
.hasSameSizeAs(mentorings);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.postgraduate.domain.mentoring.application.usecase;

import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.DoneMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.ExpectedMentoringResponse;
import com.postgraduate.domain.mentoring.application.dto.res.WaitingMentoringResponse;
import com.postgraduate.domain.mentoring.domain.entity.Mentoring;
import com.postgraduate.domain.mentoring.domain.service.MentoringGetService;
import com.postgraduate.domain.mentoring.exception.MentoringDetailNotFoundException;
import com.postgraduate.domain.mentoring.exception.MentoringNotFoundException;
import com.postgraduate.domain.payment.domain.entity.Payment;
import com.postgraduate.domain.payment.domain.entity.constant.Status;
Expand Down Expand Up @@ -32,9 +33,7 @@
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

@ExtendWith(MockitoExtension.class)
class MentoringUserInfoUseCaseTest {
Expand Down Expand Up @@ -112,7 +111,7 @@ void getWaiting() {
given(mentoringGetService.byUserWaiting(user))
.willReturn(mentorings);

AppliedMentoringResponse waiting = mentoringUserInfoUseCase.getWaiting(user);
WaitingMentoringResponse waiting = mentoringUserInfoUseCase.getWaiting(user);

assertThat(waiting.mentoringInfos())
.hasSameSizeAs(mentorings);
Expand All @@ -138,7 +137,7 @@ void getExpected() {
given(mentoringGetService.byUserExpected(user))
.willReturn(mentorings);

AppliedMentoringResponse expected = mentoringUserInfoUseCase.getExpected(user);
ExpectedMentoringResponse expected = mentoringUserInfoUseCase.getExpected(user);

assertThat(expected.mentoringInfos())
.hasSameSizeAs(mentorings);
Expand All @@ -164,7 +163,7 @@ void getDone() {
given(mentoringGetService.byUserDone(user))
.willReturn(mentorings);

AppliedMentoringResponse done = mentoringUserInfoUseCase.getDone(user);
DoneMentoringResponse done = mentoringUserInfoUseCase.getDone(user);

assertThat(done.mentoringInfos())
.hasSameSizeAs(mentorings);
Expand Down
Loading

0 comments on commit 17e619e

Please sign in to comment.