Files
v2/code_meaning.md
2026-02-01 13:24:10 +08:00

45 lines
1.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 前言
为了使Sycamore_whisper项目的后端更易于使用在v1->v2时决定统一api返回格式
{
"code":1000,
"data":{
"text1":"1",
"text2":"2",
"list":["1", "2"]
}
}
你可能已经注意到了新增的**code**字段,这样做的目的是为了**更清晰地让前端判断操作状态**而不是单纯通过http状态码或字段OKFail来判断。
编写本文是为了方便开发或调用api时理解code的含义统一code标准。
**需要注意的是code只是为了更清晰地定位后端报错而不是为了替代http状态码所以也请注意不要给每个请求都是用200 OK状态码。**
# 正文
| Code | 含义 |
| ---- | ---------------------------------------------------- |
| 1000 | 正常。适用于大多数成功的请求的返回。 |
| 1002 | 正常。提交内容需要等待审核。 |
| 2000 | 失败。请求格式错误,例如缺少指定参数。 |
| 2001 | 失败。未初始化。不应该在成功初始化后继续使用该code。 |
| 2002 | 失败。数据不存在。 |
| 2003 | 失败。服务器内部错误。表示未预期的服务端异常,不应频繁出现。 |
| 2004 | 失败。试图使用不存在的Identity。 |
| 2005 | 失败。提交内容包含违禁词。 |
| 2006 | 失败。上传的图片超出限制大小。 |
| 2007 | 失败。上传的图片类型不支持。 |
| 2008 | 失败。上传的图片损坏。 |
| | |
| | |
| | |
| | |