自习室优化ok

This commit is contained in:
zhutao
2025-11-28 13:31:23 +08:00
parent 4ecb0c35d6
commit 57305c5804
57 changed files with 2500 additions and 597 deletions

View File

@@ -0,0 +1,18 @@
import '../dto/common/qiu_token_dto.dart';
import '../dto/common/version_dto.dart';
import '../network/request.dart';
///获取七牛token
/// - [fileKey]: 文件key
Future<QiuTokenDto> getQiuTokenApi(String fileKey) async {
var response = await Request().get("/files/get_qiniu_upload_token", {
"file_key": fileKey,
});
return QiuTokenDto.fromJson(response);
}
///获取APP最新版本
Future<VersionDto> getAppVersionApi() async {
var response = await Request().get("/get_latest_version");
return VersionDto.fromJson(response);
}

View File

@@ -1,12 +1,12 @@
import 'package:app/request/dto/room/rtc_token_dto.dart';
import 'package:app/request/network/request.dart';
import '../dto/room/room_info_dto.dart';
import '../dto/room/room_list_item_dto.dart';
/// 获取房间列表
Future<List<RoomInfoDto>> getRoomListApi() async {
Future<List<RoomListItemDto >> getRoomListApi() async {
var res = await Request().get('/study_room/get_study_room_list');
return List<RoomInfoDto>.from(res.map((x) => RoomInfoDto.fromJson(x)));
return List<RoomListItemDto >.from(res.map((x) => RoomListItemDto .fromJson(x)));
}
///获取自习室的websocket令牌

View File

@@ -0,0 +1,24 @@
class QiuTokenDto {
String? uploadUrl;
String? upToken;
String? fileKey;
String? domain;
QiuTokenDto({this.uploadUrl, this.upToken, this.fileKey, this.domain});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["upload_url"] = uploadUrl;
map["up_token"] = upToken;
map["file_key"] = fileKey;
map["domain"] = domain;
return map;
}
QiuTokenDto.fromJson(dynamic json) {
uploadUrl = json["upload_url"] ?? "";
upToken = json["up_token"] ?? "";
fileKey = json["file_key"] ?? "";
domain = json["domain"] ?? "";
}
}

View File

@@ -0,0 +1,47 @@
class VersionDto {
VersionDto({
required this.latestVersion,
required this.updatedAt,
required this.downloadUrl,
required this.updateContent,
required this.createdAt,
required this.lowVersion,
required this.id,
required this.downloadSize,
required this.platform,
});
String latestVersion;
DateTime updatedAt;
String downloadUrl;
List<String> updateContent;
DateTime createdAt;
String lowVersion;
int id;
String downloadSize;
int platform;
factory VersionDto.fromJson(Map<dynamic, dynamic> json) => VersionDto(
latestVersion: json["latest_version"],
updatedAt: DateTime.parse(json["updated_at"]),
downloadUrl: json["download_url"],
updateContent: List<String>.from(json["update_content"].map((x) => x)),
createdAt: DateTime.parse(json["created_at"]),
lowVersion: json["low_version"],
id: json["id"],
downloadSize: json["download_size"],
platform: json["platform"],
);
Map<dynamic, dynamic> toJson() => {
"latest_version": latestVersion,
"updated_at": updatedAt.toIso8601String(),
"download_url": downloadUrl,
"update_content": List<dynamic>.from(updateContent.map((x) => x)),
"created_at": createdAt.toIso8601String(),
"low_version": lowVersion,
"id": id,
"download_size": downloadSize,
"platform": platform,
};
}

View File

@@ -1,41 +1,52 @@
class RoomInfoDto {
final int studyRoomId;
final int teacherId;
final int teacherRtcUid;
final String teacherWsClientId;
final int roomStatus;
final String dataType;
final String roomStartTime;
final String roomEndTime;
final String boardUuid;
RoomInfoDto({
required this.teacherBackground,
required this.teacherAvatar,
required this.roomName,
required this.startTime,
required this.teacherName,
required this.endTime,
required this.id,
required this.studyRoomId,
required this.teacherId,
required this.teacherRtcUid,
required this.teacherWsClientId,
required this.roomStatus,
required this.dataType,
required this.roomStartTime,
required this.roomEndTime,
required this.boardUuid,
});
String teacherBackground;
String teacherAvatar;
String roomName;
String startTime;
String teacherName;
String endTime;
int id;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["study_room_id"] = studyRoomId;
map["teacher_id"] = teacherId;
map["teacher_rtc_uid"] = teacherRtcUid;
map["teacher_ws_client_id"] = teacherWsClientId;
map["room_status"] = roomStatus;
map["data_type"] = dataType;
map["room_start_time"] = roomStartTime;
map["room_end_time"] = roomEndTime;
map["whiteboard_uuid"] = boardUuid;
return map;
}
factory RoomInfoDto.fromJson(Map<dynamic, dynamic> json) =>
RoomInfoDto(
teacherBackground: json["teacher_background"],
teacherAvatar: json["teacher_avatar"],
roomName: json["room_name"],
startTime: json["start_time"],
teacherName: json["teacher_name"],
endTime: json["end_time"],
id: json["id"],
);
Map<dynamic, dynamic> toJson() =>
{
"teacher_background": teacherBackground,
"teacher_avatar": teacherAvatar,
"room_name": roomName,
"start_time": startTime,
"teacher_name": teacherName,
"end_time": endTime,
"id": id,
};
factory RoomInfoDto.fromJson(Map<String, dynamic> json) {
return RoomInfoDto(
studyRoomId: json["study_room_id"] ?? 0,
teacherId: json["teacher_id"] ?? 0,
teacherRtcUid: json["teacher_rtc_uid"] ?? 0,
teacherWsClientId: json["teacher_ws_client_id"] ?? "",
roomStatus: json["room_status"] ?? 0,
dataType: json["data_type"] ?? "",
roomStartTime: json["room_start_time"] ?? "",
roomEndTime: json["room_end_time"] ?? "",
boardUuid: json["whiteboard_uuid"] ?? "",
);
}
}

View File

@@ -0,0 +1,51 @@
class RoomListItemDto {
RoomListItemDto({
required this.teacherGrade,
required this.roomName,
required this.startTime,
required this.teacherName,
required this.teacherAvatar,
required this.endTime,
required this.teacherSchoolName,
required this.teacherIntroduction,
required this.id,
required this.teacherMajor,
});
String teacherGrade;
String roomName;
String startTime;
String teacherName;
String teacherAvatar;
String endTime;
String teacherSchoolName;
String teacherIntroduction;
int id;
String teacherMajor;
factory RoomListItemDto.fromJson(Map<dynamic, dynamic> json) => RoomListItemDto(
teacherGrade: json["teacher_grade"],
roomName: json["room_name"],
startTime: json["start_time"],
teacherName: json["teacher_name"],
teacherAvatar: json["teacher_avatar"],
endTime: json["end_time"],
teacherSchoolName: json["teacher_school_name"],
teacherIntroduction: json["teacher_introduction"],
id: json["id"],
teacherMajor: json["teacher_major"],
);
Map<dynamic, dynamic> toJson() => {
"teacher_grade": teacherGrade,
"room_name": roomName,
"start_time": startTime,
"teacher_name": teacherName,
"teacher_avatar": teacherAvatar,
"end_time": endTime,
"teacher_school_name": teacherSchoolName,
"teacher_introduction": teacherIntroduction,
"id": id,
"teacher_major": teacherMajor,
};
}

View File

@@ -1,39 +0,0 @@
class RoomTypeDto {
final int studyRoomId;
final int teacherId;
final int teacherRtcUid;
final String teacherWsClientId;
final int roomStatus;
final String dataType;
RoomTypeDto({
required this.studyRoomId,
required this.teacherId,
required this.teacherRtcUid,
required this.teacherWsClientId,
required this.roomStatus,
required this.dataType,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["study_room_id"] = studyRoomId;
map["teacher_id"] = teacherId;
map["teacher_rtc_uid"] = teacherRtcUid;
map["teacher_ws_client_id"] = teacherWsClientId;
map["room_status"] = roomStatus;
map["data_type"] = dataType;
return map;
}
factory RoomTypeDto.fromJson(Map<String, dynamic> json) {
return RoomTypeDto(
studyRoomId: json["study_room_id"] ?? 0,
teacherId: json["teacher_id"] ?? 0,
teacherRtcUid: json["teacher_rtc_uid"] ?? 0,
teacherWsClientId: json["teacher_ws_client_id"] ?? "",
roomStatus: json["room_status"] ?? 0,
dataType: json["data_type"] ?? "",
);
}
}

View File

@@ -10,7 +10,7 @@ class RoomUserDto {
/// 1是学生2是老师
final int userType;
final List<String> filesList;
List<String> filesList;
final String dataType;
int handup;
int online; //0离线1在线

View File

@@ -80,6 +80,12 @@ enum RoomEvent {
///老师关闭学生的麦克风
closeStudentMic("sys_control_mute_microphone"),
///老师打开学生的麦克风
openStudentMic("sys_control_unmute_microphone"),
///老师开启学生的摄像头
openStudentCamera("sys_control_unmute_camera"),
///老师关闭学生的摄像头
closeStudentCamera("sys_control_mute_camera"),

View File

@@ -66,7 +66,10 @@ class RoomWebSocket {
print("未识别的 action: ${jsonMap['action']},消息已忽略");
return; // 直接跳过
} else {
logger.i("接收到事件: ${event.value}");
logger.i("""
接收到事件: ${event.value}
数据: ${jsonMap['data']}
""");
}
final msg = RoomMessage(event, jsonMap['data']);
_msgController.add(msg);
@@ -96,7 +99,7 @@ class RoomWebSocket {
"action": action.value,
if (params != null) ...params,
};
if(action != RoomCommand.ping){
if (action != RoomCommand.ping) {
logger.i("发送指令:$msg");
}