提交 9838b8f3 编写于 作者: yubinCloud's avatar yubinCloud

完善了 DocController 的Swagger注释

上级 1a71c2ae
...@@ -8,12 +8,16 @@ import io.github.yubincloud.fairywiki.dto.resp.ErrorCode; ...@@ -8,12 +8,16 @@ import io.github.yubincloud.fairywiki.dto.resp.ErrorCode;
import io.github.yubincloud.fairywiki.dto.resp.PageRespDto; import io.github.yubincloud.fairywiki.dto.resp.PageRespDto;
import io.github.yubincloud.fairywiki.dto.resp.RestfulModel; import io.github.yubincloud.fairywiki.dto.resp.RestfulModel;
import io.github.yubincloud.fairywiki.service.DocService; import io.github.yubincloud.fairywiki.service.DocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
@Api("文档管理")
@RestController @RestController
@RequestMapping("/doc") @RequestMapping("/doc")
public class DocController { public class DocController {
...@@ -21,10 +25,9 @@ public class DocController { ...@@ -21,10 +25,9 @@ public class DocController {
@Resource @Resource
private DocService docService; private DocService docService;
/**
* 获取全部 Doc 的接口
*/
@GetMapping("/query/{ebookId}") @GetMapping("/query/{ebookId}")
@ApiOperation(value = "获取属于某个 ebook 的全部 doc ")
public RestfulModel<List<DocQueryRespDto>> queryDocs(@PathVariable Long ebookId) { public RestfulModel<List<DocQueryRespDto>> queryDocs(@PathVariable Long ebookId) {
List<DocQueryRespDto> docList = docService.queryDocs(ebookId); List<DocQueryRespDto> docList = docService.queryDocs(ebookId);
return new RestfulModel<>(ErrorCode.SUCCESS, "", docList); return new RestfulModel<>(ErrorCode.SUCCESS, "", docList);
...@@ -41,27 +44,25 @@ public class DocController { ...@@ -41,27 +44,25 @@ public class DocController {
return new RestfulModel<>(ErrorCode.SUCCESS, "", bookList); return new RestfulModel<>(ErrorCode.SUCCESS, "", bookList);
} }
/**
* 根据请求的参数保存一个 doc,若id非空则为更新,否则为新增
*/
@PostMapping("/save") @PostMapping("/save")
@ApiOperation(value = "保存一个 doc",
notes = "若id非空则为更新,否则为新增")
public RestfulModel<Integer> saveDoc(@RequestBody @Valid DocSaveReqDto docSaveReqDto) { public RestfulModel<Integer> saveDoc(@RequestBody @Valid DocSaveReqDto docSaveReqDto) {
docService.save(docSaveReqDto); docService.save(docSaveReqDto);
return new RestfulModel<>(ErrorCode.SUCCESS, "", 0); return new RestfulModel<>(ErrorCode.SUCCESS, "", 0);
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")
@ApiOperation(value = "删除一个 doc")
public RestfulModel<Integer> deleteDoc(@RequestBody @Valid DocDeleteReqDto docDeleteReqDto) { public RestfulModel<Integer> deleteDoc(@RequestBody @Valid DocDeleteReqDto docDeleteReqDto) {
docService.deleteDocs(docDeleteReqDto.getIds()); docService.deleteDocs(docDeleteReqDto.getIds());
return new RestfulModel<>(ErrorCode.SUCCESS, "", 0); return new RestfulModel<>(ErrorCode.SUCCESS, "", 0);
} }
/**
* 读取文档的内容
* @param docId 所要读取的文档的 id
* @return 读取到的内容
*/
@GetMapping("/read-content/{docId}") @GetMapping("/read-content/{docId}")
@ApiOperation(value = "读取文档的内容", notes = "同时会对该文档的阅读数 + 1")
@ApiParam(name = "docId", value = "文档的id", required = true)
public RestfulModel<String> readDocContent(@PathVariable Long docId) { public RestfulModel<String> readDocContent(@PathVariable Long docId) {
String docContent = docService.readDocContent(docId); String docContent = docService.readDocContent(docId);
return new RestfulModel<>(0, "", docContent); return new RestfulModel<>(0, "", docContent);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册