Interface specification documents

I. Introduction

The system uses the document as a basis for swagger

 

Two landing

This system requires three landing 

Uuid transmits a verification code to the interface to the graphics needs to call upon a graphical interface call codes 

2 graphics need a verification code and send uuid username and password to log in with an interface / login

After 3 successful login / login and return access_token currently logged in user data

 

Three Permissions

Interface follows all the rules for

/ public /  beginning of interfaces for public interface does not require permission to directly access

/ api /  beginning of the interface need access interface 

Access / api / acquisition time required to carry landed in the header of the request when the interface at the beginning of access_token

Examples are as follows

Authorization:bearea c9290bf64e2704e499c0987e42261e53

Authorization which is key 

Wherein bearea c9290bf64e2704e499c0987e42261e53 value [bearea intermediate spaces]

 

Four return data

Interface has returned response format consistent format

{
    success:true //服务器返回正确还是错误

    code:900  //此处code为特殊逻辑 不常用 不能代表服务器返回状态

    data:{} //需要获取数据的接口 数据会放到 data中

    msg:""  //当提交成功,或者出现错误时,这里会打印信息

    timestamp:1256556666 //时间戳信息

}

 

Five request data

When the requested data if necessary submitting entity, in Swagger to see the need to submit the data structure

When describing the required use request descriptor get request, invoke methods in particular in the Swagger

 

Six CURD Interface

I mentioned here a lot CURD interface is fully compliant resful specification

Query using the GET method needs to acquire a single data path interface {id} is replaced by the actual ID

DELETE Delete embodiment using a single data needs to be deleted interface path {id} is replaced by the actual ID

Update using PUT way

New way of using POST

 

Seven paging and sorting

Method system, less than the default resful interface to get a list of pages in the document with the sort seen in a unified package supports pagination

Paging interface has three parameters

page: need to look at the first few pages defaults to 0 

size: a few lines of data to be displayed per page defaults to 10

Examples of the following page

/api/user?page=1&size=100

sort: Sorting the following examples

sort=id desc&sort=time asc

The interface is explained using positive sequence id reverse time manner and

Page data is returned as follows

"total": 2, 总数
"size": 2, 每页大小
"current": 1, 当前页面
"searchCount": true, 
"pages": 1 总页数


Eight client version control

We do not have version control and restraint in the current version supports client 

But it may begin to support the next version

 

Version control is also needed to increase the number of header request header parameters

version: The current software version number

system: the current software operating system

 

 

Nine front-end form validation

Type
Indicates the type of validator to use. Recognised type values are:

string: Must be of type string. This is the default type.
number: Must be of type number.
boolean: Must be of type boolean.
method: Must be of type function.
regexp: Must be an instance of RegExp or a string that does not generate an exception when creating a new RegExp.
integer: Must be of type number and an integer.
float: Must be of type number and a floating point number.
array: Must be an array as determined by Array.isArray.
object: Must be of type object and not Array.isArray.
enum: Value must exist in the enum.
date: Value must be valid as determined by Date
url: Must be of type url.
hex: Must be of type hex.
email: Must be of type email.

Select the class Form Notes

https://blog.csdn.net/winnershili/article/details/90269408

 

Nine, small micro-channel program call interface example

//GET
app.api.get('/public/area/getByPid',{params:{pid:37,id:100}}).then(res => {
    console.info(res);
})
//POST
app.api.post('/public/area', { name: 'admin',sex:1 }).then(res => {
    console.info(res);
})

//PUT
app.api.put('/public/sys_area', { name: 'admin', sex: 2 }).then(res => {
    console.info(res);
})

//REMOVE
app.api.remove('/public/sys_area', { params: { id:100 } }).then(res => {
    console.info(res);
})

Ten, AdminLTE control tab page

top.show_new_page('id','标题','想要打开的页面地址')
这个方法将会在当前tab的右侧 打开一个新的tab, 
第一参数id为tab的id 这个id的作用是 不会重复打开id相同的页面,
第二参数为tab显示的文本
第三参数为tab对应的地址

top.close_current_page()
会关闭当前正在使用的tab页面 

 

 

 

 

Guess you like

Origin blog.csdn.net/winnershili/article/details/89976911