Skip to content

Commit e7da211

Browse files
committed
feat get newest curation Id api
1 parent 4a4e6fb commit e7da211

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

WableServer/src/main/java/com/wable/www/WableServer/api/curation/controller/CurationController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.wable.www.WableServer.api.curation.controller;
22

33
import com.wable.www.WableServer.api.curation.dto.response.CurationGetAllResponseDto;
4+
import com.wable.www.WableServer.api.curation.dto.response.CurationNumberGetResponseDto;
45
import com.wable.www.WableServer.api.curation.service.CurationQueryService;
56
import com.wable.www.WableServer.common.response.ApiResponse;
67
import com.wable.www.WableServer.common.util.MemberUtil;
@@ -33,4 +34,10 @@ public ResponseEntity<ApiResponse<List<CurationGetAllResponseDto>>> getCurationA
3334
@RequestParam(value = "cursor") Long cursor) {
3435
return ApiResponse.success(GET_CURATION_ALL_SUCCESS, curationQueryService.getCurationAll(MemberUtil.getMemberId(principal), cursor));
3536
}
37+
38+
@GetMapping("v1/curation/number")
39+
@Operation(summary = "큐레이션 최신 번호 조회 API 입니다.",description = "Curation Newest Id Get")
40+
public ResponseEntity<ApiResponse<CurationNumberGetResponseDto>> getCurationNumber(Principal principal) {
41+
return ApiResponse.success(GET_CURATION_NUMBER_SUCCESS, curationQueryService.getCurationNumber());
42+
}
3643
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.wable.www.WableServer.api.curation.dto.response;
2+
3+
public record CurationNumberGetResponseDto(
4+
Long curationId
5+
) {
6+
public static CurationNumberGetResponseDto of(Long curationId) {
7+
return new CurationNumberGetResponseDto(
8+
curationId
9+
);
10+
}
11+
}

WableServer/src/main/java/com/wable/www/WableServer/api/curation/repository/CurationRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ public interface CurationRepository extends JpaRepository<Curation, Long> {
1515
Slice<Curation> findCurationsByNextPage(Long lastCurationId, PageRequest pageRequest);
1616

1717
Slice<Curation> findTop15ByOrderByCreatedAtDesc(PageRequest pageRequest);
18+
19+
Curation findTop1ByOrderByCreatedAtDesc();
1820
}

WableServer/src/main/java/com/wable/www/WableServer/api/curation/service/CurationQueryService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.wable.www.WableServer.api.curation.domain.Curation;
44
import com.wable.www.WableServer.api.curation.dto.response.CurationGetAllResponseDto;
5+
import com.wable.www.WableServer.api.curation.dto.response.CurationNumberGetResponseDto;
56
import com.wable.www.WableServer.api.curation.repository.CurationRepository;
67
import com.wable.www.WableServer.common.util.TimeUtilCustom;
78
import lombok.RequiredArgsConstructor;
@@ -35,4 +36,9 @@ public List<CurationGetAllResponseDto> getCurationAll(Long memberId, Long cursor
3536
TimeUtilCustom.refineTime(oneCuration.getCreatedAt())))
3637
.collect(Collectors.toList());
3738
}
39+
40+
public CurationNumberGetResponseDto getCurationNumber() {
41+
Curation curation = curationRepository.findTop1ByOrderByCreatedAtDesc();
42+
return CurationNumberGetResponseDto.of(curation.getId());
43+
}
3844
}

WableServer/src/main/java/com/wable/www/WableServer/common/response/SuccessStatus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public enum SuccessStatus {
8888
/**
8989
* Viewit
9090
*/
91-
GET_CURATION_ALL_SUCCESS(HttpStatus.OK, "큐레이션 목록 조회 성공")
91+
GET_CURATION_ALL_SUCCESS(HttpStatus.OK, "큐레이션 목록 조회 성공"),
92+
GET_CURATION_NUMBER_SUCCESS(HttpStatus.OK, "최신 큐레이션 번호 조회 성공")
9293
;
9394

9495
private final HttpStatus httpStatus;

0 commit comments

Comments
 (0)