198c761063
ShopProfile 补上 allowMultiShop/allowIndependentOrders/dispatchMode,Post 补上 pinned/linkedOrderId。这些字段在 RPC proto、数据库和写入逻辑中均已存在,但 API 响应类型和映射函数遗漏了它们。同时补回 community.api 中 CreateCommentReq 的 PostId 字段定义。
121 lines
2.8 KiB
Plaintext
121 lines
2.8 KiB
Plaintext
syntax = "v1"
|
|
|
|
import "common.api"
|
|
|
|
type (
|
|
PathId {
|
|
Id int64 `path:"id"`
|
|
}
|
|
Post {
|
|
Id int64 `json:"id"`
|
|
Title string `json:"title"`
|
|
Content string `json:"content"`
|
|
Images []string `json:"images"`
|
|
Tags []string `json:"tags"`
|
|
LinkedOrderId int64 `json:"linkedOrderId,optional"`
|
|
Pinned bool `json:"pinned"`
|
|
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 int64 `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 {
|
|
PostId int64 `json:"-"`
|
|
Content string `json:"content"`
|
|
}
|
|
ListCommentsReq {
|
|
PathId
|
|
PageReq
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: api/v1
|
|
group: community
|
|
)
|
|
service community-api {
|
|
@doc "获取帖子列表"
|
|
@handler ListPosts
|
|
get /posts (PostListReq) returns (PostListResp)
|
|
|
|
@doc "获取帖子详情"
|
|
@handler GetPost
|
|
get /posts/:id (PathId) returns (Post)
|
|
|
|
@doc "获取帖子评论"
|
|
@handler ListComments
|
|
get /posts/:id/comments (ListCommentsReq) returns (CommentListResp)
|
|
|
|
@doc "获取用户帖子"
|
|
@handler ListUserPosts
|
|
get /users/:id/posts (ListCommentsReq) returns (PostListResp)
|
|
}
|
|
|
|
@server (
|
|
prefix: api/v1
|
|
group: community
|
|
)
|
|
service community-api {
|
|
@doc "发布帖子"
|
|
@handler CreatePost
|
|
post /posts (CreatePostReq) returns (Post)
|
|
|
|
@doc "点赞帖子"
|
|
@handler LikePost
|
|
post /posts/:id/like (PathId) returns (EmptyResp)
|
|
|
|
@doc "取消点赞帖子"
|
|
@handler UnlikePost
|
|
delete /posts/:id/like (PathId) returns (EmptyResp)
|
|
|
|
@doc "置顶帖子"
|
|
@handler PinPost
|
|
post /posts/:id/pin (PathId) returns (EmptyResp)
|
|
|
|
@doc "取消置顶"
|
|
@handler UnpinPost
|
|
delete /posts/:id/pin (PathId) returns (EmptyResp)
|
|
|
|
@doc "发表评论"
|
|
@handler CreateComment
|
|
post /posts/:id/comments (CreateCommentReq) returns (Comment)
|
|
|
|
@doc "点赞评论"
|
|
@handler LikeComment
|
|
post /comments/:id/like (PathId) returns (EmptyResp)
|
|
|
|
@doc "取消点赞评论"
|
|
@handler UnlikeComment
|
|
delete /comments/:id/like (PathId) returns (EmptyResp)
|
|
}
|
|
|