管理员端API——任仲行

管理员登录界面
  • 管理员登录
  /administrator/log_in GET

  Request

  {

    "name": 张三,

    "password_hash": awgyu223

  }

 

  Response

  {

    "error":null

    "data":{  

      "state_code":0, // 0-成功,-1-用户名不存在,1-密码不正确

      "id_admin": 139179

      "role_name": "admin1"

      }

 

  }

 
职工管理界面
  查看职工列表(前端有分页但并不涉及搜索)
  /administrator/stuff/stuff_list GET

  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”

        }]

      }

    

  }

 

  查看职工详情,可以用于职工信息修改页渲染时的数据注入
  /administrator/stuff/stuff_detail GET

  Request

  {

    "id":xxxxxxx    

  }

 

  Response

  {

    "error":null

    "data":{  

      stuffs: {

          "id": 1234556,

          “gender”:“女”,

          "name": nkcs1612941,

          "role_name": "teacher1",

          "user_status": “normal”

        }

      }

 

  }

 

 

  增加职工
  /administrator/stuff/stuff_create POST

  Request

  {

    stuff: {

        "id": 1612841

        "name": nkcs1612941,

        "role_name": "teacher",

        "gender": "女",

        "user_status":"normal"

      }

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-添加职工成功,-1-添加职工失败

      }

 

  }

 

  职工信息修改
  /administrator/stuff/stuff_modify POST

  Request

  {

    stuff: {

        "id": 1612841

        "name": nkcs1612941,

        "id_role": "teacher",

        "gender": "女",

        "user_status":"normal"

      }

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-修改职工成功,-1-修改职工失败

      }

 

  }

 
  删除职工
  /administrator/stuff/stuff_delete POST

  Request

  {

    "id":xxxxxxx    

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-删除职工成功,-1-删除职工失败

      }

 

  }

学生管理界面
  查看学生列表(存在分页,也存在搜索)
  /administrator/student/student_list POST

  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”

        }]

      }

 

  }

 

  查看学生详情,可以用于学生信息修改页面的数据注入过程
  /administrator/student/student_detail GET 

  Request

  {

    "id_student": “139179”

  }

 

  Response

  {

    "error":null

    "data":{

      student: {

          "id": “1234556”,

          “gender”:“女”,

          "name": “nkcs1612941”,

          "class”:2,

          "province":1,

          "user_status": “normal”,

          "room":415

        }

      }

 

  }

 

 

  增加学生
  /administrator/student/student_create POST

  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-添加学生失败

      }

 

  }

  学生信息修改
  /administrator/student/student_modify POST

 

  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-修改学生失败

      }

 

  }

 

  删除学生
  /administrator/stuff/student_delete POST

  Request

  {

    "id":xxxxxxx    

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-删除学生成功,-1-删除学生失败

      }

  }

权限管理界面
  角色分配
  /administrator/role/role_distribute POST

  Request

  {

    distribution:[{

        "id_user": 1612841

        "id_role":23

          }]

 

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-角色分配成功,-1-角色分配失败

      }

    

  }

 

  角色列表(role_number指的是该角色的人数,存在分页,也存在搜索)
  /administrator/role/role_list POST

  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

        }]

      }

 

  }

  角色新建
  /administrator/role/create_role POST

  Request

  {

    "id_role": 123

    "permission": [

      ”id_permission”:123

      }]

    "name":"admin1"

    "description":"This is a..."

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-添加角色成功,-1-添加角色失败

      }

 

  }

 
  查看角色详情
  /administrator/role/role_detail GET

  Request

  {

    "id_role": 139179

  }

 

  Response

  {

    "error":null

    "data":{

      "role": {

        "id_role": 12346,

        "name”:"admin1",

        "description":"This is a..."

        "permission": [

          ”id_permission”:123

          ]

        }

      }

    

  }

  角色修改
  /administrator/role/modify_role POST

  Request

  {

    role: {

        "id_role": 12346,

        "name”:"admin1",

        "description":"This is a..."

        "permission": [

          ”id_permission”:123

          }]

      }

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-修改角色成功,-1-修改角色失败

      }

 

  }

  删除角色
  /administrator/stuff/role_delete POST

  Request

  {

    "id":xxxxxxx    

  }

 

  Response

  {

    "error":null

    "data":{

      "state_code":0 // 0-删除角色成功,-1-删除角色失败

      }

 

  }

  批量导入成员
  /administrator/role/batch_import POST

  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方法。

posted @ 2019-05-15 14:14  cs_Sunday  阅读(317)  评论(0编辑  收藏  举报