-
Notifications
You must be signed in to change notification settings - Fork 0
기술면접 질문 게시판 기능 구현 #6
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
base: main
Are you sure you want to change the base?
Conversation
DTOs, and repository layer
사용자 회원가입 및 로그인
… answer management
f-lab-moony
left a comment
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.
고생 많으셨습니다 ~ 피드백 확인 부탁드려요 ~
|
|
||
| @Configuration | ||
| @EnableJpaAuditing | ||
| public class JpaConfig {} 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.
별도의 설정이 없는데 이 클래스 굳이 필요할까요 ?
|
|
||
| String jwt = getJwtFromRequest(request); | ||
| long jwtExtractTime = System.currentTimeMillis(); | ||
| log.debug("JWT 추출 시간: {}ms", jwtExtractTime - startTime); |
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.
걸린 시간은 왜 뽑아보는건가요 ?
| log.debug("사용자명 추출 시간: {}ms", usernameExtractTime - jwtExtractTime); | ||
|
|
||
| // User 엔티티를 먼저 조회 (한 번만 DB 조회) | ||
| User user = userRepository.findByUsername(username) |
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가 아니라 Service를 참조하는게 어떨까요 ?
| log.debug("User 엔티티 로딩 시간: {}ms", userEntityTime - usernameExtractTime); | ||
|
|
||
| // UserDetails는 User 엔티티에서 직접 생성 (DB 조회 없음) | ||
| UserDetails userDetails = org.springframework.security.core.userdetails.User.builder() |
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.
여기서 패키지명까지 명시한 User와 직접 만드신 User는 어떤 차이가 있나요 ?
|
|
||
| private final AnswerService answerService; | ||
|
|
||
| @PostMapping("/{questionId}/answers") |
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.
answer 도메인인데 questionId를 pathVariable로 받아야 할 필요가 있나요 ?
| JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager); | ||
|
|
||
| // 🚀 2단계 쿼리 최적화: 태그 조건이 있으면 서브쿼리로 ID만 먼저 조회 | ||
| if (searchRequest.getTags() != null && !searchRequest.getTags().isEmpty()) { |
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.
태그 조건 유무를 기준으로 메서드를 분리해보면 어떨까요 ?
| questions = questions.subList(0, pageable.getPageSize()); | ||
| } | ||
|
|
||
| return new PageImpl<>(questions, pageable, hasNextPage ? pageable.getOffset() + questions.size() + 1 : pageable.getOffset() + questions.size()); |
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 jakarta.persistence.PersistenceContext; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public class QuestionRepositoryImpl implements QuestionRepositoryCustom { |
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.
클래스 전체적으로 리팩토링이 필요할 것 같아요
| private final UserService userService; | ||
| private final QuestionRepositoryImpl questionRepositoryImpl; | ||
|
|
||
| public AnswerService(AnswerRepository answerRepository, @Lazy QuestionService questionService, UserService userService, QuestionRepositoryImpl questionRepositoryImpl) { |
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.
@Lazy 는 왜 붙은걸까요 ?
| Optional<Answer> existingAnswer = answerRepository.findByUserIdAndQuestionId( | ||
| currentUser.get().getId(), questionId); | ||
|
|
||
| if (existingAnswer.isPresent()) { |
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.
만약 생성 요청이 아주 짧은 시간 안에 복수개가 요청이 되면 여기서 어떻게 동작을 하게 될까요 ?
멀티 모듈 구조 전환 및 추천 서비스 분리
개요
기술 면접 질문 대시보드 기능을 구현한 PR입니다. 사용자가 기술 면접 질문을 검색하고, 답변을 작성하며, 관리자가 질문을 관리할 수 있는 기능을 제공합니다.
주요 기능
1. 기술 질문 검색 및 조회
2. 답변 관리 기능
3. 관리자 기능
/api/v1/admin/*엔드포인트4. 태그 시스템
findOrCreate메서드를 통한 태그 자동 생성5. 인증 및 보안
성능 최적화
1. 캐싱 전략
CacheConfig를 통한 중앙화된 캐시 관리2. 데이터베이스 쿼리 최적화
3. 쿼리 성능 개선