-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/9 기관 프로필 조회 기능 구현 #32
Conversation
- 예외 메시지를 ExceptionMessage enum으로 분리하여 중앙 관리 - 상수로 관리하여 메시지의 일관성 유지 및 중복 제거 - 향후 메시지 변경 시 한 곳에서 관리 가능하도록 개선
- 기관이 선호하는 물품을 등록할 수 있는 API 추가 - 선호물품 테이블 추가 - 선호물품 등록 요청 DTO 구현 - 선호물품 등록 서비스 레이어 구현 - 테스트 코드 작성 및 검증 완료
- 기관 존재 여부를 확인하는 validateCenterExists 메서드 구현 - 존재하지 않는 센터에 대해 BadRequestException 처리 추가 - 테스트 코드 작성및 검증 완
- 기관 id로 기관 정보와 기관이 등록한 선호 물품을 조회하는 메서드 구현 - 레포지토리에 기관 id를 통한 단건 조회 메서드 추가 - 기관과 선호물품을 함께 반환하기 위한 응답Dto 구현 - 테스트 코드 작성및 검증 완료
- 누락된 exclude 설정을 추가
- 코딩 표준을 준수하기 위해 "no newline at end of file" 경고를 수정했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다. 테스트가 엄청 많네요~
@Repository | ||
public interface PreferItemRepository extends JpaRepository<PreferItem, Long> { | ||
|
||
@Query("SELECT p FROM PreferItem p WHERE p.centerId = :centerId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리를 명시하신 이유가 있으신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
후에 CQRS 구현시 조회는 QueryDSL로 모두 이동시키려고 표시해놓은건데
다시보니 현재는 단순 id조회라 불필요하다는 생각이 듭니다 수정해놓겠습니다
private Center getCenterById(UUID centerId) { | ||
return centerRepository.findCenterById(centerId) | ||
.orElseThrow(() -> new BadRequestException(NOT_EXISTS_CENTER.getMessage())); | ||
} | ||
|
||
@Override | ||
public void validateCenterExists(UUID id) { | ||
if (centerRepository.doesNotExistById(id)) { | ||
throw new BadRequestException(NOT_EXISTS_CENTER.getMessage()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
퍼블릭 메서드가 위로 올라가면 좋을 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다 수정하겠습니다
@RequiredArgsConstructor | ||
@Service | ||
public class CreatePreferItemService implements CreatePreferItemUseCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션이 빠졌어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 말해놓고 트랙잭션을 빼먹었네요 수정하겠습니다!
@RequiredArgsConstructor | ||
@Service | ||
public class PreferItemQueryService implements PreferItemQueryUseCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션 빠졌어요~
NOT_EXISTS_CENTER("존재하지 않는 기관 ID 입니다.") | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOT_EXISTS_CENTER("존재하지 않는 기관 ID 입니다.") | |
; | |
NOT_EXISTS_CENTER("존재하지 않는 기관 ID 입니다.") |
; <-- 이거 없애는걸 권장하는 것 같더라구요. 어떻게 생각하시나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message라는 필드가 존재하는 열거형 클래스라 ;없이는 에러가 발생해서 넣어줬습니다
혹시 ;를 제거할 수 있는 방법이 있는건가요?
- 서비스 레이어의 public 메서드를 상단에 배치하여 가독성 향상 - CQRS 적용을 위한 Query, Command 서비스 클래스에 @Transactinal(readOnly = true), @Transactinal 어노테이션을 각각 추가 - 레포지토리의 불필요한 @query 어노테이션 삭제
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다.
많은 부분을 테스트하려고 노력하신게 보이네요.
궁금한점 몇가지 코멘트 드렸으니 답변 부탁드리겠습니다.
String imgUrl, | ||
String introduce, | ||
String homepageLink, | ||
List<PreferItem> preferItems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엔티티를 노출하는 것보다 Dto로 감싸서 보내는게 좋아보입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 의견 감사합니다 반영하겠습니다
PreferItem preferItem2 = PreferItem.create(UUID.fromString("1a1a1a1a-1a1a-1a1a-1a1a-1a1a1a1a1a2"), "수건"); | ||
PreferItem preferItem3 = PreferItem.create(UUID.fromString("1a1a1a1a-1a1a-1a1a-1a1a-1a1a1a1a1a3"), "식재료"); | ||
preferItemRepository.saveAll(List.of(preferItem, preferItem1, preferItem2, preferItem3)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
centerId 변수로 빼는 것이 좋아보입니다.
다 같은 centerId로 보여서 아래 테스트가 잘못 적은 줄 알았네요
centerOneId, centerTwoId, centerThreeId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 방법이네요 적용해보겠습니다
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@Transactional | ||
class CreatePreferItemServiceTest extends IntegrationTestSupport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트에 @transactional로 데이터 클렌징하는것 보다 레포지토리 주입받아서 클렌징하는 것 어떻게 생각하시나요?
테스트에 @Transcational 걸면 실제 서비스 클래스에 @Transcational을 안 붙였음에도 사용한 것처럼 동작해서 테스트 단계예서 확인할 수 없어서 저는 후자를 선호합니다.
레포지토리 테스트 정도는 @Transcational 사용해도 좋은것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AfterEach안에 직접 쿼리를 넣어서 클렌징 하는 방법을 말씀하시는건가요?
CQRS 패턴 적용으로 모든 서비스 클래스에 @Transactinal이 강제 되는 상황이라
편의상 @Transactinal을 이용했는데 어떻게 생각하시나요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아직 레포지토리 구조는 반영을 안하신 거겠죠?
테스트 코드를 정말 다 작성하셨네요.. 저도 참고해서 작성하겠습니다
고생하셨습니다!!
- 예외 메시지를 ExceptionMessage enum으로 분리하여 중앙 관리 - 상수로 관리하여 메시지의 일관성 유지 및 중복 제거 - 향후 메시지 변경 시 한 곳에서 관리 가능하도록 개선
- 기관이 선호하는 물품을 등록할 수 있는 API 추가 - 선호물품 테이블 추가 - 선호물품 등록 요청 DTO 구현 - 선호물품 등록 서비스 레이어 구현 - 테스트 코드 작성 및 검증 완료
- 기관 존재 여부를 확인하는 validateCenterExists 메서드 구현 - 존재하지 않는 센터에 대해 BadRequestException 처리 추가 - 테스트 코드 작성및 검증 완
- 기관 id로 기관 정보와 기관이 등록한 선호 물품을 조회하는 메서드 구현 - 레포지토리에 기관 id를 통한 단건 조회 메서드 추가 - 기관과 선호물품을 함께 반환하기 위한 응답Dto 구현 - 테스트 코드 작성및 검증 완료
- 누락된 exclude 설정을 추가
- 코딩 표준을 준수하기 위해 "no newline at end of file" 경고를 수정했습니다.
- 서비스 레이어의 public 메서드를 상단에 배치하여 가독성 향상 - CQRS 적용을 위한 Query, Command 서비스 클래스에 @Transactinal(readOnly = true), @Transactinal 어노테이션을 각각 추가 - 레포지토리의 불필요한 @query 어노테이션 삭제
…' into feature/9-get-center-prefer-item # Conflicts: # build.gradle
- 기관 프로필 조회 응답값중 선호 물품 엔티티를 직접 응답하는것이 아닌 Dto로 전환하여 응답하도록 수정과 그에 따른 usecase, service 수정, 선호물품 응답 Dto 생성 - 단위 테스트 코드 작성과 검증 완료
네 맞습니다 CQRS 적용하면서 한번에 변경하려고 했습니다! |
|
* feat: 예외 메시지 상수를 enum으로 관리하도록 개선 - 예외 메시지를 ExceptionMessage enum으로 분리하여 중앙 관리 - 상수로 관리하여 메시지의 일관성 유지 및 중복 제거 - 향후 메시지 변경 시 한 곳에서 관리 가능하도록 개선 * feat: 선호물품 등록 기능 구현 - 기관이 선호하는 물품을 등록할 수 있는 API 추가 - 선호물품 테이블 추가 - 선호물품 등록 요청 DTO 구현 - 선호물품 등록 서비스 레이어 구현 - 테스트 코드 작성 및 검증 완료 * feat: 기관 존재 여부 검증 기능 추가 - 기관 존재 여부를 확인하는 validateCenterExists 메서드 구현 - 존재하지 않는 센터에 대해 BadRequestException 처리 추가 - 테스트 코드 작성및 검증 완 * feat: 기관 프로필 조회 기능 구현 - 기관 id로 기관 정보와 기관이 등록한 선호 물품을 조회하는 메서드 구현 - 레포지토리에 기관 id를 통한 단건 조회 메서드 추가 - 기관과 선호물품을 함께 반환하기 위한 응답Dto 구현 - 테스트 코드 작성및 검증 완료 * chore: sonar 커버리지 설정 변경 - 누락된 exclude 설정을 추가 * chore: 파일 마지막 라인에 개행 추가 - 코딩 표준을 준수하기 위해 "no newline at end of file" 경고를 수정했습니다. * Fix: 코드 리뷰 사항 반영 - 서비스 레이어의 public 메서드를 상단에 배치하여 가독성 향상 - CQRS 적용을 위한 Query, Command 서비스 클래스에 @Transactinal(readOnly = true), @Transactinal 어노테이션을 각각 추가 - 레포지토리의 불필요한 @query 어노테이션 삭제 * feat: 예외 메시지 상수를 enum으로 관리하도록 개선 - 예외 메시지를 ExceptionMessage enum으로 분리하여 중앙 관리 - 상수로 관리하여 메시지의 일관성 유지 및 중복 제거 - 향후 메시지 변경 시 한 곳에서 관리 가능하도록 개선 * feat: 선호물품 등록 기능 구현 - 기관이 선호하는 물품을 등록할 수 있는 API 추가 - 선호물품 테이블 추가 - 선호물품 등록 요청 DTO 구현 - 선호물품 등록 서비스 레이어 구현 - 테스트 코드 작성 및 검증 완료 * feat: 기관 존재 여부 검증 기능 추가 - 기관 존재 여부를 확인하는 validateCenterExists 메서드 구현 - 존재하지 않는 센터에 대해 BadRequestException 처리 추가 - 테스트 코드 작성및 검증 완 * feat: 기관 프로필 조회 기능 구현 - 기관 id로 기관 정보와 기관이 등록한 선호 물품을 조회하는 메서드 구현 - 레포지토리에 기관 id를 통한 단건 조회 메서드 추가 - 기관과 선호물품을 함께 반환하기 위한 응답Dto 구현 - 테스트 코드 작성및 검증 완료 * chore: sonar 커버리지 설정 변경 - 누락된 exclude 설정을 추가 * chore: 파일 마지막 라인에 개행 추가 - 코딩 표준을 준수하기 위해 "no newline at end of file" 경고를 수정했습니다. * Fix: 코드 리뷰 사항 반영 - 서비스 레이어의 public 메서드를 상단에 배치하여 가독성 향상 - CQRS 적용을 위한 Query, Command 서비스 클래스에 @Transactinal(readOnly = true), @Transactinal 어노테이션을 각각 추가 - 레포지토리의 불필요한 @query 어노테이션 삭제 * Refactor: 코드 리뷰 사항 반영 - 기관 프로필 조회 응답값중 선호 물품 엔티티를 직접 응답하는것이 아닌 Dto로 전환하여 응답하도록 수정과 그에 따른 usecase, service 수정, 선호물품 응답 Dto 생성 - 단위 테스트 코드 작성과 검증 완료
resolved : #9
📌 과제 설명
기관 프로필 조회 기능 구현과 그에 따른 기관 선호물품 등록, 조회 기능 구현
👩💻 요구 사항과 구현 내용
✅ PR 포인트 & 궁금한 점