add: some user api and all api desc
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
syntax = "v1"
|
||||
import "common.api"
|
||||
|
||||
type (
|
||||
Post {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
Liked bool `json:"liked"`
|
||||
Author UserProfile `json:"author"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
CreatePostReq {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LinkedOrderId string `json:"linkedOrderId,optional"`
|
||||
}
|
||||
|
||||
PostListReq {
|
||||
PageReq
|
||||
Tags string `form:"tags,optional"`
|
||||
SortBy string `form:"sortBy,optional"`
|
||||
}
|
||||
|
||||
PostListResp {
|
||||
Items []Post `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
|
||||
Comment {
|
||||
Id string `json:"id"`
|
||||
Content string `json:"content"`
|
||||
Author UserProfile `json:"author"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
Liked bool `json:"liked"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
CommentListResp {
|
||||
Items []Comment `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
|
||||
CreateCommentReq {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
)
|
||||
|
||||
@server(
|
||||
prefix: api/v1
|
||||
group: community
|
||||
)
|
||||
service juwan-api {
|
||||
@doc "获取帖子列表"
|
||||
@handler ListPosts
|
||||
get /posts (PostListReq) returns (PostListResp)
|
||||
|
||||
@doc "获取帖子详情"
|
||||
@handler GetPost
|
||||
get /posts/:id (EmptyResp) returns (Post)
|
||||
|
||||
@doc "获取帖子评论"
|
||||
@handler ListComments
|
||||
get /posts/:id/comments (PageReq) returns (CommentListResp)
|
||||
|
||||
@doc "获取用户帖子"
|
||||
@handler ListUserPosts
|
||||
get /users/:id/posts (PageReq) returns (PostListResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
prefix: api/v1
|
||||
group: community
|
||||
jwt: Auth
|
||||
)
|
||||
service juwan-api {
|
||||
@doc "发布帖子"
|
||||
@handler CreatePost
|
||||
post /posts (CreatePostReq) returns (Post)
|
||||
|
||||
@doc "点赞帖子"
|
||||
@handler LikePost
|
||||
post /posts/:id/like (EmptyResp) returns (EmptyResp)
|
||||
|
||||
@doc "取消点赞帖子"
|
||||
@handler UnlikePost
|
||||
delete /posts/:id/like (EmptyResp) returns (EmptyResp)
|
||||
|
||||
@doc "置顶帖子"
|
||||
@handler PinPost
|
||||
post /posts/:id/pin (EmptyResp) returns (EmptyResp)
|
||||
|
||||
@doc "取消置顶"
|
||||
@handler UnpinPost
|
||||
delete /posts/:id/pin (EmptyResp) returns (EmptyResp)
|
||||
|
||||
@doc "发表评论"
|
||||
@handler CreateComment
|
||||
post /posts/:id/comments (CreateCommentReq) returns (Comment)
|
||||
|
||||
@doc "点赞评论"
|
||||
@handler LikeComment
|
||||
post /comments/:id/like (EmptyResp) returns (EmptyResp)
|
||||
|
||||
@doc "取消点赞评论"
|
||||
@handler UnlikeComment
|
||||
delete /comments/:id/like (EmptyResp) returns (EmptyResp)
|
||||
}
|
||||
Reference in New Issue
Block a user