1919import io .f1 .backend .domain .user .dao .UserRepository ;
2020import io .f1 .backend .domain .user .entity .User ;
2121
22+ import io .micrometer .common .util .StringUtils ;
23+ import java .util .NoSuchElementException ;
2224import lombok .RequiredArgsConstructor ;
2325
26+ import lombok .extern .slf4j .Slf4j ;
2427import org .springframework .beans .factory .annotation .Value ;
2528import org .springframework .data .domain .Page ;
2629import org .springframework .data .domain .Pageable ;
3538import java .util .NoSuchElementException ;
3639import java .util .UUID ;
3740
41+ @ Slf4j
3842@ Service
3943@ RequiredArgsConstructor
4044public class QuizService {
@@ -110,7 +114,8 @@ public void deleteQuiz(Long quizId) {
110114 .findById (quizId )
111115 .orElseThrow (() -> new NoSuchElementException ("존재하지 않는 퀴즈입니다." ));
112116
113- if (1L != quiz .getCreator ().getId ()) {
117+ // TODO : util 메서드에서 사용자 ID 꺼내쓰는 식으로 수정하기
118+ if (1L != quiz .getCreator ().getId ()) {
114119 throw new RuntimeException ("권한이 없습니다." );
115120 }
116121
@@ -156,13 +161,13 @@ private void deleteOldThumbnailFileIfNeeded(String oldFilename) {
156161
157162 try {
158163 boolean deleted = deleteIfExists (filePath );
159- if ( deleted ) {
160- System . out . println ("기존 썸네일 삭제 완료 : " + filePath );
164+ if ( deleted ) {
165+ log . info ("기존 썸네일 삭제 완료 : {}" , filePath );
161166 } else {
162- System . out . println ("기존 썸네일 존재 X : " + filePath );
167+ log . info ("기존 썸네일 존재 X : {}" , filePath );
163168 }
164169 } catch (IOException e ) {
165- System . err . println ("기존 썸네일 삭제 중 오류 : " + filePath );
170+ log . error ("기존 썸네일 삭제 중 오류 : {}" , filePath );
166171 throw new RuntimeException (e );
167172 }
168173 }
@@ -173,9 +178,9 @@ public QuizListPageResponse getQuizzes(String title, String creator, Pageable pa
173178 Page <Quiz > quizzes ;
174179
175180 // 검색어가 있을 때
176- if ( title != null && ! title .isBlank ()) {
181+ if ( StringUtils .isBlank (title )) {
177182 quizzes = quizRepository .findQuizzesByTitleContaining (title , pageable );
178- } else if ( creator != null && ! creator .isBlank ()) {
183+ } else if ( StringUtils .isBlank (creator )) {
179184 quizzes = quizRepository .findQuizzesByCreator_NicknameContaining (creator , pageable );
180185 } else { // 검색어가 없을 때 혹은 빈 문자열일 때
181186 quizzes = quizRepository .findAll (pageable );
0 commit comments