Skip to content

Commit

Permalink
Merge pull request #259 from sharemindteam/feature/257-add-rejection-…
Browse files Browse the repository at this point in the history
…reason

feat: 상담사 프로필 업데이트 거절 시 사유 알려주는 란 추가
  • Loading branch information
aeyongdodam authored Sep 11, 2024
2 parents a9b577d + 8e392c0 commit f385516
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface AdminService {
SmsGetResponse updateConsultIsPaid(Long consultId);
List<CounselorGetProfileResponse> getPendingCounselors();

void updateProfileStatus(Long counselorId, Boolean isPassed);
void updateProfileStatus(Long counselorId, Boolean isPassed, String reason);

List<PaymentGetRefundWaitingResponse> getRefundWaitingPayments();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public List<CounselorGetProfileResponse> getPendingCounselors() {

@Transactional
@Override
public void updateProfileStatus(Long counselorId, Boolean isPassed) {
public void updateProfileStatus(Long counselorId, Boolean isPassed, String reason) {
Counselor counselor = counselorService.getCounselorByCounselorId(counselorId);
if ((counselor.getProfileStatus() == null) ||
(!counselor.getProfileStatus().equals(ProfileStatus.EVALUATION_PENDING))) {
Expand All @@ -124,6 +124,7 @@ public void updateProfileStatus(Long counselorId, Boolean isPassed) {
emailService.sendEmail(email, EmailType.COUNSELOR_PROFILE_FAIL, "");
}
counselor.updateProfileStatusAndProfileUpdatedAt(profileStatus);
counselor.updateProfileReason(reason);

if (counselor.getProfileStatus().equals(ProfileStatus.EVALUATION_COMPLETE)) {
Customer customer = customerService.getCustomerByCounselor(counselor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public ResponseEntity<List<CounselorGetProfileResponse>> getPendingCounselors()
}

@Operation(summary = "상담사 프로필 심사 상태 수정",
description = "상담사 프로필 심사 상태 수정(최초 심사 통과 시 COUNSELOR 권한 부여), " +
"주소 형식: /api/v1/admins/pending-profiles/{counselorId}?isPassed=true")
description =
"상담사 프로필 심사 상태 수정(최초 심사 통과 시 COUNSELOR 권한 부여), reason의 경우 리젝시에만 보내주면 되는 optional한 값입니다."
+
"주소 형식: /api/v1/admins/pending-profiles/{counselorId}?isPassed=true&reason='test'")

@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공"),
@ApiResponse(responseCode = "400", description = "심사 중이 아닌 상담사 프로필에 대한 요청",
Expand All @@ -88,12 +91,13 @@ public ResponseEntity<List<CounselorGetProfileResponse>> getPendingCounselors()
})
@Parameters({
@Parameter(name = "counselorId", description = "상담사 아이디"),
@Parameter(name = "isPassed", description = "심사 통과 여부")
@Parameter(name = "isPassed", description = "심사 통과 여부"),
@Parameter(name = "reason", description = "리젝 사유")
})
@PatchMapping("/pending-profiles/{counselorId}")
public ResponseEntity<Void> updateProfileStatus(@PathVariable Long counselorId,
@RequestParam Boolean isPassed) {
adminService.updateProfileStatus(counselorId, isPassed);
@RequestParam Boolean isPassed, @RequestParam(required = false) String reason) {
adminService.updateProfileStatus(counselorId, isPassed, reason);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ List<CounselorGetRandomListResponse> getRandomCounselorsByCustomer(Long customer
String sortType, int index);

List<CounselorGetRandomListResponse> getAllRandomCounselors(String sortType, int index);

String getCounselorFailureReason(Long counselorId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ public List<Counselor> getCounselorsByNicknameOrEmail(String keyword) {
return counselorRepository.findAllByNicknameOrEmail(keyword);
}

@Override
public String getCounselorFailureReason(Long customerId) {
Counselor counselor = getCounselorByCustomerId(customerId);
if (counselor.getProfileStatus() == ProfileStatus.EVALUATION_FAIL)
return counselor.getFailureReason();
return "";
}

@Scheduled(cron = "0 0 * * * *", zone = "Asia/Seoul")
public void updateRealtimeCounselors() {
List<Counselor> counselors = counselorRepository.findAllByProfileStatusIsEvaluationCompleteAndIsActivatedIsTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class Counselor extends BaseEntity {
@Enumerated(EnumType.STRING)
private ProfileStatus profileStatus;

@Column(name = "failure_reason")
private String failureReason;

@ElementCollection(targetClass = ConsultCost.class, fetch = FetchType.LAZY)
@JoinTable(name = "consult_costs", joinColumns = @JoinColumn(name = "counselor_id"))
@Column(name = "consult_costs")
Expand Down Expand Up @@ -174,6 +177,10 @@ public void updateIsEducated(Boolean isEducated) {
}
}

public void updateProfileReason(String reason) {
this.failureReason = reason;
}

public void updateTotalReviewAndRatingAverage(Integer rating) {
double preTotalRating = this.ratingAverage * this.totalReview;
this.totalReview += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,15 @@ public ResponseEntity<Long> getCounselorId(
counselorService.getCounselorByCustomerId(customUserDetails.getCustomer()
.getCustomerId()).getCounselorId());
}

@Operation(summary = "프로필 리젝 사유 조회",
description = "프로필 리젝 사유 리턴하는 함수, 프로필 상태가 실패가 아니면 빈 문자열이 리턴됩니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "조회 성공")
})
@GetMapping("/profile-rejection")
public ResponseEntity<String> getCounselorFailureReason(@AuthenticationPrincipal CustomUserDetails customUserDetails) {
return ResponseEntity.ok(counselorService.getCounselorFailureReason(customUserDetails.getCustomer()
.getCustomerId()));
}
}

0 comments on commit f385516

Please sign in to comment.