员工工资管理系统的接口设计
时间: 2023-05-29 07:07:49 浏览: 66
1. 登录接口
URL:/api/login
Method:POST
Request:
{
"username": "xxx",
"password": "xxx"
}
Response:
{
"code": 200,
"msg": "登录成功",
"data": {
"token": "xxx",
"user_id": "xxx",
"username": "xxx"
}
}
2. 获取员工列表接口
URL:/api/employees
Method:GET
Request:
{
"page": 1,
"limit": 10,
"keyword": "xxx"
}
Response:
{
"code": 200,
"msg": "获取员工列表成功",
"data": {
"total": 100,
"list": [
{
"id": "xxx",
"name": "xxx",
"department": "xxx",
"position": "xxx",
"salary": "xxx"
},
...
]
}
}
3. 新增员工接口
URL:/api/employees
Method:POST
Request:
{
"name": "xxx",
"department": "xxx",
"position": "xxx",
"salary": "xxx"
}
Response:
{
"code": 200,
"msg": "新增员工成功",
"data": {
"id": "xxx",
"name": "xxx",
"department": "xxx",
"position": "xxx",
"salary": "xxx"
}
}
4. 修改员工接口
URL:/api/employees/:id
Method:PUT
Request:
{
"name": "xxx",
"department": "xxx",
"position": "xxx",
"salary": "xxx"
}
Response:
{
"code": 200,
"msg": "修改员工成功",
"data": {
"id": "xxx",
"name": "xxx",
"department": "xxx",
"position": "xxx",
"salary": "xxx"
}
}
5. 删除员工接口
URL:/api/employees/:id
Method:DELETE
Response:
{
"code": 200,
"msg": "删除员工成功",
"data": null
}