Skip to content

Commit 3ad9c68

Browse files
authored
Merge pull request #97 from Team-Wable/feat/#93
[FEAT] get newest curation Id api
2 parents 7474e1a + e7da211 commit 3ad9c68

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
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
}

WableServer/src/main/java/com/wable/www/WableServer/api/curation/dto/response/CurationGetAllResponseDto.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44
import com.wable.www.WableServer.api.member.domain.Member;
55

66
public record CurationGetAllResponseDto(
7-
Long memberId,
8-
String memberProfileUrl,
9-
String memberNickname,
107
Long curationId,
118
String curationLink,
129
String time
1310
) {
14-
public static CurationGetAllResponseDto of(Member member, Curation curation, String time) {
11+
public static CurationGetAllResponseDto of(Curation curation, String time) {
1512
return new CurationGetAllResponseDto(
16-
member.getId(),
17-
member.getProfileUrl(),
18-
member.getNickname(),
1913
curation.getId(),
2014
curation.getCurationLink(),
2115
time
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
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;
6-
import com.wable.www.WableServer.api.member.repository.MemberRepository;
77
import com.wable.www.WableServer.common.util.TimeUtilCustom;
88
import lombok.RequiredArgsConstructor;
99
import org.springframework.data.domain.PageRequest;
@@ -18,7 +18,6 @@
1818
@RequiredArgsConstructor
1919
@Transactional(readOnly = true)
2020
public class CurationQueryService {
21-
private final MemberRepository memberRepository;
2221
private final CurationRepository curationRepository;
2322

2423
public List<CurationGetAllResponseDto> getCurationAll(Long memberId, Long cursor) {
@@ -33,9 +32,13 @@ public List<CurationGetAllResponseDto> getCurationAll(Long memberId, Long cursor
3332

3433
return curationList.stream()
3534
.map(oneCuration -> CurationGetAllResponseDto.of(
36-
memberRepository.findMemberByIdOrThrow(oneCuration.getMemberId()),
3735
oneCuration,
3836
TimeUtilCustom.refineTime(oneCuration.getCreatedAt())))
3937
.collect(Collectors.toList());
4038
}
39+
40+
public CurationNumberGetResponseDto getCurationNumber() {
41+
Curation curation = curationRepository.findTop1ByOrderByCreatedAtDesc();
42+
return CurationNumberGetResponseDto.of(curation.getId());
43+
}
4144
}

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)