Skip to content

Commit 14c1bb2

Browse files
committed
feat: 마이페이지 게시글 목록 조회 API 구현
1 parent 5cd70ff commit 14c1bb2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.back.domain.history.controller;
2+
3+
import com.back.domain.history.dto.HistoryPostListDto;
4+
import com.back.domain.history.service.HistoryService;
5+
import com.back.global.rsData.RsData;
6+
import jakarta.validation.constraints.Max;
7+
import jakarta.validation.constraints.Min;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.format.annotation.DateTimeFormat;
10+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
11+
import org.springframework.validation.annotation.Validated;
12+
import org.springframework.web.bind.annotation.GetMapping;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestParam;
15+
import org.springframework.web.bind.annotation.RestController;
16+
17+
import java.time.LocalDateTime;
18+
19+
@RestController
20+
@RequestMapping("/api/me")
21+
@RequiredArgsConstructor
22+
@Validated
23+
public class MyHistoryController {
24+
25+
private final HistoryService historyService;
26+
27+
@GetMapping("/posts")
28+
public RsData<HistoryPostListDto> getMyPosts(
29+
@AuthenticationPrincipal(expression = "id") Long userId,
30+
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt,
31+
@RequestParam(required = false) Long lastId,
32+
@RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit
33+
) {
34+
HistoryPostListDto body = historyService.getMyPosts(userId, lastCreatedAt, lastId, limit);
35+
return RsData.successOf(body);
36+
}
37+
}
38+

0 commit comments

Comments
 (0)