update
This commit is contained in:
parent
27f00e43a7
commit
3572f90b24
24 changed files with 290 additions and 257 deletions
|
|
@ -4,37 +4,48 @@ class RefMedicines {
|
|||
final SupabaseClient _supabase = Supabase.instance.client;
|
||||
|
||||
Future<List> getList() async {
|
||||
final data = await _supabase.from('ref_medicines').select('medicine_name').order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
}
|
||||
|
||||
Future<List> getList2() async {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('medicine_name, ref_manufactorers(manufactorer_name)')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
try {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('medicine_name, ref_manufactorers(manufactorer_name)')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<List> getListWithUUID() async {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('ref_medicines_uuid, medicine_name')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
try {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('ref_medicines_uuid, medicine_name')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getUUID(String name) async {
|
||||
final data = await _supabase.from('ref_medicines').select('ref_medicines_uuid').eq('medicine_name', name);
|
||||
return data.first['ref_medicines_uuid'];
|
||||
try {
|
||||
final data = await _supabase.from('ref_medicines').select('ref_medicines_uuid').eq('medicine_name', name);
|
||||
return data.first['ref_medicines_uuid'];
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getBarcode(String name) async {
|
||||
final data = await _supabase.from('ref_medicines').select('barcode').eq('medicine_name', name);
|
||||
return data.first['barcode'];
|
||||
try {
|
||||
final data = await _supabase.from('ref_medicines').select('barcode').eq('medicine_name', name);
|
||||
return data.first['barcode'];
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode) async {
|
||||
Future<bool> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode) async {
|
||||
final medicine = {
|
||||
'ref_medicines_uuid': uuid,
|
||||
'medicine_name': name,
|
||||
|
|
@ -44,6 +55,11 @@ class RefMedicines {
|
|||
'barcode': barcode
|
||||
};
|
||||
|
||||
await _supabase.from('ref_medicines').insert(medicine);
|
||||
try {
|
||||
await _supabase.from('ref_medicines').insert(medicine);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue