Skip to content

Commit 62af1bc

Browse files
committed
refactor: 내 문의 조회 시 PageResponse 타입을 반환하도록 변경
1 parent c69beee commit 62af1bc

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/main/java/com/example/log4u/domain/supports/controller/SupportController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.example.log4u.domain.supports.controller;
22

3-
import org.springframework.data.domain.Page;
43
import org.springframework.http.HttpStatus;
54
import org.springframework.http.ResponseEntity;
65
import org.springframework.security.core.annotation.AuthenticationPrincipal;
@@ -12,6 +11,7 @@
1211
import org.springframework.web.bind.annotation.RequestParam;
1312
import org.springframework.web.bind.annotation.RestController;
1413

14+
import com.example.log4u.common.dto.PageResponse;
1515
import com.example.log4u.common.oauth2.dto.CustomOAuth2User;
1616
import com.example.log4u.domain.supports.dto.SupportCreateRequestDto;
1717
import com.example.log4u.domain.supports.dto.SupportGetResponseDto;
@@ -39,13 +39,14 @@ public ResponseEntity<Void> createSupport(
3939
}
4040

4141
@GetMapping
42-
public ResponseEntity<Page<SupportOverviewGetResponseDto>> getSupportOverviewPage(
42+
public ResponseEntity<PageResponse<SupportOverviewGetResponseDto>> getSupportOverviewPage(
4343
@AuthenticationPrincipal CustomOAuth2User customOAuth2User,
4444
@RequestParam(defaultValue = "1") int page,
4545
@RequestParam(required = false) SupportType supportType
4646
) {
4747
long requesterId = customOAuth2User.getUserId();
48-
Page<SupportOverviewGetResponseDto> supportOverviewPage = supportService.getSupportPage(requesterId, page,
48+
PageResponse<SupportOverviewGetResponseDto> supportOverviewPage = supportService.getSupportPage(requesterId,
49+
page,
4950
supportType);
5051
return ResponseEntity.ok().body(supportOverviewPage);
5152
}

src/main/java/com/example/log4u/domain/supports/service/SupportService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.example.log4u.domain.supports.service;
22

3-
import org.springframework.data.domain.Page;
43
import org.springframework.data.domain.PageRequest;
54
import org.springframework.data.domain.Pageable;
65
import org.springframework.stereotype.Service;
76
import org.springframework.transaction.annotation.Transactional;
87

8+
import com.example.log4u.common.dto.PageResponse;
99
import com.example.log4u.domain.supports.dto.SupportCreateRequestDto;
1010
import com.example.log4u.domain.supports.dto.SupportGetResponseDto;
1111
import com.example.log4u.domain.supports.dto.SupportOverviewGetResponseDto;
@@ -31,13 +31,14 @@ public void createSupport(
3131
}
3232

3333
@Transactional(readOnly = true)
34-
public Page<SupportOverviewGetResponseDto> getSupportPage(
34+
public PageResponse<SupportOverviewGetResponseDto> getSupportPage(
3535
long requesterId,
3636
int page,
3737
SupportType supportType
3838
) {
3939
Pageable pageable = PageRequest.of(page - 1, 10);
40-
return supportQuerydsl.getSupportOverviewGetResponseDtoPage(requesterId, pageable, supportType);
40+
return PageResponse.of(
41+
supportQuerydsl.getSupportOverviewGetResponseDtoPage(requesterId, pageable, supportType));
4142
}
4243

4344
@Transactional(readOnly = true)

src/test/java/com/example/log4u/domain/support/service/SupportServiceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.springframework.data.domain.PageImpl;
1616
import org.springframework.data.domain.PageRequest;
1717

18+
import com.example.log4u.common.dto.PageResponse;
1819
import com.example.log4u.domain.supports.dto.SupportCreateRequestDto;
1920
import com.example.log4u.domain.supports.dto.SupportGetResponseDto;
2021
import com.example.log4u.domain.supports.dto.SupportOverviewGetResponseDto;
@@ -62,10 +63,10 @@ void testGetSupportPage() {
6263
given(supportQuerydsl.getSupportOverviewGetResponseDtoPage(requesterId, pageable, supportType))
6364
.willReturn(supportPage);
6465

65-
Page<SupportOverviewGetResponseDto> result = supportService.getSupportPage(requesterId, 1, supportType);
66+
PageResponse<SupportOverviewGetResponseDto> result = supportService.getSupportPage(requesterId, 1, supportType);
6667

6768
assertNotNull(result);
68-
assertEquals(1, result.getTotalElements());
69+
assertEquals(1, result.pageInfo().totalElements());
6970
}
7071

7172
@DisplayName("성공 테스트 : 특정 문의 상세 조회")

0 commit comments

Comments
 (0)