Skip to content

Conversation

@silver-eunjoo
Copy link
Collaborator

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

🛰️ Issue Number

🪐 작업 내용

1. 퀴즈 삭제

  • 퀴즈 삭제 시 서버에 저장된 썸네일까지 같이 삭제되도록 하였습니다.
  • 퀴즈 제작자인지 확인하는 로직에서도 지금은 하드코딩을 해두었습니다. 이후 수정하도록 하겠습니다.
// TODO : util 메서드에서 사용자 ID 꺼내쓰는 식으로 수정하기
 if(1L != quiz.getCreator().getId()) {
        throw new RuntimeException("권한이 없습니다.");
}

2. 퀴즈 수정

  • 제목, 설명, 파일을 검사하고, null이 아닐 시, 변경되었다고 여깁니다.
  • 기존 화면 설계대로 썸네일은 변경만 가능할 뿐, 삭제는 없다는 설정으로 구현했습니다.
  • RequestPart로 들어온 파일의 유효성 검사를 하고, 새로운 썸네일로 바꾸기 전 이전 파일을 서버에서 삭제하도록 합니다.
  • 기존 썸네일이 디폴트 이미지일 경우, 삭제하지 않습니다.

3. 퀴즈 조회

  • 페이징으로 한 페이지에 10개씩 조회 가능하도록 했습니다.
  • 제목, 제작자를 기준으로 검색도 가능합니다.
    • 제목이나 제작자가 null 이지 않고, 빈 문자열이 없을 때 검색어가 있다고 판단합니다.
  • 빈문자열일 땐 전체 조회
스크린샷 2025-07-14 오후 4 51 42

포스트맨에서 모두 응답이 잘 나오는 것을 확인하였습니다.

📚 Reference

✅ Check List

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

@silver-eunjoo silver-eunjoo self-assigned this Jul 14, 2025
@silver-eunjoo silver-eunjoo added the enhancement New feature or request label Jul 14, 2025
@silver-eunjoo silver-eunjoo linked an issue Jul 14, 2025 that may be closed by this pull request
3 tasks
@RequestParam(required = false) String creator) {

Pageable pageable = PageRequest.of(page - 1, size);
QuizListPageResponse quizzes = quizService.getQuizzes(title, creator, pageable);
Copy link
Collaborator

Choose a reason for hiding this comment

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

이부분은 지금 퀴즈리스트에 대한 정렬이 적용이 된건가요?.?

Copy link
Collaborator Author

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 Jul 14, 2025

Choose a reason for hiding this comment

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

[L4-변경제안]
최신순, 인기순 정렬을 변경하는 기능은 정의하지 않았지만, 디폴트 정렬은 있어야 사용자에게 일관적인 리스트를 보여줄 수 있다고 생각합니다!(명시하지않아서 디폴트 정렬로 나오는 것 같지만, 안정적으로 명시하는게 좋다는 의견입니다) 현재 1번부터 나오는 asc라면 desc로 정렬하면(최신순) 어떨까하는 의견입니다. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오..! 그렇군요. 페이징을 처음해봐서 정렬까지 같이 처리해주는 기능이 있는지 몰랐는데 디폴트로 정렬기준이 있다면 아주 유용하고 좋을 것 같습니다. 의견 반영해서 커밋 다시 올렸습니다. 좋은 의견 감사합니다 !!

Copy link
Collaborator

@jiwon1217 jiwon1217 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ! 참고할만한 리뷰 남겼습니다

try {
boolean deleted = deleteIfExists(filePath);
if (deleted) {
System.out.println("기존 썸네일 삭제 완료 : " + filePath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L4-변경제안]
출력문을 log로 대체하는 것이 좋아보입니다 !
[참고 링크] https://hudi.blog/do-not-use-system-out-println-for-logging/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

뭔가 @Slf4j 라는 추가적인 어노테이션을 달지 않아도 System.out.println로 로그를 찍어볼 수 있는 게 아닌가? 하고 생각했었는데,,, 생각해보니 제공되는 정보의 양이 차이가 많이나는군요 !!

좋은 인사이트 감사합니다. 수정하겠습니다 !

Page<Quiz> quizzes;

// 검색어가 있을 때
if (title != null && !title.isBlank()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L4-변경제안]
string 조건 비교 시 Apache Commons에서 제공하는 유틸 메서드를 사용하면 조건문을 간단하게 표현할 수 있습니다 !
StringUtils.isBlack() 하나로 처리 가능합니다 !
[참고링크] https://hyeri0903.tistory.com/235

Copy link
Collaborator

Choose a reason for hiding this comment

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

와우 저도 하나 얻어갑니다.. 💨

[L4-변경제안] string 조건 비교 시 Apache Commons에서 제공하는 유틸 메서드를 사용하면 조건문을 간단하게 표현할 수 있습니다 ! StringUtils.isBlack() 하나로 처리 가능합니다 ! [참고링크] https://hyeri0903.tistory.com/235

Copy link
Collaborator Author

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.

수고하셨습니다! 🧚‍♀️

}

private void deleteOldThumbnailFileIfNeeded(String oldFilename) {
if (oldFilename.contains("default")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L5-참고의견]
"default"를 상수로 만들어 사용하면 안전할 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

확인했습니다 ! 이 부분도 수정하겠습니다 !

}
}

private void deleteOldThumbnailFileIfNeeded(String oldFilename) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L5-참고의견]
메서드 명을 deleteFile로 간단하게 정의해도 괜찮을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

옹 그렇군요 ! 흠 그래도 일반 파일을 지우는 메서드가 아니라 필요없는 썸네일 파일을 지우는 거라.. deleteOldThumbnailFile이나 deleteThumbnailFile로 가보겠습니다 !! 좋은 의견 감사합니다 :)

Page<Quiz> quizzes;

// 검색어가 있을 때
if (StringUtils.isBlank(title)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[L5-참고의견]
StringUtils의 사용은 Apache Commons를 주로 사용하는 것 같습니다. (멘토링 코드 리뷰 때 알게 됐습니다)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

헉 import가 잘못됐네요 ! 감사합니다 ! 혹시 멘토링 때 그 차이점이 뭐라고 하셨나요?

@silver-eunjoo silver-eunjoo merged commit 5501997 into dev Jul 15, 2025
@silver-eunjoo silver-eunjoo deleted the feat/23 branch July 15, 2025 00:19
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] 퀴즈 수정, 삭제, 조회 API 구현

6 participants