joinClass static method
Implementation
static Future<TCICJoinClassRepModel?> joinClass(JoinClassBody body) async {
// 判断当前平台
int platform;
// if (Platform.isAndroid) {
// platform = PlatformEnum.flutterAndroid.index;
// } else if (Platform.isIOS) {
// platform = PlatformEnum.flutterIOS.index;
// } else if (Platform.isMacOS) {
// platform = PlatformEnum.flutterMacOS.index;
// } else if (Platform.isWindows) {
// platform = PlatformEnum.flutterWindows.index;
// } else if (Platform.isLinux) {
// platform = PlatformEnum.flutterLinux.index;
// } else {
// platform = PlatformEnum.unknown.index;
// }
int device;
if (Platform.isAndroid) {
platform = PlatformEnum.android.index;
device = TDeviceEnum.phone.index;
} else if (Platform.isIOS) {
platform = PlatformEnum.ios.index;
device = TDeviceEnum.phone.index;
} else if (Platform.isMacOS) {
platform = PlatformEnum.mac.index;
device = TDeviceEnum.mac.index;
} else if (Platform.isWindows) {
platform = PlatformEnum.windows.index;
device = TDeviceEnum.windows.index;
} else {
platform = PlatformEnum.unknown.index;
device = TDeviceEnum.unknown.index;
}
if(!Tools.isPlatformAvailable(platform)){
final str = TCICController.instance.getStringObs().getString(StringEnum.platformNotAvailable);
TCICLog.info('JoinClass isPlatformAvailable false ${body.toJson()} platform $platform',actionModule: ActionModule.memberService.name,actionName: ActionName.joinClass.name);
return TCICJoinClassRepModel.fromJson({
"error_code": -1,
"error_msg": str,
});
}
body.platform = platform;
body.device = device;
// 特殊处理老师和助教
if(body.role ==RoleEnum.supervisor.index){
body.role = 1;
} else {
body.role = 0;
}
//设置device
var data = await HttpClient.post<TCICJoinClassRepModel, JoinClassBody>(
api: "/v1/member/join",
body: body,
fromJson: TCICJoinClassRepModel.fromJson,
);
TCICLog.info(' JoinClass ${data?.toJson()}',actionModule: ActionModule.memberService.name,actionName: ActionName.joinClass.name);
return data;
}