Skip to content

Commit

Permalink
fix: 🐛 카테고리 별 소비 내역 리스트 조회 정렬 조건 수정 (#157)
Browse files Browse the repository at this point in the history
* fix: 정렬 조건 spend_at 내림차순, id 오름차순으로 수정

* docs: swagger error 커스텀 어노테이션으로 지정
  • Loading branch information
psychology50 authored Aug 22, 2024
1 parent 24d7262 commit 96d9bd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.co.pennyway.api.apis.ledger.dto.SpendingCategoryDto;
import kr.co.pennyway.api.apis.ledger.dto.SpendingSearchRes;
import kr.co.pennyway.api.common.annotation.ApiExceptionExplanation;
import kr.co.pennyway.api.common.annotation.ApiResponseExplanations;
import kr.co.pennyway.api.common.query.SpendingCategoryType;
import kr.co.pennyway.api.common.security.authentication.SecurityUserDetails;
import kr.co.pennyway.domain.domains.spending.exception.SpendingErrorCode;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
Expand Down Expand Up @@ -93,20 +96,14 @@ ResponseEntity<?> getSpendingTotalCountByCategory(
}),
@Parameter(name = "size", description = "페이지 사이즈 (default: 30)", example = "30", in = ParameterIn.QUERY),
@Parameter(name = "page", description = "페이지 번호 (default: 0)", example = "0", in = ParameterIn.QUERY),
@Parameter(name = "sort", description = "정렬 기준 (default: sending.spendAt)", example = "spending.spendAt", in = ParameterIn.QUERY),
@Parameter(name = "direction", description = "정렬 방식 (default: DESC)", example = "DESC", in = ParameterIn.QUERY),
@Parameter(name = "sort", description = "정렬 기준 (default: 소비내역 내림차순, 식별값 오름차순)", example = "spending.spendAt,DESC&sort=spending.id,ASC", in = ParameterIn.QUERY, allowReserved = true),
@Parameter(name = "pageable", hidden = true)
})
@ApiResponses({
@ApiResponse(responseCode = "200", description = "지출 내역 조회 성공", content = @Content(mediaType = "application/json", schemaProperties = @SchemaProperty(name = "spendings", schema = @Schema(implementation = SpendingSearchRes.MonthSlice.class)))),
@ApiResponse(responseCode = "400", description = "type과 categoryId 미스 매치", content = @Content(examples =
@ExampleObject(name = "type과 categoryId가 유효하지 않은 조합", description = "type이 default면서, categoryId가 CUSTOM(0) 혹은 OTHER(12)일 수는 없다.", value = """
{
"code": "4005",
"message": "type의 정보와 categoryId의 정보가 존재할 수 없는 조합입니다."
}
"""
)))
})
@ApiResponseExplanations(errors = {
@ApiExceptionExplanation(value = SpendingErrorCode.class, constant = "INVALID_TYPE_WITH_CATEGORY_ID", name = "type과 categoryId 미스 매치", description = "type이 default면서, categoryId가 CUSTOM(0) 혹은 OTHER(12)일 수는 없다.")
})
ResponseEntity<?> getSpendingsByCategory(
@PathVariable(value = "categoryId") Long categoryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public ResponseEntity<?> getSpendingTotalCountByCategory(
public ResponseEntity<?> getSpendingsByCategory(
@PathVariable(value = "categoryId") Long categoryId,
@RequestParam(value = "type") SpendingCategoryType type,
@PageableDefault(size = 30, page = 0) @SortDefault(sort = "spending.spendAt", direction = Sort.Direction.DESC) Pageable pageable,
@PageableDefault(size = 30, page = 0) @SortDefault.SortDefaults({
@SortDefault(sort = "spending.spendAt", direction = Sort.Direction.DESC),
@SortDefault(sort = "spending.id", direction = Sort.Direction.ASC)
}) Pageable pageable,
@AuthenticationPrincipal SecurityUserDetails user
) {
if (type.equals(SpendingCategoryType.DEFAULT) && (categoryId.equals(0L) || categoryId.equals(12L))) {
Expand Down

0 comments on commit 96d9bd8

Please sign in to comment.