Skip to content

Commit

Permalink
feature(#45): getEmail Mapper 리턴타입 변경
Browse files Browse the repository at this point in the history
- String -> Optional<String> 으로 변경
- 해당하는 유저 없을 경우 `NotFoundException` 예외 날림
  • Loading branch information
memoer committed Jul 29, 2022
1 parent 079893e commit 05edff6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.airjnc.user.domain.UserEntity;
import com.airjnc.user.dto.request.CreateDTO;
import com.airjnc.user.dto.response.UserDTO;
import java.time.LocalDate;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2022-07-26T18:22:14+0900",
date = "2022-07-29T19:30:31+0900",
comments = "version: 1.5.2.Final, compiler: javac, environment: Java 11.0.10 (AdoptOpenJDK)"
)
@Component
Expand Down Expand Up @@ -46,6 +47,9 @@ public UserEntity createDTOToUserEntity(CreateDTO createDTO) {
userEntity.password( createDTO.getPassword() );
userEntity.name( createDTO.getName() );
userEntity.gender( createDTO.getGender() );
if ( createDTO.getBirthDate() != null ) {
userEntity.birthDate( LocalDate.parse( createDTO.getBirthDate() ) );
}

return userEntity.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public UserEntity save(CreateDTO createDTO) {

@Override
public String getEmail(FindEmailDTO findEmailDTO) {
return userMapper.getEmail(findEmailDTO);
return userMapper.getEmail(findEmailDTO).orElseThrow(NotFoundException::new);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/airjnc/user/dao/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface UserMapper {

int save(CreateDTO createDTO);

String getEmail(FindEmailDTO findEmailDTO);
Optional<String> getEmail(FindEmailDTO findEmailDTO);

Optional<UserEntity> findById(Long id);

Expand Down

0 comments on commit 05edff6

Please sign in to comment.