Github地址
https://github.com/EDDYCJY/go-gin-example
返回值
字段:code、msg、data
舉例
# 失敗 { "code": 10001, "msg": "已存在該標簽名稱", "data": null } #成功 { "code": 200, "msg": "ok", "data": null }
接口列表
模塊 | 接口 | 功能 | 協議 | 參數 | 返回值 | 示例 | 問題-備注 |
認證 | /auth | GET | username password |
{"code":200,"msg":"ok","data":{"token":"eyJhbGd24ciO"}} |
apiv1.Use(jwt.JWT()) 使用jwt身份驗證時,每個接口訪問是都需要加上token驗證 |
||
/swagger/index.html | 自動生成接口文檔 | GET | 安裝: go get *** 生成:swag init 訪問:http://127.0.0.1:8080/swagger/index.html 類型不識別// @Param file body file true "Excel File" |
||||
/upload | POST | ? | |||||
標簽
|
/api/v1/tags | 獲取 | GET | name state |
{ "code": 200, |
modle 與 db table 如何關聯 | |
/api/v1/tags | 添加 | POST | name created_by state |
{ |
|||
/api/v1/tags/id | 修改 | PUT | name modified_by state |
||||
/api/v1/tags/id | 刪除 | DELETE | |||||
/tags/export | 導出 | POST | name state |
||||
/tags/import | 導入 | POST | file文件 | ||||
文件 | /api/v1/articles | 列表 | GET | state tag_id |
傳入參數,因是post獲取,無法解析 | ||
/api/v1/articles/id | 指定列表 | GET | |||||
/api/v1/articles | 新建 | POST | tag_id title desc content created_by state cover_image_url |
{ "code": 200, |
校驗參數如何關聯的? [通過form] |
||
/api/v1/articles/id | 更新 | PUT | id tag_id title desc content modified_by state cover_image_url |
有必要傳所有參數嗎? | |||
/api/v1/articles/id | 刪除 | DELETE | { "code": 200, |
刪除了deleted_on賦值,不物理刪除 | |||
/api/v1/articles/poster/generate | 生成海報 | POST |