ZZU.Py 文档#
郑州大学移动校园的 Python API 封装
API Base#
- class api.ZZUPy(usercode: str, password: str, cookie: SimpleCookie | None = None)[源代码]#
基类:
object
初始化一个 ZZUPy 对象
- 参数:
usercode (str) – 学号
password (str) – 密码
cookie (SimpleCookie) – 统一认证 Cookie。目前必须包含 ‘userToken’,否则会抛出 ValueError
- 抛出:
ValueError – Cookie 中缺少 ‘userToken’ 时抛出
- property is_logged_in: bool#
判断是否已登录
- login(app_version: str = 'SWSuperApp/1.0.42', app_id: str = 'com.supwisdom.zzu', os_type: str = 'android') LoginResult [源代码]#
登录
- 参数:
app_version (str) – APP 版本 ,一般类似 “SWSuperApp/1.0.39” ,可自行更新版本号。
app_id (str) – APP 包名,一般不需要修改
os_type (str) – 系统类型,一般不需要修改
- 返回:
Tuple[str, str]
usercode (str) – 学号
name (str) – 姓名
- 返回类型:
Tuple[str,str]
- 抛出:
LoginException – 登录失败时抛出
- async login_async(app_version: str = 'SWSuperApp/1.0.42', app_id: str = 'com.supwisdom.zzu', os_type: str = 'android') LoginResult [源代码]#
登录
- 参数:
app_version (str) – APP 版本 ,一般类似 “SWSuperApp/1.0.39” ,可自行更新版本号。
app_id (str) – APP 包名,一般不需要修改
os_type (str) – 系统类型,一般不需要修改
- 返回:
Tuple[str, str]
usercode (str) – 学号
name (str) – 姓名
- 返回类型:
Tuple[str,str]
- 抛出:
LoginException – 登录失败时抛出
- set_device_params(**kwargs: Unpack[Dict[str, Any]]) None [源代码]#
设置设备参数。这些参数都需要抓包获取,但其实可有可无,因为目前并没有观察到相关风控机制
- 参数:
deviceName (str) – 设备名 ,位于 “passwordLogin” 请求的 User-Agent 中,组成为 ‘{appVersion}({deviceName})’
deviceId (str) – 设备 ID ,
deviceInfo (str) – 设备信息,位于名为 “X-Device-Info” 的请求头中
deviceInfos (str) – 设备信息,位于名为 “X-Device-Infos” 的请求头中
userAgentPrecursor (str) – 设备 UA 前体 ,只需要包含 “SuperApp” 或 “uni-app Html5Plus/1.0 (Immersed/38.666668)” 前面的部分
Supwisdom#
- class supwisdom.Supwisdom(parent)[源代码]#
基类:
object
树维教务相关功能的类
初始化Supwisdom实例
- 参数:
parent – 父对象,通常是ZZUPy实例
- get_courses(start_date: str, semester_id: str | int = None, biz_type_id: str | int = None) Courses [源代码]#
获取课程表
- 参数:
start_date (str) – 课表的开始日期,格式必须为 YYYY-MM-DD ,且必须为某一周周一,否则课表会时间错乱
semester_id (str) – 学期ID
biz_type_id (str) – 业务类型 ID,用于区分本科生和研究生
- 返回:
返回课程表数据
- 返回类型:
- 抛出:
ValueError – 如果日期格式不正确
Exception – 如果API请求失败
- async get_courses_async(start_date: str, semester_id: str | int = None, biz_type_id: str | int = None) Courses [源代码]#
异步获取课程表
- 参数:
start_date (str) – 课表的开始日期,格式必须为 YYYY-MM-DD ,且必须为某一周周一,否则课表会时间错乱
semester_id (str) – 学期ID
biz_type_id (str) – 业务类型 ID,用于区分本科生和研究生
- 返回:
返回课程表数据
- 返回类型:
- 抛出:
ValueError – 如果日期格式不正确
Exception – 如果API请求失败
- get_current_week_courses(semester_id: str | int = None, biz_type_id: str | int = None) Courses [源代码]#
获取本周课程表
- 参数:
semester_id (str) – 学期ID
biz_type_id (str) – 业务类型 ID,用于区分本科生和研究生
- 返回:
返回本周课程表数据
- 返回类型:
- async get_current_week_courses_async(semester_id: str | int = None, biz_type_id: str | int = None) Courses [源代码]#
异步获取本周课程表
- 参数:
semester_id (str) – 学期ID。
biz_type_id (str) – 业务类型 ID,用于区分本科生和研究生
- 返回:
返回本周课程表数据
- 返回类型:
- get_room_data(building_id: int | str, date_str: str = '2025-05-22') RoomOccupancyData [源代码]#
获取教室占用数据
- 参数:
building_id – 建筑ID
date_str – 日期字符串,格式为YYYY-MM-DD,默认为当天
- 返回:
返回教室占用数据
- 返回类型:
- 抛出:
Exception – 如果API请求失败
- async get_room_data_async(building_id: int | str, date_str: str = '2025-05-22') RoomOccupancyData [源代码]#
异步获取教室占用数据
- 参数:
building_id – 建筑ID
date_str – 日期字符串,格式为YYYY-MM-DD,默认为当天
- 返回:
返回教室占用数据
- 返回类型:
- 抛出:
Exception – 如果API请求失败
- get_semester_data(biz_type_id: str | int = None) SemesterData [源代码]#
获取学期数据
- 参数:
biz_type_id – 业务类型 ID,用于区分本科生和研究生。
- 返回:
返回学期数据
- 返回类型:
- 抛出:
Exception – 如果API请求失败
- async get_semester_data_async(biz_type_id: str | int = None) SemesterData [源代码]#
异步获取学期数据
- 参数:
biz_type_id – 业务类型 ID,用于区分本科生和研究生。
- 返回:
返回学期数据
- 返回类型:
- 抛出:
Exception – 如果API请求失败
eCard#
- class ecard.eCard(parent)[源代码]#
基类:
object
初始化 eCard 实例
- 参数:
parent – 父对象
- get_remaining_energy(room: str | None = None) float [源代码]#
获取剩余电量
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
- 返回:
剩余能源
- 返回类型:
float
- async get_remaining_energy_async(room: str | None = None) float [源代码]#
异步获取剩余电量
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
- 返回:
剩余能源
- 返回类型:
float
- get_remaining_power(room: str | None = None) float [源代码]#
获取剩余电量
已被废弃,请使用 get_remaining_energy()
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
- 返回:
剩余能源
- 返回类型:
float
- get_room_dict(id: str) dict [源代码]#
获取房间的字典
- 参数:
id (str) – 已知房间 ID 。例如: ‘’, ‘99’, ‘99-12’, ‘99-12–33’
- 返回:
对应的字典
- 返回类型:
dict
- async get_room_dict_async(id: str) dict [源代码]#
异步获取房间的字典
- 参数:
id (str) – 已知房间 ID 。例如: ‘’, ‘99’, ‘99-12’, ‘99-12–33’
- 返回:
对应的字典
- 返回类型:
dict
- recharge_electricity(payment_password: str, amt: int, room: str | None = None) Tuple[bool, str] [源代码]#
为 room 充值电费
已被废弃,请使用 recharge_energy()
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
payment_password (str) – 支付密码
amt (int) – 充值金额
- 返回:
Tuple[bool, str]
success (bool) – 充值是否成功
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[bool,str]
- async recharge_electricity_async(payment_password: str, amt: int, room: str | None = None) Tuple[bool, str] [源代码]#
异步为 room 充值电费
已被废弃,请使用 recharge_energy_async()
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
payment_password (str) – 支付密码
amt (int) – 充值金额
- 返回:
Tuple[bool, str]
success (bool) – 充值是否成功
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[bool,str]
- recharge_energy(payment_password: str, amt: int, room: str | None = None) Tuple[bool, str] [源代码]#
为 room 充值电费
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
payment_password (str) – 支付密码
amt (int) – 充值金额
- 返回:
Tuple[bool, str]
success (bool) – 充值是否成功
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[bool,str]
- async recharge_energy_async(payment_password: str, amt: int, room: str | None = None) Tuple[bool, str] [源代码]#
异步为 room 充值电费
- 参数:
room (str) – 房间 ID 。格式应为 ‘areaid-buildingid–unitid-roomid’,可通过 get_room_dict() 获取
payment_password (str) – 支付密码
amt (int) – 充值金额
- 返回:
Tuple[bool, str]
success (bool) – 充值是否成功
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[bool,str]
Network#
- class network.Network(parent)[源代码]#
基类:
object
初始化网络管理类
- 参数:
parent – 父对象,通常是ZZUPy实例
- login(loginurl: str = 'http://10.2.7.16:8080', ua: str = None) bool [源代码]#
登录自助服务平台
- 参数:
loginurl (str) – 自助服务平台的登录 URL
ua (str) – User Agent,默认随机生成
- 返回:
登录是否成功
- 返回类型:
bool
- async login_async(loginurl: str = 'http://10.2.7.16:8080', ua: str = None) bool [源代码]#
异步登录自助服务平台
- 参数:
loginurl (str) – 自助服务平台的登录 URL
ua (str) – User Agent,默认随机生成
- 返回:
登录是否成功
- 返回类型:
bool
- logout_device(sessionid: str) bool [源代码]#
注销指定设备
- 参数:
sessionid (str) – sessionid,可通过 get_online_devices() 获取
- 返回:
成功或失败
- 返回类型:
bool
- async logout_device_async(sessionid: str) bool [源代码]#
异步注销指定设备
- 参数:
sessionid (str) – sessionid,可通过 get_online_devices_async() 获取
- 返回:
成功或失败
- 返回类型:
bool
- portal_auth(interface: str = None, authurl: str = 'http://10.2.7.8:801', ua: str = None, isp: str = 'campus') Tuple[str, bool, str] [源代码]#
进行校园网认证
- 参数:
interface (str) – 网络接口名
authurl (str) – PortalAuth 服务器。根据情况修改
ua (str) – User-Agent,默认随机生成
isp (str) – 运营商。可选项:campus,cm,ct,cu
- 返回:
Tuple[str, bool, str]
interface (str) – 本次认证调用的网络接口。
success (bool) – 认证是否成功。(不可信,有时失败仍可正常上网)
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[str,bool,str]
- async portal_auth_async(interface: str = None, authurl: str = 'http://10.2.7.8:801', ua: str = None, isp: str = 'campus') Tuple[str, bool, str] [源代码]#
异步进行校园网认证
- 参数:
interface (str) – 网络接口名
authurl (str) – PortalAuth 服务器。根据情况修改
ua (str) – User-Agent,默认随机生成
isp (str) – 运营商。可选项:campus,cm,ct,cu
- 返回:
Tuple[str, bool, str]
interface (str) – 本次认证调用的网络接口。
success (bool) – 认证是否成功。(不可信,有时失败仍可正常上网)
msg (str) – 服务端返回信息。
- 返回类型:
Tuple[str,bool,str]
Models#
- pydantic model models.Course[源代码]#
基类:
BaseModel
单个课程信息模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "Course", "description": "\u5355\u4e2a\u8bfe\u7a0b\u4fe1\u606f\u6a21\u578b", "type": "object", "properties": { "course_code": { "title": "Course Code", "type": "string" }, "course_name": { "title": "Course Name", "type": "string" }, "date": { "title": "Date", "type": "string" }, "end_time": { "title": "End Time", "type": "string" }, "end_unit": { "title": "End Unit", "type": "integer" }, "lesson_id": { "title": "Lesson Id", "type": "integer" }, "lesson_no": { "title": "Lesson No", "type": "string" }, "rooms": { "items": { "$ref": "#/$defs/Room" }, "title": "Rooms", "type": "array" }, "start_time": { "title": "Start Time", "type": "string" }, "start_unit": { "title": "Start Unit", "type": "integer" }, "teachclass_std_count": { "title": "Teachclass Std Count", "type": "integer" }, "teachers": { "items": { "$ref": "#/$defs/Teacher" }, "title": "Teachers", "type": "array" }, "weeks": { "title": "Weeks", "type": "string" }, "weekstate": { "title": "Weekstate", "type": "string" } }, "$defs": { "Room": { "description": "\u6559\u5ba4\u4fe1\u606f\u6a21\u578b", "properties": { "address": { "title": "Address", "type": "string" }, "building": { "title": "Building", "type": "string" }, "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "latitude": { "default": "", "title": "Latitude", "type": "string" }, "longitude": { "default": "", "title": "Longitude", "type": "string" }, "name": { "title": "Name", "type": "string" } }, "required": [ "address", "building", "code", "id", "name" ], "title": "Room", "type": "object" }, "Teacher": { "description": "\u6559\u5e08\u4fe1\u606f\u6a21\u578b", "properties": { "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "name": { "title": "Name", "type": "string" } }, "required": [ "code", "id", "name" ], "title": "Teacher", "type": "object" } }, "required": [ "course_code", "course_name", "date", "end_time", "end_unit", "lesson_id", "lesson_no", "rooms", "start_time", "start_unit", "teachclass_std_count", "teachers", "weeks", "weekstate" ] }
- Fields:
- field course_code: str [Required]#
课程代码
- field course_name: str [Required]#
课程名称
- field date: str [Required]#
上课日期,格式为YYYY-MM-DD
- field end_time: str [Required]#
下课时间,格式为HH:MM
- field end_unit: int [Required]#
结束节次
- field lesson_id: int [Required]#
课程ID
- field lesson_no: str [Required]#
课程编号
- field start_time: str [Required]#
上课时间,格式为HH:MM
- field start_unit: int [Required]#
开始节次
- field teachclass_std_count: int [Required]#
班级学生数量
- field weeks: str [Required]#
周次
- field weekstate: str [Required]#
周状态
- pydantic model models.Courses[源代码]#
基类:
BaseModel
课程列表模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "Courses", "description": "\u8bfe\u7a0b\u5217\u8868\u6a21\u578b", "type": "object", "properties": { "courses": { "description": "\u8bfe\u7a0b\u5217\u8868", "items": { "$ref": "#/$defs/Course" }, "title": "Courses", "type": "array" } }, "$defs": { "Course": { "description": "\u5355\u4e2a\u8bfe\u7a0b\u4fe1\u606f\u6a21\u578b", "properties": { "course_code": { "title": "Course Code", "type": "string" }, "course_name": { "title": "Course Name", "type": "string" }, "date": { "title": "Date", "type": "string" }, "end_time": { "title": "End Time", "type": "string" }, "end_unit": { "title": "End Unit", "type": "integer" }, "lesson_id": { "title": "Lesson Id", "type": "integer" }, "lesson_no": { "title": "Lesson No", "type": "string" }, "rooms": { "items": { "$ref": "#/$defs/Room" }, "title": "Rooms", "type": "array" }, "start_time": { "title": "Start Time", "type": "string" }, "start_unit": { "title": "Start Unit", "type": "integer" }, "teachclass_std_count": { "title": "Teachclass Std Count", "type": "integer" }, "teachers": { "items": { "$ref": "#/$defs/Teacher" }, "title": "Teachers", "type": "array" }, "weeks": { "title": "Weeks", "type": "string" }, "weekstate": { "title": "Weekstate", "type": "string" } }, "required": [ "course_code", "course_name", "date", "end_time", "end_unit", "lesson_id", "lesson_no", "rooms", "start_time", "start_unit", "teachclass_std_count", "teachers", "weeks", "weekstate" ], "title": "Course", "type": "object" }, "Room": { "description": "\u6559\u5ba4\u4fe1\u606f\u6a21\u578b", "properties": { "address": { "title": "Address", "type": "string" }, "building": { "title": "Building", "type": "string" }, "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "latitude": { "default": "", "title": "Latitude", "type": "string" }, "longitude": { "default": "", "title": "Longitude", "type": "string" }, "name": { "title": "Name", "type": "string" } }, "required": [ "address", "building", "code", "id", "name" ], "title": "Room", "type": "object" }, "Teacher": { "description": "\u6559\u5e08\u4fe1\u606f\u6a21\u578b", "properties": { "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "name": { "title": "Name", "type": "string" } }, "required": [ "code", "id", "name" ], "title": "Teacher", "type": "object" } } }
- Fields:
- pydantic model models.DeviceParams[源代码]#
基类:
BaseModel
设备参数模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "DeviceParams", "description": "\u8bbe\u5907\u53c2\u6570\u6a21\u578b", "type": "object", "properties": { "deviceName": { "title": "Devicename", "type": "string" }, "deviceId": { "title": "Deviceid", "type": "string" }, "deviceInfo": { "title": "Deviceinfo", "type": "string" }, "deviceInfos": { "title": "Deviceinfos", "type": "string" }, "userAgentPrecursor": { "title": "Useragentprecursor", "type": "string" } }, "required": [ "deviceName", "deviceId", "deviceInfo", "deviceInfos", "userAgentPrecursor" ] }
- field deviceId: str [Required]#
设备ID
- field deviceInfo: str [Required]#
设备信息
- field deviceInfos: str [Required]#
设备详细信息
- field deviceName: str [Required]#
设备名称
- field userAgentPrecursor: str [Required]#
用户代理前缀
- pydantic model models.LoginResult[源代码]#
基类:
BaseModel
登录结果模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "LoginResult", "description": "\u767b\u5f55\u7ed3\u679c\u6a21\u578b", "type": "object", "properties": { "success": { "title": "Success", "type": "boolean" }, "usercode": { "title": "Usercode", "type": "string" }, "name": { "title": "Name", "type": "string" }, "user_token": { "title": "User Token", "type": "string" }, "refresh_token": { "title": "Refresh Token", "type": "string" }, "dynamic_secret": { "title": "Dynamic Secret", "type": "string" }, "dynamic_token": { "title": "Dynamic Token", "type": "string" }, "biz_type_id": { "title": "Biz Type Id", "type": "integer" }, "current_semester_id": { "title": "Current Semester Id", "type": "integer" } }, "required": [ "success", "usercode", "name", "user_token", "refresh_token", "dynamic_secret", "dynamic_token", "biz_type_id", "current_semester_id" ] }
- Fields:
- field biz_type_id: int [Required]#
业务类型 ID,区分本科生与研究生
- field current_semester_id: int [Required]#
当前学期 ID
- field dynamic_secret: str [Required]#
动态 Secret
- field dynamic_token: str [Required]#
动态 Token
- field name: str [Required]#
用户姓名
- field refresh_token: str [Required]#
刷新 Token
- field success: bool [Required]#
登录是否成功
- field user_token: str [Required]#
用户 Token
- field usercode: str [Required]#
学号
- pydantic model models.OnlineDevice[源代码]#
基类:
BaseModel
在线设备信息模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "OnlineDevice", "description": "\u5728\u7ebf\u8bbe\u5907\u4fe1\u606f\u6a21\u578b", "type": "object", "properties": { "brasid": { "title": "Brasid", "type": "string" }, "downFlow": { "title": "Downflow", "type": "string" }, "hostName": { "default": "", "title": "Hostname", "type": "string" }, "ip": { "title": "Ip", "type": "string" }, "loginTime": { "title": "Logintime", "type": "string" }, "mac": { "title": "Mac", "type": "string" }, "sessionId": { "title": "Sessionid", "type": "string" }, "terminalType": { "title": "Terminaltype", "type": "string" }, "upFlow": { "title": "Upflow", "type": "string" }, "useTime": { "title": "Usetime", "type": "string" }, "userId": { "title": "Userid", "type": "integer" } }, "required": [ "brasid", "downFlow", "ip", "loginTime", "mac", "sessionId", "terminalType", "upFlow", "useTime", "userId" ] }
- Fields:
- field brasid: str [Required]#
BRAS ID
- field downFlow: str [Required]#
下行流量
- field hostName: str = ''#
主机名
- field ip: str [Required]#
IP地址
- field loginTime: str [Required]#
登录时间,格式为YYYY-MM-DD HH:MM:SS
- field mac: str [Required]#
MAC地址
- field sessionId: str [Required]#
会话ID
- field terminalType: str [Required]#
终端类型
- field upFlow: str [Required]#
上行流量
- field useTime: str [Required]#
使用时间(秒)
- field userId: int [Required]#
用户ID
- pydantic model models.OnlineDevices[源代码]#
基类:
BaseModel
在线设备列表模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "OnlineDevices", "description": "\u5728\u7ebf\u8bbe\u5907\u5217\u8868\u6a21\u578b", "type": "object", "properties": { "devices": { "description": "\u5728\u7ebf\u8bbe\u5907\u5217\u8868", "items": { "$ref": "#/$defs/OnlineDevice" }, "title": "Devices", "type": "array" } }, "$defs": { "OnlineDevice": { "description": "\u5728\u7ebf\u8bbe\u5907\u4fe1\u606f\u6a21\u578b", "properties": { "brasid": { "title": "Brasid", "type": "string" }, "downFlow": { "title": "Downflow", "type": "string" }, "hostName": { "default": "", "title": "Hostname", "type": "string" }, "ip": { "title": "Ip", "type": "string" }, "loginTime": { "title": "Logintime", "type": "string" }, "mac": { "title": "Mac", "type": "string" }, "sessionId": { "title": "Sessionid", "type": "string" }, "terminalType": { "title": "Terminaltype", "type": "string" }, "upFlow": { "title": "Upflow", "type": "string" }, "useTime": { "title": "Usetime", "type": "string" }, "userId": { "title": "Userid", "type": "integer" } }, "required": [ "brasid", "downFlow", "ip", "loginTime", "mac", "sessionId", "terminalType", "upFlow", "useTime", "userId" ], "title": "OnlineDevice", "type": "object" } } }
- field devices: List[OnlineDevice] [Optional]#
在线设备列表
- classmethod from_list(devices_list: List[Dict[str, Any]]) OnlineDevices [源代码]#
从设备列表创建OnlineDevices对象
- pydantic model models.Room[源代码]#
基类:
BaseModel
教室信息模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "Room", "description": "\u6559\u5ba4\u4fe1\u606f\u6a21\u578b", "type": "object", "properties": { "address": { "title": "Address", "type": "string" }, "building": { "title": "Building", "type": "string" }, "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "latitude": { "default": "", "title": "Latitude", "type": "string" }, "longitude": { "default": "", "title": "Longitude", "type": "string" }, "name": { "title": "Name", "type": "string" } }, "required": [ "address", "building", "code", "id", "name" ] }
- field address: str [Required]#
教室地址
- field building: str [Required]#
所在建筑
- field code: str [Required]#
教室代码
- field id: int [Required]#
教室ID
- field latitude: str = ''#
纬度
- field longitude: str = ''#
经度
- field name: str [Required]#
教室名称
- pydantic model models.RoomOccupancy[源代码]#
基类:
BaseModel
教室占用信息模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "RoomOccupancy", "description": "\u6559\u5ba4\u5360\u7528\u4fe1\u606f\u6a21\u578b", "type": "object", "properties": { "building_code": { "title": "Building Code", "type": "string" }, "building_name": { "title": "Building Name", "type": "string" }, "campus_code": { "title": "Campus Code", "type": "string" }, "campus_name": { "title": "Campus Name", "type": "string" }, "floor": { "title": "Floor", "type": "string" }, "occupy_units": { "title": "Occupy Units", "type": "string" }, "room_capacity": { "title": "Room Capacity", "type": "integer" }, "room_code": { "title": "Room Code", "type": "string" }, "room_id": { "title": "Room Id", "type": "string" }, "room_name": { "title": "Room Name", "type": "string" }, "room_type": { "title": "Room Type", "type": "string" } }, "required": [ "building_code", "building_name", "campus_code", "campus_name", "floor", "occupy_units", "room_capacity", "room_code", "room_id", "room_name", "room_type" ] }
- Fields:
- field building_code: str [Required]#
建筑代码
- field building_name: str [Required]#
建筑名称
- field campus_code: str [Required]#
校区代码
- field campus_name: str [Required]#
校区名称
- field floor: str [Required]#
楼层
- field occupy_units: str [Required]#
占用单元,字符串形式的二进制表示(1表示占用,0表示空闲)
- field room_capacity: int [Required]#
教室容量
- field room_code: str [Required]#
教室代码
- field room_id: str [Required]#
教室ID
- field room_name: str [Required]#
教室名称
- field room_type: str [Required]#
教室类型
- pydantic model models.RoomOccupancyData[源代码]#
基类:
BaseModel
教室占用数据模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "RoomOccupancyData", "description": "\u6559\u5ba4\u5360\u7528\u6570\u636e\u6a21\u578b", "type": "object", "properties": { "date": { "title": "Date", "type": "string" }, "max_unit": { "title": "Max Unit", "type": "integer" }, "rooms": { "items": { "$ref": "#/$defs/RoomOccupancy" }, "title": "Rooms", "type": "array" } }, "$defs": { "RoomOccupancy": { "description": "\u6559\u5ba4\u5360\u7528\u4fe1\u606f\u6a21\u578b", "properties": { "building_code": { "title": "Building Code", "type": "string" }, "building_name": { "title": "Building Name", "type": "string" }, "campus_code": { "title": "Campus Code", "type": "string" }, "campus_name": { "title": "Campus Name", "type": "string" }, "floor": { "title": "Floor", "type": "string" }, "occupy_units": { "title": "Occupy Units", "type": "string" }, "room_capacity": { "title": "Room Capacity", "type": "integer" }, "room_code": { "title": "Room Code", "type": "string" }, "room_id": { "title": "Room Id", "type": "string" }, "room_name": { "title": "Room Name", "type": "string" }, "room_type": { "title": "Room Type", "type": "string" } }, "required": [ "building_code", "building_name", "campus_code", "campus_name", "floor", "occupy_units", "room_capacity", "room_code", "room_id", "room_name", "room_type" ], "title": "RoomOccupancy", "type": "object" } }, "required": [ "date", "max_unit", "rooms" ] }
- field date: str [Required]#
日期,格式为YYYY-MM-DD
- field max_unit: int [Required]#
最大单元数(一天中的时间段总数)
- field rooms: List[RoomOccupancy] [Required]#
教室占用信息列表
- get_available_rooms(unit_index: int) List[RoomOccupancy] [源代码]#
获取指定时间单元可用的教室列表
- 参数:
unit_index – 时间单元索引(从1开始)
- 返回:
可用教室列表
- 返回类型:
List[RoomOccupancy]
- 抛出:
ValueError – 如果时间单元索引超出范围
- pydantic model models.Semester[源代码]#
基类:
BaseModel
学期模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "Semester", "description": "\u5b66\u671f\u6a21\u578b", "type": "object", "properties": { "code": { "title": "Code", "type": "string" }, "end_date": { "title": "End Date", "type": "string" }, "id": { "title": "Id", "type": "string" }, "name": { "title": "Name", "type": "string" }, "season": { "title": "Season", "type": "string" }, "start_date": { "title": "Start Date", "type": "string" }, "week_start_day": { "title": "Week Start Day", "type": "integer" }, "year": { "title": "Year", "type": "string" } }, "required": [ "code", "end_date", "id", "name", "season", "start_date", "week_start_day", "year" ] }
- Fields:
- field code: str [Required]#
学期号
- field end_date: str [Required]#
学期结束日期
- field id: str [Required]#
学期 ID
- field name: str [Required]#
学期名
- field season: str [Required]#
学期季节
- field start_date: str [Required]#
学期开始日期
- field week_start_day: int [Required]#
学期周起始日
- field year: str [Required]#
学期年份
- pydantic model models.SemesterData[源代码]#
基类:
BaseModel
学期数据模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "SemesterData", "description": "\u5b66\u671f\u6570\u636e\u6a21\u578b", "type": "object", "properties": { "cur_semester_id": { "title": "Cur Semester Id", "type": "integer" }, "semesters": { "items": { "$ref": "#/$defs/Semester" }, "title": "Semesters", "type": "array" } }, "$defs": { "Semester": { "description": "\u5b66\u671f\u6a21\u578b", "properties": { "code": { "title": "Code", "type": "string" }, "end_date": { "title": "End Date", "type": "string" }, "id": { "title": "Id", "type": "string" }, "name": { "title": "Name", "type": "string" }, "season": { "title": "Season", "type": "string" }, "start_date": { "title": "Start Date", "type": "string" }, "week_start_day": { "title": "Week Start Day", "type": "integer" }, "year": { "title": "Year", "type": "string" } }, "required": [ "code", "end_date", "id", "name", "season", "start_date", "week_start_day", "year" ], "title": "Semester", "type": "object" } }, "required": [ "cur_semester_id", "semesters" ] }
- field cur_semester_id: int [Required]#
默认学期ID
- pydantic model models.Teacher[源代码]#
基类:
BaseModel
教师信息模型
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "Teacher", "description": "\u6559\u5e08\u4fe1\u606f\u6a21\u578b", "type": "object", "properties": { "code": { "title": "Code", "type": "string" }, "id": { "title": "Id", "type": "integer" }, "name": { "title": "Name", "type": "string" } }, "required": [ "code", "id", "name" ] }
- Fields:
- field code: str [Required]#
教师代码
- field id: int [Required]#
教师ID
- field name: str [Required]#
教师姓名