Skip to content

Commit fc758f9

Browse files
authored
Merge pull request #94 from Final-Project-Team-Temporary/feature/용어-검색-삭제-API구현
Feat: 주간 챌린지 오류 수정
2 parents b05fc41 + d5da1de commit fc758f9

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/main/java/com/example/whiplash/auth/service/AuthService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,19 @@ public TokenResponseDTO authenticateByKakao(String code) {
7979

8080
userRepository.save(kakaoUser);
8181

82+
return loginByKakao(kakaoUser);
83+
8284
// 회원가입의 경우 임시토큰 생성
83-
String tempToken = jwtTokenProvider.generateTempSocialToken(kakaoUser);
84-
return AuthConverter.toTokenResponseDTO(tempToken, null, UserStatus.PENDING, LoginStatus.NEW_USER, kakaoUser.getName());
85+
// String tempToken = jwtTokenProvider.generateTempSocialToken(kakaoUser);
86+
// return AuthConverter.toTokenResponseDTO(tempToken, null, UserStatus.PENDING, LoginStatus.NEW_USER, kakaoUser.getName());
8587
}
8688

8789
@Transactional
8890
public TokenResponseDTO loginByKakao(User user) {
8991

90-
if (user.getUserStatus() == UserStatus.PENDING || user.getUserStatus() == UserStatus.INACTIVE) {
91-
throw new WhiplashException(ErrorStatus.USER_NOT_ACTIVATED);
92-
}
92+
// if (user.getUserStatus() == UserStatus.PENDING || user.getUserStatus() == UserStatus.INACTIVE) {
93+
// throw new WhiplashException(ErrorStatus.USER_NOT_ACTIVATED);
94+
// }
9395

9496
// 모든 사용자 타입에 대해 user.getId()를 사용
9597
String userId = String.valueOf(user.getId());

src/main/java/com/example/whiplash/quiz/dto/response/MixedQuizResDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.AllArgsConstructor;
44
import lombok.Data;
5+
import lombok.NoArgsConstructor;
56

67
import java.time.LocalDateTime;
78
import java.util.List;
@@ -25,6 +26,7 @@ public class MixedQuizResDto {
2526
*/
2627
@Data
2728
@AllArgsConstructor
29+
@NoArgsConstructor
2830
public static class QuizWithTerm {
2931
private String question;
3032
private List<String> options;

src/main/java/com/example/whiplash/quiz/service/WeeklyChallengeService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public WeeklyChallengeResDto getWeeklyChallenge(Long userId) {
5454
Optional<ChallengeAttempt> attemptOpt = challengeAttemptRepository
5555
.findByUserIdAndChallengeId(userId, challenge.getId());
5656

57+
log.info("weekly challenge : {}", challenge.getQuizzesJson());
58+
5759
// 4. 퀴즈 데이터 (이미 도전했으면 null)
5860
List<MixedQuizResDto.QuizWithTerm> quizzes = attemptOpt.isPresent()
5961
? null
@@ -266,23 +268,31 @@ private Double calculateAverageScore(Long challengeId) {
266268
*/
267269
private String convertToJson(Object obj) {
268270
try {
269-
return objectMapper.writeValueAsString(obj);
271+
String json = objectMapper.writeValueAsString(obj);
272+
log.debug("JSON 변환 성공: type={}, length={}", obj.getClass().getSimpleName(), json.length());
273+
return json;
270274
} catch (JsonProcessingException e) {
271-
throw new RuntimeException("JSON 변환 실패", e);
275+
log.error("JSON 변환 실패: obj={}", obj, e);
276+
throw new RuntimeException("JSON 변환 실패: " + e.getMessage(), e);
272277
}
273278
}
274279

275280
private List<MixedQuizResDto.QuizWithTerm> parseQuizzesFromJson(String json) {
276281
try {
277-
return objectMapper.readValue(
282+
log.debug("JSON 파싱 시도: json={}", json);
283+
List<MixedQuizResDto.QuizWithTerm> result = objectMapper.readValue(
278284
json,
279285
objectMapper.getTypeFactory().constructCollectionType(
280286
List.class,
281287
MixedQuizResDto.QuizWithTerm.class
282288
)
283289
);
290+
log.debug("JSON 파싱 성공: size={}", result.size());
291+
return result;
284292
} catch (JsonProcessingException e) {
285-
throw new RuntimeException("JSON 파싱 실패", e);
293+
log.error("JSON 파싱 실패 - json 내용: {}", json, e);
294+
log.error("에러 상세: {}", e.getMessage());
295+
throw new RuntimeException("JSON 파싱 실패: " + e.getMessage(), e);
286296
}
287297
}
288298

0 commit comments

Comments
 (0)