10-博客api接口项目实战之接口文档

辰漪
2022-01-20 / 4 评论 / 93 阅读 / 正在检测是否收录...

title: 个人博客 v1.0.0
language_tabs:

  • shell: Shell
  • http: HTTP
  • javascript: JavaScript
  • ruby: Ruby
  • python: Python
  • php: PHP
  • java: Java
  • go: Go
    toc_footers: []

includes: []
search: true
highlight_theme: darkula
headingLevel: 2


个人博客

v1.0.0

Default

POST 登录

POST /api/login

Body 请求参数

type: object
properties:
  username:
    type: string
    description: 用户名
    example: admin
  password:
    type: string
    description: 密码
    example: "1314521999"
required:
  - username
  - password

请求参数

名称位置类型必选说明
bodybodyobjectfalsenone
» usernamebodystringtrue用户名
» passwordbodystringtrue密码

返回示例

成功

{
  "status": 0,
  "message": "登陆成功!",
  "userInfo": {
    "user_id": 15,
    "username": "admin",
    "password": "",
    "nickname": "辰漪",
    "user_pic": "https://wrz521.top:8080/uploads/art_cover-2021-09-13 16-56-36.png",
    "is_admin": 1,
    "is_use": 1,
    "reg_time": "2021-08-26T08:08:08.000Z"
  },
  "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxNSwidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiIiwibmlja25hbWUiOiLovrDmvKoiLCJ1c2VyX3BpYyI6Imh0dHBzOi8vd3J6NTIxLnRvcDo4MDgwL3VwbG9hZHMvYXJ0X2NvdmVyLTIwMjEtMDktMTMgMTYtNTYtMzYucG5nIiwiaXNfYWRtaW4iOjEsImlzX3VzZSI6MSwicmVnX3RpbWUiOiIyMDIxLTA4LTI2VDA4OjA4OjA4LjAwMFoiLCJpYXQiOjE2NDAxNDk4MjcsImV4cCI6MTY0MDE4NTgyN30.bXcGc-iMvVhICfF64EWpBZcQxETbkCFqWORnRgiCnCg"
}

返回结果

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenone是否成功 0 成功 1 失败
» messagestringtruenone说明信息
» userInfoobjecttruenone用户信息
»» user_idintegertruenone用户id
»» usernamestringtruenone用户名
»» passwordstringtruenone密码
»» nicknamestringtruenone昵称
»» user_picstringtruenone用户头像
»» is_adminintegertruenone是否管理员
»» is_useintegertruenone能否使用
»» reg_timestringtruenone注册时间
» tokenstringtruenonetoken

blog

GET 获取用户信息列表分页

GET /my/getUserListPage

请求参数

名称位置类型必选说明
fuzzyquerystringfalse查询字符串(通过username 或者 nickname)可以传空 获取全部
pageNumquerystringfalse当前页码(默认 1)
pageSizequerystringfalse每页显示条数(默认 10)
sortKeyquerystringfalse根据哪个字段排序
sortValuequerystringfalsedesc降序 asc升序
Authorizationheaderstringtruenone

返回示例

成功

{
  "status": 0,
  "msg": "获取用户列表成功!",
  "total": 6,
  "data": [
    {
      "user_id": 44,
      "username": "admin3",
      "nickname": "辰漪3",
      "user_pic": "3",
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-13T05:44:04.000Z"
    },
    {
      "user_id": 43,
      "username": "admin2",
      "nickname": "辰漪1",
      "user_pic": "1",
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-12T06:22:14.000Z"
    },
    {
      "user_id": 39,
      "username": "admin11561",
      "nickname": null,
      "user_pic": null,
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-11T07:25:21.000Z"
    },
    {
      "user_id": 30,
      "username": "admin1",
      "nickname": null,
      "user_pic": null,
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-11T06:44:05.000Z"
    },
    {
      "user_id": 26,
      "username": "admin",
      "nickname": null,
      "user_pic": null,
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-11T06:35:04.000Z"
    },
    {
      "user_id": 16,
      "username": "123",
      "nickname": null,
      "user_pic": null,
      "is_admin": 0,
      "is_use": 1,
      "reg_time": "2022-01-11T06:06:24.000Z"
    }
  ]
}

返回结果

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenonenone
» msgstringtruenonenone
» totalintegertruenonenone
» data[object]truenonenone
»» user_idintegertruenonenone
»» usernamestringtruenonenone
»» nicknamestring¦nulltruenonenone
»» user_picstring¦nulltruenonenone
»» is_adminintegertruenonenone
»» is_useintegertruenonenone
»» reg_timestringtruenonenone

POST 用户注册

POST /api/reguser

Body 请求参数

type: object
properties:
  username:
    type: string
    description: 用户名
  password:
    type: string
    description: 密码
required:
  - username
  - password

请求参数

名称位置类型必选说明
bodybodyobjectfalsenone
» usernamebodystringtrue用户名
» passwordbodystringtrue密码

返回示例

成功

{
  "status": 0,
  "msg": "注册成功!"
}

返回结果

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenonenone
» msgstringtruenonenone

POST 文件上传

POST /my/uploads

Body 请求参数

type: object
properties:
  avatar:
    type: string
    description: 要上传的文件信息
    format: binary

请求参数

名称位置类型必选说明
Authorizationheaderstringtrue身份认证
bodybodyobjectfalsenone
» avatarbodystring(binary)false要上传的文件信息

返回示例

成功

{
  "status": 0,
  "fileInfo": {
    "fieldname": "avatar",
    "originalname": "g.png",
    "encoding": "7bit",
    "mimetype": "image/png",
    "destination": "./uploads",
    "filename": "avatar-2022-01-20 14-43-33.png",
    "path": "/uploads/avatar-2022-01-20 14-43-33.png",
    "size": 19531
  },
  "msg": "上传成功!"
}

返回结果

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenonenone
» fileInfoobjecttruenonenone
»» fieldnamestringtruenonenone
»» originalnamestringtruenonenone
»» encodingstringtruenonenone
»» mimetypestringtruenonenone
»» destinationstringtruenonenone
»» filenamestringtruenonenone
»» pathstringtruenonenone
»» sizeintegertruenonenone
» msgstringtruenonenone

PUT 更新用户基本资料

PUT /my/updateInfo

Body 请求参数

type: object
properties:
  nickname:
    type: string
    description: 昵称
  user_pic:
    type: string
    description: 头像
  is_admin:
    type: string
    description: 是否管理员
  is_use:
    type: string
    description: 账号是否可用

请求参数

名称位置类型必选说明
user_idquerystringtrue用户id
Authorizationheaderstringtruetoken
bodybodyobjectfalsenone
» nicknamebodystringfalse昵称
» user_picbodystringfalse头像
» is_adminbodystringfalse是否管理员
» is_usebodystringfalse账号是否可用

返回示例

成功

{
  "status": 0,
  "msg": "修改成功!"
}

返回结果

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenonenone
» msgstringtruenonenone

PUT 修改密码

PUT /my/updatePwd

Body 请求参数

type: object
properties:
  currentPwd:
    type: string
    description: 当前密码
  editPwd:
    type: string
    description: 要修改的密码
  repeatPwd:
    type: string
    description: 重复密码
required:
  - currentPwd
  - editPwd
  - repeatPwd

请求参数

名称位置类型必选说明
user_idquerystringtrue用户id
Authorizationheaderstringtruetoken
bodybodyobjectfalsenone
» currentPwdbodystringtrue当前密码
» editPwdbodystringtrue要修改的密码
» repeatPwdbodystringtrue重复密码

返回示例

返回结果

状态码状态码含义说明数据模型
200OK失败Inline

返回数据结构

状态码 200

名称类型必选约束说明
» statusintegertruenonenone
» msgstringtruenonenone

数据模型

1
选择打赏方式:
微信

评论 (4)

取消
  1. 头像
    爱你的老婆
    Windows 10 · Google Chrome

    小哥哥写的太好了,怎么就不火,没有热度呢?

    回复
    1. 头像
      辰漪 作者
      Windows 10 · Google Chrome
      @ 爱你的老婆

      画图

      回复
      1. 头像
        爱你的老婆
        Windows 10 · Google Chrome
        @ 辰漪

        画图

        回复
        1. 头像
          辰漪 作者
          Windows 10 · Google Chrome
          @ 爱你的老婆

          不可以瑟瑟哦表情

          回复