Api数据 ================== .. _error_json: 错误信息 ------------------ 服务器接收请求后,如遇到异常情况(如访问未授权、页面不存在)将返回错误信息。 错误Json ^^^^^^^^^^ :: { "error": "错误类型", "message": "错误信息" } 错误信息列表 ^^^^^^^^^^^^^^ +----------------+------------+--------------+ | 错误名称 | http状态码 | 错误类型 | +================+============+==============+ | 无法识别的请求 | 400 | bad_request | +----------------+------------+--------------+ | 未认证 | 401 | unauthorized | +----------------+------------+--------------+ | 权限不足 | 403 | forbidden | +----------------+------------+--------------+ | 找不到页面 | 404 | not found | +----------------+------------+--------------+ .. _role_json: 角色信息 ----------------- 角色信息Json ^^^^^^^^^^^^^^ :: { "roles": [ { "name": "Administrator", "permissions": 255 }, { "name": "Teacher", "permissions": 12 }, { "name": "Student", "permissions": 3 } ] } 角色信息Json字段解释 ^^^^^^^^^^^^^^^^^^^^ 主体Json +--------+----------+------+--------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +========+==========+======+====================+ | roles | 角色列表 | list | 列表中节点请见下表 | +--------+----------+------+--------------------+ 角色列表中节点 角色Json +-------------+------------------+------+------+ | 字段名 | 字段说明 | 类型 | 备注 | +=============+==================+======+======+ | name | 该角色的名称 | str | | +-------------+------------------+------+------+ | permissions | 该角色拥有的权限 | int | | +-------------+------------------+------+------+ .. _user_json: 用户信息 ----------------- 用户信息Json ^^^^^^^^^^^^^^ :: { "id": 1, "last_seen": "2017-05-26 17:14:42 CST", "member_since": "2017-05-26 17:14:42 CST", "school_code": "4140200000", "url": "http://127.0.0.1:5000/api/v1.0/users/1", "username": null } 用户信息Json字段解释 ^^^^^^^^^^^^^^^^^^^^^ +--------------+--------------+------+-------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==============+==============+======+=============+ | id | 用户id | int | 允许为空 | +--------------+--------------+------+-------------+ | username | 用户昵称 | str | 10位数字 | +--------------+--------------+------+-------------+ | url | 用户信息url | str | | +--------------+--------------+------+-------------+ | school_code | 学号 | str | | +--------------+--------------+------+-------------+ | permissions | 权限 | int | | +--------------+--------------+------+-------------+ | role | 角色名 | str | | +--------------+--------------+------+-------------+ | member_since | 注册时间 | str | 详见 [#f1]_ | +--------------+--------------+------+-------------+ | last_seen | 上次访问时间 | str | | +--------------+--------------+------+-------------+ .. _schedule_json: 课程表 ---------------- 课程表Json ^^^^^^^^^^^ :: { "class_code": null, "class_name": "14计本1", "department": null, "grade": null, "major": null, "school_year": "2016", "semester": "1", "courses": [ { "name": "C#程序设计A", "nickname": null, "parity": null, "teacher": "张铁军", "week": [], "week_raw": "1-7", "when_code": "044", "where": null, "which_room": "A305", "worth": null }, ... ] } json实例 :download:`点击下载Schedule.json <_static/json/Schedule.json>` 课程表Json字段解释 ^^^^^^^^^^^^^^^^^^^ json主体 +--------------+----------------+--------+-----------------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==============+================+========+=============================+ | *cache* | 是否使用了缓存 | 布尔 | true/false | +--------------+----------------+--------+-----------------------------+ | *cache-date* | 缓存时间 | string | | +--------------+----------------+--------+-----------------------------+ | class_code | 班级代码 | string | | +--------------+----------------+--------+-----------------------------+ | class_name | 班级名 | string | | +--------------+----------------+--------+-----------------------------+ | department | 院/系 | string | | +--------------+----------------+--------+-----------------------------+ | grade | | | | +--------------+----------------+--------+-----------------------------+ | major | 专业 | string | | +--------------+----------------+--------+-----------------------------+ | school_year | 学年 | string | 2016代表2016-2017学年 | +--------------+----------------+--------+-----------------------------+ | semester | 学期 | string | '0':上学期 '1'下学期 | +--------------+----------------+--------+-----------------------------+ | courses | 课程 | 列表 | 课程Json :ref:`course_json` | +--------------+----------------+--------+-----------------------------+ .. _course_json: 课程json --------- 课程表中的课程Json与课程接口的课程Json并不完全相同。 这是因为课程表接口的课程直接从教务系统抓取,并不存储于数据库中。 未来课程表会重构,届时会标准化此数据。 课程Json示例(课程表中):: { "name": "C#程序设计A", "nickname": null, "parity": null, "teacher": "张铁军", "week": [], "week_raw": "1-7", "when_code": "044", "where": null, "which_room": "A305", "worth": null } 课程Json示例(课程表中)字段解释 +------------+----------------------+--------+---------------------------------------------------------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +============+======================+========+=====================================================================+ | name | 课程名称 | string | | +------------+----------------------+--------+---------------------------------------------------------------------+ | nickname | 课程昵称 | string | 如"毛泽东思想和中国特色社会主义理论体系概论"的昵称为"毛概" | +------------+----------------------+--------+---------------------------------------------------------------------+ | parity | 单双周 | string | "单周" "双周" 或null | +------------+----------------------+--------+---------------------------------------------------------------------+ | teacher | 教师姓名 | string | | +------------+----------------------+--------+---------------------------------------------------------------------+ | week | 解析后的上课周次信息 | 列表 | 列表内为数字 | +------------+----------------------+--------+---------------------------------------------------------------------+ | week_raw | 未解析的上课周次信息 | string | 如1-7代表1到7周, | +------------+----------------------+--------+---------------------------------------------------------------------+ | when_code | 上课时间信息 | string | 三位数字,第一位为0, 第二位星期几, 第三位第几节 如044代表周四第四节 | +------------+----------------------+--------+---------------------------------------------------------------------+ | where | 上课位置 | string | | +------------+----------------------+--------+---------------------------------------------------------------------+ | which_room | 上课教室 | string | 如:A305 | +------------+----------------------+--------+---------------------------------------------------------------------+ | worth | 学分 | string | | +------------+----------------------+--------+---------------------------------------------------------------------+ 课程Json示例(标准):: { "id": 1, "name": "计算机网络", "nickname": null, "parity": "单周", "raw_course_id": 1, "teacher": null, "teacher_id": 1, "url": "http://127.0.0.1:5000/api/v1.0/courses/1", "week": [ 1, 2, 3, 4, 5 ], "week_raw": "[1-5]", "when_code": "011", "where": "北校区", "which_room": "A305" "classes": [ 41402061, 41402062 ] } 课程Json示例(标准)字段解释 +---------------+----------------------+-----------+--------------------------------------------------------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +===============+======================+===========+====================================================================+ | url | 课程url | string | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | raw_course_id | 原课程id | int | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | teacher_id | 任课教师id | int | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | classes | 上课班级 | list(int) | 哪些班级上课 列表内为班级的id | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | name | 课程名称 | string | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | nickname | 课程昵称 | string | 如"毛泽东思想和中国特色社会主义理论体系概论"的昵称为"毛概" | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | parity | 单双周 | string | "单周" "双周" 或null | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | teacher | 教师姓名 | string | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | week | 解析后的上课周次信息 | 列表 | 列表内为数字 | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | week_raw | 未解析的上课周次信息 | string | 如1-7代表1到7周, | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | when_code | 上课时间信息 | string | 三位数字,第一位为0, 第二位星期几, 第三位第几节 如044代表周四第四节 | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | where | 上课位置 | string | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | which_room | 上课教室 | string | 如:A305 | +---------------+----------------------+-----------+--------------------------------------------------------------------+ | worth | 学分 | string | | +---------------+----------------------+-----------+--------------------------------------------------------------------+ .. _school_structure_json: 学校结构 ---------------------- :: 按现在抓取的数据分析来看, 各个年级的院系部代码和专业代码都是不变的. 但为稳妥起见(以防抽风改成不一致), 仍按照教务系统原有的从年份开始设计json. 结构为 学校-年份-系别(院系部)-专业-班级. classes = {'name': '14计本1', 'code': '2014020601'} specialty = {'name': '计算机专业与技术', 'code': '4001', 'classes': [c1, c2...]} department = {'name': '计算机专业与技术系', 'code': '40', 'specialties': [s1, s2...]} school_year = {'year': '2014', 'departments': [department1, department2...]} school = {'school_years': [school_year1, school_year2...]} 学校结构json ^^^^^^^^^^^^^ :: { "cache": true, "cache-date": "2017-06-01 10:45:39 CST", "school_years": [ { "year": "2013", "departments": [ { "code": "31", "name": "机电工程系", "specialties": [ { "code": "0105", "name": "机械设计制造及其自动化", "classes": [ { "code": "2013010501", "name": "13机本1" } ] } ] } ] } ] } json实例 :download:`点击下载Structure.json <_static/json/Structure.json>` 学校结构json字段解释 ^^^^^^^^^^^^^^^^^^^^^^ json主体 +--------------+----------------+--------+------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==============+================+========+============+ | *cache* | 是否使用了缓存 | 布尔 | true/false | +--------------+----------------+--------+------------+ | *cache-date* | 缓存时间 | string | | +--------------+----------------+--------+------------+ | school_years | 学年 | 列表 | | +--------------+----------------+--------+------------+ 学年json +-------------+------------+--------+------------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +=============+============+========+========================+ | year | 学年 | string | 四位年 | +-------------+------------+--------+------------------------+ | departments | 该学年的系 | 列表 | 目前每个学年的系都一样 | +-------------+------------+--------+------------------------+ 系别json +-------------+------------+--------+------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +=============+============+========+==================+ | code | 系别代号 | string | 貌似都是两位数字 | +-------------+------------+--------+------------------+ | name | 系名称 | string | | +-------------+------------+--------+------------------+ | specialties | 该系的专业 | 列表 | | +-------------+------------+--------+------------------+ 专业json +---------+----------------+--------+------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +=========+================+========+==================+ | code | 专业代号 | string | 貌似都是四位数字 | +---------+----------------+--------+------------------+ | name | 专业名称 | string | | +---------+----------------+--------+------------------+ | classes | 该专业下的班级 | 列表 | | +---------+----------------+--------+------------------+ 班级json +--------+----------+--------+------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +========+==========+========+==================+ | code | 班级代号 | string | 貌似都是十位数字 | +--------+----------+--------+------------------+ | name | 班级名称 | string | | +--------+----------+--------+------------------+ .. _semester_json: 学年学期 ---------- 学年学期json ^^^^^^^^^^^^^^ :: { "school_year": "2016", "semester": "1" } 学年学期json字段解释 ^^^^^^^^^^^^^^^^^^^^^ +-------------+----------+--------+------------------------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +=============+==========+========+====================================+ | school_year | 学年 | string | "2016" 意为:“2016-2017学年” | +-------------+----------+--------+------------------------------------+ | semester | 学期 | string | "1" 意为下半学期; "0" 意为上半学期 | +-------------+----------+--------+------------------------------------+ .. _score_json: 成绩 --------- 成绩json ^^^^^^^^^^^^ :: { "department": "计算机科学与技术系", "major": "14计本1", "stu_id": "4140206139", "user_code": "201400000407" "score_tables": [ { "semester": "2014-2015学年第一学期", "scores": [ { "exam_method": "考试", "get_method": "初修取得", "id": "1", "name": "大学英语A(一)", "ps": "", "quale": "初修", "score": "70.0", "type": "公共课/必修课", "worth": "4.0" }, ... ] }, ... ], } json实例 :download:`点击下载Score.json <_static/json/Score.json>` 成绩json字段解释 ^^^^^^^^^^^^^^^^^ json主体 +--------------+------------------------------+--------+--------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==============+==============================+========+====================+ | department | 系别 | string | | +--------------+------------------------------+--------+--------------------+ | major | 班级代号(年级专业班级一体) | string | | +--------------+------------------------------+--------+--------------------+ | stu_id | 学号 | string | | +--------------+------------------------------+--------+--------------------+ | user_code | 用户编号 | string | | +--------------+------------------------------+--------+--------------------+ | score_tables | 成绩表 | 列表 | 按学期分隔的成绩表 | +--------------+------------------------------+--------+--------------------+ 成绩表json +----------+----------+--------+------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==========+==========+========+==================+ | semester | 学期 | string | 当前成绩表的学期 | +----------+----------+--------+------------------+ | scores | 分数 | 列表 | | +----------+----------+--------+------------------+ 分数json +-------------+------------------+--------+--------------------+ | 字段名 | 字段说明 | 类型 | 备注 | +=============+==================+========+====================+ | id | 在成绩表中的编号 | string | 没啥用,可以不解析 | +-------------+------------------+--------+--------------------+ | name | 课程名 | string | | +-------------+------------------+--------+--------------------+ | worth | 学分 | string | | +-------------+------------------+--------+--------------------+ | type | 课程类别 | string | 公共课、必修课 | +-------------+------------------+--------+--------------------+ | quale | 修读性质 | string | 初修/重修 | +-------------+------------------+--------+--------------------+ | exam_method | 考核方式 | string | 考试/考察 | +-------------+------------------+--------+--------------------+ | get_method | 取得方式 | string | 初修取得 | +-------------+------------------+--------+--------------------+ | score | 成绩 | string | 分数/合格 | +-------------+------------------+--------+--------------------+ | ps | 备注 | string | 一般都是空 | +-------------+------------------+--------+--------------------+ .. _raw_course_json: 原课程 ------ 原课程Json(raw_course Json) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: { "course_code": "1", "id": 1, "name": "计算机网络", "nickname": null, "url": "http://127.0.0.1:5000/api/v1.0/raw_courses/1", "worth": "11" } raw_course Json 字段释义 ^^^^^^^^^^^^^^^^^^^^^^^^ +--------------+-----------------+------+------------+ | 字段名 | 字段说明 | 类型 | 备注 | +==============+=================+======+============+ | id | 自增id | int | | +--------------+-----------------+------+------------+ | courese_code | 课程代码 | str | | +--------------+-----------------+------+------------+ | name | 课程名 | str | 课程原名 | +--------------+-----------------+------+------------+ | nickname | 课程名 | str | 如《毛概》 | +--------------+-----------------+------+------------+ | url | 访问本资源的URL | str | | +--------------+-----------------+------+------------+ | worth | 学分 | str | 本课程学分 | +--------------+-----------------+------+------------+ .. rubric:: Footnotes .. [#f1] 时间格式化字符串为`%Y-%m-%d %H:%M:%S %Z` 意为:年-月-日 24进制小时-分钟-秒数 时区代号