Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5] DB연동 및 docker-compose 적용 #6

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

mingmong0018
Copy link
Collaborator

해결하려는 문제

  • DB를 연동하여 실제 데이터를 관리한다.
  • 개발 환경에서 필요한 컴포넌트 설치와 초기 설정의 번거로움을 없애고, 일관된 개발 환경을 유지할 수 있어야한다.

변경 사항

  • mybatis, mysql 의존성 추가
  • mybatis 작성
  • docker-compose 적용
  • 컨테이너가 시작될 때 자동으로 데이터베이스를 초기화하기 위해 init.sql 설정
  • 테스트 코드 작성 (진행중)

참고 사항

CheckList

  • 커밋 메시지 컨벤션에 맞게 작성했나요?
  • 코드에서 발생한 모든 경고와 오류가 해결되었나요?
  • 변경 사항에 대한 테스트가 충분히 수행되었나요?

@mingmong0018 mingmong0018 linked an issue Oct 31, 2024 that may be closed by this pull request
Comment on lines +20 to +22
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
throw new IllegalArgumentException("이메일 중복");
}
Copy link
Collaborator

@f-lab-lyan f-lab-lyan Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
throw new IllegalArgumentException("이메일 중복");
}
Stream.of(user.getEmail())
.map(userRepository::findByEmail)
.getOrElse(() => throw new IllegalArgumentException("이메일 중복"))
.collect();
Suggested change
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
throw new IllegalArgumentException("이메일 중복");
}
userRepository
.findByEmail(user.getEmail())
.getOrElse(() => throw new IllegalArgumentException("이메일 중복"));


public LoginResponseDto createUser(SignUpRequestDto request) {
User user = request.toDomain();
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
if (userRepository.findByEmail(user.getEmail()) == null) {

if (userRepository.findByEmailAndPassword(user.getEmail(), user.getPassword()).isEmpty()) {
throw new IllegalArgumentException("로그인 정보가 올바르지 않습니다.");
}
return LoginResponseDto.of(user, "asdf");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service에서 DTO를 알고 있는 것이 좋은 것인가요?

@@ -14,4 +16,8 @@ public class SignUpRequestDto {
private String email;
@Schema(description = "사용자 비밀번호")
private String password;

public User toDomain() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO안에 비지니스 로직이 들어가는 것이 좋은 것인가요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DB연동 및 docker-compose 적용
2 participants