Skip to content

Commit

Permalink
Merge pull request kahluaband#49 from woogieon8on/admin-apply
Browse files Browse the repository at this point in the history
kahluaband#17 Feat: add admin applicant get method
  • Loading branch information
woogieon8on authored Aug 4, 2024
2 parents 503077e + 353e10b commit 319bf0e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import kahlua.KahluaProject.apipayload.code.status.ErrorStatus;
import kahlua.KahluaProject.domain.apply.Preference;
import kahlua.KahluaProject.domain.user.UserType;
import kahlua.KahluaProject.dto.apply.response.ApplyAdminGetResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyGetResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyListResponse;
import kahlua.KahluaProject.exception.GeneralException;
Expand All @@ -32,12 +33,12 @@ public ApiResponse<ApplyListResponse> getApplyList(@AuthenticationPrincipal Auth

@GetMapping("/{applyId}")
@Operation(summary = "지원자 상세정보 조회", description = "지원자 상세정보를 조회합니다")
public ApiResponse<ApplyGetResponse> getApplyDetail(@PathVariable Long applyId, @AuthenticationPrincipal AuthDetails authDetails) {
public ApiResponse<ApplyAdminGetResponse> getApplyDetail(@PathVariable Long applyId, @AuthenticationPrincipal AuthDetails authDetails) {
if(authDetails.getUser().getUserType() != UserType.ADMIN){
throw new GeneralException(ErrorStatus.UNAUTHORIZED);
}
ApplyGetResponse applyGetResponse = applyService.getApply(applyId);
return ApiResponse.onSuccess(applyGetResponse);
ApplyAdminGetResponse applyAdminGetResponse = applyService.getApplyAdmin(applyId);
return ApiResponse.onSuccess(applyAdminGetResponse);
}

@GetMapping
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/kahlua/KahluaProject/converter/ApplyConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kahlua.KahluaProject.domain.apply.Apply;
import kahlua.KahluaProject.dto.apply.request.ApplyCreateRequest;
import kahlua.KahluaProject.dto.apply.response.ApplyAdminGetResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyCreateResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyGetResponse;

Expand Down Expand Up @@ -65,4 +66,22 @@ public static ApplyGetResponse toApplyGetResponse(Apply apply) {
.readiness(apply.getReadiness())
.build();
}

public static ApplyAdminGetResponse toApplyAdminGetResponse(Apply apply) {
return ApplyAdminGetResponse.builder()
.id(apply.getId())
.name(apply.getName())
.gender(apply.getGender())
.birth_date(apply.getBirth_date())
.phone_num(apply.getPhoneNum())
.address(apply.getAddress())
.major(apply.getMajor())
.first_preference(apply.getFirstPreference())
.second_preference(apply.getSecondPreference())
.motive(apply.getMotive())
.experience_and_reason(apply.getExperience_and_reason())
.play_instrument(apply.getPlay_instrument())
.readiness(apply.getReadiness())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package kahlua.KahluaProject.dto.apply.response;

import io.swagger.v3.oas.annotations.media.Schema;
import kahlua.KahluaProject.domain.apply.Gender;
import kahlua.KahluaProject.domain.apply.Preference;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@AllArgsConstructor
@Builder
public class ApplyAdminGetResponse {

private Long id;
private String name;
private Gender gender;
private String birth_date;

private String phone_num;
private String address;
private String major;
private Preference first_preference;
private Preference second_preference;

@Schema(description = "깔루아 지원 동기")
private String motive;
@Schema(description = "지원 세션에 대한 경력 및 지원 이유")
private String experience_and_reason;
@Schema(description = "이외에 다룰 줄 아는 악기")
private String play_instrument;
@Schema(description = "포부 및 각오")
private String readiness;
}
14 changes: 10 additions & 4 deletions src/main/java/kahlua/KahluaProject/service/ApplyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import kahlua.KahluaProject.domain.user.User;
import kahlua.KahluaProject.domain.user.UserType;
import kahlua.KahluaProject.dto.apply.request.ApplyCreateRequest;
import kahlua.KahluaProject.dto.apply.response.ApplyCreateResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyGetResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyItemResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyListResponse;
import kahlua.KahluaProject.dto.apply.response.*;
import kahlua.KahluaProject.exception.GeneralException;
import kahlua.KahluaProject.repository.ApplyRepository;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -49,6 +46,15 @@ public ApplyGetResponse getApply(Long applyId) {
return applyGetResponse;
}

public ApplyAdminGetResponse getApplyAdmin(Long applyId) {

Apply apply = applyRepository.findById(applyId)
.orElseThrow(() -> new GeneralException(ErrorStatus.APPLICANT_NOT_FOUND));

ApplyAdminGetResponse applyAdminGetResponse = ApplyConverter.toApplyAdminGetResponse(apply);
return applyAdminGetResponse;
}

public ApplyListResponse getApplyList(User user) {

if(user.getUserType() != UserType.ADMIN){
Expand Down

0 comments on commit 319bf0e

Please sign in to comment.