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 @@ -70,8 +70,9 @@ public ResponseEntity<SuccessResponse<PreReservationDTO>> getPreReservationInfo(
@GetMapping(value = "/transferee")
@Operation(summary = "양도 시 이메일을 통한 양수자 정보 조회",
description = "양도 시 이메일을 통한 양수자 정보 조회. ex) GET /api/users/transferee?email=test@test.com")
public ResponseEntity<SuccessResponse<AssignmentDTO>> transfereeInfo(@RequestParam String email){
AssignmentDTO assignmentDTO = userInfoService.transfereeInfo(email);
public ResponseEntity<SuccessResponse<AssignmentDTO>> transfereeInfo(@AuthenticationPrincipal String principal, @RequestParam String email){
Long userId = Long.parseLong(principal);
AssignmentDTO assignmentDTO = userInfoService.transfereeInfo(userId, email);
return ApiResponseUtil.success(assignmentDTO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ public PreReservationDTO getPreReservationInfo(Long userId){
return PreReservationDTO.fromUserEntity(findUser);
}

public AssignmentDTO transfereeInfo(String email){
User findUser = userRepository.findByEmail(email)
public AssignmentDTO transfereeInfo(Long userId, String email){
User transferor = userRepository.findById(userId)
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));

return AssignmentDTO.fromUserEntity(findUser);
if(transferor.getEmail().equals(email))
throw new BusinessException(ErrorCode.SELF_TRANSFER_FORBIDDEN);

User transferee = userRepository.findByEmail(email)
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));

return AssignmentDTO.fromUserEntity(transferee);
}

public AssignmentDTO transferorInfo(Long userId){
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/tekcit/festival/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum ErrorCode {
ADDRESS_NOT_ALLOWED("U009", "허용되지 않는 행동입니다. 작성자만이 주소를 수정 또는 삭제할 수 있습니다.", HttpStatus.FORBIDDEN),
ADDRESS_DEFAULT_NOT_DELETED("U010", "기본 주소지는 삭제할 수 없습니다.", HttpStatus.BAD_REQUEST),
INVALID_RESIDENT_NUMBER("U011", "올바르지 못한 주민번호입니다.", HttpStatus.BAD_REQUEST),
SELF_TRANSFER_FORBIDDEN("U012", "본인에게는 양도를 할 수 없습니다.", HttpStatus.BAD_REQUEST),
// AUTH 관련 에러입니다.
AUTH_PASSWORD_NOT_EQUAL_ERROR("A001","일치하지 않는 비밀번호입니다.",HttpStatus.BAD_REQUEST),
AUTH_REFRESH_TOKEN_EXPIRED("A002", "Refresh Token이 만료되었습니다.", HttpStatus.UNAUTHORIZED),
Expand Down