Skip to content

트레이너 프로필 단일 조회#46

Open
seongminQa wants to merge 12 commits intodevfrom
feature/#43-trainer-profile-read
Open

트레이너 프로필 단일 조회#46
seongminQa wants to merge 12 commits intodevfrom
feature/#43-trainer-profile-read

Conversation

@seongminQa
Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

#43

📝작업 내용

TrainerProfileResponse 작성 (자격증, 해시태그 미적용 / API 명세서 확인)
QueryDSL 의존성 추가 및 JpaConfig 파일 등록 (민형님과 동일)
트레이너 프로필 단일 조회 (로그인한 트레이너 기준)

스크린샷 (선택)

image

💬리뷰 요구사항(선택)

userId는 현재 4L, 임의의 값으로 두었습니다.

@seongminQa seongminQa changed the title Feature/#43 trainer profile read 트레이너 프로필 단일 조회 May 24, 2025
@seongminQa seongminQa added feature 🧩 새로운 기능 성민 성민 labels May 24, 2025
@seongminQa seongminQa force-pushed the feature/#43-trainer-profile-read branch from 1749efe to 2754bf6 Compare May 27, 2025 18:33
Copy link
Copy Markdown
Contributor

@mh-algo mh-algo left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Comment on lines +66 to +67
// 날짜/시간 타입(JSON 직렬화 지원)
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spring-boot-starter-web를 추가하면 jsr310이 자동으로 추가되기 때문에 의존성을 추가하지 않아도 괜찮습니다!

Comment on lines +14 to 21
return new TrainerAddress(
null,
null,
dto.getRoadAddress(),
dto.getDetailAddress(),
null,
coordinates
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

null 주입을 TrainerAddress 생성자 내부에서 처리해도 좋을 것 같아요

Comment on lines +38 to +49
@Override
public Optional<TrainerAddress> findById(Long addressId) {
return jpaRepository.findById(addressId)
.map(entity -> new TrainerAddress(
entity.getId(),
entity.getNumberAddress(),
entity.getRoadAddress(),
entity.getDetailAddress(),
entity.getPostalCode(),
new Coordinates(entity.getLatitude(), entity.getLongitude())
));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저는 매핑을 레포지토리보단 서비스에서 하는게 좋을 것 같다고 생각해요
레포지토리 내부에서 매핑을 사용한다면 재사용성이 떨어집니다.
그리고 jpa가 아닌 다른 서비스로 변경할 경우 레포지토리를 새로 추가해야 하는데 매핑 로직까지 새로 작성해야하는 문제도 발생합니다.
마지막으로 레포지토리의 책임이 많다는 생각이 듭니다. 레포지토리는 데이터 조회랑 저장까지만 담당하고 그걸 변형하거나 검증하는 등의 비즈니스 로직은 서비스에서 담당하는게 좋을 것 같아요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

저는 매핑을 레포지토리보단 서비스에서 하는게 좋을 것 같다고 생각해요 레포지토리 내부에서 매핑을 사용한다면 재사용성이 떨어집니다. 그리고 jpa가 아닌 다른 서비스로 변경할 경우 레포지토리를 새로 추가해야 하는데 매핑 로직까지 새로 작성해야하는 문제도 발생합니다. 마지막으로 레포지토리의 책임이 많다는 생각이 듭니다. 레포지토리는 데이터 조회랑 저장까지만 담당하고 그걸 변형하거나 검증하는 등의 비즈니스 로직은 서비스에서 담당하는게 좋을 것 같아요

생각해보니 그렇네요! 수정해보도록 하겠습니다!!

Long userId = 4L; // TODO: 로그인 사용자 임시

trainerProfileService.createProfile(request, userId);
return ResponseEntity.status(201).body(ApiResponse.created("트레이너 프로필이 성공적으로 등록되었습니다."));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

response에 Location 헤더의 추가가 필요할 것 같습니다!

Comment on lines +24 to +27
AccountEntity trainer = em.getReference(AccountEntity.class, profile.getUserId());
TrainerAddressEntity address = em.getReference(TrainerAddressEntity.class, profile.getAddressId());

AccountEntity trainer = em.getReference(AccountEntity.class, profile.getUserId());
TrainerAddressEntity address = em.getReference(TrainerAddressEntity.class, profile.getAddressId());
TrainerProfileEntity entity = TrainerProfileMapper.toEntity(profile, trainer, address);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저장해야할 엔티티는 서비스에서 생성한 후 레포지토리로 넘기는게 좋을 것 같다고 생각합니다.
AccountEntityTrainerAdderssEntitygetReference를 사용하기보단 레포지토리를 통해서 직접 조회하여 검증한 다음, TrainerProfileEntity에 넣어주는게 좋을 것 같아요

Copy link
Copy Markdown
Contributor

@dy1214 dy1214 left a comment

Choose a reason for hiding this comment

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

확인했습니다! 고생많으셨습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 🧩 새로운 기능 성민 성민

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants