[关闭]
@zhongjianxin 2018-11-27T00:25:40.000000Z 字数 2287 阅读 854

REST API Practice - Tell Good API

OOCL


Function-driven vs Data-driven

As a Author UI i want to crate a Post so that i can see all posts and read indicated post content later

Create a post

  1. http//api.blog.com/createPost
  2. body: {tittle: "my article", {content: "my article bit content"}}
  1. POST http//api.blog.com/Posts
  2. body: {tittle: "my article", {content: "my article bit content"}}

Get all posts List

  1. http//api.blog.com/getPostList
  1. GET http//api.blog.com/Posts

Get a indicated post

  1. http//api.blog.com/getPostById?id=3
  1. GET http//api.blog.com/Posts/3

As a Author i want to delete a indicated post directly

  1. http//api.blog.com/deletePostById?id=3
  1. DETELE http//api.blog.com/Posts/3

As a Author i want to update content of a indicated post

  1. http//api.blog.com/updatePostById?id=3
  1. PUT http//api.blog.com/Posts/3

As a Reader i want to comment the indicated post

  1. http//api.blog.com/addCommentToPostById
  2. body: {postId: "3", tittle: "my article", {content: "my article bit content"}}
  1. POST http//api.blog.com/Posts/3/Comments
  2. body: {tittle: "my article", {content: "my article bit content"}}

As a Reader i want to see all comments in a indicated post

  1. http//api.blog.com/getAllCommentsByPostId?postId=3
  2. body: {postId: 3, content: "my comments"}
  1. POST http//api.blog.com/Posts/3/Comments
  2. body: {content: "all comments for this post"}

As a Manager i want to delete indicated comment in any post

  1. http//api.blog.com/deleteCommentsByPostIdAndCommentId?postId=3&commentId=2
  1. DELETET http//api.blog.com/Posts/3/Comments/2

As a Reader i want to update indicated comment in any post

  1. http//api.blog.com/updateCommentsByPostIdAndCommentId?postId=3&commentId=2
  2. body: {content: "update this comment"}
  1. PUT http//api.blog.com/Posts/3/Comments/2
  2. body: {content: "update this comment"}

As a Manager i can help vip author create a post and assign the post to this author

  1. http//api.blog.com/createPostForIndicateAuthorByManager?AuthorId=2&ManagerId=1
  2. body: {tittle: "my article", {content: "my article bit content"}}
  1. POST http//api.blog.com/Authors/2/Posts
  2. body: {tittle: "my article", {content: "my article bit content"}}

As a Author i can create a post by myself

  1. http//api.blog.com/createPostByAuthor?AuthorId=2
  2. body: {tittle: "my article", {content: "my article bit content"}}
  1. POST http//api.blog.com/Authors/2/Posts
  2. body: {tittle: "my article", {content: "my article bit content"}}

As a manager i can get pagable comments belong to a indicate author

  1. http//api.blog.com/getAllCommentsByAuthorId?AuthorId=2&page=1&pageSize=10
  1. GET http//api.blog.com/Authors/2/Comments?page=1&pageSize=10
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注