Skip to content

Commit

Permalink
Merge branch 'develop' into feature/cqrs-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
decten authored Jan 29, 2024
2 parents 9b875f2 + 5b9e16b commit 50c1f62
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum PointStatus {

CANCELED("취소 완료", "충전", "취소"),
PAID("결제 완료", "충전", "포인트"),
REMAINED("잔액 존재", "충전", "포인트"),
REMAINED("구매 확정", "충전", "포인트"),
USED("구매 확정", "사용", "포인트");

private final String status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface PointChargesRepository extends JpaRepository<PointCharges, Long>,
PointChargesCustomRepository {

Page<PointCharges> findPageByPointId(Long pointId, Pageable pageable);
Page<PointCharges> findPageByPointIdOrderByIdDesc(Long pointId, Pageable pageable);

List<PointCharges> findByPointId(Long pointId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface PointUsageRepository extends JpaRepository<PointUsage, Long>,
PointUsageCustomRepository {

Page<PointUsage> findPageByPointId(Long pointId, Pageable pageable);
Page<PointUsage> findPageByPointIdOrderByIdDesc(Long pointId, Pageable pageable);

List<PointUsage> findByPointId(Long pointId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
Expand All @@ -62,6 +61,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -115,15 +115,14 @@ public PointTotalBalanceResponse getPointTotalBalanceResponse(Long memberId) {
@Transactional(readOnly = true)
public PointChargePageResponse getPointChargePageResponse(Long memberId, Pageable pageable) {
Long pointId = getMemberPoint(memberId).getId();
Page<PointCharges> pagePointCharges = pointChargesRepository.findPageByPointId(pointId,
Page<PointCharges> pagePointCharges = pointChargesRepository.findPageByPointIdOrderByIdDesc(pointId,
pageable);

List<PointCharges> pointCharges = new ArrayList<>();
for (PointCharges pointCharge : pagePointCharges) {
pointCharges.add(pointCharge);
}

pointCharges.sort((p1, p2) -> Long.compare(p2.getId(), p1.getId()));

return PointChargePageResponse.of(new PageImpl<>(
getPointChargeDetailResponses(pointCharges),
pageable,
Expand All @@ -143,16 +142,14 @@ public PointChargeResponse getDetailChargePointResponse(Long chargeId) {
@Transactional(readOnly = true)
public PointUsagePageResponse getPointUsagePageResponse(Long memberId, Pageable pageable) {
Long pointId = getMemberPoint(memberId).getId();
Page<PointUsage> pagePointUsages = pointUsageRepository.findPageByPointId(
Page<PointUsage> pagePointUsages = pointUsageRepository.findPageByPointIdOrderByIdDesc(
pointId, pageable
);
List<PointUsage> pointUsages = new ArrayList<>();
for (PointUsage pointusage : pagePointUsages) {
pointUsages.add(pointusage);
}

pointUsages.sort((p1, p2) -> Long.compare(p2.getId(), p1.getId()));

return PointUsagePageResponse.of(new PageImpl<>(
getPointUsageDetailResponses(pointUsages),
pageable,
Expand Down

0 comments on commit 50c1f62

Please sign in to comment.