Skip to content

Conversation

@silver-eunjoo
Copy link
Collaborator

@silver-eunjoo silver-eunjoo commented Jul 12, 2025

🛰️ Issue Number

🪐 작업 내용

1. 퀴즈 생성 API

퀴즈 생성 API를 생성했습니다.
스크린샷 2025-07-13 오전 3 44 35

  • Postman 에서도 정상적으로 생성되는 것을 확인했습니다.
  • 이 부분은 테스트 코드를 지금 짜둬도 이후 시큐리티 구현 이후 변경되는 부분이 많을 것 같아 이후 테스트 코드를 작성하도록 하겠습니다.

2. 유의점

아직 시큐리티가 적용되어있지 않아, User는 하드 코딩해서 넣어주었습니다.
저희는 db client 콘솔으로 INSERT 문을 실행하는 게 쉽지만, 혹시나 프론트 개발자님이 그 부분이 어려우실까봐 application.yml

spring:
  sql:
    init:
      mode: always # 현재는 data.sql 에서 더미 유저 자동 추가를 위해 넣어뒀음.
  jpa:
    defer-datasource-initialization: true # 현재는 data.sql 에서 더미 유저 자동 추가를 위해 넣어뒀음.

이 부분을 추가해두었습니다.

resources/data.sql에는 Stat이 비워져있는 id=1인 User를 INSERT 해두었습니다.

  • 또, 많은 부분에서 Quiz 생성에 필요한 User creator 때문에 TODO 주석이 있습니다. 참고바랍니다.

3. 이미지 저장 경로

  • 프로젝트의 루트 경로에서 images/thumbnail/ 에 저장됩니다.
  • application.yml에서 퀴즈 썸네일 디폴트 이미지 경로도 설정해두었습니다. 환경에서는 임의의 default.png를 두고 테스트를 진행했습니다.

4. 확장성 관련

  • 아직 확장성을 고려해서 코드를 작성하진 않았습니다.
  • 퀴즈 생성 이외에 수정, 삭제 등의 API 를 추가 구현하면서 더 고민해보고 리팩토링을 해보도록 하겠습니다.

📚 Reference

✅ Check List

  • 코드가 정상적으로 컴파일되나요?
  • 테스트 코드를 통과했나요?
  • Postman으로 테스트 했는지?
  • merge할 브랜치의 위치를 확인했나요?
  • Label을 지정했나요?

@silver-eunjoo silver-eunjoo self-assigned this Jul 12, 2025
@silver-eunjoo silver-eunjoo added the enhancement New feature or request label Jul 12, 2025
@silver-eunjoo silver-eunjoo linked an issue Jul 12, 2025 that may be closed by this pull request
5 tasks
}
}

private String saveThumbnail(MultipartFile file) throws IOException {
Copy link
Collaborator

@jiwon1217 jiwon1217 Jul 13, 2025

Choose a reason for hiding this comment

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

[L4-변경제안]
이미지 경로를 변환하는 작업을 수행하기 때문에 "썸네일을 저장한다"는 이름보다 메서드의 동작을 잘 나타내는 이름을 정하는 것이 좋다고 생각합니다 !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

파일을 서버에 올린다(?)는 걸 저장한다고 생각해서 saveThumbnail으로 정했는데, 생각해보니 좀 모호한 메서드명인 것 같습니다. 파일을 썸네일 경로에 저장하겠다는 의미로 convertToThumbnailPath로 수정하겠습니다 !

의견 감사합니다 👍

this.quizType = quizType;
this.thumbnailUrl = thumbnailUrl;
this.creator = creator;
}
Copy link
Collaborator

@sehee123 sehee123 Jul 13, 2025

Choose a reason for hiding this comment

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

[L4-변경제안]
현재 id를 제외한 모든 필드가 필수값으로 보이는데 이런 상황에선 생성자를 사용하게되면 필수값들을 강제할 수 있다는 점에서 빌더보단 생성자가 의도가 더 명확하지않나 생각됩니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

의견 감사합니다 ! 사실 처음에 생성자로 했다가 빌더로 변경했었는데, 그 이유가 아무래도 들어가는 필드값이 많다보니 생성자로 해두었을 때 가독성이 낮고, 어떤 필드에 뭐가 들어가는건지 좀 보기 힘들더라구요..! 그래서 빌더패턴으로 수정했었는데,,,

세희님 리뷰 듣고 저 두 특징에 대해 고민을 좀 해봤는데, 어차피 dto -> entity를 mapper로 분리해놨으니, 서비스에서 이 생성자 코드를 볼 일은 없다고 생각이 되고, 그렇게 되면 가독성 이슈를 조금 덜 신경써도 되겠다는 생각이 듭니다! 그래서 필드값을 강제할 수 있는 생성자로 수정하는 것도 괜찮겠다고 생각이드네요..! 이 부분 수정하겠습니다 👍

@Transactional
public void saveQuestion(Quiz quiz, QuestionRequest request) {

Question question = QuestionMapper.questionRequestToQuestion(quiz, request);
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L4-변경제안]
Mapper 호출 부분은 스태틱 임포트해서 더 간결하게 표현하면 어떨까요 🤔

Copy link
Collaborator

@LimKangHyun LimKangHyun left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Copy link
Collaborator

@sehee123 sehee123 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 🙌

@silver-eunjoo silver-eunjoo merged commit e1bc7b6 into dev Jul 14, 2025
@silver-eunjoo silver-eunjoo deleted the feat/4 branch July 14, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] Quiz 생성 API 개발

6 participants