Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,25 @@ public ResponseEntity<CommonResponse<String>> signUpApplicant(@RequestBody Appli

// 지원자 정보 조회
@Operation(summary = "지원자 정보 조회 API", description = "지원자 정보를 조회.")
@GetMapping("/{applicantId}")
public CommonResponse<ApplicantResponseDto> getApplicantInfo(@PathVariable Long applicantId, HttpSession session) {
ApplicantResponseDto applicantResponse = applicantService.getApplicantInfo(applicantId, session);
@GetMapping()
public CommonResponse<ApplicantResponseDto> getApplicantInfo(HttpSession session) {
ApplicantResponseDto applicantResponse = applicantService.getApplicantInfo(session);
return new CommonResponse<>(applicantResponse);
}

/**
* 지원자 정보 수정
*
* @param applicantId 지원자 ID
* @param updateRequestDto 지원자 수정 요청 DTO
* @param session 사용자 세션
* @return CommonResponse
*/
@Operation(summary = "지원자 정보 수정 API", description = "지원자 정보를 수정.")
@PutMapping("/{applicantId}")
public CommonResponse<String> updateApplicantInfo(@PathVariable Long applicantId,
@PutMapping()
public CommonResponse<String> updateApplicantInfo(
@RequestBody ApplicantUpdateRequestDto updateRequestDto,
HttpSession session) {
applicantService.updateApplicantInfo(applicantId, updateRequestDto, session);
applicantService.updateApplicantInfo(updateRequestDto, session);
return new CommonResponse<>("지원자 정보가 수정되었습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ public class ApplicantUpdateRequestDto {

private String name;
private String major;
private String phoneNum;
private String password;

@Builder
public ApplicantUpdateRequestDto(String name, String major, String phoneNum, String password) {
public ApplicantUpdateRequestDto(String name, String major, String password) {
this.name = name;
//this.school = school;
this.major = major;
this.phoneNum = phoneNum;
this.password = password;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public class ApplicantResponseDto {
private String school;
private String major;
private String studentNumber;
private String phoneNum;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ public void signUpApplicant(ApplicantSignUpRequestDto requestDto) {
/**
* 지원자 회원 정보 조회
*
* @param applicantId 조회하려는 지원자 ID
* @param session 사용자 세션
* @return ApplicantResponseDto
*/
public ApplicantResponseDto getApplicantInfo(Long applicantId, HttpSession session) {
public ApplicantResponseDto getApplicantInfo(HttpSession session) {
// 세션에서 사용자 정보 확인
Applicant applicant = checkApplicant(session);

// 요청된 applicantId와 세션의 applicantId 비교
if (!applicant.getId().equals(applicantId)) {
throw new UnauthorizedException("해당 지원자 접근 권한이 없습니다.");
}
// if (!applicant.getId().equals(applicantId)) {
// throw new UnauthorizedException("해당 지원자 접근 권한이 없습니다.");
// }

return toApplicantResponseDto(applicant);
}
Expand All @@ -95,32 +94,29 @@ private ApplicantResponseDto toApplicantResponseDto(Applicant applicant) {
.school(applicant.getSchool())
.major(applicant.getMajor())
.studentNumber(applicant.getStudentNumber())
.phoneNum(applicant.getPhoneNum())
.build();
}

/**
* 지원자 정보 수정
*
* @param applicantId 지원자 ID
* @param updateRequestDto 지원자 수정 요청 DTO
* @param session 사용자 세션
*/
@Transactional
public void updateApplicantInfo(Long applicantId, ApplicantUpdateRequestDto updateRequestDto, HttpSession session) {
public void updateApplicantInfo(ApplicantUpdateRequestDto updateRequestDto, HttpSession session) {
// 세션에서 사용자 정보 확인
Applicant applicant = checkApplicant(session);

// 요청된 applicantId와 세션의 applicantId 비교
if (!applicant.getId().equals(applicantId)) {
throw new UnauthorizedException("해당 지원자 접근 권한이 없습니다.");
}
// if (!applicant.getId().equals(applicantId)) {
// throw new UnauthorizedException("해당 지원자 접근 권한이 없습니다.");
// }

// 지원자 정보 업데이트
applicant.setName(updateRequestDto.getName());
//applicant.setSchool(updateRequestDto.getSchool());
applicant.setMajor(updateRequestDto.getMajor());
applicant.setPhoneNum(updateRequestDto.getPhoneNum());
applicant.setPassword(updateRequestDto.getPassword());
applicantRepository.save(applicant);
}
Expand Down
Loading