|
|
@@ -13,6 +13,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -195,9 +197,27 @@ public class ArticleController {
|
|
|
|
|
|
@PostMapping("/my-posts")
|
|
|
public Result<Page<Article>> myPosts(@RequestBody Map<String, Object> body,
|
|
|
- @RequestAttribute("userId") Long userId) {
|
|
|
+ @RequestAttribute("userId") Long userId) {
|
|
|
int page = body.get("page") != null ? Integer.parseInt(body.get("page").toString()) : 1;
|
|
|
int size = body.get("size") != null ? Integer.parseInt(body.get("size").toString()) : 20;
|
|
|
return Result.success(articleService.getMyPosts(userId, page, size));
|
|
|
}
|
|
|
+
|
|
|
+ @Operation(summary = "增量查询文章(RAG)")
|
|
|
+ @PostMapping("/updated-since")
|
|
|
+ public Result<List<Article>> updatedSince(@RequestBody Map<String, Object> body) {
|
|
|
+ String since = (String) body.get("since");
|
|
|
+ String status = (String) body.get("status");
|
|
|
+ if (since == null || since.trim().isEmpty()) {
|
|
|
+ return Result.error("since 参数不能为空");
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
+ Date sinceDate;
|
|
|
+ try {
|
|
|
+ sinceDate = sdf.parse(since);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("since 格式无效,请使用 ISO 8601 格式");
|
|
|
+ }
|
|
|
+ return Result.success(articleService.getUpdatedSince(sinceDate, status));
|
|
|
+ }
|
|
|
}
|