Skip to content

Commit

Permalink
[MERGE] Merge pull request #203 from Team-WSS/fix/#202
Browse files Browse the repository at this point in the history
[FIX] 유저 등록 작품 수 조회 기능 수정
  • Loading branch information
Kim-TaeUk authored Sep 28, 2024
2 parents 96f885b + 043b24a commit 6c070e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ public ResponseEntity<Void> registerUserInfo(Principal principal,
.build();
}

@GetMapping("/user-novel-stats")
public ResponseEntity<UserNovelCountGetResponse> getUserNovelStatistics(Principal principal) {
User user = userService.getUserOrException(Long.valueOf(principal.getName()));
@GetMapping("/{userId}/user-novel-stats")
public ResponseEntity<UserNovelCountGetResponse> getUserNovelStatistics(@PathVariable("userId") Long userId) {
return ResponseEntity
.status(OK)
.body(userNovelService.getUserNovelStatistics(user));
.body(userNovelService.getUserNovelStatistics(userId));
}

@GetMapping("/{userId}/novels")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public interface UserNovelCustomRepository {

UserNovelCountGetResponse findUserNovelStatistics(User user);
UserNovelCountGetResponse findUserNovelStatistics(Long userId);

List<Long> findTodayPopularNovelsId(Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class UserNovelCustomRepositoryImpl implements UserNovelCustomRepository
private final JPAQueryFactory jpaQueryFactory;

@Override
public UserNovelCountGetResponse findUserNovelStatistics(User user) {
public UserNovelCountGetResponse findUserNovelStatistics(Long userId) {
return jpaQueryFactory
.select(Projections.constructor(UserNovelCountGetResponse.class,
userNovel.isInterest
Expand Down Expand Up @@ -59,7 +59,7 @@ public UserNovelCountGetResponse findUserNovelStatistics(User user) {
.coalesce(0)
))
.from(userNovel)
.where(userNovel.user.eq(user))
.where(userNovel.user.userId.eq(userId))
.fetchOne();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ private List<KeywordGetResponse> getKeywordGetResponses(UserNovel userNovel) {
}

@Transactional(readOnly = true)
public UserNovelCountGetResponse getUserNovelStatistics(User user) {
return userNovelRepository.findUserNovelStatistics(user);
public UserNovelCountGetResponse getUserNovelStatistics(Long ownerId) {
return userNovelRepository.findUserNovelStatistics(ownerId);
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 6c070e0

Please sign in to comment.