Skip to content

Api DOC

vanilla111 edited this page Aug 19, 2017 · 2 revisions

FORMAT: 1A

活动平台 API

用于设计活动及活动流程,活动报名,管理报名人员信息。 所有API返回三个信息

  • Parameters
    • status 0或者1,前者代表改请求得到未能达到期望的返回,1代表成功
    • message 成功此处填写 success , 失败会将失败的原因填写至此,如有多条错误,此字段可能会有多个值
    • data 如有额外数据返回,将填写在此字段

活动管理员

检查记住我 [/api/auth/checkremember][GET]

该接口应在登陆页发起这个请求,如果后台判定该电脑上一次登陆勾选了记住我,并且合法(两周之内),会直接返回账号accounttoken,用户不在需要输入密码即可登录。如果登录过但没有勾选记住我,会返回一个账号,status=0。如果cookie过期或没有,status=0,data为空;

  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
          	 "account": "hywx_web",
               "token": "eyJhbGciOiJIUzI1..."
          }
      }
    
  • Response 200 (application/json)

      {
          "status": 0,
          "message": "no remember token",
          "data": {
              "account": "hywx_web"
          }
      }
    

取消记住我 [/api/auth/cancelremember][GET]

若用户登录过程中点击了取消记住我,则应该发起这个请求(反复只需要一次请求即可)

  • Request (application/json)

      {
      	"account": "hywx_web"
      }
    
  • Response 200 (application/json)

      {
      	"status": 1,
      	"messsage": "success"
      }
    

登陆 [/api/auth/login][POST]

登陆将返回一个token,需要有前端保存,此后所有关于该平台的请求都需要带上,有效时间120分钟

  • Request (application/json)

      {
      	"account": "hywx_web",
      	"password": "046952",
      	remember_me: 1
      }
    
  • Response 200 (application/json)

      {
      	"status": 1,
      	"message": "success",
      	"data": {
      		"token":"eyJhbGciOiJIUzI1NiIsInR5cC..."
      	}
      }
    

子账号 [/api/org]

只有各大校级组织及超级管理员有权创建子账号

+ Paremeters
	admin_id 账户的id,随列表api返回

子账号列表 [GET]

返回该账户下所有有效的子账号

  • Request

  • Response 200 (application/json)

子账号详情 [/api/org/{admin_id}][GET]

  • Request

  • Response 200 (application/json)

创建子账号 [POST]

为该账户创建一个子账号,生成的账号为 原账号 + "_" + 所设置的账号名,请求成功返回新的账号名。失败可能是因为账号已经存在

  • Request (application/json)

      {
      	"token": "xxx...",
      	"account": "ydkfb",
      	"password": "123456",
      	"author_code": "2015211516", //以下可选
      	"author_phone": "15736335536",
      	"author_name": "wws"
      }
    
  • Response 200 (application/json)

      {
      	"status": 1,
      	"message": "success",
      	"data": {
      		"account": "hywx_ydkfb"
      	}
      }
    

更新一个子账号信息 [/api/org/{admin_id}][PUT]

修改一个子账号的信息,包括修改账户主人的学号,姓名,电话,密码

  • Request

      {
      	"token": "xxx...", 
      	"password": "123456", //以下可选
      	"author_code": "2015211516",
      	"author_phone": "15736335536",
      	"author_name": "wws"
      }
    
  • Response 201 (application/json)

      {
      	"status": 1,
      	"messsage": "success"
      }
    

删除一个子账号 [/api/org/{admin_id}][DELETE]

  • Request

  • Response 206 (application/json)

活动

该组接口包括活动的设计,修改,获取详情,开启(关闭)活动的报名通道等接口

	+ Paremeters
		act_key (int) 每个活动对应的唯一标示

活动设计与操作 [/api/act]

获取所有活动列表 [GET]

该接口可实现数据表格的常用操作,包括分页,指定排序,页面大小,偏移,模糊查询

  • Request (application/json)

      {
      	"token": "xxx...",
      	"page": 1,
      	"per_page": 10,
      	"sortby": "created_at|updated_at|start_time|activity_name",
      	"sort": "asc|desc",
      	"act_key": 1000, //以下将进行模糊查询
      	"act_name": "招新"
      }
    
  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
              "total": 1,
              "per_page": 10,
              "current_page": 1,
              "last_page": 1,
              "next_page_url": null,
              "prev_page_url": null,
              "from": 1,
              "to": 1,
              "data": [
                  {
                      "activity_id": 1000,
                      "activity_name": "【招新】红岩网校WEB开发部",
                      "num_limit": 3000, //设置的报名人数限制
                      "current_num": 1, //当前已报名的人数
                      "start_time": "2017-09-01 00:00:00",
                      "created_at": "2017-08-16 14:24:27",
                      "updated_at": "2017-08-16 19:27:43",
                      "status": 1
                  }
              ]
          }
      }
    

新增一个活动 [/api/act][POST]

设计一个活动并存储,会自动生成一个报名流程

  • Rquest (application/json)

      {
      	"token": "xxx...",
      	"activity_name": "【招新】红岩网校移动开发部",
      	"summary": "简介",
      	"max_num": 5000, //人数限制,若修改的值低于已报名的人数会返回错误
      	"location": "地点",
      	"start_time": "2017-09-17 00:00:00",
      	"end_time": "2017-09-25 00:00:00",
      	"time_description": "关于时间的描述"
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取活动详情 [/api/act/{act_key}][GET]

获取活动详情时同时会获取该活动下的所有流程

  • Request

  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
              "author_id": 1,
              "num_limit": 3000,
              "current_num": 1,
              "current_flow": 1,
              "activity_name": "【招新】红岩网校WEB开发部",
              "time_description": "工作日上午10点到晚上7点",
              "summary": "欢迎来到互联网的世界,大家一起学习进步,走上人生巅峰",
              "start_time": "2017-09-01 00:00:00",
              "end_time": "2017-09-20 00:00:00",
              "created_at": "2017-08-16 14:24:27",
              "flowList": [
      	            {
      	                "flow_id": 1,
      	                "activity_key": 1000,
      	                "flow_name": "报名阶段",
      	                "location": "线上",
      	                "type": 0,
      	                "status": 1,
      	                "sms_temp_id": null,
      	                "score": 1,
      	                "evaluation": 1,
      	                "time_description": null,
      	                "start_time": null,
      	                "end_time": null,
      	                "created_at": "2017-08-16 14:24:27",
      	                "updated_at": "2017-08-16 14:24:27"
      	            },
      	     ]
          }
      }
    

修改活动属性 [/api/act/{act_key}][PUT]

修改一个活动的属性,若活动已经开始,则不允许修改活动名称与开始时间。未开始则可以修改任意信息。

  • Request

      {
      	"token": "xxx...",
      	"activity_name": "【招新】红岩网校移动开发部",
      	"summary": "简介",
      	"max_num": 5000, //人数限制,若修改的值低于已报名的人数会返回错误
      	"location": "地点",
      	"start_time": "2017-09-17 00:00:00",
      	"end_time": "2017-09-25 00:00:00",
      	"time_description": "关于时间的描述" //以上数据可单个发送请求
      }
    
  • Response 201 (application/json)

      {
          "status": 1,
          "message": "信息修改成功"
      }
    

开通或关闭活动的报名通道 [/api/act/{act_key}/[start|end]]

  • Request

  • Response 200

      {
          "status": 1,
          "message": "活动开启成功"
      }
    

流程

流程设计与操作 [/api/flow]

  • Paremeters
    • flow_id 流程id,所有带有流程id的请求,都会检查越权操作

获取一个活动下所有流程列表 [GET]

  • Request (application/json)

      {
      	"token": "xxx...",
      	"act_key": 1000,
      }
    
  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": [
              {
                  "flow_name": "报名阶段",
                  "flow_id": 1
              },
              {
                  "flow_name": "第一轮面试",
                  "flow_id": 2
              }
          ]
      }
    

新增流程 [POST]

设计一个流程并存储,若使用短信服务,则应该调用短信模版接口

  • Rquest (application/json)

      {
      	"token": "xxx...",
      	"flow_name": "第一轮面试",
      	"act_key": 1000,
      	"location": "地点",
      	"time_description": "关于时间的描述",
      	"type": 1, //枚举类型 0 报名, 1 面试, 2 笔试
      	"sms_temp_id": 1, //短信模版id
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取流程详情 [/api/flow/{flow_id}][GET]

获取的同时会返回该流程下短信模版的信息。

  • Request

  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
              "flow_name": "第一轮面试",
              "location": "网校A区",
              "type": 2,
              "start_time": null,
              "end_time": null,
              "time_description": null,
              "sms_temp_id": 3,
              "created_at": "2017-08-16 18:42:25",
              "sms_temp": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
              "sms_variables": {
                  "name": "${full_name}",
                  "content": "恭喜你通过面试",
                  "next": "明天到数图参加面试"
              }
          }
      }
    

修改流程属性 [/api/flow/{flow_id}][PUT]

修改一个活动的属性,若活动已经开始,则不允许修改活动名称与开始时间。未开始则可以修改任意信息。

  • Request

      {
      	"token": "xxx...",
      	"flow_name": "第一轮面试",
      	"location": "地点",
      	"time_description": "关于时间的描述",
      	"type": 1, //枚举类型 0 报名, 1 面试, 2 笔试
      	"sms_temp_id": 1, //短信模版id
      	"start_time": "", //虽然写了,但好像没什么用,可以无视
      	"end_time": "",
      }
    
  • Response 201 (application/json)

      {
          "status": 1,
          "message": "信息修改成功"
      }
    

删除一个流程 [/api/flow/{flow_id}][DELETE]

删除一个流程,软删除,状态码204没有返回信息.

  • Response 204 (application/json)

短信模版

网校提供的后台模版 [/api/sms/templet][GET]

短信变量可赋值为静态变量,若要发送动态的变量,比如说 name 需要根据不同的人发送不同的名字, 则赋值 ${full_name}

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": [
              {
                  "admin_temp_id": 1,
                  "temp_name": "活动消息通知",
                  "sms_temp": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
                  "sms_variables": [
                      "name",
                      "content",
                      "next"
                  ],
                  "dynamic_variables": {
                      "name": {
                          "${full_name}": "姓名"
                      },
                      "content": "",
                      "next": ""
                  }
              }
          ]
      }
    

短信模版设计与操作 [/api/sms]

  • Paremeters
    • sms_id 模版id

模版测试 [/api/sms/test][POST]

  • Request

      {
      	"token": "xxx...",
      	"rec_num": "15736335536",
      	"temp_id": 3
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取改用户所保存的短信模版列表 [GET]

若用户在设计流程时选中了某个模版,如果这个模版它未测试过,则应该提示它 模版未测试,如使用该模版发送短信,可能会因为长度,敏感词等因素造成发送失败

  • Request (application/json)

      {
      	"token": "xxx...",
      }
    
  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
              "temp_id": 3,
              "temp_name": "通过面试",
              "content": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息"
              "was_test": 0
          }
      }
    

新增一个短信模版 [POST]

设计一个模版并保存,变量赋值限制在15字以内

  • Paremeters

    • admin_temp_id 网校模版的id
    • variables (array)网校模版中变量,以key-value的形式请求
  • Rquest (application/json)

      {
      	"token": "xxx...",
      	"admin_temp_id": 1,
      	"temp_name": "面试通过通知",
      	"variables": {
      		"name": "${full_name}",
      		"content": "恭喜你通过面试",
      		"next": "明天到数图参加面试"
      	}
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取流程详情 [/api/sms/{sms_id}][GET]

获取的模版的详细信息

  • Request

  • Response 200 (application/json)

      {
          "status": 1,
          "message": "success",
          "data": {
              "temp_id": 3,
              "author_id": 1,
              "temp_name": "通过面试",
              "admin_temp_id": 1,
              "variables": {
                  "name": "${full_name}",
                  "content": "恭喜你通过面试",
                  "next": "明天到数图参加面试"
              },
              "content": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
              "type": 1,
              "created_at": "2017-08-17 14:24:56",
              "updated_at": "2017-08-17 14:24:56"
          }
      }
    

修改短信模版属性 [/api/sms/{sms_id}][PUT]

用了同一套验证,所以需要将每个属性都传过来

  • Request

      {
      	"token": "xxx...",
      	"admin_temp_id": 1,
      	"temp_name": "面试通过通知",
      	"variables": {
      		"name": "${full_name}",
      		"content": "恭喜你通过面试",
      		"next": "明天到数图参加面试"
      	}
      }
    
  • Response 201 (application/json)

      {
          "status": 1,
          "message": "success"
      }
    

删除一个短信模版 [/api/sms/{sms_id}][DELETE]

  • Response 204 (application/json)

申请信息

申请数据操作 [/api/applydata]

  • Parematers
    • enroll_id 申请信息的id

数据列表

支持数据table的常用操作

  • Request

      {
      	"token": "xxx...",
      	"act_key": 1000,
      	"name": "王", //模糊查询
      	"stu_code": "2015", //模糊查询
      	"college": "计算机", //模糊查询
      	"flow_id": "1,2,3", //多个流程逗号分隔
      	"sortby": "updated_at|created_at|score|stu_code|grade", 
      	"sort": "asc|desc", //还未支持多个变量综合排序
      	"page": 1,
      	"per_page": 20
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success",
          "date": {
              "total": 1,
              "per_page": "2",
              "current_page": 1,
              "last_page": 1,
              "next_page_url": null,
              "prev_page_url": null,
              "from": 1,
              "to": 1,
              "data": [
                  {
                      "enroll_id": 1,
                      "user_id": 38,
                      "stu_code": 2015211519,
                      "full_name": "xxx",
                      "contact": "15736335536",
                      "college": 0,
                      "gender": "男",
                      "score": false,
                      "evaluation": false
                  }
              ]
          }
      }
    

添加申请数据

  • Request

      {
      	"token": "xxx...",
      	"college": "计算机",
      	"stu_code": "2015211516",
      	"passowrd": "123456", //身份证后六位,会验证该学号与密码是否匹配
      	"contact": "15736335536",
      	"act_key": 1000, //哪个活动
      	"flow_id": 1 //加入哪个流程
      }
    
  • Response 200

      {
      	"status": 1,
      	"message": "添加成功"
      }
    

获取一个申请信息的详情 [/api/applydata/{enroll_id}][GET]

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": {
              "enroll_id": 1,
              "user_id": 38,
              "activity_key": "1000",
              "act_name": "【招新】红岩网校WEB开发部",
              "current_step": 2,
              "full_name": "刘祖意",
              "stu_code": 2015211519,
              "contact": "17623659604",
              "college": "0",
              "gender": "男",
              "grade": 2015,
              "status": 1,
              "was_send_sms": 0,
              "created_at": "2017-08-16 19:27:43",
              "updated_at": "2017-08-16 12:38:25",
              "score": false,
              "evaluation": false
          }
      }
    

更新一个申请信息数据 [/api/applydata/{enroll_id}][PUT]

每一个流程的数据共享存放位置,故分数,评价等历史信息不回保留

  • Request

      {
      	"token": "xxx...",
      	"contact": "17723947248",
      	"college": "软件",
      	"score": 88, //分数
      	"evaluation": "评价。。。",
      }
    
  • Response 200

      {
      	"status": 1,
      	"message": "success"
      }
    

删除一条申请信息 [/api/applydata/{enroll_id}][DELETE]

  • Response 204

数据操作之升级到下一流程 [/api/applydata/operation/][POST]

  • Request

      {
      	"enroll_id": "1,2,3" //多个数据用逗号分隔
      	"flow_id": 1, //仅支持操作同一流程下的数据
      	"action": "up|de", //仅实现了升级操作(up)
      }
    
  • Response 200

      {
      	"status": 1,
      	"message": "申请已进入处理队列,如有失败,请重新操作"
      }
    

数据操作之导入CSV | Excel文件

数据操作之导出CSV | Excel文件

数据操作之一键升级到下一个流程 [/api/applydata/onekeyup][POST]

将发送过短信的数据升级到下一个流程

  • Request

      {
      	"token": "xxx...",
      	"flow_id": 1
      }
    
  • Response

      {
      	"status": 1,
      	"message": "success"
      }
    

数据操作之发送短信 [/api/applydata/sendsms][POST]

失败的情况有,越权操作,模版失效,短信余额不足,短信平台报错等等

  • Request

      {
      	"token": "xxx...",
      	"flow_id": "1,2", //允许多个流程同时发送,但是短信模版需要一致才可,上限5个流程
      	"enroll_id": "1,2,3,4" //必需,同时为多个人发送短信
      }
    
  • Response 200

      {
      	"status": 1,
      	"message": "发送任务已进入队列,如有失败请重新尝试"
      }
    

获取短信发送历史

还未实现

用户

用户登录 [/api/user/login]

  • Request

      {
      	"stu_code": "2015211516",
      	"password": "123456"
      }
    
  • Response 200

      {
          "status": 1,
          "message": "登录成功",
          "data": "2015211519"
      }
    

用户报名 [/api/user/enroll]

  • Request

      {
      	"act_key": "1000,10001" //多个活动逗号分隔
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

用户报名历史 [/api/user/applydata]

  • Request

      {
      	"page": 1,
      	"per_page": 10,
      	"name": "红岩网校", //模糊查询
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": {
              "total": 1,
              "per_page": 5,
              "current_page": 1,
              "last_page": 1,
              "next_page_url": null,
              "prev_page_url": null,
              "from": 1,
              "to": 1,
              "data": [
                  {
                      "activity_key": "1000",
                      "act_name": "【招新】红岩网校移动开发部",
                      "current_step": 1,
                      "status": 1,
                      "score": false,
                      "evaluation": false,
                      "created_at": "2017-08-19 11:15:01"
                  }
              ]
          }
      }
    

用户信息 [/api/user]

  • Parematers
    • stu_code 学号

获取用户信息 [/api/user/{stu_code}][GET]

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": {
              "stu_code": "2015211519",
              "full_name": "刘祖意",
              "gender": "男",
              "college": "0",
              "contact": "15736335536"
          }
      }
    

修改用户信息 [/api/user/{stu_code}][POST]

  • Request

      {
      	"contact": "17723947648"
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

超级管理员

账号管理 [/api/admin/org]

账号列表 [GET]

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": [
              {
                  "admin_id": 2,
                  "admin_name": "严澄",
                  "account": "hywx",
                  "pid": 0,
                  "author_code": "20152111211",
                  "author_phone": "13636335536",
                  "out_of_dept": 2,
                  "created_at": "2017-08-19 19:03:02",
                  "updated_at": "2017-08-19 19:03:02",
                  "sms_num": 100 //短息余额
              }
          ]
      }
    

添加一个账号 [POST]

  • Request

      {
      	"token": "xxx...",
      	"account": "hywx",
      	"password": "123456",
      	"admin_name": "严澄",
      	"author_code": "2015211211",
      	"author_phone": "15736335536",
      	"out_of_dept": 2
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取一个账号详情 [/api/admin/org/{admin_id}][GET]

这个接口显得多余,跟列表访问的信息是一样的

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": {
              "admin_id": 2,
              "admin_name": "严澄",
              "account": "hywx",
              "pid": 0,
              "author_code": "20152111211",
              "author_phone": "13636335536",
              "out_of_dept": 2,
              "created_at": "2017-08-19 19:03:02",
              "updated_at": "2017-08-19 19:03:02"
              "sms_num": 100
          }
      }
    

修改一个账号 [/api/admin/org/{admin_id}][PUT]

  • Request

      {
      	"token": "xxx...",
      	"password": "654321",
      	"admin_name": "xxx",
      	"author_coed": "1234567890",
      	"author_phone": "1234567890"
      }
    
  • Response 200

      {
      	"status": 1,
      	"message": "success"
      }
    

冻结(删除)一个账号 [/api/admin/org/{admin_id}][DELETE]

为实现

短信模版管理 [/api/admin/smstemp]

模版列表 [GET]

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": [
              {
                  "admin_temp_id": 1,
                  "sms_provider": 1,
                  "admin_id": 1,
                  "temp_name": "活动消息通知",
                  "sms_temp": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
                  "sms_type": "normal",
                  "sms_free_sign_name": "红岩网校工作站",
                  "sms_id": "SMS_21705072",
                  "sms_variables": "name,content,next",
                  "dynamic_variables": {
                      "name": {
                          "${full_name}": "姓名"
                      },
                      "content": "",
                      "next": ""
                  },
                  "content": null,
                  "type": 1,
                  "status": 1,
                  "created_at": "2017-08-16 18:38:13",
                  "updated_at": "2017-08-16 18:38:13"
              }
          ]
      }
    

添加一个模版 [POST]

这个接口的比较复杂,用的时候商量一下

  • Request

      {
      	"tempName": "活动消息通知",
      	"smsTemp": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
      	"smsID": "SMS_21705072",
      	"smsFreeSignName": "红岩网校工作站",
      	"smsVars": "name,content,next",
      	"dyVars": "{"name":{"${full_name}":"姓名"},"content":"","next":""}"
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

获取一个模版详情 [/api/amdin/smstemp/{admin_temp_id}][GET]

  • Response 200

      {
          "status": 1,
          "message": "success",
          "data": {
              "admin_temp_id": 1,
              "sms_provider": 1,
              "admin_id": 1,
              "temp_name": "活动消息通知",
              "sms_temp": "亲爱的${name}同学,恭喜你${content}。${next}。请注意诈骗等非法信息",
              "sms_type": "normal",
              "sms_free_sign_name": "红岩网校工作站",
              "sms_id": "SMS_21705072",
              "sms_variables": "name,content,next",
              "dynamic_variables": {
                  "name": {
                      "${full_name}": "姓名"
                  },
                  "content": "",
                  "next": ""
              },
              "content": null,
              "type": 1,
              "status": 1,
              "created_at": "2017-08-16 18:38:13",
              "updated_at": "2017-08-16 18:38:13"
          }
      }
    

修改一个模版 [/api/amdin/smstemp/{admin_temp_id}][PUT]

未实现。不建议修改,如果这个模版已被投入使用,会引发麻烦的错误

删除一个模版 [/api/amdin/smstemp/{admin_temp_id}][DELETE]

未实现.

短信充值 [/api/admin/smscharge][POST]

只能为管理员账户充值,其子账户暂不支持充值.sms_num 为整数,会在原来的值上进行加减。改接口限制同一个ip每三秒调用一次

  • Request

      {
      	"token": "xxx...",
      	"amdin_id": "2",
      	"sms_num": 100
      }
    
  • Response 200

      {
          "status": 1,
          "message": "success"
      }
    

微信端报名

Clone this wiki locally