Skip to content

Commit

Permalink
feat: 지원자 정보 수정(이름, 전공, 전화번호)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorapang committed Dec 25, 2024
1 parent 68479f0 commit e21195b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.likelion.innerjoin.common.response.CommonResponse;
import com.likelion.innerjoin.user.model.dto.request.ApplicantSignUpRequestDto;
import com.likelion.innerjoin.user.model.dto.request.ApplicantUpdateRequestDto;
import com.likelion.innerjoin.user.model.dto.response.ApplicantResponseDto;
import com.likelion.innerjoin.user.model.dto.response.ClubResponseDto;
import com.likelion.innerjoin.user.service.ApplicantService;
Expand Down Expand Up @@ -40,4 +41,21 @@ public CommonResponse<ApplicantResponseDto> getApplicantInfo(@PathVariable Long
ApplicantResponseDto applicantResponse = applicantService.getApplicantInfo(applicantId, 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,
@RequestBody ApplicantUpdateRequestDto updateRequestDto,
HttpSession session) {
applicantService.updateApplicantInfo(applicantId, updateRequestDto, session);
return new CommonResponse<>("지원자 정보가 수정되었습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package com.likelion.innerjoin.user.model.dto.request;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class ApplicantUpdateRequestDto {

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

@Builder
public ApplicantUpdateRequestDto(String name, String major, String phoneNum) {
this.name = name;
//this.school = school;
this.major = major;
this.phoneNum = phoneNum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.likelion.innerjoin.user.exception.EmailValidationException;
import com.likelion.innerjoin.user.exception.SignUpIDException;
import com.likelion.innerjoin.user.model.dto.request.ApplicantSignUpRequestDto;
import com.likelion.innerjoin.user.model.dto.request.ApplicantUpdateRequestDto;
import com.likelion.innerjoin.user.model.dto.response.ApplicantResponseDto;
import com.likelion.innerjoin.user.model.entity.Applicant;
import com.likelion.innerjoin.user.repository.ApplicantRepository;
Expand Down Expand Up @@ -97,4 +98,29 @@ private ApplicantResponseDto toApplicantResponseDto(Applicant applicant) {
.phoneNum(applicant.getPhoneNum())
.build();
}

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

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

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

0 comments on commit e21195b

Please sign in to comment.