Ingatlanok tulajdoni lapok és tulajdonosok táblázatos és térképi megjelenítése.
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
import '../models/field_party.dart';
|
||||
import '../models/field_property.dart';
|
||||
|
||||
/// Ingatlan-nyilvántartás lekérdezései — SZÁNDÉKOSAN tisztán online,
|
||||
/// nincs helyi outbox/tükör-tábla (a kapcsolatokkal/mérésekkel
|
||||
/// ellentétben). Ez az adat nem kerülhet a készülék adatbázisába.
|
||||
class FieldPropertyService extends GetxService {
|
||||
static FieldPropertyService get to => Get.find();
|
||||
|
||||
SupabaseClient get _client => Supabase.instance.client;
|
||||
|
||||
/// Ingatlanok listája, kereséssel/szűréssel.
|
||||
Future<List<FieldProperty>> listProperties({
|
||||
required String projectId,
|
||||
String? search,
|
||||
String? settlement,
|
||||
String? mailingStatus,
|
||||
}) async {
|
||||
var query = _client
|
||||
.from('terepi_seged_field_properties_view')
|
||||
.select()
|
||||
.eq('project_id', projectId);
|
||||
|
||||
if (settlement != null && settlement.isNotEmpty) {
|
||||
query = query.eq('settlement', settlement);
|
||||
}
|
||||
if (mailingStatus != null && mailingStatus.isNotEmpty) {
|
||||
query = query.eq('mailing_status', mailingStatus);
|
||||
}
|
||||
if (search != null && search.trim().isNotEmpty) {
|
||||
final s = search.trim().replaceAll(',', ' ');
|
||||
query = query.or(
|
||||
'parcel_number.ilike.%$s%,owner_names.ilike.%$s%,settlement.ilike.%$s%',
|
||||
);
|
||||
}
|
||||
|
||||
final rows = await query
|
||||
.order('settlement', ascending: true)
|
||||
.order('parcel_number', ascending: true)
|
||||
.limit(1000);
|
||||
return rows.map((r) => FieldProperty.fromMap(r)).toList();
|
||||
}
|
||||
|
||||
/// Tulajdonosok keresése név szerint.
|
||||
Future<List<FieldParty>> searchParties({
|
||||
required String projectId,
|
||||
String? search,
|
||||
}) async {
|
||||
var query = _client
|
||||
.from('terepi_seged_field_parties_view')
|
||||
.select()
|
||||
.eq('project_id', projectId);
|
||||
|
||||
if (search != null && search.trim().isNotEmpty) {
|
||||
query = query.ilike('name', '%${search.trim()}%');
|
||||
}
|
||||
|
||||
final rows = await query.order('name', ascending: true).limit(1000);
|
||||
return rows.map((r) => FieldParty.fromMap(r)).toList();
|
||||
}
|
||||
|
||||
/// Egy adott tulajdonos ÖSSZES ingatlana.
|
||||
Future<List<FieldProperty>> listPropertiesForParty(String partyId) async {
|
||||
final links = await _client
|
||||
.from('terepi_seged_field_property_parties')
|
||||
.select('property_id')
|
||||
.eq('party_id', partyId)
|
||||
.eq('is_current', true);
|
||||
|
||||
final propertyIds =
|
||||
links.map((r) => r['property_id'] as String).toSet().toList();
|
||||
if (propertyIds.isEmpty) return [];
|
||||
|
||||
final rows = await _client
|
||||
.from('terepi_seged_field_properties_view')
|
||||
.select()
|
||||
.inFilter('id', propertyIds)
|
||||
.order('settlement')
|
||||
.order('parcel_number');
|
||||
|
||||
return rows.map((r) => FieldProperty.fromMap(r)).toList();
|
||||
}
|
||||
|
||||
/// Egy ingatlan tulajdonosi/kezelői bontása, tulajdoni hányaddal — a
|
||||
/// részletnézethez.
|
||||
Future<List<Map<String, dynamic>>> propertyOwnershipDetail(
|
||||
String propertyId) async {
|
||||
final rows = await _client
|
||||
.from('terepi_seged_field_property_parties')
|
||||
.select('*, terepi_seged_field_parties(name, party_type)')
|
||||
.eq('property_id', propertyId)
|
||||
.eq('is_current', true);
|
||||
return List<Map<String, dynamic>>.from(rows);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user