Skip to content

Commit

Permalink
[Hotfix] convert name and parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
Han-Jeong committed May 12, 2024
1 parent bdde3b6 commit 2fa7c08
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface QuestionQueryService {

Page<Question> getPagedQuestions(Pageable pageable);

Page<Question> getPagedQuestionsByFilter(QuestionSortParam sortParam, Pageable pageable);
Page<Question> getPagedQuestionsBySortParam(QuestionSortParam sortParam, Pageable pageable);

List<Question> getRepresentativeQuestionList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public Page<Question> getPagedQuestions(Pageable pageable) {
}

@Override
public Page<Question> getPagedQuestionsByFilter(QuestionSortParam sortParam, Pageable pageable) {
return questionRepository.findQuestionsByFilter(sortParam, pageable);
public Page<Question> getPagedQuestionsBySortParam(QuestionSortParam sortParam, Pageable pageable) {
return questionRepository.findQuestionsBySortParam(sortParam, pageable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.waggle.domain.board.application.story;

import com.example.waggle.domain.board.persistence.entity.Story;
import com.example.waggle.domain.board.presentation.dto.story.StoryFilterParam;
import com.example.waggle.domain.board.presentation.dto.story.StorySortParam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

Expand All @@ -19,7 +19,7 @@ public interface StoryQueryService {

Page<Story> getPagedStories(Pageable pageable);

Page<Story> getPagedStoriesByFilter(StoryFilterParam filterParam, Pageable pageable);
Page<Story> getPagedStoriesBySortParam(StorySortParam sortParam, Pageable pageable);

Story getStoryByBoardId(Long boardId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.waggle.domain.board.persistence.dao.story.jpa.StoryRepository;
import com.example.waggle.domain.board.persistence.entity.Story;
import com.example.waggle.domain.board.presentation.dto.story.StoryFilterParam;
import com.example.waggle.domain.board.presentation.dto.story.StorySortParam;
import com.example.waggle.exception.object.handler.StoryHandler;
import com.example.waggle.exception.payload.code.ErrorStatus;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -49,8 +49,8 @@ public Page<Story> getPagedStories(Pageable pageable) {
}

@Override
public Page<Story> getPagedStoriesByFilter(StoryFilterParam filterParam, Pageable pageable) {
return storyRepository.findStoriesByFilter(filterParam, pageable);
public Page<Story> getPagedStoriesBySortParam(StorySortParam sortParam, Pageable pageable) {
return storyRepository.findStoriesBySortParam(sortParam, pageable);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import org.springframework.data.domain.Pageable;

public interface QuestionQueryRepository {
Page<Question> findQuestionsByFilter(QuestionSortParam sortParam, Pageable pageable);
Page<Question> findQuestionsBySortParam(QuestionSortParam sortParam, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class QuestionQueryRepositoryImpl implements QuestionQueryRepository {
private final JPAQueryFactory query;

@Override
public Page<Question> findQuestionsByFilter(QuestionSortParam sortParam, Pageable pageable) {
public Page<Question> findQuestionsBySortParam(QuestionSortParam sortParam, Pageable pageable) {
JPAQuery<Question> baseQuery = query.selectFrom(question);
if (sortParam == QuestionSortParam.RECOMMEND) {
baseQuery.leftJoin(recommend).on(recommend.board.eq(question._super));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.example.waggle.domain.board.persistence.dao.story.querydsl;

import com.example.waggle.domain.board.persistence.entity.Story;
import com.example.waggle.domain.board.presentation.dto.story.StoryFilterParam;
import com.example.waggle.domain.board.presentation.dto.story.StorySortParam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface StoryQueryRepository {
Page<Story> findStoriesByFilter(StoryFilterParam filterParam, Pageable pageable);
Page<Story> findStoriesBySortParam(StorySortParam sortParam, Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.waggle.domain.board.persistence.dao.story.querydsl;

import com.example.waggle.domain.board.persistence.entity.Story;
import com.example.waggle.domain.board.presentation.dto.story.StoryFilterParam;
import com.example.waggle.domain.board.presentation.dto.story.StorySortParam;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand All @@ -23,14 +23,14 @@ public class StoryQueryRepositoryImpl implements StoryQueryRepository {
private final JPAQueryFactory query;

@Override
public Page<Story> findStoriesByFilter(StoryFilterParam filterParam, Pageable pageable) {
public Page<Story> findStoriesBySortParam(StorySortParam sortParam, Pageable pageable) {
JPAQuery<Story> baseQuery = query.selectFrom(story);
if (filterParam.equals(StoryFilterParam.recommend)) {
if (sortParam.equals(StorySortParam.RECOMMEND)) {
baseQuery.leftJoin(recommend).on(story._super.eq(recommend.board));
baseQuery.groupBy(story);
}
List<Story> storyList = baseQuery
.orderBy(createOrderFilter(filterParam))
.orderBy(createSortingOrder(sortParam))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
Expand All @@ -40,12 +40,12 @@ public Page<Story> findStoriesByFilter(StoryFilterParam filterParam, Pageable pa
return new PageImpl<>(storyList, pageable, count);
}

private OrderSpecifier[] createOrderFilter(StoryFilterParam filterParam) {
switch (filterParam) {
case latest -> {
private OrderSpecifier[] createSortingOrder(StorySortParam sortParam) {
switch (sortParam) {
case LATEST -> {
return new OrderSpecifier[]{story.createdDate.desc()};
}
case recommend -> {
case RECOMMEND -> {
return new OrderSpecifier[]{
recommend.count().desc(),
story.createdDate.desc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public ApiResponseDto<QuestionSummaryListDto> getAllQuestions(
})
@GetMapping("/sort")
public ApiResponseDto<QuestionSummaryListDto> getQuestionsBySortParam(
@RequestParam(name = "filterParam") QuestionSortParam sortParam,
@RequestParam(name = "sortParam") QuestionSortParam sortParam,
@RequestParam(name = "currentPage", defaultValue = "0") int currentPage) {
Pageable pageable = PageRequest.of(currentPage, PageUtil.QUESTION_SIZE);
Page<Question> questions = questionQueryService.getPagedQuestionsByFilter(sortParam, pageable);
Page<Question> questions = questionQueryService.getPagedQuestionsBySortParam(sortParam, pageable);
QuestionSummaryListDto listDto = QuestionConverter.toListDto(questions);
setRecommendCntInList(listDto.getQuestionList());
return ApiResponseDto.onSuccess(listDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import com.example.waggle.domain.board.application.story.StoryQueryService;
import com.example.waggle.domain.board.persistence.entity.Story;
import com.example.waggle.domain.board.presentation.converter.StoryConverter;
import com.example.waggle.domain.board.presentation.dto.story.StoryFilterParam;
import com.example.waggle.domain.board.presentation.dto.story.StoryRequest;
import com.example.waggle.domain.board.presentation.dto.story.StoryResponse.StoryDetailDto;
import com.example.waggle.domain.board.presentation.dto.story.StoryResponse.StorySummaryListDto;
import com.example.waggle.domain.board.presentation.dto.story.StorySortParam;
import com.example.waggle.domain.member.persistence.entity.Member;
import com.example.waggle.domain.recommend.application.query.RecommendQueryService;
import com.example.waggle.exception.payload.code.ErrorStatus;
import com.example.waggle.exception.payload.dto.ApiResponseDto;
import com.example.waggle.global.annotation.api.ApiErrorCodeExample;
import com.example.waggle.global.annotation.auth.AuthUser;
import com.example.waggle.exception.payload.dto.ApiResponseDto;
import com.example.waggle.exception.payload.code.ErrorStatus;
import com.example.waggle.global.util.MediaUtil;
import com.example.waggle.global.util.PageUtil;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -85,17 +85,17 @@ public ApiResponseDto<StorySummaryListDto> getAllStories(
StoryConverter.toListDto(storyQueryService.getPagedStories(pageable)));
}

@Operation(summary = "스토리 필터 조회", description = "필터 옵션에 맞추어 결과를 조회합니다.")
@Operation(summary = "스토리 정렬 조회", description = "필터 옵션에 맞추어 결과를 조회합니다.")
@ApiErrorCodeExample({
ErrorStatus._INTERNAL_SERVER_ERROR
})
@GetMapping("/filter")
@GetMapping("/sort")
public ApiResponseDto<StorySummaryListDto> getStoryByFilter(
@RequestParam(name = "filterParam") StoryFilterParam filterParam,
@RequestParam(name = "sortParam") StorySortParam sortParam,
@RequestParam(name = "currentPage", defaultValue = "0") int currentPage) {
Pageable pageable = PageRequest.of(currentPage, PageUtil.STORY_SIZE);
return ApiResponseDto.onSuccess(
StoryConverter.toListDto(storyQueryService.getPagedStoriesByFilter(filterParam, pageable)));
StoryConverter.toListDto(storyQueryService.getPagedStoriesBySortParam(sortParam, pageable)));
}

@Operation(summary = "사용자의 스토리 목록 조회", description = "특정 사용자가 작성한 스토리 목록을 조회합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.waggle.domain.board.presentation.dto.story;

public enum StoryFilterParam {
recommend, latest;
public enum StorySortParam {
RECOMMEND, LATEST;
}

0 comments on commit 2fa7c08

Please sign in to comment.