From 569da21edf0627f27d61832af621566c620baaae Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sun, 13 Aug 2023 20:43:55 +0800 Subject: [PATCH] docs: update for content --- _fixtures/java/api/0.json | 220 +++++++++++++++++++++++++ _fixtures/java/api/BlogController.java | 33 ++++ 2 files changed, 253 insertions(+) create mode 100644 _fixtures/java/api/0.json create mode 100644 _fixtures/java/api/BlogController.java diff --git a/_fixtures/java/api/0.json b/_fixtures/java/api/0.json new file mode 100644 index 0000000..15e0052 --- /dev/null +++ b/_fixtures/java/api/0.json @@ -0,0 +1,220 @@ +[ + { + "NodeName": "BlogController", + "Module": "root", + "Type": "CLASS", + "Functions": [ + { + "Name": "getAllBlogs", + "ReturnType": "ResponseEntity", + "FunctionCalls": [ + { + "Package": "org.springframework.http", + "Type": "CHAIN", + "NodeName": "ResponseEntity", + "FunctionName": "ok", + "Parameters": [ + { + "TypeValue": "\"List of all blogs\"", + "TypeType": "" + } + ], + "Position": { + "StartLine": 15, + "StartLinePosition": 30, + "StopLine": 15, + "StopLinePosition": 52 + } + } + ], + "Annotations": [ + { + "Name": "GetMapping" + }, + { + "Name": "ApiOperation", + "KeyValues": [ + { + "Key": "\"获取所有博客\"", + "Value": "\"获取所有博客\"" + } + ] + } + ], + "Position": { + "StartLine": 13, + "StartLinePosition": 11, + "StopLine": 16, + "StopLinePosition": 4 + }, + "BodyHash": 40602143 + }, + { + "Name": "createBlog", + "ReturnType": "ResponseEntity", + "Parameters": [ + { + "TypeValue": "blogContent", + "TypeType": "String" + } + ], + "FunctionCalls": [ + { + "Package": "org.springframework.http", + "Type": "CHAIN", + "NodeName": "ResponseEntity", + "FunctionName": "ok", + "Parameters": [ + { + "TypeValue": "\"Blog created successfully\"", + "TypeType": "" + } + ], + "Position": { + "StartLine": 22, + "StartLinePosition": 30, + "StopLine": 22, + "StopLinePosition": 60 + } + } + ], + "Annotations": [ + { + "Name": "PostMapping" + }, + { + "Name": "ApiOperation", + "KeyValues": [ + { + "Key": "\"创建新博客\"", + "Value": "\"创建新博客\"" + } + ] + } + ], + "Position": { + "StartLine": 20, + "StartLinePosition": 11, + "StopLine": 23, + "StopLinePosition": 4 + }, + "LocalVariables": [ + { + "TypeValue": "blogContent", + "TypeType": "String" + } + ], + "BodyHash": -129622863 + }, + { + "Name": "getBlogById", + "ReturnType": "ResponseEntity", + "Parameters": [ + { + "TypeValue": "id", + "TypeType": "Long" + } + ], + "FunctionCalls": [ + { + "Package": "org.springframework.http", + "Type": "CHAIN", + "NodeName": "ResponseEntity", + "FunctionName": "ok", + "Parameters": [ + { + "TypeValue": "\"Blog with ID \"+id", + "TypeType": "" + } + ], + "Position": { + "StartLine": 29, + "StartLinePosition": 30, + "StopLine": 29, + "StopLinePosition": 53 + } + } + ], + "Annotations": [ + { + "Name": "GetMapping", + "KeyValues": [ + { + "Key": "\"/{id}\"", + "Value": "\"/{id}\"" + } + ] + }, + { + "Name": "ApiOperation", + "KeyValues": [ + { + "Key": "\"获取指定ID的博客\"", + "Value": "\"获取指定ID的博客\"" + } + ] + } + ], + "Position": { + "StartLine": 27, + "StartLinePosition": 11, + "StopLine": 30, + "StopLinePosition": 4 + }, + "LocalVariables": [ + { + "TypeValue": "blogContent", + "TypeType": "String" + }, + { + "TypeValue": "id", + "TypeType": "Long" + } + ], + "BodyHash": -1220519629 + } + ], + "Annotations": [ + { + "Name": "RestController" + }, + { + "Name": "RequestMapping", + "KeyValues": [ + { + "Key": "\"/api/blogs\"", + "Value": "\"/api/blogs\"" + } + ] + }, + { + "Name": "Api", + "KeyValues": [ + { + "Key": "tags", + "Value": "\"博客管理\"" + } + ] + } + ], + "Imports": [ + { + "Source": "io.swagger.annotations.Api" + }, + { + "Source": "io.swagger.annotations.ApiOperation" + }, + { + "Source": "org.springframework.http.ResponseEntity" + }, + { + "Source": "org.springframework.web.bind.annotation" + } + ], + "Position": { + "StartLine": 9, + "StartLinePosition": 7, + "StopLine": 33 + } + } +] \ No newline at end of file diff --git a/_fixtures/java/api/BlogController.java b/_fixtures/java/api/BlogController.java new file mode 100644 index 0000000..42a53f7 --- /dev/null +++ b/_fixtures/java/api/BlogController.java @@ -0,0 +1,33 @@ +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/blogs") +@Api(tags = "博客管理") +public class BlogController { + + @GetMapping + @ApiOperation("获取所有博客") + public ResponseEntity getAllBlogs() { + // 从数据库或其他数据源获取博客列表的逻辑 + return ResponseEntity.ok("List of all blogs"); + } + + @PostMapping + @ApiOperation("创建新博客") + public ResponseEntity createBlog(@RequestBody String blogContent) { + // 解析请求中的博客内容,并将其保存到数据库的逻辑 + return ResponseEntity.ok("Blog created successfully"); + } + + @GetMapping("/{id}") + @ApiOperation("获取指定ID的博客") + public ResponseEntity getBlogById(@PathVariable Long id) { + // 根据ID从数据库中获取博客的逻辑 + return ResponseEntity.ok("Blog with ID " + id); + } + + // 可以添加其他操作,比如更新博客、删除博客等 +} \ No newline at end of file