Skip to content

Commit

Permalink
feat: add paging processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kang1221 committed Sep 12, 2024
1 parent 005d236 commit fb6a6d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/co/orange/ddanzi/dto/common/PageInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.orange.ddanzi.dto.common;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class PageInfo {
private Long totalElements;
private Integer numberOfElements;
}
2 changes: 2 additions & 0 deletions src/main/java/co/orange/ddanzi/dto/home/HomeResponseDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.orange.ddanzi.dto.home;

import co.orange.ddanzi.dto.common.PageInfo;
import co.orange.ddanzi.dto.common.ProductInfo;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -10,5 +11,6 @@
@Builder
public class HomeResponseDto {
private String homeImgUrl;
private PageInfo pageInfo;
private List<ProductInfo> productList;
}
6 changes: 6 additions & 0 deletions src/main/java/co/orange/ddanzi/service/HomeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.orange.ddanzi.domain.Banner;
import co.orange.ddanzi.domain.product.*;
import co.orange.ddanzi.domain.user.User;
import co.orange.ddanzi.dto.common.PageInfo;
import co.orange.ddanzi.dto.common.ProductInfo;
import co.orange.ddanzi.dto.common.OptionDetailInfo;
import co.orange.ddanzi.dto.common.OptionInfo;
Expand Down Expand Up @@ -53,9 +54,14 @@ public ApiResponse<?> getProductList(Pageable pageable) {
productInfoList = setProductListInNotUser(productPage.getContent(), interestProductRepository);
}

PageInfo pageInfo = PageInfo.builder()
.totalElements(productPage.getTotalElements())
.numberOfElements(productPage.getNumberOfElements())
.build();

HomeResponseDto responseDto = HomeResponseDto.builder()
.homeImgUrl(banner.getImgUrl())
.pageInfo(pageInfo)
.productList(productInfoList).build();
return ApiResponse.onSuccess(Success.GET_HOME_INFO_SUCCESS, responseDto);
}
Expand Down

0 comments on commit fb6a6d0

Please sign in to comment.