build_app
This commit is contained in:
		
							parent
							
								
									843b272a44
								
							
						
					
					
						commit
						fcd5ef814a
					
				| @ -0,0 +1,84 @@ | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| 
 | ||||
| class TestdefaultApiService { | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
| 
 | ||||
|       final BaseNetworkService _helper = NetworkApiService(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|    Future<List<Map<String, dynamic>>> getEntities() async { | ||||
| 
 | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse('$baseUrl/Testdefault/Testdefault'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| Future<List<Map<String, dynamic>>> getAllWithPagination( | ||||
|        int page, int size) async { | ||||
|     try { | ||||
|             final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/Testdefault/Testdefault/getall/page?page=$page&size=$size'); | ||||
|       final entities = | ||||
|           (response['content'] as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<Map<String, dynamic>> createEntity( | ||||
|        Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|             print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl/Testdefault/Testdefault', entity); | ||||
| 
 | ||||
|       print(entity); | ||||
| 
 | ||||
|       // Assuming the response is a Map<String, dynamic> | ||||
|       Map<String, dynamic> responseData = response; | ||||
| 
 | ||||
|       return responseData; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|      await _helper.getPutApiResponse('$baseUrl/Testdefault/Testdefault/$entityId', | ||||
|       entity);                print(entity); | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<void> deleteEntity( int entityId) async { | ||||
|     try { | ||||
|  await _helper.getDeleteApiResponse('$baseUrl/Testdefault/Testdefault/$entityId'); | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,82 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Testdefault_viewModel/Testdefault_view_model_screen.dart'; | ||||
| import 'Testdefault_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart';  | ||||
| import '../../../../widgets/custom_dropdown_field.dart'; | ||||
| import 'dart:math'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
|   | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart' | ||||
| ;import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import 'package:just_audio/just_audio.dart'; | ||||
| import 'package:video_player/video_player.dart'; | ||||
| import 'package:google_fonts/google_fonts.dart'; | ||||
| import 'package:lottie/lottie.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'dart:io'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class TestdefaultCreateEntityScreen extends StatefulWidget { | ||||
|   const TestdefaultCreateEntityScreen({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   _TestdefaultCreateEntityScreenState createState() => _TestdefaultCreateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _TestdefaultCreateEntityScreenState extends State<TestdefaultCreateEntityScreen> { | ||||
| 
 | ||||
| final Map<String, dynamic> formData = {}; | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|    | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<TestdefaultViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityCreateScreen( | ||||
|           fields: TestdefaultFields.getFields(), | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Testdefault', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.createEntity(formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,90 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../BuilderField/shared/ui/entity_details.dart'; | ||||
| import '../Testdefault_viewModel/Testdefault_view_model_screen.dart'; | ||||
| import 'Testdefault_update_entity_screen.dart'; | ||||
| 
 | ||||
| class TestdefaultDetailsScreen extends StatefulWidget { | ||||
|   final Map<String, dynamic> entity; | ||||
| 
 | ||||
|   const TestdefaultDetailsScreen({ | ||||
|     super.key, | ||||
|     required this.entity, | ||||
|   }); | ||||
| 
 | ||||
|   @override | ||||
|   State<TestdefaultDetailsScreen> createState() => _TestdefaultDetailsScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _TestdefaultDetailsScreenState extends State<TestdefaultDetailsScreen> { | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => TestdefaultViewModelScreen(), | ||||
|           child: TestdefaultUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       // Refresh the details screen with updated data | ||||
|       setState(() {}); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Testdefault?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|                 final success = await vm.deleteEntity(entity['id']); | ||||
|                 if (success && mounted) { | ||||
|                   Navigator.pop(context); // Go back to list | ||||
|                 } | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<TestdefaultViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityDetails( | ||||
|           entity: widget.entity, | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           title: 'Testdefault', | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|           ], | ||||
|           isLoading: viewModel.isLoading, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,149 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; | ||||
| import 'Testdefault_create_entity_screen.dart'; | ||||
| import 'Testdefault_update_entity_screen.dart'; | ||||
| import '../Testdefault_viewModel/Testdefault_view_model_screen.dart'; | ||||
| import 'Testdefault_details_screen.dart';import 'package:flutter/services.dart'; | ||||
| import 'package:speech_to_text/speech_to_text.dart' as stt; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../widgets/custom_icon_button.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../theme/app_decoration.dart'; | ||||
| import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| 
 | ||||
| class Testdefault_entity_list_screen extends StatefulWidget { | ||||
|   static const String routeName = '/entity-list'; | ||||
| 
 | ||||
|   @override | ||||
|   _Testdefault_entity_list_screenState createState() => _Testdefault_entity_list_screenState(); | ||||
| } | ||||
| 
 | ||||
| class _Testdefault_entity_list_screenState extends State<Testdefault_entity_list_screen> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _loadData(); | ||||
|   } | ||||
| 
 | ||||
|   void _loadData() { | ||||
|     WidgetsBinding.instance.addPostFrameCallback((_) { | ||||
|       if (mounted) { | ||||
|         final vm = Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|         vm.getAllWithPagination(refresh: true); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToCreateScreen() { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => TestdefaultViewModelScreen(), | ||||
|           child: const TestdefaultCreateEntityScreen(), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => TestdefaultViewModelScreen(), | ||||
|           child: TestdefaultUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToDetailsScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => TestdefaultViewModelScreen(), | ||||
|           child: TestdefaultDetailsScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Testdefault?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|                 await vm.deleteEntity(entity['id']); | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<TestdefaultViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityList( | ||||
|           entities: viewModel.filteredList, | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|           hasMoreData: viewModel.hasMoreData, | ||||
|           searchQuery: viewModel.searchQuery, | ||||
|           onSearchChanged: (query) => viewModel.searchtestdefault(query), | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           onTap: (entity) => _navigateToDetailsScreen(entity), | ||||
|           onRefresh: () => viewModel.refreshData(), | ||||
|           onLoadMore: () => viewModel.getAllWithPagination(), | ||||
|           title: 'Testdefault', | ||||
|           onAddNew: _navigateToCreateScreen, | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,55 @@ | ||||
| import 'package:base_project/BuilderField/shared/fields/number_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/password_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/date_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/datetime_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/email_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/url_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; | ||||
| import '../../../../BuilderField/shared/fields/captcha_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/switch_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/url_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/checkbox_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/file_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/image_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/radio_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/video_upload_field.dart'; | ||||
| /// Field definitions for Testdefault entity | ||||
| /// This defines the structure and validation for Testdefault forms | ||||
| class TestdefaultFields { | ||||
|   /// Get field definitions for Testdefault entity | ||||
|   static List<BaseField> getFields() { | ||||
|     return [ | ||||
|       // Basic Information | ||||
|  CustomTextField( | ||||
|         fieldKey: 'name', | ||||
|         label: 'Name', | ||||
|         hint: 'Enter Name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
| CustomTextField( | ||||
|         fieldKey: 'description', | ||||
|         label: 'Description', | ||||
|         hint: 'Enter Description', | ||||
|         isRequired: false, | ||||
|         maxLength: 1000, | ||||
|       ), | ||||
| 
 | ||||
|  SwitchField( | ||||
|         fieldKey: 'active', | ||||
|         label: 'Active', | ||||
|       ), | ||||
| 
 | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,66 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Testdefault_viewModel/Testdefault_view_model_screen.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import 'Testdefault_fields.dart';import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| 
 | ||||
| import 'dart:math'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| class TestdefaultUpdateEntityScreen extends StatefulWidget { | ||||
|     final Map<String, dynamic> entity; | ||||
| 
 | ||||
| 
 | ||||
|   TestdefaultUpdateEntityScreen({required this.entity}); | ||||
| 
 | ||||
|   @override | ||||
|   _TestdefaultUpdateEntityScreenState createState() => _TestdefaultUpdateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _TestdefaultUpdateEntityScreenState extends State<TestdefaultUpdateEntityScreen> { | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
| 
 | ||||
| @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<TestdefaultViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityUpdateScreen( | ||||
|           fields: TestdefaultFields.getFields(), | ||||
|           initialData: widget.entity, | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Testdefault', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<TestdefaultViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.updateEntity(widget.entity['id'], formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,78 @@ | ||||
| import 'package:dio/dio.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import 'package:base_project/data/response/api_response.dart'; | ||||
| 
 | ||||
| class TestdefaultRepoScreen { | ||||
| 
 | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
|   final BaseNetworkService _helper = NetworkApiService(); | ||||
|   final String _endpointPath = '/Testdefault/Testdefault'; | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl$_endpointPath'); | ||||
|       return ApiResponse.success(response as List<Map<String, dynamic>>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination( | ||||
|       int page, int size) async { | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse( | ||||
|           '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); | ||||
| 
 | ||||
|       if (response is Map<String, dynamic> && response['content'] is List) { | ||||
|         final List<Map<String, dynamic>> entities = | ||||
|             (response['content'] as List).cast<Map<String, dynamic>>().toList(); | ||||
|         return ApiResponse.success(entities); | ||||
|       } else { | ||||
|         return ApiResponse.error('Invalid response format'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> createEntity( | ||||
|       Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> updateEntity( | ||||
|       int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       final response = await _helper.getPutApiResponse( | ||||
|           '$baseUrl$_endpointPath/$entityId', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<void>> deleteEntity(int entityId) async { | ||||
|     try { | ||||
|       await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); | ||||
|       return ApiResponse.success(null); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,277 @@ | ||||
| import 'package:base_project/data/response/status.dart'; | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../Testdefault_Repo/Testdefault_repo_screen.dart'; | ||||
| 
 | ||||
| class TestdefaultViewModelScreen extends ChangeNotifier{ | ||||
|   final TestdefaultRepoScreen repo = TestdefaultRepoScreen(); | ||||
| 
 | ||||
|   | ||||
|   // State variables | ||||
|   List<Map<String, dynamic>> _testdefaultList = []; | ||||
|   List<Map<String, dynamic>> _filteredList = []; | ||||
|   bool _isLoading = false; | ||||
|   String _errorMessage = ''; | ||||
|   int _currentPage = 0; | ||||
|   int _pageSize = 10; | ||||
|   bool _hasMoreData = true; | ||||
|   String _searchQuery = ''; | ||||
| 
 | ||||
|   // Getters | ||||
|   List<Map<String, dynamic>> get testdefaultList => _testdefaultList; | ||||
|   List<Map<String, dynamic>> get filteredList => _filteredList; | ||||
|   bool get isLoading => _isLoading; | ||||
|   String get errorMessage => _errorMessage; | ||||
|   bool get hasMoreData => _hasMoreData; | ||||
|   String get searchQuery => _searchQuery; | ||||
| 
 | ||||
|   // Set loading state | ||||
|   void _setLoading(bool loading) { | ||||
|     _isLoading = loading; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Set error message | ||||
|   void _setError(String error) { | ||||
|     _errorMessage = error; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear error | ||||
|   void clearError() { | ||||
|     _errorMessage = ''; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Get testdefault list | ||||
|   Future<void> getEntities() async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getEntities(); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         _testdefaultList = response.data ?? []; | ||||
|         _filteredList = List.from(_testdefaultList); | ||||
|         _currentPage = 0; | ||||
|         _hasMoreData = true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch testdefault list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch testdefault list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Get testdefault list with pagination | ||||
|   Future<void> getAllWithPagination({bool refresh = false}) async { | ||||
|     if (refresh) { | ||||
|       _currentPage = 0; | ||||
|       _testdefaultList.clear(); | ||||
|       _filteredList.clear(); | ||||
|       _hasMoreData = true; | ||||
|     } | ||||
| 
 | ||||
|     if (!_hasMoreData || _isLoading) return; | ||||
| 
 | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getAllWithPagination(_currentPage, _pageSize); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         final newItems = response.data ?? []; | ||||
| 
 | ||||
|         if (refresh) { | ||||
|           _testdefaultList = newItems; | ||||
|         } else { | ||||
|           _testdefaultList.addAll(newItems); | ||||
|         } | ||||
| 
 | ||||
|         _filteredList = List.from(_testdefaultList); | ||||
|         _currentPage++; | ||||
| 
 | ||||
|         // Check if we have more data | ||||
|         _hasMoreData = newItems.length == _pageSize; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch Testdefault list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch testdefault list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Create Testdefault | ||||
|   Future<bool> createEntity(Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.createEntity(entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'testdefault created successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Refresh the list | ||||
|         await getEntities(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to create Testdefault'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to create Testdefault', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to create testdefault: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to create Testdefault: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Update testdefault | ||||
|   Future<bool> updateEntity(int id, Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.updateEntity(id, entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Testdefault updated successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Update the item in the list | ||||
|         final index = _testdefaultList.indexWhere((item) => item['id'] == id); | ||||
|         if (index != -1) { | ||||
|           _testdefaultList[index] = response.data!; | ||||
|           _filteredList = List.from(_testdefaultList); | ||||
|           notifyListeners(); | ||||
|         } | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to update Testdefault'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to update Testdefault', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to update testdefault: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to update Testdefault: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Delete testdefault | ||||
|   Future<bool> deleteEntity(int id) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.deleteEntity(id); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Testdefault deleted successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Remove the item from the list | ||||
|         _testdefaultList.removeWhere((item) => item['id'] == id); | ||||
|         _filteredList = List.from(_testdefaultList); | ||||
|         notifyListeners(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to delete Testdefault'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to delete Testdefault', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to delete testdefault: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to delete Testdefault: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Search testdefault | ||||
|   void searchtestdefault(String query) { | ||||
|     _searchQuery = query; | ||||
| 
 | ||||
|     if (query.isEmpty) { | ||||
|       _filteredList = List.from(_testdefaultList); | ||||
|     } else { | ||||
|       _filteredList = _testdefaultList.where((item) { | ||||
|         return | ||||
| 
 | ||||
|               | ||||
| (item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| (item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)  | ||||
| 
 | ||||
| 
 | ||||
| ; | ||||
|       }).toList(); | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear search | ||||
|   void clearSearch() { | ||||
|     _searchQuery = ''; | ||||
|     _filteredList = List.from(_testdefaultList); | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Refresh data | ||||
|   Future<void> refreshData() async { | ||||
|     await getAllWithPagination(refresh: true); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -69,6 +69,9 @@ public class BuilderService { | ||||
| 		executeDump(true); | ||||
| 
 | ||||
| 		// ADD OTHER SERVICE | ||||
| addCustomMenu( "Testdefault","Testdefault",  "Transcations");  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("dashboard and menu inserted..."); | ||||
| 
 | ||||
|  | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.District_ListFilter1Service ; | ||||
| @RequestMapping(value = "/District_ListFilter1") | ||||
| @RestController | ||||
| public class District_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private District_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/District_ListFilter1") | ||||
| 	public List<District_ListFilter1> getlist() { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/District_ListFilter11/{item}") | ||||
| 	public List<District_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.State_ListFilter1Service ; | ||||
| @RequestMapping(value = "/State_ListFilter1") | ||||
| @RestController | ||||
| public class State_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private State_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/State_ListFilter1") | ||||
| 	public List<State_ListFilter1> getlist() { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/State_ListFilter11/{item}") | ||||
| 	public List<State_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.District_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/District_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_District_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private District_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/District_ListFilter1") | ||||
| 	public List<District_ListFilter1> getlist() { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/District_ListFilter11/{item}") | ||||
| 	public List<District_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.State_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/State_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_State_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private State_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/State_ListFilter1") | ||||
| 	public List<State_ListFilter1> getlist() { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/State_ListFilter11/{item}") | ||||
| 	public List<State_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.realnet.angulardatatype.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    District_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String district_name; | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.realnet.angulardatatype.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    State_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String state_name; | ||||
| } | ||||
| @ -0,0 +1,53 @@ | ||||
| package com.realnet.angulardatatype.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.angulardatatype.Repository.DistrictRepository; | ||||
| import com.realnet.angulardatatype.Entity.District; | ||||
| 
 | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class District_ListFilter1Service { | ||||
| @Autowired | ||||
| private DistrictRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<District_ListFilter1>   getlistbuilder() { | ||||
| 	List<District> list= Repository.findAll(); | ||||
| 		ArrayList<District_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (District data : list) { | ||||
| String State_name = data.getState_name(); | ||||
|  System.out.println(State_name + "\n"); | ||||
| 
 | ||||
| 			if ("item".equals(State_name)){	 | ||||
| District_ListFilter1 dummy = new District_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setDistrict_name(data.getDistrict_name()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<District_ListFilter1>   getlistbuilderparam(  String item) { | ||||
| 	List<District> list= Repository.findAll(); | ||||
| 		ArrayList<District_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (District data : list) { | ||||
| String State_name = data.getState_name(); | ||||
|  System.out.println(State_name + "\n"); | ||||
| 
 | ||||
| 			if (item.equals(State_name)){	 | ||||
| District_ListFilter1 dummy = new District_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setDistrict_name(data.getDistrict_name()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
| @ -0,0 +1,53 @@ | ||||
| package com.realnet.angulardatatype.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.angulardatatype.Repository.StateRepository; | ||||
| import com.realnet.angulardatatype.Entity.State; | ||||
| 
 | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class State_ListFilter1Service { | ||||
| @Autowired | ||||
| private StateRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<State_ListFilter1>   getlistbuilder() { | ||||
| 	List<State> list= Repository.findAll(); | ||||
| 		ArrayList<State_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (State data : list) { | ||||
| String Country_name = data.getCountry_name(); | ||||
|  System.out.println(Country_name + "\n"); | ||||
| 
 | ||||
| 			if ("item".equals(Country_name)){	 | ||||
| State_ListFilter1 dummy = new State_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setState_name(data.getState_name()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<State_ListFilter1>   getlistbuilderparam(  String item) { | ||||
| 	List<State> list= Repository.findAll(); | ||||
| 		ArrayList<State_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (State data : list) { | ||||
| String Country_name = data.getCountry_name(); | ||||
|  System.out.println(Country_name + "\n"); | ||||
| 
 | ||||
| 			if (item.equals(Country_name)){	 | ||||
| State_ListFilter1 dummy = new State_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setState_name(data.getState_name()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
| @ -0,0 +1,99 @@ | ||||
| package com.realnet.basic1.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.basic1.Entity.Testdefault; | ||||
| import com.realnet.basic1.Services.TestdefaultService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/Testdefault") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class TestdefaultController { | ||||
| 	@Autowired | ||||
| 	private TestdefaultService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Testdefault") | ||||
| 		  public Testdefault Savedata(@RequestBody Testdefault data) { | ||||
| 		Testdefault save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Testdefault/{id}") | ||||
| 	public  Testdefault update(@RequestBody Testdefault data,@PathVariable Integer id ) { | ||||
| 		Testdefault update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Testdefault/getall/page") | ||||
| 	public Page<Testdefault> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Testdefault> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Testdefault") | ||||
| 	public List<Testdefault> getdetails() { | ||||
| 		 List<Testdefault> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Testdefault") | ||||
| 	public List<Testdefault> getallwioutsec() { | ||||
| 		 List<Testdefault> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Testdefault/{id}") | ||||
| 	public  Testdefault  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Testdefault  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Testdefault/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,99 @@ | ||||
| package com.realnet.basic1.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.basic1.Entity.Testdefault; | ||||
| import com.realnet.basic1.Services.TestdefaultService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/token/Testdefault") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class tokenFree_TestdefaultController { | ||||
| 	@Autowired | ||||
| 	private TestdefaultService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Testdefault") | ||||
| 		  public Testdefault Savedata(@RequestBody Testdefault data) { | ||||
| 		Testdefault save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Testdefault/{id}") | ||||
| 	public  Testdefault update(@RequestBody Testdefault data,@PathVariable Integer id ) { | ||||
| 		Testdefault update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Testdefault/getall/page") | ||||
| 	public Page<Testdefault> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Testdefault> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Testdefault") | ||||
| 	public List<Testdefault> getdetails() { | ||||
| 		 List<Testdefault> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Testdefault") | ||||
| 	public List<Testdefault> getallwioutsec() { | ||||
| 		 List<Testdefault> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Testdefault/{id}") | ||||
| 	public  Testdefault  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Testdefault  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Testdefault/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,33 @@ | ||||
| package com.realnet.basic1.Entity; | ||||
|  import lombok.*; | ||||
| import com.realnet.WhoColumn.Entity.Extension;  | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  @Entity  | ||||
|  @Data | ||||
|  public class    Testdefault extends Extension {  | ||||
|  /** | ||||
| 	 *  | ||||
| 	 */ | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
|  @Id | ||||
|  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|  private Integer id; | ||||
| 
 | ||||
| private String  name; | ||||
| 
 | ||||
| @Column(length = 2000) | ||||
| private String description; | ||||
| 
 | ||||
| private Boolean active; | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package com.realnet.basic1.Repository; | ||||
| 
 | ||||
| 
 | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| 
 | ||||
| import org.springframework.stereotype.Repository;  | ||||
| import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| import com.realnet.basic1.Entity.Testdefault; | ||||
| 
 | ||||
| @Repository | ||||
| public interface  TestdefaultRepository  extends  JpaRepository<Testdefault, Integer>  {  | ||||
| 
 | ||||
| @Query(value = "select * from testdefault where  created_by=?1", nativeQuery = true) | ||||
| 	List<Testdefault> findAll(Long creayedBy); | ||||
| 
 | ||||
| @Query(value = "select * from testdefault where  created_by=?1", nativeQuery = true) | ||||
| 	Page<Testdefault> findAll( Long creayedBy,Pageable page); | ||||
| } | ||||
| @ -0,0 +1,93 @@ | ||||
| package com.realnet.basic1.Services; | ||||
| import com.realnet.basic1.Repository.TestdefaultRepository; | ||||
| import com.realnet.basic1.Entity.Testdefault | ||||
| ;import java.util.*; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.realnet.SequenceGenerator.Service.SequenceService; | ||||
| import org.springframework.data.domain.Page; | ||||
| import com.realnet.realm.Entity.Realm; | ||||
| import com.realnet.realm.Services.RealmService; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.http.*; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class TestdefaultService { | ||||
| @Autowired | ||||
| private TestdefaultRepository Repository; | ||||
| 	@Autowired | ||||
| 	private AppUserServiceImpl userService;  | ||||
| @Autowired | ||||
| 	private RealmService realmService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public Testdefault Savedata(Testdefault data) { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	data.setUpdatedBy(getUser().getUserId()); | ||||
| 		data.setCreatedBy(getUser().getUserId()); | ||||
| 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||
| Testdefault save = Repository.save(data); | ||||
| 				return save;	 | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| //	get all with pagination | ||||
| 	public Page<Testdefault> getAllWithPagination(Pageable page) { | ||||
| 		return Repository.findAll( getUser().getUserId(),page); | ||||
| 	}			 | ||||
| public List<Testdefault> getdetails() {   | ||||
| 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||
| List<Testdefault> all = Repository.findAll(getUser().getUserId()); | ||||
| 		 | ||||
| 		return all ;		} | ||||
| 
 | ||||
| 
 | ||||
| public Testdefault getdetailsbyId(Integer id) { | ||||
| 	return Repository.findById(id).get(); | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| 	public void delete_by_id(Integer id) { | ||||
|  Repository.deleteById(id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public Testdefault update(Testdefault data,Integer id) { | ||||
| 	Testdefault old = Repository.findById(id).get(); | ||||
| old.setName(data.getName()); | ||||
| 
 | ||||
| old.setDescription(data.getDescription()); | ||||
| 
 | ||||
| old.setActive (data.getActive()); | ||||
| 
 | ||||
| final Testdefault test = Repository.save(old); | ||||
| 		data.setUpdatedBy(getUser().getUserId()); | ||||
|   return test;}  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public AppUser getUser() { | ||||
| 		AppUser user = userService.getLoggedInUser(); | ||||
| 		return user; | ||||
| 
 | ||||
| 	}} | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import com.realnet.testdata.Services.Country_ListFilter1Service ; | ||||
| @RequestMapping(value = "/Country_ListFilter1") | ||||
| @RestController | ||||
| public class Country_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private Country_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/Country_ListFilter1") | ||||
| 	public List<Country_ListFilter1> getlist() { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/Country_ListFilter11") | ||||
| 	public List<Country_ListFilter1> getlistwithparam( ) { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilderparam( );		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import com.realnet.testdata.Services.Country_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/Country_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_Country_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private Country_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/Country_ListFilter1") | ||||
| 	public List<Country_ListFilter1> getlist() { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/Country_ListFilter11") | ||||
| 	public List<Country_ListFilter1> getlistwithparam( ) { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilderparam( );		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package com.realnet.testdata.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    Country_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String name; | ||||
|  private String description; | ||||
| } | ||||
| @ -0,0 +1,49 @@ | ||||
| package com.realnet.testdata.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.testdata.Repository.CountryRepository; | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class Country_ListFilter1Service { | ||||
| @Autowired | ||||
| private CountryRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<Country_ListFilter1>   getlistbuilder() { | ||||
| 	List<Country> list= Repository.findAll(); | ||||
| 		ArrayList<Country_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (Country data : list) { | ||||
| {	 | ||||
| Country_ListFilter1 dummy = new Country_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setName(data.getName()); | ||||
|   dummy.setDescription(data.getDescription()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<Country_ListFilter1>   getlistbuilderparam( ) { | ||||
| 	List<Country> list= Repository.findAll(); | ||||
| 		ArrayList<Country_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (Country data : list) { | ||||
| {	 | ||||
| Country_ListFilter1 dummy = new Country_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setName(data.getName()); | ||||
|   dummy.setDescription(data.getDescription()); | ||||
| 	l.add(dummy); | ||||
| }  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
							
								
								
									
										2
									
								
								testflutter03-testninesep-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								testflutter03-testninesep-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,2 @@ | ||||
| CREATE TABLE testninesep.Testdefault(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400),  PRIMARY KEY (id)); | ||||
| 
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user