Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ResponseEntity<Object> postUserFeedback(@PathVariable("cardId") Long card
@RequestHeader("access") String access,
@Validated @RequestBody UserFeedbackRequestDto userFeedbackRequestDto) {

Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

UserFeedbackResponseDto userFeedbackResponseDto = cardFeedbackService.postUserFeedback(userFeedbackRequestDto, userId, cardId);
userLevelService.updateUserLevelInfo(cardId, userId, userFeedbackResponseDto.getUserScore());
Expand All @@ -66,7 +66,7 @@ public ResponseEntity<Object> postUserFeedback(@PathVariable("cardId") Long card
public ResponseEntity<Object> postCustomUserFeedback(@PathVariable("cardId") Long cardId,
@Validated @RequestBody UserFeedbackRequestDto userFeedbackRequestDto,
@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

UserFeedbackResponseDto userFeedbackResponseDto = customCardFeedbackService.postUserFeedback(userFeedbackRequestDto, cardId, userId);
userLevelService.updateCustomCardUserLevelInfo(cardId, userId, userFeedbackResponseDto.getUserScore());
Expand All @@ -86,7 +86,7 @@ public ResponseEntity<Object> postCustomUserFeedback(@PathVariable("cardId") Lon
public ResponseEntity<Object> postTodayCardUserFeedback(@PathVariable("cardId") Long cardId,
@Validated @RequestBody UserFeedbackRequestDto userFeedbackRequestDto,
@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

UserFeedbackResponseDto userFeedbackResponseDto = todayCardFeedbackService.postUserFeedback(userFeedbackRequestDto, cardId, userId);
userLevelService.updateCustomCardUserLevelInfo(cardId, userId, userFeedbackResponseDto.getUserScore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CardInfoController {
}
)
public ResponseEntity<CardInfoResponseDto> getCardInfo(@PathVariable("cardId") Long cardId, @RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);
CardInfoResponseDto cardInfoResponseDto = cardInfoService.getCardInfo(userId, cardId);
return ResponseEntity.ok().body(cardInfoResponseDto);
}
Expand All @@ -56,7 +56,7 @@ public ResponseEntity<CardInfoResponseDto> getCardInfo(@PathVariable("cardId") L
}
)
public ResponseEntity<CardInfoResponseDto> postCustomCardInfo(@PathVariable("cardId") Long cardId, @RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);
CardInfoResponseDto cardInfoResponseDto = customCardInfoService.getCustomCardInfo(userId, cardId);

return ResponseEntity.ok().body(cardInfoResponseDto);
Expand All @@ -71,7 +71,7 @@ public ResponseEntity<CardInfoResponseDto> postCustomCardInfo(@PathVariable("car
}
)
public ResponseEntity<TodayCardInfoResponseDto> postTodayCardInfo(@PathVariable("cardId") Long cardId, @RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);
TodayCardInfoResponseDto cardInfoResponseDto = todayCardInfoService.getTodayCardInfo(userId, cardId);

return ResponseEntity.ok().body(cardInfoResponseDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TodayCourseController {
})
public ResponseEntity<TodayCourseResponseDto> getCardList(@RequestBody TodayCourseRequestDto requestDto,
@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

TodayCourseResponseDto response = todayCourseService.getCardList(userId, requestDto);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class CustomCardController {
@ApiResponse(responseCode = "400", description = "ERROR : 카드를 생성 불가(10개 이상 or 한국어 X, 35자 이상)", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity<CustomCardResponseDto> postCustomCard(@Validated @RequestBody CustomCardRequestDto customCardRequestDto, @RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

CustomCardResponseDto customCardResponse = customCardService.createCustomCardIfPossible(customCardRequestDto.getText(), userId);

Expand All @@ -47,7 +47,7 @@ public ResponseEntity<CustomCardResponseDto> postCustomCard(@Validated @RequestB
@ApiResponse(responseCode = "400", description = "ERROR : 카드 삭제 불가", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity deleteCustomCard(@PathVariable("cardId") Long cardId, @RequestHeader("access") String access) throws CardDeleteException {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

boolean isDeleted = customCardService.deleteCustomCard(userId, cardId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CustomCardListController {
@ApiResponse(responseCode = "400", description = "ERROR : 존재하지 않는 카테고리 조회", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity<CardListResponseDto<List<CustomCardDto>>> getCustomCardList(@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

List<CustomCardDto> cardDtoList = cardListService.getCustomCards(userId);
CardListResponseDto<List<CustomCardDto>> response = new CardListResponseDto<>(cardDtoList, cardDtoList.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CardListController {
})
public ResponseEntity<CardListResponseDto<List<ResponseCardDto>>> getCardList(@RequestParam("level") Long level,
@RequestHeader("access") String access){
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

List<ResponseCardDto> cardDtoList = cardListService.getCardsByCategory(level, userId);
CardListResponseDto<List<ResponseCardDto>> response = new CardListResponseDto<>(cardDtoList, cardDtoList.size());
Expand All @@ -53,7 +53,7 @@ public ResponseEntity<CardListResponseDto<List<ResponseCardDto>>> getCardList(@R
@ApiResponse(responseCode = "400", description = "ERROR : 조회 실패", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity<CourseResponseDto> getCourseList(@RequestHeader("access") String access){
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

CourseResponseDto response = cardListService.getCourseList(userId);

Expand All @@ -68,7 +68,7 @@ public ResponseEntity<CourseResponseDto> getCourseList(@RequestHeader("access")
@ApiResponse(responseCode = "400", description = "ERROR : 존재하지 않는 카드", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity updateCardBookmark(@PathVariable("cardId") Integer cardId, @RequestHeader("access") String access){
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

String message = cardListService.toggleCardBookmark(Long.valueOf(cardId), userId);
return ResponseEntity.ok().body(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BookmarkCardsController {
@ApiResponse(responseCode = "400", description = "ERROR : 존재하지 않는 카테고리 조회", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity<BookmarkCardResponseDto> getCardList(@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

BookmarkCardResponseDto responseDto = bookmarkCardsService.getCards(userId);
return ResponseEntity.ok().body(responseDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MissedCardsController {
@ApiResponse(responseCode = "400", description = "ERROR : 존재하지 않는 카테고리 조회", content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
})
public ResponseEntity<MissedCardResponseDto> getCardList(@RequestHeader("access") String access) {
Long userId = joinService.findUserBySocialId(jwtUtil.getSocialId(access)).getId();
Long userId = jwtUtil.getUserId(access);

MissedCardResponseDto responseDto = missedCardsService.getCards(userId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ public class ReportController {
private final JWTUtil jwtUtil;
private final ReportInfoService reportInfoService;

private Long extractUserIdFromToken(String access) { // access 토큰으로부터 userId 추출하는 함수
String socialId = jwtUtil.getSocialId(access);
return joinService.findUserBySocialId(socialId).getId();
}

@Operation(summary = "My report 화면 정보 조회", description = "My report 화면에 필요한 모든 정보를 반환한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "My report 화면 정보 조회 성공", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ReportInfoDto.class))),
@ApiResponse(responseCode = "500", description = "서버 오류 발생", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionDto.class)))
})
@GetMapping("/report")
public ResponseEntity<ReportInfoDto> getHomeInfo(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
ReportInfoDto response = reportInfoService.getMyReportInfo(userId);
return ResponseEntity.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,13 @@ public class WeakSoundTestController {
private final JWTUtil jwtUtil;
private final WeakSoundTestService weakSoundTestService;

private Long extractUserIdFromToken(String access) {
String socialId = jwtUtil.getSocialId(access);
return joinService.findUserBySocialId(socialId).getId();
}

@Operation(summary = "취약음소 테스트 존재 여부 확인", description = "이전에 진행중이던 테스트가 있는지 확인한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "확인 완료", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestStartResponseDto.class)))
})
@GetMapping("/test/check")
public ResponseEntity<TestStartResponseDto> checkTest(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
TestStartResponseDto response = weakSoundTestService.checkTestStatus(userId);
return ResponseEntity.ok(response);
}
Expand All @@ -59,7 +54,7 @@ public ResponseEntity<TestStartResponseDto> checkTest(@RequestHeader("access") S
})
@PostMapping("/test/new")
public ResponseEntity<List<WeakSoundTestListDto>> startNewTest(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
weakSoundTestService.startNewTest(userId);
return ResponseEntity.ok(weakSoundTestService.getAllTests());
}
Expand All @@ -71,7 +66,7 @@ public ResponseEntity<List<WeakSoundTestListDto>> startNewTest(@RequestHeader("a
})
@GetMapping("/test/continue")
public ResponseEntity<List<WeakSoundTestListDto>> continueTest(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
List<WeakSoundTestListDto> remainingTests = weakSoundTestService.getContinueTests(userId);
return ResponseEntity.ok(remainingTests);
}
Expand All @@ -85,7 +80,7 @@ public ResponseEntity<List<WeakSoundTestListDto>> continueTest(@RequestHeader("a
})
@PostMapping(value = "/test/{cardId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> uploadFile(@PathVariable("cardId") Long id, @RequestHeader("access") String access, @RequestParam("userAudio") MultipartFile userAudio) throws IOException {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);

if (userAudio.isEmpty()) {
throw new ParameterNotFoundException("사용자 음성 파일이 비었습니다.");
Expand All @@ -106,7 +101,7 @@ public ResponseEntity<String> uploadFile(@PathVariable("cardId") Long id, @Reque
})
@PostMapping("/test/finalize")
public ResponseEntity<Map<Long, Integer>> finalizeAnalysis(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
Map<Long, Integer> topPhonemes = weakSoundTestService.getTopPhonemes(userId);
weakSoundTestService.finalizeTestStatus(userId);
return ResponseEntity.ok(topPhonemes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class PhonemeController {
private final PhonemeService phonemeService;
private final PhonemeRepository phonemeRepository;

private Long extractUserIdFromToken(String access) {
String socialId = jwtUtil.getSocialId(access);
return joinService.findUserBySocialId(socialId).getId();
}

@Operation(summary = "사용자의 취약음소 제공", description = "사용자의 취약음소 4개를 제공한다.")
@ApiResponses(value = {
Expand All @@ -49,7 +45,7 @@ private Long extractUserIdFromToken(String access) {
})
@GetMapping("/test/phonemes")
public ResponseEntity<List<UserWeakSoundResponseDto>> getWeakPhonemesByUserId(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
List<UserWeakSoundResponseDto> weakPhonemes = phonemeService.getWeakPhonemes(userId);
if (weakPhonemes.isEmpty()) {
throw new ResponseNotFoundException("취약음소가 없습니다.");
Expand All @@ -64,7 +60,7 @@ public ResponseEntity<List<UserWeakSoundResponseDto>> getWeakPhonemesByUserId(@R
})
@GetMapping("/test/all")
public ResponseEntity<List<PhonemeResponseDto>> getAllPhonemesWithWeakStatus(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
return ResponseEntity.ok(phonemeService.getAllPhonemes(userId));
}

Expand All @@ -75,7 +71,7 @@ public ResponseEntity<List<PhonemeResponseDto>> getAllPhonemesWithWeakStatus(@Re
})
@PostMapping("/test/add")
public ResponseEntity<?> addWeakPhonemes(@RequestHeader("access") String access, @RequestBody List<Long> phonemeIds) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
phonemeService.addWeakPhonemes(userId, phonemeIds);
return ResponseEntity.ok("취약음소가 추가되었습니다.");
}
Expand All @@ -87,7 +83,7 @@ public ResponseEntity<?> addWeakPhonemes(@RequestHeader("access") String access,
})
@DeleteMapping("test/phonemes/{phonemeId}")
public ResponseEntity<?> deleteWeakPhoneme(@RequestHeader("access") String access, @PathVariable Long phonemeId) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
phonemeService.deleteWeakPhoneme(userId, phonemeId);
return ResponseEntity.ok("사용자의 취약음소가 삭제되었습니다.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public class HomeController {
private final HomeInfoService homeInfoService;
private final NotificationService notificationService;

private Long extractUserIdFromToken(String access) { // access 토큰으로부터 userId 추출하는 함수
String socialId = jwtUtil.getSocialId(access);
return joinService.findUserBySocialId(socialId).getId();
}

@Operation(summary = "홈 화면 정보 조회", description = "사용자의 홈 화면에 필요한 모든 정보를 반환한다.")
@ApiResponses(value = {
Expand All @@ -40,7 +36,7 @@ private Long extractUserIdFromToken(String access) { // access 토큰으로부
})
@GetMapping("/home")
public ResponseEntity<HomeInfoDto> getHomeInfo(@RequestHeader("access") String access) {
Long userId = extractUserIdFromToken(access);
Long userId = jwtUtil.getUserId(access);
HomeInfoDto response = homeInfoService.getHomeInfo(userId);
return ResponseEntity.ok(response);
}
Expand Down
Loading