Appearance
POST
/chatx/moments/comment/add
application/json
operationID
token
userID
replyToCommentID
0
postID
content
commentID
header must have operationID
token is empty
postID and userID are required
content is required
fetch("http://localhost:10010/chatx/moments/comment/add", { method: "POST", headers: { operationID: "moments-comment-add-001", token: "user-token", "Content-Type": "application/json", }, body: JSON.stringify({ postID: "p_10001", replyToCommentID: "", content: "收到,安排。", }), }) .then((res) => res.json()) .then((data) => console.log(data));
{ "postID": "p_10001", "replyToCommentID": "", "content": "收到,安排。" }
{ "errCode": 0, "errMsg": "", "errDlt": "", "data": { "comment": { "commentID": "ad01e8d7-4d0b-44c1-b4c2-1c4e53280511", "postID": "p_10001", "userID": "u_1002", "replyToCommentID": "", "content": "收到,安排。", "createTime": 1774920400000, "commenter": { "userID": "u_1002", "nickname": "Bob", "faceURL": "https://cdn.example.com/avatar/b.png" } } } }
{ "errCode": 1001, "errMsg": "ArgsError", "errDlt": "content is required" }
添加评论
1. 接口定位
2. 请求定义
POST/chatx/moments/comment/addapplication/jsonoperationID传入token传入有效登录令牌3. 请求参数
Header 参数
Body 参数
字段说明
userID注入请求体,客户端无需传入。replyToCommentID,在本链路里没有看到对该评论是否存在、是否属于同一动态的额外校验。4. 响应结构
通用响应包裹
0表示成功data 字段
comment 对象
commenter 对象
5. 业务规则
token。postID、userID、content都存在。commentID。6. 错误码与失败场景
operationIDheader must have operationIDtokentoken is emptypostID为空postID and userID are requiredcontent为空content is required7. 示例
fetch 请求示例
请求示例(JSON)
成功响应示例
失败响应示例
8. 时序流程
operationID和token。userID注入请求。postID、userID和content。commentID并写入评论。9. 变更记录