Skip to content

Commit

Permalink
[HotFix] Fix Query Condition (#243)
Browse files Browse the repository at this point in the history
* [HotFix] Add missing bracket to fix syntax error

* [HotFix] Fix Query Condition

* [HotFix] Add Test Token
  • Loading branch information
ahnsugyeong authored May 4, 2024
1 parent d460d29 commit dd037dd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,62 @@ public class CommentQueryRepositoryImpl implements CommentQueryRepository {
@Override
public Page<SirenCommentViewDto> findPagedSirenCommentsByUserUrl(String userUrl, Pageable pageable) {
List<SirenCommentViewDto> content = queryFactory.select(
Projections.constructor(SirenCommentViewDto.class, comment.id, comment.content, siren.title,
siren.status, siren.category, comment.createdDate,
Projections.fields(MemberSummaryDto.class, comment.member.id.as("memberId"),
comment.member.userUrl.as("userUrl"), comment.member.nickname.as("nickname"),
comment.member.profileImgUrl.as("profileImgUrl")))).from(siren)
.join(siren.comments, comment).where(siren.member.userUrl.eq(userUrl)).offset(pageable.getOffset())
.limit(pageable.getPageSize()).orderBy(comment.createdDate.desc()).fetch();
Projections.constructor(SirenCommentViewDto.class,
comment.id,
comment.content,
siren.title,
siren.status,
siren.category,
comment.createdDate,
Projections.fields(MemberSummaryDto.class,
comment.member.id.as("memberId"),
comment.member.userUrl.as("userUrl"),
comment.member.nickname.as("nickname"),
comment.member.profileImgUrl.as("profileImgUrl"))))
.from(siren)
.join(siren.comments, comment)
.where(comment.member.userUrl.eq(userUrl))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(comment.createdDate.desc())
.fetch();

long total = queryFactory.selectFrom(siren).join(siren.comments, comment)
.where(siren.member.userUrl.eq(userUrl)).stream().count();
long total = queryFactory
.selectFrom(siren)
.join(siren.comments, comment)
.where(siren.member.userUrl.eq(userUrl))
.stream().count();

return new PageImpl<>(content, pageable, total);
}

@Override
public Page<QuestionCommentViewDto> findPagedQuestionCommentsByUserUrl(String userUrl, Pageable pageable) {
List<QuestionCommentViewDto> content = queryFactory.select(
Projections.constructor(QuestionCommentViewDto.class, comment.id, comment.content, question.title,
question.status, comment.createdDate,
Projections.fields(MemberSummaryDto.class, comment.member.id.as("memberId"),
comment.member.userUrl.as("userUrl"), comment.member.nickname.as("nickname"),
comment.member.profileImgUrl.as("profileImgUrl")))).from(question)
.join(question.comments, comment).where(question.member.userUrl.eq(userUrl))
.offset(pageable.getOffset()).limit(pageable.getPageSize()).orderBy(comment.createdDate.desc()).fetch();

long total = queryFactory.selectFrom(question).join(question.comments, comment)
.where(question.member.userUrl.eq(userUrl)).stream().count();
Projections.constructor(QuestionCommentViewDto.class,
comment.id,
comment.content,
question.title,
question.status,
comment.createdDate,
Projections.fields(MemberSummaryDto.class,
comment.member.id.as("memberId"),
comment.member.userUrl.as("userUrl"),
comment.member.nickname.as("nickname"),
comment.member.profileImgUrl.as("profileImgUrl"))))
.from(question)
.join(question.comments, comment)
.where(comment.member.userUrl.eq(userUrl))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(comment.createdDate.desc())
.fetch();

long total = queryFactory
.selectFrom(question)
.join(question.comments, comment)
.where(question.member.userUrl.eq(userUrl))
.stream().count();

return new PageImpl<>(content, pageable, total);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public OpenAPI api() {
---
### 🔑 테스트 사용자 인증 토큰
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJiNmY1ZGZjYi0wZTk4LTQxOGEtYmIzMy05YmE0OWY0ZGQwZWQiLCJhdXRoIjoiUk9MRV9VU0VSIiwiZXhwIjoxNzE0NDgwODAxfQ.FZ630SRHlgfPqwGl3uguGxh5ri76VDWcpJZNv8F-y-c
`eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5YjJlZTgyMS0wZWM4LTQ5M2QtYTRkOS1jNzY2NDk3OWM1ZWEiLCJhdXRoIjoiUk9MRV9HVUVTVCIsImV4cCI6MTcyMDAyNjMxNH0.PRH0Lg9HZMbDLT6oRwDWTPM4PaLafa_xVb4Gdy5PKs8`
""");

Expand Down

0 comments on commit dd037dd

Please sign in to comment.