前后端分离这块松哥之前写过多篇文章和大家聊,大部分文章我后来都整理在这个网站上了:http://vhr.javaboy.org
不过Coding永无止境,有的时候松哥也会在网上看到一些别人对于前后端分离的看法,有的感觉不错,就拿出来和大家分享下,今天这篇就是,以下是正文。
1. 前言
2. 为何要分离
3. 什么是分离
4. 如何做分离
4.1 职责分离
4.2 开发流程
4.3 具体实施
5. 接口规范V1.0.0
5.1 规范原则
5.2 基本格式
5.2.1 请求基本格式
GET请求:xxx/login?body={"username":"admin","password":"123456","captcha":"scfd","rememberMe":1}
POST请求:
5.2.2 响应基本格式{
code: 200,
data: {
message: "success"
}
}
5.3 响应实体格式{
code: 200,
data: {
message: "success",
entity: {
id: 1,
name: "XXX",
code: "XXX"
}
}
}
5.4 响应列表格式{
code: 200,
data: {
message: "success",
list: [
{
id: 1,
name: "XXX",
code: "XXX"
},
{
id: 2,
name: "XXX",
code: "XXX"
}
]
}
}
5.5 响应分页格式{
code: 200,
data: {
recordCount: 2,
message: "success",
totalCount: 2,
pageNo: 1,
pageSize: 10,
list: [
{
id: 1,
name: "XXX",
code: "H001"
},
{
id: 2,
name: "XXX",
code: "H001"
} ],
totalPage: 1
}
}
5.6 特殊内容规范
5.6.1 下拉框、复选框、单选框{
code: 200,
data: {
message: "success",
list: [{
id: 1,
name: "XXX",
code: "XXX",
isSelect: 1
}, {
id: 1,
name: "XXX",
code: "XXX",
isSelect: 0
}]
}
}
5.6.2 Boolean类型
5.6.3 日期类型
6. 未来的大前端
本文地址:https://www.jianshu.com/p/c81008b68350