Background Document Interface example

What is the interface documentation?

During the project, the front and rear end is separated from the development, in order to have consistency before and after, it is necessary to define a common interface consists of front and rear development engineers, interface documentation to write again to develop interfaces according to the document, until the end of the project.

Document Interface Specification

  • method

  That is, we often write add, delete, modify, query

  • url

  Calling method, is generally transferred from the front end of the rear end address method

  • Request parameter

  Generally divided into five: Field, description, type, notes, if required 

  • Return parameters

  1, the interface returns only if the call succeeds or fails (add, delete, modify, etc.), only one structure:

      and two message code parameters;

  2, if you want to return to some parameters, there are two structures:

      是code/mesage/data;

        Parameter data is written in return, data is object type;

  3, if you want to return a list, then there are three structures,

          A code / mesage / data, data is Object, which placed the page / size / total / totalPage / list 5 parameters, wherein the list is a type Arrary, put list object, object in a specific parameter.

OK purpose

  1. User login
  2. User Registration
  3. Tree Menu
  4. Article inquiry
  5. New Articles
  6. Text Revision
  7. Article Delete

User login:

  Interface calls and requests

http request method: POST (There are two kinds GET / POST)
 https://xxx.xxx.xxx:8080/ project named /vue/userAction_login.action
Field Explanation Types of Required
uname first name String Yes
pwd password String Yes

Login successful return JSON data packet:
{
     " Msg " : " Login successful " ,
     " the Result " : {
         " uname " : " username " ,
         " pwd " : " Password " 
    }, 
    " code " : 1 
}

Or user password is empty return JSON packet:

{    
    "msg":"用户或者密码为空",
    "result":{
        "uname":"用户名",
        "pwd":"密码"
    },
    "code":0
}

用户或者密码错误返回JSON数据包:

{
    "msg":"用户或者密码错误",
    "result":{
        "uname":"用户名",
        "pwd":"密码"
    },
    "code":0
}

参数

说明

msg

提示消息

result

返回登录的用户名和密码

code

状态 0:登录失败 1:登录成功

用户注册

  接口调用

https://xxx.xxx.xxx:8080/项目命名/vue/userAction_reg.action
字段 说明 类型 是否必填
uname 名字 String
pwd 密码 String

注册返回JSON数据包:

{
    "msg":"用户注册成功",
    "code":1
}

用户注册失败返回JSON数据包:

{
    "msg":"用户注册失败",
    "code":0
}
 
 

参数

说明

msg

提示消息

code

状态码 0:失败 1:成功

树形菜单

调用接口

https://xxx.xxx.xxx:8080/项目命名/vue/treeNodeAction.action

返回的json数据表如下:

{
    "msg": "操作成功",
    "result": [
        {
            "treeNodeId": 1,
            "treeNodeName": "系统管理",
            "treeNodeType": 1,
            "url": null,
            "position": 1,
            "icon": "el-icon-setting",
            "children": [
                {
                    "treeNodeId": 2,
                    "treeNodeName": "用户管理",
                    "treeNodeType": 2,
                    "url": "/sys/VuexPage1",
                    "position": 2,
                    "icon": "el-icon-user",
                    "children": []
                },
                {
                    "treeNodeId": 3,
                    "treeNodeName": "角色管理",
                    "treeNodeType": 2,
                    "url": "/sys/VuexPage2",
                    "position": 3,
                    "icon": "",
                    "children": []
                },
                {
                    "treeNodeId": 4,
                    "treeNodeName": "密码修改",
                    "treeNodeType": 2,
                    "url": null,
                    "position": 4,
                    "icon": null,
                    "children": []
                }
            ]
        },
        {
            "treeNodeId": 5,
            "treeNodeName": "论坛管理",
            "treeNodeType": 1,
            "url": null,
            "position": 5,
            "icon": "el-icon-reading",
            "children": [
                {
                    "treeNodeId": 6,
                    "treeNodeName": "文章管理",
                    "treeNodeType": 2,
                    "url": "/sys/Articles",
                    "position": 6,
                    "icon": null,
                    "children": []
                }
            ]
        }
    ],
    "code": 1
}

参数

说明

msg

提示消息

result

返回树形菜单结果集

code

状态 0:失败 1:成功

Result树形菜单结果集

参数

说明

treeNodeId

菜单id

treeNodeName

菜单名

treeNodeType

菜单类型 1:父菜单2:跳转菜单

url

路由地址

icon

菜单图标

children

子菜单集,如果没有则为一个空json数组

文章查询

调用接口

https://xxx.xxx.xxx:8080/项目命名/vue/articleAction_list.action

参数

是否必填

说明

page

当前页码,默认为1

rows

一页展示多少条数据,默认为10

title

按文章标题查询

返回json数据包说明:

{
    "result":[{"id":1,"title":"文章标题","body":"文章内容"],
    "pageBean":{
        "page":1,
        "rows":10,
        "total":100,
    }
}

result结果集

参数

说明

id

文章id

title

文章标题

body

文章内容

pageBean 分页对象说明

参数

说明

page

当前页码

rows

一页展示的条数

total

总条数

文章添加

调用接口

https://xxx.xxx.xxx:8080/项目命名/vue/articleAction_add.action

参数

是否必填

说明

title

文章标题

Body

文章内容

添加成功返回JSON数据包:

{"msg":"新增成功","result":[],"code":1}

添加失败返回JSON数据包:

{"msg":"新增失败","result":[],"code":0}

参数

说明

msg

提示消息

code

状态码 0:失败 1:成功

文章修改

调用接口

https://xxx.xxx.xxx:8080/项目命名/vue/articleAction_edit.action

参数

是否必须

说明

id

文章id

title

文章标题

body

文章内容

修改成功返回JSON数据包:

{"msg":"修改成功","code":1}

修改失败返回JSON数据包:

{"msg":"修改失败","code":0}

参数

说明

msg

提示消息

code

状态码 0:失败 1:成功

文章删除

调用接口

https://xxx.xxx.xxx:8080/项目命名/vue/articleAction_del.action

参数

是否必须

说明

id

文章id

删除成功返回JSON数据包:

{"msg":"删除成功","code":1}

删除失败返回JSON数据包:

{"msg":"删除失败","code":0}

参数

说明

msg

提示消息

code

状态码 0:失败 1:成功

 

 

谢谢观看!

Guess you like

Origin www.cnblogs.com/huangting/p/11371951.html