build_app
This commit is contained in:
parent
b9f4d477d6
commit
e8f7111fe7
12
testflutter24sep-dbtdt-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
12
testflutter24sep-dbtdt-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
CREATE TABLE dbtdt.Support(id BIGINT NOT NULL AUTO_INCREMENT, description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
|
CREATE TABLE dbtdt.Adv4(id BIGINT NOT NULL AUTO_INCREMENT, onetoone VARCHAR(400), atdy1 VARCHAR(400), text_field VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
|
CREATE TABLE dbtdt.Ad7(id BIGINT NOT NULL AUTO_INCREMENT, button_field2 VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
|
CREATE TABLE dbtdt.Country(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
|
CREATE TABLE dbtdt.Onetomany(id BIGINT NOT NULL AUTO_INCREMENT, onetomanyextension VARCHAR(400), fileupload_field VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
|
CREATE TABLE dbtdt.Vallist(id BIGINT NOT NULL AUTO_INCREMENT, value_list_fieldb VARCHAR(400), nameb VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
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 Ad7ApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Ad7/Ad7');
|
||||||
|
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/Ad7/Ad7/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/Ad7/Ad7', 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/Ad7/Ad7/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Ad7/Ad7/$entityId');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to delete entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
// 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 '../Ad7_viewModel/Ad7_view_model_screen.dart';
|
||||||
|
import 'Ad7_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 Ad7CreateEntityScreen extends StatefulWidget {
|
||||||
|
const Ad7CreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Ad7CreateEntityScreenState createState() => _Ad7CreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Ad7CreateEntityScreenState extends State<Ad7CreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Ad7ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: Ad7Fields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Ad7',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.createEntity(formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
// 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 '../Ad7_viewModel/Ad7_view_model_screen.dart';
|
||||||
|
import 'Ad7_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class Ad7DetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const Ad7DetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Ad7DetailsScreen> createState() => _Ad7DetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Ad7DetailsScreenState extends State<Ad7DetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Ad7ViewModelScreen(),
|
||||||
|
child: Ad7UpdateEntityScreen(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 Ad7?'),
|
||||||
|
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<Ad7ViewModelScreen>(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<Ad7ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Ad7',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,196 @@
|
|||||||
|
// 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 'Ad7_create_entity_screen.dart';
|
||||||
|
import 'Ad7_update_entity_screen.dart';
|
||||||
|
import '../Ad7_viewModel/Ad7_view_model_screen.dart';
|
||||||
|
import 'Ad7_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Ad7_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Ad7_entity_list_screenState createState() => _Ad7_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Ad7_entity_list_screenState extends State<Ad7_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Ad7ViewModelScreen(),
|
||||||
|
child: const Ad7CreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Ad7ViewModelScreen(),
|
||||||
|
child: Ad7UpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Ad7ViewModelScreen(),
|
||||||
|
child: Ad7DetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Ad7?'),
|
||||||
|
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<Ad7ViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Ad7ViewModelScreen>(
|
||||||
|
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.searchad7(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Ad7',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
|
||||||
|
|
||||||
|
onInsertAction: () async {
|
||||||
|
final id = await RelatedEntityInsertField.showInsertDialog(
|
||||||
|
context: context,
|
||||||
|
relationTitle: 'Support',
|
||||||
|
fieldSchema: const [
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'label': 'Description',
|
||||||
|
'hint': 'Enter Description',
|
||||||
|
'path': 'description',
|
||||||
|
'required': false
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'label': 'Name',
|
||||||
|
'hint': 'Enter Name',
|
||||||
|
'path': 'name',
|
||||||
|
'required': false
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
onCreate: (data) =>
|
||||||
|
Provider.of<Ad7ViewModelScreen>(context, listen: false)
|
||||||
|
.insertsupport(data),
|
||||||
|
valueKey: 'id',
|
||||||
|
displayKey: 'name',
|
||||||
|
);
|
||||||
|
if (id != null && id.trim().isNotEmpty) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Support inserted (id: $id)',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
insertActionLabel: 'Support',
|
||||||
|
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Ad7_viewModel/Ad7_view_model_screen.dart';/// Field definitions for Ad7 entity
|
||||||
|
/// This defines the structure and validation for Ad7 forms
|
||||||
|
class Ad7Fields {
|
||||||
|
/// Get field definitions for Ad7 entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
return [
|
||||||
|
// Basic Information
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'name',
|
||||||
|
label: 'Name',
|
||||||
|
hint: 'Enter Name',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Ad7_viewModel/Ad7_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Ad7_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 Ad7UpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
Ad7UpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Ad7UpdateEntityScreenState createState() => _Ad7UpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Ad7UpdateEntityScreenState extends State<Ad7UpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Ad7ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = Ad7Fields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Ad7',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<Ad7ViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
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 Ad7RepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Ad7/Ad7';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<dynamic> insertsupport(Map<String, dynamic> entity) async {
|
||||||
|
try {
|
||||||
|
String apiUrl = "$baseUrl/Support/Support_insert";
|
||||||
|
final response = await _helper.getPostApiResponse(apiUrl,entity);
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to Insert: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,301 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Ad7_Repo/Ad7_repo_screen.dart';
|
||||||
|
|
||||||
|
class Ad7ViewModelScreen extends ChangeNotifier{
|
||||||
|
final Ad7RepoScreen repo = Ad7RepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _ad7List = [];
|
||||||
|
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 ad7List => _ad7List;
|
||||||
|
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 ad7 list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_ad7List = response.data ?? [];
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch ad7 list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch ad7 list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ad7 list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_ad7List.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) {
|
||||||
|
_ad7List = newItems;
|
||||||
|
} else {
|
||||||
|
_ad7List.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Ad7 list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch ad7 list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Ad7
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'ad7 created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Ad7');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Ad7',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create ad7: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Ad7: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update ad7
|
||||||
|
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: 'Ad7 updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _ad7List.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_ad7List[index] = response.data!;
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Ad7');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Ad7',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update ad7: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Ad7: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete ad7
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Ad7 deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_ad7List.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Ad7');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Ad7',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete ad7: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Ad7: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search ad7
|
||||||
|
void searchad7(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
} else {
|
||||||
|
_filteredList = _ad7List.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_ad7List);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> insertsupport(Map<String, dynamic> entity) async {
|
||||||
|
try {
|
||||||
|
print("Entity is $entity");
|
||||||
|
final responseData =
|
||||||
|
await repo.insertsupport(entity) as Map<String, dynamic>;
|
||||||
|
|
||||||
|
print(entity);
|
||||||
|
|
||||||
|
|
||||||
|
return responseData;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to Insert support: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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 Adv4ApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Adv4/Adv4');
|
||||||
|
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/Adv4/Adv4/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/Adv4/Adv4', 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/Adv4/Adv4/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Adv4/Adv4/$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 '../Adv4_viewModel/Adv4_view_model_screen.dart';
|
||||||
|
import 'Adv4_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 Adv4CreateEntityScreen extends StatefulWidget {
|
||||||
|
const Adv4CreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Adv4CreateEntityScreenState createState() => _Adv4CreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Adv4CreateEntityScreenState extends State<Adv4CreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Adv4ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: Adv4Fields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Adv4',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<Adv4ViewModelScreen>(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 '../Adv4_viewModel/Adv4_view_model_screen.dart';
|
||||||
|
import 'Adv4_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class Adv4DetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const Adv4DetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Adv4DetailsScreen> createState() => _Adv4DetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Adv4DetailsScreenState extends State<Adv4DetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Adv4ViewModelScreen(),
|
||||||
|
child: Adv4UpdateEntityScreen(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 Adv4?'),
|
||||||
|
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<Adv4ViewModelScreen>(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<Adv4ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Adv4',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'atdy1', 'label': 'atdy1', 'type': 'select'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{'key': 'text_field', 'label': 'Text Field', 'type': 'text'},
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
// 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 'Adv4_create_entity_screen.dart';
|
||||||
|
import 'Adv4_update_entity_screen.dart';
|
||||||
|
import '../Adv4_viewModel/Adv4_view_model_screen.dart';
|
||||||
|
import 'Adv4_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Adv4_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Adv4_entity_list_screenState createState() => _Adv4_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Adv4_entity_list_screenState extends State<Adv4_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<Adv4ViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Adv4ViewModelScreen(),
|
||||||
|
child: const Adv4CreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<Adv4ViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Adv4ViewModelScreen(),
|
||||||
|
child: Adv4UpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<Adv4ViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => Adv4ViewModelScreen(),
|
||||||
|
child: Adv4DetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Adv4?'),
|
||||||
|
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<Adv4ViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Adv4ViewModelScreen>(
|
||||||
|
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.searchadv4(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Adv4',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'atdy1', 'label': 'atdy1', 'type': 'select'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{'key': 'text_field', 'label': 'Text Field', 'type': 'text'},
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Adv4_viewModel/Adv4_view_model_screen.dart';/// Field definitions for Adv4 entity
|
||||||
|
/// This defines the structure and validation for Adv4 forms
|
||||||
|
class Adv4Fields {
|
||||||
|
/// Get field definitions for Adv4 entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<Adv4ViewModelScreen>(context, listen: false);
|
||||||
|
return [
|
||||||
|
// Basic Information
|
||||||
|
|
||||||
|
|
||||||
|
AutocompleteMultiSelectField(
|
||||||
|
fieldKey: 'atdy1',
|
||||||
|
label: 'atdy1',
|
||||||
|
hint: 'Select atdy1',
|
||||||
|
isRequired: false,
|
||||||
|
optionsLoader: () async =>await viewModel.getatdy1(),
|
||||||
|
|
||||||
|
|
||||||
|
valueKey: 'name',
|
||||||
|
displayKey: 'name',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
OneToOneRelationField(
|
||||||
|
fieldKey: 'support',
|
||||||
|
label: 'support',
|
||||||
|
hint: 'support details',
|
||||||
|
relationSchema: {
|
||||||
|
'title': 'support',
|
||||||
|
'box': true,
|
||||||
|
'fields': [
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'label': 'Description',
|
||||||
|
'hint': 'Enter Description',
|
||||||
|
'path': 'support.description',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'label': 'Name',
|
||||||
|
'hint': 'Enter Name',
|
||||||
|
'path': 'support.name',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'text_field',
|
||||||
|
label: 'Text Field',
|
||||||
|
hint: 'Enter Text Field',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Adv4_viewModel/Adv4_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Adv4_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 Adv4UpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
Adv4UpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Adv4UpdateEntityScreenState createState() => _Adv4UpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Adv4UpdateEntityScreenState extends State<Adv4UpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<Adv4ViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = Adv4Fields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Adv4',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<Adv4ViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
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 Adv4RepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Adv4/Adv4';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Future<dynamic> getatdy1() async {
|
||||||
|
try {
|
||||||
|
String apiUrl = "$baseUrl/Country_ListFilter1/Country_ListFilter1";
|
||||||
|
final response = await _helper.getGetApiResponse(apiUrl);
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to Get: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,322 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Adv4_Repo/Adv4_repo_screen.dart';
|
||||||
|
|
||||||
|
class Adv4ViewModelScreen extends ChangeNotifier{
|
||||||
|
final Adv4RepoScreen repo = Adv4RepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _adv4List = [];
|
||||||
|
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 adv4List => _adv4List;
|
||||||
|
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 adv4 list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_adv4List = response.data ?? [];
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch adv4 list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch adv4 list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get adv4 list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_adv4List.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) {
|
||||||
|
_adv4List = newItems;
|
||||||
|
} else {
|
||||||
|
_adv4List.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Adv4 list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch adv4 list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Adv4
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'adv4 created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Adv4');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Adv4',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create adv4: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Adv4: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update adv4
|
||||||
|
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: 'Adv4 updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _adv4List.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_adv4List[index] = response.data!;
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Adv4');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Adv4',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update adv4: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Adv4: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete adv4
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Adv4 deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_adv4List.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Adv4');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Adv4',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete adv4: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Adv4: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search adv4
|
||||||
|
void searchadv4(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
} else {
|
||||||
|
_filteredList = _adv4List.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['atdy1']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['support']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['text_field']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_adv4List);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
List<Map<String, dynamic>> atdy1Items = [];
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getatdy1() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final value = await repo.getatdy1();
|
||||||
|
atdy1Items = (value as List)
|
||||||
|
.map((item) => item as Map<String, dynamic>)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return atdy1Items;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get all: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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 OnetomanyApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Onetomany/Onetomany');
|
||||||
|
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/Onetomany/Onetomany/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/Onetomany/Onetomany', 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/Onetomany/Onetomany/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Onetomany/Onetomany/$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 '../Onetomany_viewModel/Onetomany_view_model_screen.dart';
|
||||||
|
import 'Onetomany_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 OnetomanyCreateEntityScreen extends StatefulWidget {
|
||||||
|
const OnetomanyCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_OnetomanyCreateEntityScreenState createState() => _OnetomanyCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OnetomanyCreateEntityScreenState extends State<OnetomanyCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<OnetomanyViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: OnetomanyFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Onetomany',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<OnetomanyViewModelScreen>(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 '../Onetomany_viewModel/Onetomany_view_model_screen.dart';
|
||||||
|
import 'Onetomany_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class OnetomanyDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const OnetomanyDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<OnetomanyDetailsScreen> createState() => _OnetomanyDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OnetomanyDetailsScreenState extends State<OnetomanyDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => OnetomanyViewModelScreen(),
|
||||||
|
child: OnetomanyUpdateEntityScreen(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 Onetomany?'),
|
||||||
|
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<OnetomanyViewModelScreen>(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<OnetomanyViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Onetomany',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
// 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 'Onetomany_create_entity_screen.dart';
|
||||||
|
import 'Onetomany_update_entity_screen.dart';
|
||||||
|
import '../Onetomany_viewModel/Onetomany_view_model_screen.dart';
|
||||||
|
import 'Onetomany_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Onetomany_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Onetomany_entity_list_screenState createState() => _Onetomany_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Onetomany_entity_list_screenState extends State<Onetomany_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<OnetomanyViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => OnetomanyViewModelScreen(),
|
||||||
|
child: const OnetomanyCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<OnetomanyViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => OnetomanyViewModelScreen(),
|
||||||
|
child: OnetomanyUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<OnetomanyViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => OnetomanyViewModelScreen(),
|
||||||
|
child: OnetomanyDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Onetomany?'),
|
||||||
|
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<OnetomanyViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<OnetomanyViewModelScreen>(
|
||||||
|
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.searchonetomany(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Onetomany',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Onetomany_viewModel/Onetomany_view_model_screen.dart';/// Field definitions for Onetomany entity
|
||||||
|
/// This defines the structure and validation for Onetomany forms
|
||||||
|
class OnetomanyFields {
|
||||||
|
/// Get field definitions for Onetomany entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<OnetomanyViewModelScreen>(context, listen: false);
|
||||||
|
return [
|
||||||
|
// Basic Information
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'name',
|
||||||
|
label: 'Name',
|
||||||
|
hint: 'Enter Name',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
OneToManyField(
|
||||||
|
fieldKey: 'support',
|
||||||
|
label: 'support',
|
||||||
|
fieldSchema: [
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'path': 'description',
|
||||||
|
'label': 'Description',
|
||||||
|
'hint': 'Enter Description',
|
||||||
|
'required': true,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'path': 'name',
|
||||||
|
'label': 'Name',
|
||||||
|
'hint': 'Enter Name',
|
||||||
|
'required': true,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
FileUploadField(
|
||||||
|
fieldKey: 'fileupload_field',
|
||||||
|
label: 'Fileupload Field',
|
||||||
|
isRequired: false,
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Onetomany_viewModel/Onetomany_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Onetomany_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 OnetomanyUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
OnetomanyUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_OnetomanyUpdateEntityScreenState createState() => _OnetomanyUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OnetomanyUpdateEntityScreenState extends State<OnetomanyUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<OnetomanyViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'fileupload_field',
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = OnetomanyFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Onetomany',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<OnetomanyViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
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 OnetomanyRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Onetomany/Onetomany';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<dynamic> fileupload_fieldUpload(
|
||||||
|
String ref, String refTableNmae, FormData entity) async {
|
||||||
|
try {
|
||||||
|
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||||
|
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to Upload File: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,398 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Onetomany_Repo/Onetomany_repo_screen.dart';
|
||||||
|
|
||||||
|
class OnetomanyViewModelScreen extends ChangeNotifier{
|
||||||
|
final OnetomanyRepoScreen repo = OnetomanyRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _onetomanyList = [];
|
||||||
|
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 onetomanyList => _onetomanyList;
|
||||||
|
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 onetomany list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_onetomanyList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch onetomany list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch onetomany list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get onetomany list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_onetomanyList.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) {
|
||||||
|
_onetomanyList = newItems;
|
||||||
|
} else {
|
||||||
|
_onetomanyList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Onetomany list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch onetomany list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Variable to store image files
|
||||||
|
List<Map<String, dynamic>> _fileupload_fieldFiles = [];
|
||||||
|
|
||||||
|
// Create Onetomany
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Always source image selections from EntityFieldStore for simplicity
|
||||||
|
final List<UploadItem> storefilefileupload_field = EntityFieldStore.instance
|
||||||
|
.get<List<UploadItem>>('fileupload_field') ??
|
||||||
|
<UploadItem>[];
|
||||||
|
|
||||||
|
_fileupload_fieldFiles = storefilefileupload_field
|
||||||
|
.map((u) => {'path': u.fileName, 'bytes': u.bytes})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
|
||||||
|
entity.remove('fileupload_field');
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Upload File if available
|
||||||
|
if (_fileupload_fieldFiles.isNotEmpty) {
|
||||||
|
await _uploadfileupload_field(responseId, _fileupload_fieldFiles);
|
||||||
|
_fileupload_fieldFiles.clear(); // Clear after upload
|
||||||
|
}
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'onetomany created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EntityFieldStore.instance.remove('fileupload_field');
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Onetomany');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Onetomany',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create onetomany: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Onetomany: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update onetomany
|
||||||
|
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: 'Onetomany updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _onetomanyList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_onetomanyList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Onetomany');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Onetomany',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update onetomany: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Onetomany: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete onetomany
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Onetomany deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_onetomanyList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Onetomany');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Onetomany',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete onetomany: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Onetomany: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search onetomany
|
||||||
|
void searchonetomany(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _onetomanyList.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['support']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_onetomanyList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Helper method to upload multiple image files
|
||||||
|
Future<void> _uploadfileupload_field(
|
||||||
|
String responseId, List<dynamic> Files) async {
|
||||||
|
try {
|
||||||
|
for (var File in Files) {
|
||||||
|
if (File is Map<String, dynamic> &&
|
||||||
|
File.containsKey('path')) {
|
||||||
|
String filePath = File['path'];
|
||||||
|
Uint8List fileBytes = File['bytes'];
|
||||||
|
|
||||||
|
// Upload each image file
|
||||||
|
await uploadfileupload_field(
|
||||||
|
responseId, 'Onetomany', filePath, fileBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
print('Error uploading files: $error');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: "Failed to upload images", toastType: ToastType.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify the uploadfileupload_fieldimage function
|
||||||
|
Future<void> uploadfileupload_field(String ref, String refTableNmae,
|
||||||
|
String selectedFilePath, Uint8List imageTimageBytes) async {
|
||||||
|
try {
|
||||||
|
|
||||||
|
final Uint8List fileBytes = imageTimageBytes!;
|
||||||
|
final mimeType = fileupload_fieldlookupMimeType(selectedFilePath);
|
||||||
|
|
||||||
|
FormData formData = FormData.fromMap({
|
||||||
|
'file': MultipartFile.fromBytes(
|
||||||
|
fileBytes,
|
||||||
|
filename: selectedFilePath
|
||||||
|
.split('/')
|
||||||
|
.last, // Get the file name from the path
|
||||||
|
contentType: MediaType.parse(mimeType!),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await repo.fileupload_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: "File uploaded successfully",
|
||||||
|
toastType: ToastType.success);
|
||||||
|
}).onError(
|
||||||
|
(error, stackTrace) {
|
||||||
|
print("error--$error");
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: "Failed to upload file", toastType: ToastType.error);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
print('Error occurred during form submission: $error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify the lookupMimeType function if needed
|
||||||
|
String fileupload_fieldlookupMimeType(String filePath) {
|
||||||
|
final ext = filePath.split('.').last;
|
||||||
|
switch (ext) {
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
return 'image/jpeg';
|
||||||
|
case 'png':
|
||||||
|
return 'image/png';
|
||||||
|
case 'pdf':
|
||||||
|
return 'application/pdf';
|
||||||
|
// Add more cases for other file types as needed
|
||||||
|
default:
|
||||||
|
return 'application/octet-stream'; // Default MIME type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
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 SupportApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Support/Support');
|
||||||
|
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/Support/Support/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/Support/Support', 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/Support/Support/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Support/Support/$entityId');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to delete entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
// 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 '../Support_viewModel/Support_view_model_screen.dart';
|
||||||
|
import 'Support_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 SupportCreateEntityScreen extends StatefulWidget {
|
||||||
|
const SupportCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SupportCreateEntityScreenState createState() => _SupportCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SupportCreateEntityScreenState extends State<SupportCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<SupportViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: SupportFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Support',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.createEntity(formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
// 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 '../Support_viewModel/Support_view_model_screen.dart';
|
||||||
|
import 'Support_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class SupportDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const SupportDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SupportDetailsScreen> createState() => _SupportDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SupportDetailsScreenState extends State<SupportDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => SupportViewModelScreen(),
|
||||||
|
child: SupportUpdateEntityScreen(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 Support?'),
|
||||||
|
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<SupportViewModelScreen>(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<SupportViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Support',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,153 @@
|
|||||||
|
// 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 'Support_create_entity_screen.dart';
|
||||||
|
import 'Support_update_entity_screen.dart';
|
||||||
|
import '../Support_viewModel/Support_view_model_screen.dart';
|
||||||
|
import 'Support_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Support_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Support_entity_list_screenState createState() => _Support_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Support_entity_list_screenState extends State<Support_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => SupportViewModelScreen(),
|
||||||
|
child: const SupportCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => SupportViewModelScreen(),
|
||||||
|
child: SupportUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => SupportViewModelScreen(),
|
||||||
|
child: SupportDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Support?'),
|
||||||
|
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<SupportViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<SupportViewModelScreen>(
|
||||||
|
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.searchsupport(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Support',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Support_viewModel/Support_view_model_screen.dart';/// Field definitions for Support entity
|
||||||
|
/// This defines the structure and validation for Support forms
|
||||||
|
class SupportFields {
|
||||||
|
/// Get field definitions for Support entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Support_viewModel/Support_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Support_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 SupportUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
SupportUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SupportUpdateEntityScreenState createState() => _SupportUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SupportUpdateEntityScreenState extends State<SupportUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<SupportViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = SupportFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Support',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<SupportViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
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 SupportRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Support/Support';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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,292 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Support_Repo/Support_repo_screen.dart';
|
||||||
|
|
||||||
|
class SupportViewModelScreen extends ChangeNotifier{
|
||||||
|
final SupportRepoScreen repo = SupportRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _supportList = [];
|
||||||
|
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 supportList => _supportList;
|
||||||
|
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 support list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_supportList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch support list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch support list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get support list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_supportList.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) {
|
||||||
|
_supportList = newItems;
|
||||||
|
} else {
|
||||||
|
_supportList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Support list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch support list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Support
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'support created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Support');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Support',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create support: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Support: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update support
|
||||||
|
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: 'Support updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _supportList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_supportList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Support');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Support',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update support: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Support: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete support
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Support deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_supportList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Support');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Support',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete support: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Support: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search support
|
||||||
|
void searchsupport(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _supportList.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_supportList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
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 VallistApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Vallist/Vallist');
|
||||||
|
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/Vallist/Vallist/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/Vallist/Vallist', 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/Vallist/Vallist/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Vallist/Vallist/$entityId');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to delete entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
// 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 '../Vallist_viewModel/Vallist_view_model_screen.dart';
|
||||||
|
import 'Vallist_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 VallistCreateEntityScreen extends StatefulWidget {
|
||||||
|
const VallistCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_VallistCreateEntityScreenState createState() => _VallistCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VallistCreateEntityScreenState extends State<VallistCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<VallistViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: VallistFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Vallist',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.createEntity(formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
// 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 '../Vallist_viewModel/Vallist_view_model_screen.dart';
|
||||||
|
import 'Vallist_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class VallistDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const VallistDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<VallistDetailsScreen> createState() => _VallistDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VallistDetailsScreenState extends State<VallistDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => VallistViewModelScreen(),
|
||||||
|
child: VallistUpdateEntityScreen(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 Vallist?'),
|
||||||
|
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<VallistViewModelScreen>(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<VallistViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Vallist',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'nameb', 'label': 'Nameb', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'value_list_fieldb', 'label': 'Value List Fieldb', 'type': 'value_list'},
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,153 @@
|
|||||||
|
// 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 'Vallist_create_entity_screen.dart';
|
||||||
|
import 'Vallist_update_entity_screen.dart';
|
||||||
|
import '../Vallist_viewModel/Vallist_view_model_screen.dart';
|
||||||
|
import 'Vallist_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Vallist_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Vallist_entity_list_screenState createState() => _Vallist_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Vallist_entity_list_screenState extends State<Vallist_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => VallistViewModelScreen(),
|
||||||
|
child: const VallistCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => VallistViewModelScreen(),
|
||||||
|
child: VallistUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => VallistViewModelScreen(),
|
||||||
|
child: VallistDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Vallist?'),
|
||||||
|
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<VallistViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<VallistViewModelScreen>(
|
||||||
|
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.searchvallist(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Vallist',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'nameb', 'label': 'Nameb', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'value_list_fieldb', 'label': 'Value List Fieldb', 'type': 'value_list'},
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Vallist_viewModel/Vallist_view_model_screen.dart';/// Field definitions for Vallist entity
|
||||||
|
/// This defines the structure and validation for Vallist forms
|
||||||
|
class VallistFields {
|
||||||
|
/// Get field definitions for Vallist entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
return [
|
||||||
|
// Basic Information
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'nameb',
|
||||||
|
label: 'Nameb',
|
||||||
|
hint: 'Enter Nameb',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
// 3) Value list picker â fill fields from selection (provide your loader)
|
||||||
|
ValueListPickerField(
|
||||||
|
fieldKey: 'value_list_fieldb',
|
||||||
|
label: 'Value List Fieldb',
|
||||||
|
optionsLoader: () async {
|
||||||
|
try {
|
||||||
|
await viewModel.getEntities();
|
||||||
|
final response = viewModel.vallistList;
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
// Return empty list if API fails
|
||||||
|
return <Map<String, dynamic>>[];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fillMappings: const {
|
||||||
|
|
||||||
|
|
||||||
|
'nameb': 'nameb',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Vallist_viewModel/Vallist_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Vallist_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 VallistUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
VallistUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_VallistUpdateEntityScreenState createState() => _VallistUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VallistUpdateEntityScreenState extends State<VallistUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<VallistViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = VallistFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Vallist',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<VallistViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
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 VallistRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Vallist/Vallist';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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,288 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Vallist_Repo/Vallist_repo_screen.dart';
|
||||||
|
|
||||||
|
class VallistViewModelScreen extends ChangeNotifier{
|
||||||
|
final VallistRepoScreen repo = VallistRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _vallistList = [];
|
||||||
|
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 vallistList => _vallistList;
|
||||||
|
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 vallist list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_vallistList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch vallist list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch vallist list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get vallist list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_vallistList.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) {
|
||||||
|
_vallistList = newItems;
|
||||||
|
} else {
|
||||||
|
_vallistList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Vallist list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch vallist list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Vallist
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'vallist created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Vallist');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Vallist',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create vallist: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Vallist: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update vallist
|
||||||
|
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: 'Vallist updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _vallistList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_vallistList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Vallist');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Vallist',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update vallist: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Vallist: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete vallist
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Vallist deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_vallistList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Vallist');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Vallist',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete vallist: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Vallist: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search vallist
|
||||||
|
void searchvallist(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _vallistList.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['nameb']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_vallistList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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 CountryApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Country/Country');
|
||||||
|
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/Country/Country/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/Country/Country', 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/Country/Country/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Country/Country/$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 '../Country_viewModel/Country_view_model_screen.dart';
|
||||||
|
import 'Country_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 CountryCreateEntityScreen extends StatefulWidget {
|
||||||
|
const CountryCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CountryCreateEntityScreenState createState() => _CountryCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CountryCreateEntityScreenState extends State<CountryCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CountryViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: CountryFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Country',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<CountryViewModelScreen>(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 '../Country_viewModel/Country_view_model_screen.dart';
|
||||||
|
import 'Country_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class CountryDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const CountryDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CountryDetailsScreen> createState() => _CountryDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CountryDetailsScreenState extends State<CountryDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CountryViewModelScreen(),
|
||||||
|
child: CountryUpdateEntityScreen(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 Country?'),
|
||||||
|
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<CountryViewModelScreen>(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<CountryViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Country',
|
||||||
|
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,157 @@
|
|||||||
|
// 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 'Country_create_entity_screen.dart';
|
||||||
|
import 'Country_update_entity_screen.dart';
|
||||||
|
import '../Country_viewModel/Country_view_model_screen.dart';
|
||||||
|
import 'Country_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 '../../../../BuilderField/shared/fields/realted_entity_insert_field.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class Country_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Country_entity_list_screenState createState() => _Country_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Country_entity_list_screenState extends State<Country_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<CountryViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CountryViewModelScreen(),
|
||||||
|
child: const CountryCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<CountryViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CountryViewModelScreen(),
|
||||||
|
child: CountryUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<CountryViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CountryViewModelScreen(),
|
||||||
|
child: CountryDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Country?'),
|
||||||
|
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<CountryViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CountryViewModelScreen>(
|
||||||
|
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.searchcountry(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Country',
|
||||||
|
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,76 @@
|
|||||||
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Country_viewModel/Country_view_model_screen.dart';/// Field definitions for Country entity
|
||||||
|
/// This defines the structure and validation for Country forms
|
||||||
|
class CountryFields {
|
||||||
|
/// Get field definitions for Country entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<CountryViewModelScreen>(context, listen: false);
|
||||||
|
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,77 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Country_viewModel/Country_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Country_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 CountryUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
CountryUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CountryUpdateEntityScreenState createState() => _CountryUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CountryUpdateEntityScreenState extends State<CountryUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CountryViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = CountryFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Country',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<CountryViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
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 CountryRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Country/Country';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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,305 @@
|
|||||||
|
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 '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Country_Repo/Country_repo_screen.dart';
|
||||||
|
|
||||||
|
class CountryViewModelScreen extends ChangeNotifier{
|
||||||
|
final CountryRepoScreen repo = CountryRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _countryList = [];
|
||||||
|
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 countryList => _countryList;
|
||||||
|
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 country list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_countryList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_countryList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch country list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch country list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get country list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_countryList.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) {
|
||||||
|
_countryList = newItems;
|
||||||
|
} else {
|
||||||
|
_countryList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_countryList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Country list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch country list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Country
|
||||||
|
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final response = await repo.createEntity(entity);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
// Get the response ID for image upload
|
||||||
|
|
||||||
|
final responseId = response.data!['id'].toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'country created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Country');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Country',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create country: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Country: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update country
|
||||||
|
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: 'Country updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _countryList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_countryList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_countryList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Country');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Country',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update country: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Country: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete country
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Country deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_countryList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_countryList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Country');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Country',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete country: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Country: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search country
|
||||||
|
void searchcountry(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_countryList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _countryList.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(_countryList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -69,6 +69,24 @@ public class BuilderService {
|
|||||||
executeDump(true);
|
executeDump(true);
|
||||||
|
|
||||||
// ADD OTHER SERVICE
|
// ADD OTHER SERVICE
|
||||||
|
addCustomMenu( "Vallist","Vallist", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Onetomany","Onetomany", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Country","Country", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Ad7","Ad7", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Adv4","Adv4", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Support","Support", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("dashboard and menu inserted...");
|
System.out.println("dashboard and menu inserted...");
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,98 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Ad7;
|
||||||
|
import com.realnet.angulardatatype.Services.Ad7Service ;
|
||||||
|
|
||||||
|
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Ad7")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class Ad7Controller {
|
||||||
|
@Autowired
|
||||||
|
private Ad7Service Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Ad7")
|
||||||
|
public Ad7 Savedata(@RequestBody Ad7 data) {
|
||||||
|
Ad7 save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Ad7/{id}")
|
||||||
|
public Ad7 update(@RequestBody Ad7 data,@PathVariable Integer id ) {
|
||||||
|
Ad7 update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Ad7/getall/page")
|
||||||
|
public Page<Ad7> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Ad7> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Ad7")
|
||||||
|
public List<Ad7> getdetails() {
|
||||||
|
List<Ad7> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Ad7")
|
||||||
|
public List<Ad7> getallwioutsec() {
|
||||||
|
List<Ad7> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Ad7/{id}")
|
||||||
|
public Ad7 getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Ad7 get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Ad7/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Ad7/Support_insert")
|
||||||
|
public Support insertSupport(@RequestBody Support data) {
|
||||||
|
Support insertaction = Service.insertSupport(data);
|
||||||
|
return insertaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Adv4;
|
||||||
|
import com.realnet.angulardatatype.Services.Adv4Service ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Adv4")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class Adv4Controller {
|
||||||
|
@Autowired
|
||||||
|
private Adv4Service Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Adv4")
|
||||||
|
public Adv4 Savedata(@RequestBody Adv4 data) {
|
||||||
|
Adv4 save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Adv4/{id}")
|
||||||
|
public Adv4 update(@RequestBody Adv4 data,@PathVariable Integer id ) {
|
||||||
|
Adv4 update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Adv4/getall/page")
|
||||||
|
public Page<Adv4> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Adv4> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Adv4")
|
||||||
|
public List<Adv4> getdetails() {
|
||||||
|
List<Adv4> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Adv4")
|
||||||
|
public List<Adv4> getallwioutsec() {
|
||||||
|
List<Adv4> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Adv4/{id}")
|
||||||
|
public Adv4 getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Adv4 get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Adv4/{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.angulardatatype.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.angulardatatype.Entity.Onetomany;
|
||||||
|
import com.realnet.angulardatatype.Services.OnetomanyService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Onetomany")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class OnetomanyController {
|
||||||
|
@Autowired
|
||||||
|
private OnetomanyService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Onetomany")
|
||||||
|
public Onetomany Savedata(@RequestBody Onetomany data) {
|
||||||
|
Onetomany save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Onetomany/{id}")
|
||||||
|
public Onetomany update(@RequestBody Onetomany data,@PathVariable Integer id ) {
|
||||||
|
Onetomany update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Onetomany/getall/page")
|
||||||
|
public Page<Onetomany> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Onetomany> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Onetomany")
|
||||||
|
public List<Onetomany> getdetails() {
|
||||||
|
List<Onetomany> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Onetomany")
|
||||||
|
public List<Onetomany> getallwioutsec() {
|
||||||
|
List<Onetomany> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Onetomany/{id}")
|
||||||
|
public Onetomany getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Onetomany get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Onetomany/{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,91 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Support;
|
||||||
|
import com.realnet.angulardatatype.Services.SupportService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Support")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class SupportController {
|
||||||
|
@Autowired
|
||||||
|
private SupportService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Support")
|
||||||
|
public Support Savedata(@RequestBody Support data) {
|
||||||
|
Support save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Support/{id}")
|
||||||
|
public Support update(@RequestBody Support data,@PathVariable Integer id ) {
|
||||||
|
Support update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Support/getall/page")
|
||||||
|
public Page<Support> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Support> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Support")
|
||||||
|
public List<Support> getdetails() {
|
||||||
|
List<Support> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Support")
|
||||||
|
public List<Support> getallwioutsec() {
|
||||||
|
List<Support> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Support/{id}")
|
||||||
|
public Support getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Support get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Support/{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,21 @@
|
|||||||
|
package com.realnet.angulardatatype.Controllers;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
import com.realnet.angulardatatype.Services.SupportInsertService2;
|
||||||
|
@RequestMapping(value = "/Support")
|
||||||
|
@RestController
|
||||||
|
public class SupportInsertController2{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupportInsertService2 Service;
|
||||||
|
|
||||||
|
@PostMapping("/Support_insert")
|
||||||
|
public ResponseEntity<?> insert(@RequestBody Support support) {
|
||||||
|
Support insertaction = Service.insertaction(support);
|
||||||
|
return new ResponseEntity<>(insertaction, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Vallist;
|
||||||
|
import com.realnet.angulardatatype.Services.VallistService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Vallist")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class VallistController {
|
||||||
|
@Autowired
|
||||||
|
private VallistService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Vallist")
|
||||||
|
public Vallist Savedata(@RequestBody Vallist data) {
|
||||||
|
Vallist save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Vallist/{id}")
|
||||||
|
public Vallist update(@RequestBody Vallist data,@PathVariable Integer id ) {
|
||||||
|
Vallist update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Vallist/getall/page")
|
||||||
|
public Page<Vallist> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Vallist> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Vallist")
|
||||||
|
public List<Vallist> getdetails() {
|
||||||
|
List<Vallist> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Vallist")
|
||||||
|
public List<Vallist> getallwioutsec() {
|
||||||
|
List<Vallist> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Vallist/{id}")
|
||||||
|
public Vallist getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Vallist get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Vallist/{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,98 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Ad7;
|
||||||
|
import com.realnet.angulardatatype.Services.Ad7Service ;
|
||||||
|
|
||||||
|
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Ad7")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_Ad7Controller {
|
||||||
|
@Autowired
|
||||||
|
private Ad7Service Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Ad7")
|
||||||
|
public Ad7 Savedata(@RequestBody Ad7 data) {
|
||||||
|
Ad7 save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Ad7/{id}")
|
||||||
|
public Ad7 update(@RequestBody Ad7 data,@PathVariable Integer id ) {
|
||||||
|
Ad7 update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Ad7/getall/page")
|
||||||
|
public Page<Ad7> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Ad7> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Ad7")
|
||||||
|
public List<Ad7> getdetails() {
|
||||||
|
List<Ad7> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Ad7")
|
||||||
|
public List<Ad7> getallwioutsec() {
|
||||||
|
List<Ad7> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Ad7/{id}")
|
||||||
|
public Ad7 getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Ad7 get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Ad7/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Ad7/Support_insert")
|
||||||
|
public Support insertSupport(@RequestBody Support data) {
|
||||||
|
Support insertaction = Service.insertSupport(data);
|
||||||
|
return insertaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Adv4;
|
||||||
|
import com.realnet.angulardatatype.Services.Adv4Service ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Adv4")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_Adv4Controller {
|
||||||
|
@Autowired
|
||||||
|
private Adv4Service Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Adv4")
|
||||||
|
public Adv4 Savedata(@RequestBody Adv4 data) {
|
||||||
|
Adv4 save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Adv4/{id}")
|
||||||
|
public Adv4 update(@RequestBody Adv4 data,@PathVariable Integer id ) {
|
||||||
|
Adv4 update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Adv4/getall/page")
|
||||||
|
public Page<Adv4> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Adv4> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Adv4")
|
||||||
|
public List<Adv4> getdetails() {
|
||||||
|
List<Adv4> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Adv4")
|
||||||
|
public List<Adv4> getallwioutsec() {
|
||||||
|
List<Adv4> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Adv4/{id}")
|
||||||
|
public Adv4 getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Adv4 get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Adv4/{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.angulardatatype.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.angulardatatype.Entity.Onetomany;
|
||||||
|
import com.realnet.angulardatatype.Services.OnetomanyService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Onetomany")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_OnetomanyController {
|
||||||
|
@Autowired
|
||||||
|
private OnetomanyService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Onetomany")
|
||||||
|
public Onetomany Savedata(@RequestBody Onetomany data) {
|
||||||
|
Onetomany save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Onetomany/{id}")
|
||||||
|
public Onetomany update(@RequestBody Onetomany data,@PathVariable Integer id ) {
|
||||||
|
Onetomany update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Onetomany/getall/page")
|
||||||
|
public Page<Onetomany> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Onetomany> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Onetomany")
|
||||||
|
public List<Onetomany> getdetails() {
|
||||||
|
List<Onetomany> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Onetomany")
|
||||||
|
public List<Onetomany> getallwioutsec() {
|
||||||
|
List<Onetomany> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Onetomany/{id}")
|
||||||
|
public Onetomany getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Onetomany get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Onetomany/{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,91 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Support;
|
||||||
|
import com.realnet.angulardatatype.Services.SupportService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Support")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_SupportController {
|
||||||
|
@Autowired
|
||||||
|
private SupportService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Support")
|
||||||
|
public Support Savedata(@RequestBody Support data) {
|
||||||
|
Support save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Support/{id}")
|
||||||
|
public Support update(@RequestBody Support data,@PathVariable Integer id ) {
|
||||||
|
Support update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Support/getall/page")
|
||||||
|
public Page<Support> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Support> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Support")
|
||||||
|
public List<Support> getdetails() {
|
||||||
|
List<Support> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Support")
|
||||||
|
public List<Support> getallwioutsec() {
|
||||||
|
List<Support> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Support/{id}")
|
||||||
|
public Support getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Support get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Support/{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,91 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Vallist;
|
||||||
|
import com.realnet.angulardatatype.Services.VallistService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Vallist")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_VallistController {
|
||||||
|
@Autowired
|
||||||
|
private VallistService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Vallist")
|
||||||
|
public Vallist Savedata(@RequestBody Vallist data) {
|
||||||
|
Vallist save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Vallist/{id}")
|
||||||
|
public Vallist update(@RequestBody Vallist data,@PathVariable Integer id ) {
|
||||||
|
Vallist update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Vallist/getall/page")
|
||||||
|
public Page<Vallist> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Vallist> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Vallist")
|
||||||
|
public List<Vallist> getdetails() {
|
||||||
|
List<Vallist> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Vallist")
|
||||||
|
public List<Vallist> getallwioutsec() {
|
||||||
|
List<Vallist> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Vallist/{id}")
|
||||||
|
public Vallist getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Vallist get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Vallist/{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,28 @@
|
|||||||
|
package com.realnet.angulardatatype.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Ad7 extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.realnet.angulardatatype.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Adv4 extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String atdy1;
|
||||||
|
|
||||||
|
@OneToOne( cascade=CascadeType.ALL)
|
||||||
|
private Support support;
|
||||||
|
|
||||||
|
private String text_field;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.realnet.angulardatatype.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Onetomany extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@OneToMany( cascade=CascadeType.ALL)
|
||||||
|
private List<Support> support = new ArrayList<>();
|
||||||
|
|
||||||
|
private String fileupload_fieldname;
|
||||||
|
private String fileupload_fieldpath ;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.realnet.angulardatatype.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Support 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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.realnet.angulardatatype.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Vallist extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String nameb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Ad7;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface Ad7Repository extends JpaRepository<Ad7, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from ad7 where created_by=?1", nativeQuery = true)
|
||||||
|
List<Ad7> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from ad7 where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Ad7> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Adv4;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface Adv4Repository extends JpaRepository<Adv4, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from adv4 where created_by=?1", nativeQuery = true)
|
||||||
|
List<Adv4> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from adv4 where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Adv4> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Onetomany;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface OnetomanyRepository extends JpaRepository<Onetomany, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from onetomany where created_by=?1", nativeQuery = true)
|
||||||
|
List<Onetomany> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from onetomany where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Onetomany> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface SupportRepository extends JpaRepository<Support, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from support where created_by=?1", nativeQuery = true)
|
||||||
|
List<Support> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from support where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Support> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.realnet.angulardatatype.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.angulardatatype.Entity.Vallist;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface VallistRepository extends JpaRepository<Vallist, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from vallist where created_by=?1", nativeQuery = true)
|
||||||
|
List<Vallist> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from vallist where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Vallist> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.Ad7Repository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Ad7
|
||||||
|
;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 com.realnet.angulardatatype.Entity.Support;
|
||||||
|
|
||||||
|
import com.realnet.angulardatatype.Repository.SupportRepository;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class Ad7Service {
|
||||||
|
@Autowired
|
||||||
|
private Ad7Repository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Ad7 Savedata(Ad7 data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Ad7 save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Ad7> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Ad7> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Ad7> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Ad7 getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Ad7 update(Ad7 data,Integer id) {
|
||||||
|
Ad7 old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Ad7 test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Insert Action
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupportRepository supportinsertrepository;
|
||||||
|
|
||||||
|
public Support insertSupport(Support data) {
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
|
||||||
|
|
||||||
|
final Support save = supportinsertrepository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.Adv4Repository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Adv4
|
||||||
|
;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 Adv4Service {
|
||||||
|
@Autowired
|
||||||
|
private Adv4Repository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Adv4 Savedata(Adv4 data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Adv4 save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Adv4> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Adv4> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Adv4> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Adv4 getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Adv4 update(Adv4 data,Integer id) {
|
||||||
|
Adv4 old = Repository.findById(id).get();
|
||||||
|
old.setAtdy1(data.getAtdy1());
|
||||||
|
|
||||||
|
old.setSupport(data.getSupport());
|
||||||
|
|
||||||
|
old.setText_field(data.getText_field());
|
||||||
|
|
||||||
|
final Adv4 test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.OnetomanyRepository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Onetomany
|
||||||
|
;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 OnetomanyService {
|
||||||
|
@Autowired
|
||||||
|
private OnetomanyRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Onetomany Savedata(Onetomany data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Onetomany save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Onetomany> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Onetomany> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Onetomany> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Onetomany getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Onetomany update(Onetomany data,Integer id) {
|
||||||
|
Onetomany old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
old.setSupport(data.getSupport());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Onetomany test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.SupportRepository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Support;
|
||||||
|
import java.util.List;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SupportInsertService2 {
|
||||||
|
@Autowired
|
||||||
|
private SupportRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
|
|
||||||
|
public Support insertaction(Support support ) {
|
||||||
|
|
||||||
|
|
||||||
|
support.setUpdatedBy(getUser().getUserId());
|
||||||
|
support.setCreatedBy(getUser().getUserId());
|
||||||
|
support.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
final Support save = Repository.save(support);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.SupportRepository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Support
|
||||||
|
;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 SupportService {
|
||||||
|
@Autowired
|
||||||
|
private SupportRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Support Savedata(Support data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Support save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Support> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Support> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Support> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Support getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Support update(Support data,Integer id) {
|
||||||
|
Support old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
old.setDescription(data.getDescription());
|
||||||
|
|
||||||
|
final Support test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.realnet.angulardatatype.Services;
|
||||||
|
import com.realnet.angulardatatype.Repository.VallistRepository;
|
||||||
|
import com.realnet.angulardatatype.Entity.Vallist
|
||||||
|
;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 VallistService {
|
||||||
|
@Autowired
|
||||||
|
private VallistRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Vallist Savedata(Vallist data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Vallist save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Vallist> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Vallist> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Vallist> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Vallist getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Vallist update(Vallist data,Integer id) {
|
||||||
|
Vallist old = Repository.findById(id).get();
|
||||||
|
old.setNameb(data.getNameb());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Vallist test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.realnet.testdata.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.testdata.Entity.Country;
|
||||||
|
import com.realnet.testdata.Services.CountryService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Country")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class CountryController {
|
||||||
|
@Autowired
|
||||||
|
private CountryService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Country")
|
||||||
|
public Country Savedata(@RequestBody Country data) {
|
||||||
|
Country save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Country/{id}")
|
||||||
|
public Country update(@RequestBody Country data,@PathVariable Integer id ) {
|
||||||
|
Country update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Country/getall/page")
|
||||||
|
public Page<Country> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Country> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Country")
|
||||||
|
public List<Country> getdetails() {
|
||||||
|
List<Country> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Country")
|
||||||
|
public List<Country> getallwioutsec() {
|
||||||
|
List<Country> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Country/{id}")
|
||||||
|
public Country getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Country get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Country/{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,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,99 @@
|
|||||||
|
package com.realnet.testdata.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.testdata.Entity.Country;
|
||||||
|
import com.realnet.testdata.Services.CountryService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Country")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_CountryController {
|
||||||
|
@Autowired
|
||||||
|
private CountryService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Country")
|
||||||
|
public Country Savedata(@RequestBody Country data) {
|
||||||
|
Country save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Country/{id}")
|
||||||
|
public Country update(@RequestBody Country data,@PathVariable Integer id ) {
|
||||||
|
Country update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Country/getall/page")
|
||||||
|
public Page<Country> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Country> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Country")
|
||||||
|
public List<Country> getdetails() {
|
||||||
|
List<Country> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Country")
|
||||||
|
public List<Country> getallwioutsec() {
|
||||||
|
List<Country> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Country/{id}")
|
||||||
|
public Country getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Country get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Country/{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,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,33 @@
|
|||||||
|
package com.realnet.testdata.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Country 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,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,30 @@
|
|||||||
|
package com.realnet.testdata.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.testdata.Entity.Country;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CountryRepository extends JpaRepository<Country, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from country where created_by=?1", nativeQuery = true)
|
||||||
|
List<Country> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from country where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Country> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.realnet.testdata.Services;
|
||||||
|
import com.realnet.testdata.Repository.CountryRepository;
|
||||||
|
import com.realnet.testdata.Entity.Country
|
||||||
|
;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 CountryService {
|
||||||
|
@Autowired
|
||||||
|
private CountryRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Country Savedata(Country data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Country save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Country> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Country> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Country> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Country getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Country update(Country data,Integer id) {
|
||||||
|
Country old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
old.setDescription(data.getDescription());
|
||||||
|
|
||||||
|
old.setActive (data.getActive());
|
||||||
|
|
||||||
|
final Country test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
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) {
|
||||||
|
Boolean isActive = data.getActive();
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(isActive)) {{
|
||||||
|
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) {
|
||||||
|
Boolean isActive = data.getActive();
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(isActive)) {{
|
||||||
|
Country_ListFilter1 dummy = new Country_ListFilter1();
|
||||||
|
dummy.setId(data.getId());
|
||||||
|
dummy.setName(data.getName());
|
||||||
|
dummy.setDescription(data.getDescription());
|
||||||
|
l.add(dummy);
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
return l;}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user