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

refactor: 환영 메시지 태그 파싱 로직 단순화 #542

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

hoonyworld
Copy link
Member

👩‍💻 Contents

  • 환영 메시지 태그 파싱 로직을 단순화 하였습니다.

📝 Review Note

JPQL를 이용해서 jsonb 타입 불러오기

  • jsonb 타입인 welcomeMessageTypes 필드를 JPQL로 불러오는 코드를 기존에 작성했었습니다.
  • 이때 String으로 불러와졌기에, 서비스 레이어에서 직접 파싱을 해야하는 번거로움이 있었습니다.
  • JPQL를 이용하게 되면 변환기(@convert 또는 @type)를 거치지 않기 때문에 String으로 불러와지는 이슈였습니다.
  • 변환기가 작동하지 않는 예상되는 부분은 @type 어노테이션은 Hibernate의 기능에 의존하는데, JPQL은 Hibernate의 세부 구현 사항을 다루지 않기 때문에, @type이 적용되지 않는 것 같습니다. (추측이긴 합니다!)

타입 변환기 이용

  • 그래서 Spring Data JPA와 Projection을 이용해서 문제를 해결하려고 했습니다.
  • 그래서 Projection에서는 변환기가 작동을 하는지 확인을 해보았고, 적용되는 것을 확인해서 서비스에서 파싱하는 로직을 제거했습니다.

📣 Related Issue

✅ 점검사항

  • docker-compose.yml 파일에 마이그레이션 한 API의 포워딩을 변경해줬나요?
  • Spring Secret 값을 수정하거나 추가했다면 Github Secret에서 수정을 해줬나요?
  • Nestjs Secret 값을 수정하거나 추가했다면 Docker-Compose.yml 파일 및 인스턴스 내부의 .env 파일을 수정했나요?

- @convert@type 간의 충돌
- @type이 이미 JSON 처리를 맡아 @convert를 덮어쓴 상황이라 필요없다는 어노테이션이라고 판단
- NPE 방지를 위해 환영 메시지 저장 시 null 값이라도 DB에는 빈 리스트로 저장하도록 변경
- 서비스 레이어에서 필터링 하는 대신 프로젝션으로 바로 enum 객체를 가져올 수 있도록 변경
@hoonyworld hoonyworld added the 🛠️ refactor 리팩토링 및 개선 label Jan 23, 2025
@hoonyworld hoonyworld self-assigned this Jan 23, 2025
@hoonyworld hoonyworld linked an issue Jan 23, 2025 that may be closed by this pull request
1 task
Copy link

height bot commented Jan 23, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@mikekks mikekks self-requested a review January 24, 2025 05:13
Copy link
Member

@mikekks mikekks left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !! 조금 더 읽기 좋아진 것 같아요!

@hoonyworld hoonyworld merged commit 39f8fb1 into develop Jan 24, 2025
1 check passed
@hoonyworld hoonyworld deleted the refactor/#541 branch January 24, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ refactor 리팩토링 및 개선 size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: 번쩍 상세 조회 시 환영 메시지 파싱 로직 개선
2 participants