管理员端API——任仲行
- 管理员登录
Request
{
"name": 张三,
"password_hash": awgyu223
}
Response
{
"error":null
"data":{
"state_code":0, // 0-成功,-1-用户名不存在,1-密码不正确
"id_admin": 139179
"role_name": "admin1"
}
}
Request
{
"page":1
"items_per_page":10
}
Response
{
"error":null
"data":{
"total_pages"=10
"current_page"=1
stuffs: [{
"id": 1234556,
"name": nkcs1612941,
"role_name": "teacher",
"user_status": “normal”
}]
}
}
Request
{
"id":xxxxxxx
}
Response
{
"error":null
"data":{
stuffs: {
"id": 1234556,
“gender”:“女”,
"name": nkcs1612941,
"role_name": "teacher1",
"user_status": “normal”
}
}
}
Request
{
stuff: {
"id": 1612841
"name": nkcs1612941,
"role_name": "teacher",
"gender": "女",
"user_status":"normal"
}
}
Response
{
"error":null
"data":{
"state_code":0 // 0-添加职工成功,-1-添加职工失败
}
}
Request
{
stuff: {
"id": 1612841
"name": nkcs1612941,
"id_role": "teacher",
"gender": "女",
"user_status":"normal"
}
}
Response
{
"error":null
"data":{
"state_code":0 // 0-修改职工成功,-1-修改职工失败
}
}
Request
{
"id":xxxxxxx
}
Response
{
"error":null
"data":{
"state_code":0 // 0-删除职工成功,-1-删除职工失败
}
}
Request
{
"page":1
"items_per_page":10
"search_items":{
"id":“xxxxx”,
"account":xxxxxx,
"nick_name":xxxxxx,
"state":xxxxxx,
“gender”:“女”
}
}
Response
{
"error":null
"data":{
"total_pages":10
"current_page"=1
students: [{
"id": “1234556”,
"name": “nkcs1612941”,
“gender”:“女”,
"user_status": “normal”
}]
}
}
Request
{
"id_student": “139179”
}
Response
{
"error":null
"data":{
student: {
"id": “1234556”,
“gender”:“女”,
"name": “nkcs1612941”,
"class”:2,
"province":1,
"user_status": “normal”,
"room":415
}
}
}
Request
{
students: {
"id_student": “1234556”,
“gender”:“女”,
"nickname":XXXX,
"name": “nkcs1612941”,
"class”:“class3”,
"province":1,
"user_status": “normal”,
"room":415
}
}
Response
{
"error":null
"data":{
"state_code":0 // 0-添加学生成功,-1-添加学生失败
}
}
Request
{
student: {
"id_student": “123456”,
“gender”:“女”,
"name": “nkcs1612941”,
"class”:“class3”,
"province":1,
"user_status": “normal”,
"room":“415”
}
}
Response
{
"error":null
"data":{
"state_code":0 // 0-修改学生成功,-1-修改学生失败
}
}
Request
{
"id":xxxxxxx
}
Response
{
"error":null
"data":{
"state_code":0 // 0-删除学生成功,-1-删除学生失败
}
}
Request
{
distribution:[{
"id_user": 1612841
"id_role":23
}]
}
Response
{
"error":null
"data":{
"state_code":0 // 0-角色分配成功,-1-角色分配失败
}
}
Request
{
"items_per_page":10
"page":1
"search_request":{
"role_id":xxxxxx,
"role_name":xxxxxx,
"role_description":xxxxxx
}
}
Response
{
"error":null
"data":{
"current_page"=1
"total_pages":10
roles: [{
"id_role": 1234556,
"name": "adman1",
“description”:"This is a ...",
"role_number": 100
}]
}
}
Request
{
"id_role": 123
"permission": [
”id_permission”:123
}]
"name":"admin1"
"description":"This is a..."
}
Response
{
"error":null
"data":{
"state_code":0 // 0-添加角色成功,-1-添加角色失败
}
}
Request
{
"id_role": 139179
}
Response
{
"error":null
"data":{
"role": {
"id_role": 12346,
"name”:"admin1",
"description":"This is a..."
"permission": [
”id_permission”:123
]
}
}
}
Request
{
role: {
"id_role": 12346,
"name”:"admin1",
"description":"This is a..."
"permission": [
”id_permission”:123
}]
}
}
Response
{
"error":null
"data":{
"state_code":0 // 0-修改角色成功,-1-修改角色失败
}
}
Request
{
"id":xxxxxxx
}
Response
{
"error":null
"data":{
"state_code":0 // 0-删除角色成功,-1-删除角色失败
}
}
Request
{
users: [{
"user_id":123
"user_name": nkcs1612941,
"role": "student",
}]
}
Response
{
"error":null
"data":{
"state_code":0 // 0-批量导入成功成功,-1-批量导入失败
}
}
写在最后:
以上api的POST与GET方法的使用取决于实际任务状况;基本上只要是向后台发送的元素过多而不得不使用json的时候,就一定要使用POST方法;在发送的元素不多而且返回的数据量大的时候使用GET方法;在发的少返回的也少的时候使用的还是POST方法。