Xử hàm đăng nhập

This commit is contained in:
minhhieu2312 2026-02-26 16:48:36 +07:00
parent 81410f6f15
commit 9c67d123c8
21 changed files with 2421 additions and 4212 deletions

View File

@ -162,6 +162,31 @@ class SwaggerRequestsGenerator {
options: options,
);
// Nếu cấu hình override multipart cho url + method này,
// force signature dùng @Part() Map<String, dynamic> body.
final hasMultipartOverride = options.requestOverrideValueMap.any(
(override) =>
override.url == path &&
override.method.toLowerCase() == requestType.toLowerCase() &&
override.paramName.toLowerCase() == 'multipart',
);
if (hasMultipartOverride) {
parameters
..clear()
..add(
Parameter(
(p) => p
..name = kBody
..named = true
..type = Reference('Map<String, dynamic>')
..annotations.add(
refer('Part').call([]),
),
),
);
}
// Override request params
final temp = options.requestOverrideValueMap
.firstWhereOrNull((element) => element.url == path && element.method == 'get');
@ -226,7 +251,9 @@ class SwaggerRequestsGenerator {
options: options,
))
..name = effectiveMethodName
..annotations.add(_getMethodAnnotation(requestType, path, hasOptionalBody))
..annotations.addAll(
_getMethodAnnotations(requestType, path, hasOptionalBody, options),
)
..returns = Reference(returns));
if (_hasEnumProperties(method)) {
@ -291,14 +318,37 @@ class SwaggerRequestsGenerator {
return Code('return _$publicMethodName($parametersListString);');
}
Expression _getMethodAnnotation(
/// Trả về danh sách annotation cho method ( dụ: @POST + @MultiPart).
List<Expression> _getMethodAnnotations(
String requestType,
String path,
bool hasOptionalBody,
GeneratorOptions options,
) {
return refer(requestType.pascalCase.toUpperCase()).call([literalString(path)],
final annotations = <Expression>[];
// Annotation HTTP method chính (@GET/@POST/...)
annotations.add(
refer(requestType.pascalCase.toUpperCase()).call(
[literalString(path)],
//{kPath: literalString(path), if (hasOptionalBody) 'optionalBody': refer(true.toString())},
{});
{},
),
);
// Nếu override kiểu "multipart" cho url + method này thì thêm @MultiPart()
final isMultipart = options.requestOverrideValueMap.any(
(override) =>
override.url == path &&
override.method.toLowerCase() == requestType.toLowerCase() &&
override.paramName.toLowerCase() == 'multipart',
);
if (isMultipart) {
annotations.add(refer('MultiPart').call([]));
}
return annotations;
}
String _getCommentsForMethod({
@ -472,7 +522,13 @@ class SwaggerRequestsGenerator {
.toList();
final overridenRequests = options.requestOverrideValueMap;
;
final isMultipartOverride = overridenRequests.any(
(override) =>
override.url == path &&
override.method.toLowerCase() == requestType.toLowerCase() &&
override.paramName.toLowerCase() == 'multipart',
);
final result = _getParameter(parameters, ignoreHeaders, excludeParams)
// .where((element) => excludeParams.isEmpty || !excludeParams.contains(element.name.toLowerCase()))
@ -529,6 +585,26 @@ class SwaggerRequestsGenerator {
final schema = requestBody.content?.schema;
if (schema != null) {
// Nếu endpoint đưc đánh dấu multipart trong request_override_value_map,
// sinh một param duy nhất dạng @Part() Map<String, dynamic> body
// đ caller tự build map/form-data.
if (isMultipartOverride) {
result.add(
Parameter(
(p) => p
..name = kBody
..named = true
..type = Reference('Map<String, dynamic>')
..annotations.add(
refer('Part').call([]),
),
),
);
// Không thêm @Body nữa.
return result.distinctParameters();
}
if (schema.format == kBinary) {
typeName = kObject.pascalCase;
} else {

View File

@ -63,6 +63,14 @@ targets:
- "/weatherforecast/get"
response_override_value_map:
request_override_value_map:
- url: "/api/v1/account/login"
method: post
param_name: "body"
overridden_value: "LoginDto"
- url: "/api/v1/account/login"
method: post
param_name: "multipart"
overridden_value: "true"
# default_header_values_map:
# - header_name: "X-Entitlements-Token"
# default_value: "X-Entitlements-Token"

View File

@ -1,20 +1,20 @@
import 'package:baseproject/core/common/custom_interceptor.dart';
import 'package:baseproject/core/components/alice.dart';
import 'package:baseproject/features/presentation/app/view/app.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
// import 'package:baseproject/core/common/custom_interceptor.dart';
// import 'package:baseproject/core/components/alice.dart';
// import 'package:baseproject/features/presentation/app/view/app.dart';
// import 'package:dio/dio.dart';
// import 'package:flutter/foundation.dart';
// import 'package:injectable/injectable.dart';
@module
abstract class RegisterCommonModule {
@lazySingleton
Dio get dio => Dio()
..interceptors.addAll(kDebugMode
? [CustomInterceptor(), CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor()]
: [CustomInterceptor()])
..options = BaseOptions(
receiveTimeout: 10000,
connectTimeout: 10000,
sendTimeout: 10000,
);
}
// @module
// abstract class RegisterCommonModule {
// @lazySingleton
// Dio get dio => Dio()
// ..interceptors.addAll(kDebugMode
// ? [CustomInterceptor(), CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor()]
// : [CustomInterceptor()])
// ..options = BaseOptions(
// receiveTimeout: 10000,
// connectTimeout: 10000,
// sendTimeout: 10000,
// );
// }

View File

@ -19,7 +19,6 @@ class CustomInterceptor extends InterceptorsWrapper {
// options.queryParameters[key] = value.toInt();
// }
// });
}
return super.onRequest(options, handler);
@ -78,18 +77,18 @@ class CustomInterceptor extends InterceptorsWrapper {
final dynamic errorData = err.response?.data;
//&& err.response?.statusCode == 400
if (errorData != null && errorData["responseException"] != null) {
final dynamic temp = errorData["responseException"]["exceptionMessage"];
try {
if (temp != null && temp["error"] != null) {
err.response?.data = temp["error"];
} else {
err.response?.data = temp;
}
} catch (e) {
err.response?.data = temp;
}
}
// if (errorData != null && errorData["responseException"] != null) {
// final dynamic temp = errorData["responseException"]["exceptionMessage"];
// try {
// if (temp != null && temp["error"] != null) {
// err.response?.data = temp["error"];
// } else {
// err.response?.data = temp;
// }
// } catch (e) {
// err.response?.data = temp;
// }
// }
return super.onError(err, handler);
}

View File

@ -5,11 +5,13 @@
// **************************************************************************
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:dio/dio.dart' as _i3;
import 'package:get_it/get_it.dart' as _i1;
import 'package:injectable/injectable.dart' as _i2;
import 'common_module.dart' as _i4; // ignore_for_file: unnecessary_lambdas
import '../../features/presentation/account/bloc/login_bloc.dart' as _i5;
import '../../features/repositories/hra_repository.dart' as _i4;
import '../../features/usecases/user_use_cases.dart'
as _i3; // ignore_for_file: unnecessary_lambdas
// ignore_for_file: lines_longer_than_80_chars
/// initializes the registration of provided dependencies inside of [GetIt]
@ -23,9 +25,8 @@ _i1.GetIt $initGetIt(
environment,
environmentFilter,
);
final registerCommonModule = _$RegisterCommonModule();
gh.lazySingleton<_i3.Dio>(() => registerCommonModule.dio);
gh.lazySingleton<_i3.UserUseCases>(
() => _i3.UserUseCases(get<_i4.HraRepository>()));
gh.factory<_i5.LoginBloc>(() => _i5.LoginBloc(get<_i3.UserUseCases>()));
return get;
}
class _$RegisterCommonModule extends _i4.RegisterCommonModule {}

View File

@ -1,17 +1,48 @@
import 'package:baseproject/core/common/custom_interceptor.dart';
import 'package:baseproject/core/components/alice.dart';
import 'package:baseproject/core/constants/index.dart';
import 'package:baseproject/features/presentation/app/view/app.dart';
import 'package:baseproject/features/repositories/account_repository.dart';
import 'package:baseproject/features/repositories/hra_repository.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:get_it/get_it.dart';
import 'package:injectable/injectable.dart';
import 'injection.config.dart';
import 'package:baseproject/core/constants/index.dart';
import 'package:baseproject/features/repositories/hra_repository.dart';
import 'package:dio/dio.dart';
final GetIt getItSuper = GetIt.instance;
@injectableInit
void configureInjection() {
// Khởi tạo các dependency đưc generate bởi injectable
$initGetIt(getItSuper);
getItSuper
.registerSingleton<HraRepository>(HraRepository(Dio(), baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra));
// Khởi tạo Dio với CustomInterceptor + Alice
final dio = Dio()
..interceptors.addAll(
kDebugMode
? <Interceptor>[
CustomInterceptor(),
CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor(),
]
: <Interceptor>[
CustomInterceptor(),
],
)
..options = BaseOptions(
baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra,
receiveTimeout: 10000,
connectTimeout: 10000,
sendTimeout: 10000,
);
getItSuper.registerSingleton<Dio>(dio);
getItSuper.registerSingleton<HraRepository>(
HraRepository(
dio,
baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra,
),
);
}

View File

@ -1 +1 @@
export 'login_dto.dart';
export 'package:baseproject/features/repositories/hra_repository_models.dart';

View File

@ -1,27 +0,0 @@
class LoginDto {
LoginDto({
this.userName,
this.password,
this.rememberMe = false,
this.captchaText,
this.captchaToken,
this.captchaInputText,
});
String? userName;
String? password;
bool rememberMe;
String? captchaText;
String? captchaToken;
String? captchaInputText;
Map<String, dynamic> toJson() => {
'UserName': userName,
'Password': password,
'RememberMe': rememberMe,
'CaptchaText': captchaText,
'CaptchaToken': captchaToken,
'CaptchaInputText': captchaInputText,
};
}

View File

@ -0,0 +1,101 @@
import 'package:baseproject/core/common/bloc/bloc_index.dart';
import 'package:baseproject/core/common/index.dart';
import 'package:baseproject/features/repositories/hra_repository.dart';
import 'package:baseproject/features/usecases/user_use_cases.dart';
class LoginViewModel {
LoginViewModel({
this.isLoading = false,
this.errorMessage,
this.loginResponse,
this.captcha,
});
final bool isLoading;
final String? errorMessage;
final LoginResponseDto? loginResponse;
final DNTCaptchaApiResponse? captcha;
LoginViewModel copyWith({
bool? isLoading,
String? errorMessage,
LoginResponseDto? loginResponse,
DNTCaptchaApiResponse? captcha,
}) {
return LoginViewModel(
isLoading: isLoading ?? this.isLoading,
errorMessage: errorMessage,
loginResponse: loginResponse ?? this.loginResponse,
captcha: captcha ?? this.captcha,
);
}
}
class LoginBloc extends BaseCubit<BaseStateBloc<LoginViewModel>> {
LoginBloc(this._userUseCases) : super(InitState<LoginViewModel>(LoginViewModel())) {
loadCaptcha();
}
final UserUseCases _userUseCases;
Future<void> loadCaptcha() async {
final currentModel = state.model;
final result = await _userUseCases.getCaptcha();
result.fold(
(error) {
showErrorMessage(error);
},
(captcha) {
emit(
LoadedState<LoginViewModel>(
currentModel.copyWith(
isLoading: false,
errorMessage: null,
captcha: captcha,
),
),
);
},
);
}
Future<void> login(LoginDto request) async {
final currentModel = state.model;
emit(
LoadingState<LoginViewModel>(
currentModel.copyWith(isLoading: true, errorMessage: null),
),
);
final result = await _userUseCases.loginAccount(request);
result.fold(
(error) {
showErrorMessage(error);
emit(
ErrorState<LoginViewModel>(
currentModel.copyWith(
isLoading: false,
errorMessage: error,
),
),
);
loadCaptcha();
},
(response) {
emit(
LoadedState<LoginViewModel>(
currentModel.copyWith(
isLoading: false,
errorMessage: null,
loginResponse: response,
),
),
);
},
);
}
}

View File

@ -1,7 +1,7 @@
import 'package:baseproject/core/common/index.dart';
import 'package:baseproject/core/components/index.dart';
import 'package:baseproject/features/model/login_dto.dart';
import 'package:baseproject/features/usecases/user_use_cases.dart';
import 'package:baseproject/features/presentation/account/bloc/login_bloc.dart';
import 'package:baseproject/features/repositories/hra_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -14,9 +14,8 @@ class LoginScreen extends StatefulWidget {
class _LoginScreenState extends State<LoginScreen> {
final GlobalKey<FormBuilderState> _formKey = GlobalKey<FormBuilderState>();
bool _isLoading = false;
String? _error;
bool _rememberMe = false;
final LoginBloc _loginBloc = getItSuper<LoginBloc>();
Future<void> _onSubmit() async {
final formState = _formKey.currentState;
@ -25,7 +24,6 @@ class _LoginScreenState extends State<LoginScreen> {
if (!formState.saveAndValidate()) {
return;
}
final value = formState.value;
final dto = LoginDto(
@ -33,121 +31,159 @@ class _LoginScreenState extends State<LoginScreen> {
password: value['password'] as String?,
rememberMe: _rememberMe,
);
final captcha = _loginBloc.state.model.captcha;
dto.captchaText = "999999"; //captcha?.dntCaptchaTextValue;
dto.captchaToken = captcha?.dntCaptchaTokenValue;
dto.captchaInputText = "999999";
setState(() {
_isLoading = true;
_error = null;
});
final userUseCases = getItSuper<UserUseCases>();
final result = await userUseCases.loginAccount(dto);
result.fold(
(l) => setState(() {
_error = l;
_isLoading = false;
}),
(r) {
setState(() {
_isLoading = false;
});
// TODO: điều hướng sang màn hình chính sau khi login thành công
},
);
_loginBloc.login(dto);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Đăng nhập'),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: FormBuilder(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (_error != null)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Text(
_error!,
style: const TextStyle(color: Colors.red),
),
),
FormControl(
labelText: 'Tên đăng nhập',
isShowTextRequire: true,
child: TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Nhập tên đăng nhập',
),
validator: FormBuilderValidators.required<String>(
context,
),
onSaved: (value) {
_formKey.currentState?.setInternalFieldValue(
'userName',
value,
isUpdateState: false,
);
},
),
),
const SizedBox(height: 16),
FormControl(
labelText: 'Mật khẩu',
isShowTextRequire: true,
child: TextFormField(
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Nhập mật khẩu',
),
validator: FormBuilderValidators.required<String>(
context,
),
onSaved: (value) {
_formKey.currentState?.setInternalFieldValue(
'password',
value,
isUpdateState: false,
);
},
),
),
const SizedBox(height: 8),
Row(
children: <Widget>[
Checkbox(
value: _rememberMe,
onChanged: (v) {
setState(() {
_rememberMe = v ?? false;
});
},
),
const Text('Ghi nhớ đăng nhập'),
],
),
const SizedBox(height: 24),
SizedBox(
height: 48,
child: ElevatedButton(
onPressed: _isLoading ? null : _onSubmit,
child: _isLoading
? const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
)
: const Text('Đăng nhập'),
),
),
],
return BlocProvider(
create: (_) => _loginBloc,
child: Scaffold(
appBar: AppBar(
title: const Text('Đăng nhập'),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: FormBuilder(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: BlocBuilder<LoginBloc, BaseStateBloc<LoginViewModel>>(
builder: (context, state) {
final vm = state.model;
final isLoading = state is LoadingState<LoginViewModel> || vm.isLoading;
final error = vm.errorMessage;
final captcha = vm.captcha;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (error != null)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Text(
error,
style: const TextStyle(color: Colors.red),
),
),
FormControl(
labelText: 'Tên đăng nhập',
isShowTextRequire: true,
child: TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Nhập tên đăng nhập',
),
validator: FormBuilderValidators.required<String>(
context,
),
onSaved: (value) {
_formKey.currentState?.setInternalFieldValue(
'userName',
value,
isUpdateState: false,
);
},
),
),
const SizedBox(height: 16),
FormControl(
labelText: 'Mật khẩu',
isShowTextRequire: true,
child: TextFormField(
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Nhập mật khẩu',
),
validator: FormBuilderValidators.required<String>(
context,
),
onSaved: (value) {
_formKey.currentState?.setInternalFieldValue(
'password',
value,
isUpdateState: false,
);
},
),
),
// const SizedBox(height: 8),
// if (captcha != null) ...[
// const SizedBox(height: 16),
// GestureDetector(
// onTap: () {
// _loginBloc.loadCaptcha();
// },
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// const Text('Captcha'),
// const SizedBox(height: 8),
// Image.network(
// captcha.dntCaptchaImgUrl ?? '',
// height: 60,
// errorBuilder: (_, __, ___) => Text(
// captcha.dntCaptchaImgUrl ?? '',
// style: const TextStyle(color: Colors.blue),
// ),
// ),
// ],
// ),
// ),
// const SizedBox(height: 8),
// FormControl(
// labelText: 'Nhập mã captcha',
// isShowTextRequire: true,
// child: TextFormField(
// decoration: const InputDecoration(
// border: OutlineInputBorder(),
// hintText: 'Nhập mã captcha',
// ),
// validator: FormBuilderValidators.required<String>(
// context,
// ),
// onSaved: (value) {
// _formKey.currentState?.setInternalFieldValue(
// 'captchaInput',
// value,
// isUpdateState: false,
// );
// },
// ),
// ),
// ],
const SizedBox(height: 8),
Row(
children: <Widget>[
Checkbox(
value: _rememberMe,
onChanged: (v) {
setState(() {
_rememberMe = v ?? false;
});
},
),
const Text('Ghi nhớ đăng nhập'),
],
),
const SizedBox(height: 24),
SizedBox(
height: 48,
child: ConstantWidget.buildPrimaryButton(
onPressed: isLoading ? null : _onSubmit,
text: 'Đăng nhập',
),
),
],
);
},
),
),
),
),

View File

@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
final GlobalKey<NavigatorState>? navigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
@ -49,8 +49,8 @@ class _AppState extends State<App> {
children: <Widget>[
child!,
Positioned(
bottom: 0,
right: 0,
bottom: 10,
right: 10,
child: Container(
width: 30,
height: 30,

View File

@ -1,4 +1,6 @@
import 'package:baseproject/core/components/constants_widget.dart';
import 'package:baseproject/core/language/app_localizations.dart';
import 'package:baseproject/features/route/route_goto.dart';
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
@ -13,7 +15,19 @@ class _HomeState extends State<Home> {
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(AppLocalizations.of(context)!.translate("first_string")),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(AppLocalizations.of(context)!.translate("first_string")),
ConstantWidget.buildPrimaryButton(
onPressed: () {
gotoLogin(context);
},
text: 'Đăng nhập',
),
],
),
),
);
}

View File

@ -43,9 +43,15 @@ abstract class HraRepository {
@POST('/api/v1/account/register')
Future<dynamic> accountRegister(@Body() RegisterDto body);
///
@POST('/api/v1/account/login-mobile')
Future<LoginResponseDtoApiResponse> accountLoginMobile(@Body() LoginDto body);
///
@POST('/api/v1/account/login')
Future<LoginResponseDtoApiResponse> accountLogin(@Body() Object body);
@MultiPart()
Future<LoginResponseDtoApiResponse> accountLogin(
@Part() Map<String, dynamic> body);
///
@POST('/api/v1/account/login-with-google')
@ -1441,4 +1447,8 @@ abstract class HraRepository {
///
@GET('/api/v1/user-web-token/generate')
Future<VapidDetailsApiResponse> userWebTokenGenerate();
///
@POST('/api/zoom-webhook')
Future<dynamic> zoomWebhook();
}

View File

@ -135,16 +135,41 @@ class _HraRepository implements HraRepository {
}
@override
Future<LoginResponseDtoApiResponse> accountLogin(body) async {
Future<LoginResponseDtoApiResponse> accountLoginMobile(body) async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = body;
final _data = <String, dynamic>{};
_data.addAll(body.toJson());
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<LoginResponseDtoApiResponse>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/v1/account/login-mobile',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
final value = LoginResponseDtoApiResponse.fromJson(_result.data!);
return value;
}
@override
Future<LoginResponseDtoApiResponse> accountLogin(body) async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = FormData.fromMap(body);
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<LoginResponseDtoApiResponse>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
contentType: 'multipart/form-data',
)
.compose(
_dio.options,
@ -6447,6 +6472,28 @@ class _HraRepository implements HraRepository {
return value;
}
@override
Future<dynamic> zoomWebhook() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.fetch(_setStreamType<dynamic>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/zoom-webhook',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
final value = _result.data;
return value;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||

View File

@ -3369,6 +3369,11 @@ class ClassDetailDto {
this.zoomMeetingId,
this.zoomPassword,
this.description,
this.zoomHostVideo,
this.zoomParticipantVideo,
this.zoomJoinBeforeHost,
this.zoomMuteUponEntry,
this.zoomAutoRecording,
this.classUsers,
this.assignExams,
this.classSessions,
@ -3428,6 +3433,16 @@ class ClassDetailDto {
String? zoomPassword;
@JsonKey(name: 'description', includeIfNull: true)
String? description;
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
bool? zoomHostVideo;
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
bool? zoomParticipantVideo;
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
bool? zoomJoinBeforeHost;
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
bool? zoomMuteUponEntry;
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
String? zoomAutoRecording;
@JsonKey(
name: 'classUsers',
includeIfNull: true,
@ -3478,6 +3493,11 @@ class ClassEntity {
this.zoomMeetingId,
this.zoomPassword,
this.description,
this.zoomHostVideo,
this.zoomParticipantVideo,
this.zoomJoinBeforeHost,
this.zoomMuteUponEntry,
this.zoomAutoRecording,
this.classUsers,
this.assignExams,
this.classSessions,
@ -3536,6 +3556,16 @@ class ClassEntity {
String? zoomPassword;
@JsonKey(name: 'description', includeIfNull: true)
String? description;
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
bool? zoomHostVideo;
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
bool? zoomParticipantVideo;
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
bool? zoomJoinBeforeHost;
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
bool? zoomMuteUponEntry;
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
String? zoomAutoRecording;
@JsonKey(
name: 'classUsers',
includeIfNull: true,
@ -3669,6 +3699,11 @@ class ClassListDto {
this.zoomMeetingId,
this.zoomPassword,
this.description,
this.zoomHostVideo,
this.zoomParticipantVideo,
this.zoomJoinBeforeHost,
this.zoomMuteUponEntry,
this.zoomAutoRecording,
this.classUsers,
this.assignExams,
this.classSessions,
@ -3738,6 +3773,16 @@ class ClassListDto {
String? zoomPassword;
@JsonKey(name: 'description', includeIfNull: true)
String? description;
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
bool? zoomHostVideo;
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
bool? zoomParticipantVideo;
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
bool? zoomJoinBeforeHost;
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
bool? zoomMuteUponEntry;
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
String? zoomAutoRecording;
@JsonKey(
name: 'classUsers',
includeIfNull: true,
@ -4179,6 +4224,7 @@ class ClassSessionEntity {
this.zoomStartLink,
this.zoomPassword,
this.recordingUrl,
this.zoomAccountIndex,
this.actualDurationMinutes,
this.status,
this.notes,
@ -4226,6 +4272,8 @@ class ClassSessionEntity {
String? zoomPassword;
@JsonKey(name: 'recordingUrl', includeIfNull: true)
String? recordingUrl;
@JsonKey(name: 'zoomAccountIndex', includeIfNull: true)
int? zoomAccountIndex;
@JsonKey(name: 'actualDurationMinutes', includeIfNull: true)
int? actualDurationMinutes;
@JsonKey(
@ -8814,6 +8862,37 @@ class LocalityGetListQuery {
Map<String, dynamic> toJson() => _$LocalityGetListQueryToJson(this);
}
@JsonSerializable(explicitToJson: true)
class LoginDto {
LoginDto({
this.userName,
this.password,
this.rememberMe,
this.captchaText,
this.captchaToken,
this.captchaInputText,
});
factory LoginDto.fromJson(Map<String, dynamic> json) =>
_$LoginDtoFromJson(json);
@JsonKey(name: 'userName', includeIfNull: true)
String? userName;
@JsonKey(name: 'password', includeIfNull: true)
String? password;
@JsonKey(name: 'rememberMe', includeIfNull: true)
bool? rememberMe;
@JsonKey(name: 'captchaText', includeIfNull: true)
String? captchaText;
@JsonKey(name: 'captchaToken', includeIfNull: true)
String? captchaToken;
@JsonKey(name: 'captchaInputText', includeIfNull: true)
String? captchaInputText;
static const fromJsonFactory = _$LoginDtoFromJson;
static const toJsonFactory = _$LoginDtoToJson;
Map<String, dynamic> toJson() => _$LoginDtoToJson(this);
}
@JsonSerializable(explicitToJson: true)
class LoginResponseDto {
LoginResponseDto({

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,2 @@
const String appInitRouteName = '/app_init';
const String loginRouteName = '/login';

View File

@ -1,3 +1,4 @@
import 'package:baseproject/features/presentation/account/login_screen.dart';
import 'package:baseproject/features/presentation/home/view/home.dart';
import 'package:baseproject/features/route/route_const.dart';
import 'package:flutter/material.dart';
@ -9,6 +10,8 @@ class RouteGenerator {
switch (setting.name) {
case appInitRouteName:
return MaterialPageRoute<void>(settings: setting, builder: (_) => const Home());
case loginRouteName:
return MaterialPageRoute<void>(settings: setting, builder: (_) => const LoginScreen());
default:
return null;
}

View File

@ -0,0 +1,6 @@
import 'package:flutter/material.dart';
import 'route_const.dart';
void gotoLogin(BuildContext context) {
Navigator.pushNamed(context, loginRouteName);
}

View File

@ -1,4 +1,3 @@
import 'package:baseproject/features/model/index.dart';
import 'package:baseproject/features/repositories/hra_repository.dart';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
@ -11,7 +10,7 @@ class UserUseCases {
Future<Either<String, LoginResponseDto>> loginAccount(LoginDto request) async {
try {
final result = await _hraRepository.accountLogin(request);
final result = await _hraRepository.accountLoginMobile(request);
if (result.data == null) {
return Left<String, LoginResponseDto>(result.message ?? 'Login failed');

View File

@ -1,7 +1,18 @@
import 'dart:async';
import 'package:baseproject/core/common/index.dart';
import 'package:baseproject/features/presentation/app/view/app.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const App());
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
configureInjection();
await LocalStoreManager.init();
Loading.configLoading();
runApp(const App());
}, (error, stackTrace) {
print(error);
print(stackTrace);
});
}