Skip to content

Commit 85e2c41

Browse files
committed
feat: 마이페이지 댓글 히스토리 API 추가
1 parent 493ac99 commit 85e2c41

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.back.domain.myhistory.controller;
2+
3+
import com.back.domain.myhistory.dto.MyHistoryCommentGoResponseDto;
4+
import com.back.domain.myhistory.dto.MyHistoryCommentListDto;
5+
import com.back.domain.myhistory.dto.MyHistoryPostListDto;
6+
import com.back.domain.myhistory.service.MyHistoryService;
7+
import com.back.global.rsData.RsData;
8+
import jakarta.validation.constraints.Max;
9+
import jakarta.validation.constraints.Min;
10+
import lombok.RequiredArgsConstructor;
11+
import org.springframework.format.annotation.DateTimeFormat;
12+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
13+
import org.springframework.validation.annotation.Validated;
14+
import org.springframework.web.bind.annotation.*;
15+
16+
import java.time.LocalDateTime;
17+
18+
@RestController
19+
@RequestMapping("/api/me")
20+
@RequiredArgsConstructor
21+
@Validated
22+
public class MyHistoryController {
23+
24+
private final MyHistoryService myHistoryService;
25+
26+
@GetMapping("/posts")
27+
public RsData<MyHistoryPostListDto> getMyPosts(
28+
@AuthenticationPrincipal(expression = "id") Long userId,
29+
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt,
30+
@RequestParam(required = false) Long lastId,
31+
@RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit
32+
) {
33+
MyHistoryPostListDto body = myHistoryService.getMyPosts(userId, lastCreatedAt, lastId, limit);
34+
return RsData.successOf(body);
35+
}
36+
37+
@GetMapping("/comments")
38+
public RsData<MyHistoryCommentListDto> getMyComments(
39+
@AuthenticationPrincipal(expression = "id") Long userId,
40+
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt,
41+
@RequestParam(required = false) Long lastId,
42+
@RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit
43+
) {
44+
MyHistoryCommentListDto body = myHistoryService.getMyComments(userId, lastCreatedAt, lastId, limit);
45+
return RsData.successOf(body);
46+
}
47+
48+
@GetMapping("/comments/{id}")
49+
public RsData<MyHistoryCommentGoResponseDto> goFromComment(
50+
@AuthenticationPrincipal(expression = "id") Long userId,
51+
@PathVariable("id") Long commentId
52+
) {
53+
var body = myHistoryService.getPostLinkFromMyComment(userId, commentId);
54+
return RsData.successOf(body);
55+
}
56+
}
57+

0 commit comments

Comments
 (0)