Skip to content

Commit

Permalink
[Refactor] 멘티 신청 후 멘토가 수락할 때 멘티에게 궁금한 점을 기입하도록 수정한다 (#162)
Browse files Browse the repository at this point in the history
* feat: 멘티 신청 -> 멘토 수락 시 멘티에게 궁금한 점 필드 추가

* refactor: 멘토가 멘티에게 궁금한 점 관련 필드 스펙 추가
  • Loading branch information
sjiwon authored Feb 20, 2024
1 parent 07505b5 commit 2b3e828
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public void reject(final RejectAppliedCoffeeChatCommand command) {
@KoddyWritableTransactional
public void approve(final ApproveAppliedCoffeeChatCommand command) {
final CoffeeChat coffeeChat = coffeeChatRepository.getByIdAndMentorId(command.coffeeChatId(), command.mentorId());
coffeeChat.approveFromMenteeApply(Strategy.of(command.type(), command.value(), encryptor));
coffeeChat.approveFromMenteeApply(
command.question(),
Strategy.of(command.type(), command.value(), encryptor)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public record ApproveAppliedCoffeeChatCommand(
long mentorId,
long coffeeChatId,
String question,
Strategy.Type type,
String value
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ public void rejectFromMenteeApply(final String rejectReason) {
/**
* 멘티의 신청 -> 멘토가 수락
*/
public void approveFromMenteeApply(final Strategy strategy) {
public void approveFromMenteeApply(final String question, final Strategy strategy) {
if (this.status != MENTEE_APPLY) {
throw new CoffeeChatException(CANNOT_APPROVE_STATUS);
}

this.question = question;
this.strategy = strategy;
this.status = MENTOR_APPROVE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.koddy.server.auth.domain.model.Authenticated;
import com.koddy.server.coffeechat.application.usecase.HandleMenteeAppliedCoffeeChatUseCase;
import com.koddy.server.coffeechat.application.usecase.command.ApproveAppliedCoffeeChatCommand;
import com.koddy.server.coffeechat.application.usecase.command.RejectAppliedCoffeeChatCommand;
import com.koddy.server.coffeechat.presentation.request.ApproveAppliedCoffeeChatRequest;
import com.koddy.server.coffeechat.presentation.request.RejectAppliedCoffeeChatRequest;
import com.koddy.server.global.annotation.Auth;
Expand Down Expand Up @@ -36,11 +34,7 @@ public ResponseEntity<Void> reject(
@PathVariable final Long coffeeChatId,
@RequestBody @Valid final RejectAppliedCoffeeChatRequest request
) {
handleMenteeAppliedCoffeeChatUseCase.reject(new RejectAppliedCoffeeChatCommand(
authenticated.id,
coffeeChatId,
request.rejectReason()
));
handleMenteeAppliedCoffeeChatUseCase.reject(request.toCommand(authenticated.id, coffeeChatId));
return ResponseEntity.noContent().build();
}

Expand All @@ -52,12 +46,7 @@ public ResponseEntity<Void> approve(
@PathVariable final Long coffeeChatId,
@RequestBody @Valid final ApproveAppliedCoffeeChatRequest request
) {
handleMenteeAppliedCoffeeChatUseCase.approve(new ApproveAppliedCoffeeChatCommand(
authenticated.id,
coffeeChatId,
request.toStrategyType(),
request.chatValue()
));
handleMenteeAppliedCoffeeChatUseCase.approve(request.toCommand(authenticated.id, coffeeChatId));
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
package com.koddy.server.coffeechat.presentation.request;

import com.koddy.server.coffeechat.application.usecase.command.ApproveAppliedCoffeeChatCommand;
import com.koddy.server.coffeechat.domain.model.Strategy;
import jakarta.validation.constraints.NotBlank;

public record ApproveAppliedCoffeeChatRequest(
@NotBlank(message = "멘티에게 궁금한 점은 필수입니다.")
String question,

@NotBlank(message = "멘토링 진행 방식은 필수입니다.")
String chatType,

@NotBlank(message = "멘토링 진행 방식에 대한 URL이나 메신저 ID는 필수입니다.")
String chatValue
) {
public Strategy.Type toStrategyType() {
return Strategy.Type.from(chatType);
public ApproveAppliedCoffeeChatCommand toCommand(
final long mentorId,
final long coffeeChatId
) {
return new ApproveAppliedCoffeeChatCommand(
mentorId,
coffeeChatId,
question,
Strategy.Type.from(chatType),
chatValue
);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package com.koddy.server.coffeechat.presentation.request;

import com.koddy.server.coffeechat.application.usecase.command.RejectAppliedCoffeeChatCommand;
import jakarta.validation.constraints.NotBlank;

public record RejectAppliedCoffeeChatRequest(
@NotBlank(message = "거절 사유는 필수입니다.")
String rejectReason
) {
public RejectAppliedCoffeeChatCommand toCommand(
final long mentorId,
final long coffeeChatId
) {
return new RejectAppliedCoffeeChatCommand(
mentorId,
coffeeChatId,
rejectReason
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public class CoffeeChatAcceptanceStep {
.build(coffeeChatId)
.getPath();

final ApproveAppliedCoffeeChatRequest request = new ApproveAppliedCoffeeChatRequest(fixture.getType().getEng(), fixture.getValue());
final ApproveAppliedCoffeeChatRequest request = new ApproveAppliedCoffeeChatRequest(
"질문..",
fixture.getType().getEng(),
fixture.getValue()
);

return patchRequestWithAccessToken(uri, request, accessToken);
}
Expand Down
Loading

0 comments on commit 2b3e828

Please sign in to comment.