feat: Add triggers and functions for user management and location handling

- Implemented user creation, update, and deletion triggers to manage officer and standard user data.
- Created functions to handle user type changes and conditional updates based on user metadata.
- Added a function to retrieve nearby units based on geographical coordinates.
- Established triggers to update distance to units upon location changes.
- Created spatial indexes for efficient querying of units and locations.
- Added a function to delete the current user from the auth.users table.
This commit is contained in:
vergiLgood1 2025-05-18 13:52:26 +07:00
parent 07c53818a5
commit c7bdb24ceb
135 changed files with 158586 additions and 151 deletions

View File

@ -1,18 +1,17 @@
# Update these with your Supabase details from your project settings > API
# https://app.supabase.com/project/_/settings/api
# Supabase Production URL
# # Supabase Production URL
# SUPABASE_URL=https://bhfzrlgxqkbkjepvqeva.supabase.co
# SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJoZnpybGd4cWtia2plcHZxZXZhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDY1MTU2ODUsImV4cCI6MjA2MjA5MTY4NX0.qDe8QNOON5ra6-JSQ-mhBEXdRFxoQGPPifBpB_-5FrU
# # Supabase Service Role Secret Key
# SERVICE_ROLE_SECRET="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNwcGVqcm9leW9uc3F4dWxpbmFqIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTczOTM2MTEyNiwiZXhwIjoyMDU0OTM3MTI2fQ.iYIVeUChLIcC7NRaeJ6dViI9JiUZSMUKufFsDTfAkjA"
# SUPABASE_STORAGE_URL="https://cppejroeyonsqxulinaj.supabase.co/storage/v1/object/public"
# Connect to Supabase via connection pooling
# # Connect to Supabase via connection pooling
# DATABASE_URL="postgresql://postgres.bhfzrlgxqkbkjepvqeva:TA-SIGAP2024@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
# Direct connection to the database. Used for migrations
# # Direct connection to the database. Used for migrations
# DIRECT_URL="postgresql://postgres.bhfzrlgxqkbkjepvqeva:TA-SIGAP2024@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres"
# Supabase Local URL

View File

@ -1,7 +1,7 @@
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:sigap/src/cores/repositories/authentication/authentication_repositories.dart';
import 'package:sigap/src/features/daily-ops/models/officers_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/officers_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:sigap/src/utils/exceptions/format_exceptions.dart';
import 'package:sigap/src/utils/exceptions/platform_exceptions.dart';

View File

@ -1,6 +1,6 @@
import 'package:get/get.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/daily-ops/models/patrol_units_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/patrol_units_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -1,6 +1,6 @@
import 'package:get/get.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/daily-ops/models/unit_statistics_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/unit_statistics_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -1,8 +1,8 @@
import 'package:get/get.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/daily-ops/models/units_model.dart';
import 'package:sigap/src/features/daily-ops/models/patrol_units_model.dart';
import 'package:sigap/src/features/daily-ops/models/unit_statistics_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/units_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/patrol_units_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/unit_statistics_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/cities_model.dart';
import 'package:sigap/src/features/map/models/models/cities_model.dart';
class CitiesRepository extends GetxController {
static CitiesRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/Logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/demographics_model.dart';
import 'package:sigap/src/features/map/models/models/demographics_model.dart';
class DemographicsRepository extends GetxController {
static DemographicsRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/districts_model.dart';
import 'package:sigap/src/features/map/models/models/districts_model.dart';
class DistrictsRepository extends GetxController {
static DistrictsRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/geographics_model.dart';
import 'package:sigap/src/features/map/models/models/geographics_model.dart';
class GeographicsRepository extends GetxController {
static GeographicsRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/location_logs_model.dart';
import 'package:sigap/src/features/map/models/models/location_logs_model.dart';
class LocationLogsRepository extends GetxController {
static LocationLogsRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/map/models/locations_model.dart';
import 'package:sigap/src/features/map/models/models/locations_model.dart';
class LocationsRepository extends GetxController {
static LocationsRepository get instance => Get.find();

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/Logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/personalization/models/permissions_model.dart';
import 'package:sigap/src/features/personalization/models/models/permissions_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:logger/Logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/personalization/models/profile_model.dart';
import 'package:sigap/src/features/personalization/models/models/profile_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:sigap/src/utils/exceptions/format_exceptions.dart';
import 'package:sigap/src/utils/exceptions/platform_exceptions.dart';

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/personalization/models/resources_model.dart';
import 'package:sigap/src/features/personalization/models/models/resources_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -1,8 +1,8 @@
import 'package:get/get.dart';
import 'package:logger/Logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/personalization/models/permissions_model.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/permissions_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

View File

@ -2,8 +2,8 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:logger/Logger.dart';
import 'package:sigap/src/cores/services/supabase_service.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/users_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/users_model.dart';
import 'package:sigap/src/utils/exceptions/exceptions.dart';
import 'package:sigap/src/utils/exceptions/format_exceptions.dart';
import 'package:sigap/src/utils/exceptions/platform_exceptions.dart';

View File

@ -1,5 +1,5 @@
import 'package:sigap/src/features/daily-ops/models/officers_model.dart';
import 'package:sigap/src/features/personalization/models/profile_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/officers_model.dart';
import 'package:sigap/src/features/personalization/models/models/profile_model.dart';
class UserMetadataModel {
final bool isOfficer;

View File

@ -1,4 +1,8 @@
export 'officers_model.dart';
export 'patrol_units_model.dart';
export 'unit_statistics_model.dart';
export 'units_model.dart';
export 'models/officers_model.dart';
export 'models/patrol_units_model.dart';
export 'models/unit_statistics_model.dart';
export 'models/units_model.dart';
export 'supadart-models/officers_model_supadart.dart';
export 'supadart-models/patrol_units_model_supadart.dart';
export 'supadart-models/unit_statistics_model_supadart.dart';
export 'supadart-models/units_model_supadart.dart';

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
class OfficerModel {
final String id;

View File

@ -1,6 +1,6 @@
import 'package:sigap/src/features/daily-ops/models/units_model.dart';
import 'package:sigap/src/features/map/models/locations_model.dart';
import 'package:sigap/src/features/daily-ops/models/officers_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/units_model.dart';
import 'package:sigap/src/features/map/models/models/locations_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/officers_model.dart';
class PatrolUnitModel {
final String id;

View File

@ -1,6 +1,6 @@
import 'package:sigap/src/features/daily-ops/models/patrol_units_model.dart';
import 'package:sigap/src/features/daily-ops/models/unit_statistics_model.dart';
import 'package:sigap/src/features/daily-ops/models/officers_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/patrol_units_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/unit_statistics_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/officers_model.dart';
enum UnitType { polda, polsek, polres, other }

View File

@ -0,0 +1,378 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Officers implements SupadartClass<Officers> {
final String unitId;
final String roleId;
final String nrp;
final String name;
final String? rank;
final String? position;
final String? phone;
final String? email;
final String? avatar;
final DateTime? validUntil;
final String? qrCode;
final DateTime? createdAt;
final DateTime? updatedAt;
final String patrolUnitId;
final String id;
final String? bannedReason;
final DateTime? bannedUntil;
final bool isBanned;
final int panicStrike;
final int spoofingAttempts;
final PatrolUnits? patrolUnit;
final Roles? roleObj;
final Units? unit;
const Officers({
required this.unitId,
required this.roleId,
required this.nrp,
required this.name,
this.rank,
this.position,
this.phone,
this.email,
this.avatar,
this.validUntil,
this.qrCode,
this.createdAt,
this.updatedAt,
required this.patrolUnitId,
required this.id,
this.bannedReason,
this.bannedUntil,
required this.isBanned,
required this.panicStrike,
required this.spoofingAttempts,
this.patrolUnit,
this.roleObj,
this.unit,
});
static String get table_name => 'officers';
static String get c_unitId => 'unit_id';
static String get c_roleId => 'role_id';
static String get c_nrp => 'nrp';
static String get c_name => 'name';
static String get c_rank => 'rank';
static String get c_position => 'position';
static String get c_phone => 'phone';
static String get c_email => 'email';
static String get c_avatar => 'avatar';
static String get c_validUntil => 'valid_until';
static String get c_qrCode => 'qr_code';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_patrolUnitId => 'patrol_unit_id';
static String get c_id => 'id';
static String get c_bannedReason => 'banned_reason';
static String get c_bannedUntil => 'banned_until';
static String get c_isBanned => 'is_banned';
static String get c_panicStrike => 'panic_strike';
static String get c_spoofingAttempts => 'spoofing_attempts';
static List<Officers> converter(List<Map<String, dynamic>> data) {
return data.map(Officers.fromJson).toList();
}
static Officers converterSingle(Map<String, dynamic> data) {
return Officers.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? unitId,
String? roleId,
String? nrp,
String? name,
String? rank,
String? position,
String? phone,
String? email,
String? avatar,
DateTime? validUntil,
String? qrCode,
DateTime? createdAt,
DateTime? updatedAt,
String? patrolUnitId,
String? id,
String? bannedReason,
DateTime? bannedUntil,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return {
if (unitId != null) 'unit_id': unitId,
if (roleId != null) 'role_id': roleId,
if (nrp != null) 'nrp': nrp,
if (name != null) 'name': name,
if (rank != null) 'rank': rank,
if (position != null) 'position': position,
if (phone != null) 'phone': phone,
if (email != null) 'email': email,
if (avatar != null) 'avatar': avatar,
if (validUntil != null) 'valid_until': validUntil.toIso8601String(),
if (qrCode != null) 'qr_code': qrCode,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (patrolUnitId != null) 'patrol_unit_id': patrolUnitId,
if (id != null) 'id': id,
if (bannedReason != null) 'banned_reason': bannedReason,
if (bannedUntil != null) 'banned_until': bannedUntil.toIso8601String(),
if (isBanned != null) 'is_banned': isBanned,
if (panicStrike != null) 'panic_strike': panicStrike,
if (spoofingAttempts != null) 'spoofing_attempts': spoofingAttempts,
};
}
static Map<String, dynamic> insert({
required String unitId,
required String roleId,
required String nrp,
required String name,
String? rank,
String? position,
String? phone,
String? email,
String? avatar,
DateTime? validUntil,
String? qrCode,
DateTime? createdAt,
DateTime? updatedAt,
required String patrolUnitId,
String? id,
String? bannedReason,
DateTime? bannedUntil,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return _generateMap(
unitId: unitId,
roleId: roleId,
nrp: nrp,
name: name,
rank: rank,
position: position,
phone: phone,
email: email,
avatar: avatar,
validUntil: validUntil,
qrCode: qrCode,
createdAt: createdAt,
updatedAt: updatedAt,
patrolUnitId: patrolUnitId,
id: id,
bannedReason: bannedReason,
bannedUntil: bannedUntil,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
);
}
static Map<String, dynamic> update({
String? unitId,
String? roleId,
String? nrp,
String? name,
String? rank,
String? position,
String? phone,
String? email,
String? avatar,
DateTime? validUntil,
String? qrCode,
DateTime? createdAt,
DateTime? updatedAt,
String? patrolUnitId,
String? id,
String? bannedReason,
DateTime? bannedUntil,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return _generateMap(
unitId: unitId,
roleId: roleId,
nrp: nrp,
name: name,
rank: rank,
position: position,
phone: phone,
email: email,
avatar: avatar,
validUntil: validUntil,
qrCode: qrCode,
createdAt: createdAt,
updatedAt: updatedAt,
patrolUnitId: patrolUnitId,
id: id,
bannedReason: bannedReason,
bannedUntil: bannedUntil,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
);
}
factory Officers.fromJson(Map<String, dynamic> jsonn) {
return Officers(
unitId: jsonn['unit_id'] != null ? jsonn['unit_id'].toString() : '',
roleId: jsonn['role_id'] != null ? jsonn['role_id'].toString() : '',
nrp: jsonn['nrp'] != null ? jsonn['nrp'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
rank: jsonn['rank'] != null ? jsonn['rank'].toString() : null,
position: jsonn['position'] != null ? jsonn['position'].toString() : null,
phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
email: jsonn['email'] != null ? jsonn['email'].toString() : null,
avatar: jsonn['avatar'] != null ? jsonn['avatar'].toString() : null,
validUntil:
jsonn['valid_until'] != null
? DateTime.parse(jsonn['valid_until'].toString())
: null,
qrCode: jsonn['qr_code'] != null ? jsonn['qr_code'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
patrolUnitId:
jsonn['patrol_unit_id'] != null
? jsonn['patrol_unit_id'].toString()
: '',
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
bannedReason:
jsonn['banned_reason'] != null
? jsonn['banned_reason'].toString()
: null,
bannedUntil:
jsonn['banned_until'] != null
? DateTime.parse(jsonn['banned_until'].toString())
: null,
isBanned: jsonn['is_banned'] != null ? jsonn['is_banned'] as bool : false,
panicStrike:
jsonn['panic_strike'] != null
? int.parse(jsonn['panic_strike'].toString())
: 0,
spoofingAttempts:
jsonn['spoofing_attempts'] != null
? int.parse(jsonn['spoofing_attempts'].toString())
: 0,
patrolUnit:
jsonn['patrol_units'] != null
? PatrolUnits.fromJson(
jsonn['patrol_units'] as Map<String, dynamic>,
)
: null,
roleObj:
jsonn['roles'] != null
? Roles.fromJson(jsonn['roles'] as Map<String, dynamic>)
: null,
unit:
jsonn['units'] != null
? Units.fromJson(jsonn['units'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
unitId: unitId,
roleId: roleId,
nrp: nrp,
name: name,
rank: rank,
position: position,
phone: phone,
email: email,
avatar: avatar,
validUntil: validUntil,
qrCode: qrCode,
createdAt: createdAt,
updatedAt: updatedAt,
patrolUnitId: patrolUnitId,
id: id,
bannedReason: bannedReason,
bannedUntil: bannedUntil,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
// 'patrol_units': patrolUnit?.toJson(),
// 'roles': roleObj?.toJson(),
// 'units': unit?.toJson(),
);
}
static const _unset = Object();
Officers copyWith({
Object? unitId = _unset,
Object? roleId = _unset,
Object? nrp = _unset,
Object? name = _unset,
Object? rank = _unset,
Object? position = _unset,
Object? phone = _unset,
Object? email = _unset,
Object? avatar = _unset,
Object? validUntil = _unset,
Object? qrCode = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? patrolUnitId = _unset,
Object? id = _unset,
Object? bannedReason = _unset,
Object? bannedUntil = _unset,
Object? isBanned = _unset,
Object? panicStrike = _unset,
Object? spoofingAttempts = _unset,
Object? patrolUnit = _unset,
Object? roleObj = _unset,
Object? unit = _unset,
}) {
return Officers(
unitId: unitId == _unset ? this.unitId : unitId as String,
roleId: roleId == _unset ? this.roleId : roleId as String,
nrp: nrp == _unset ? this.nrp : nrp as String,
name: name == _unset ? this.name : name as String,
rank: rank == _unset ? this.rank : rank as String?,
position: position == _unset ? this.position : position as String?,
phone: phone == _unset ? this.phone : phone as String?,
email: email == _unset ? this.email : email as String?,
avatar: avatar == _unset ? this.avatar : avatar as String?,
validUntil:
validUntil == _unset ? this.validUntil : validUntil as DateTime?,
qrCode: qrCode == _unset ? this.qrCode : qrCode as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
patrolUnitId:
patrolUnitId == _unset ? this.patrolUnitId : patrolUnitId as String,
id: id == _unset ? this.id : id as String,
bannedReason:
bannedReason == _unset ? this.bannedReason : bannedReason as String?,
bannedUntil:
bannedUntil == _unset ? this.bannedUntil : bannedUntil as DateTime?,
isBanned: isBanned == _unset ? this.isBanned : isBanned as bool,
panicStrike:
panicStrike == _unset ? this.panicStrike : panicStrike as int,
spoofingAttempts:
spoofingAttempts == _unset
? this.spoofingAttempts
: spoofingAttempts as int,
patrolUnit:
patrolUnit == _unset ? this.patrolUnit : patrolUnit as PatrolUnits?,
roleObj: roleObj == _unset ? this.roleObj : roleObj as Roles?,
unit: unit == _unset ? this.unit : unit as Units?,
);
}
}

View File

@ -0,0 +1,186 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class PatrolUnits implements SupadartClass<PatrolUnits> {
final String unitId;
final String locationId;
final String name;
final String type;
final String status;
final double radius;
final DateTime createdAt;
final String id;
final Locations? locationObj;
final Units? unitObj;
const PatrolUnits({
required this.unitId,
required this.locationId,
required this.name,
required this.type,
required this.status,
required this.radius,
required this.createdAt,
required this.id,
this.locationObj,
this.unitObj,
});
static String get table_name => 'patrol_units';
static String get c_unitId => 'unit_id';
static String get c_locationId => 'location_id';
static String get c_name => 'name';
static String get c_type => 'type';
static String get c_status => 'status';
static String get c_radius => 'radius';
static String get c_createdAt => 'created_at';
static String get c_id => 'id';
static List<PatrolUnits> converter(List<Map<String, dynamic>> data) {
return data.map(PatrolUnits.fromJson).toList();
}
static PatrolUnits converterSingle(Map<String, dynamic> data) {
return PatrolUnits.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? unitId,
String? locationId,
String? name,
String? type,
String? status,
double? radius,
DateTime? createdAt,
String? id,
}) {
return {
if (unitId != null) 'unit_id': unitId,
if (locationId != null) 'location_id': locationId,
if (name != null) 'name': name,
if (type != null) 'type': type,
if (status != null) 'status': status,
if (radius != null) 'radius': radius.toString(),
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (id != null) 'id': id,
};
}
static Map<String, dynamic> insert({
required String unitId,
required String locationId,
required String name,
required String type,
required String status,
required double radius,
DateTime? createdAt,
String? id,
}) {
return _generateMap(
unitId: unitId,
locationId: locationId,
name: name,
type: type,
status: status,
radius: radius,
createdAt: createdAt,
id: id,
);
}
static Map<String, dynamic> update({
String? unitId,
String? locationId,
String? name,
String? type,
String? status,
double? radius,
DateTime? createdAt,
String? id,
}) {
return _generateMap(
unitId: unitId,
locationId: locationId,
name: name,
type: type,
status: status,
radius: radius,
createdAt: createdAt,
id: id,
);
}
factory PatrolUnits.fromJson(Map<String, dynamic> jsonn) {
return PatrolUnits(
unitId: jsonn['unit_id'] != null ? jsonn['unit_id'].toString() : '',
locationId:
jsonn['location_id'] != null ? jsonn['location_id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
type: jsonn['type'] != null ? jsonn['type'].toString() : '',
status: jsonn['status'] != null ? jsonn['status'].toString() : '',
radius:
jsonn['radius'] != null
? double.parse(jsonn['radius'].toString())
: 0.0,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
locationObj:
jsonn['locations'] != null
? Locations.fromJson(jsonn['locations'] as Map<String, dynamic>)
: null,
unitObj:
jsonn['units'] != null
? Units.fromJson(jsonn['units'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
unitId: unitId,
locationId: locationId,
name: name,
type: type,
status: status,
radius: radius,
createdAt: createdAt,
id: id,
// 'locations': locationObj?.toJson(),
// 'units': unitObj?.toJson(),
);
}
static const _unset = Object();
PatrolUnits copyWith({
Object? unitId = _unset,
Object? locationId = _unset,
Object? name = _unset,
Object? type = _unset,
Object? status = _unset,
Object? radius = _unset,
Object? createdAt = _unset,
Object? id = _unset,
Object? locationObj = _unset,
Object? unitObj = _unset,
}) {
return PatrolUnits(
unitId: unitId == _unset ? this.unitId : unitId as String,
locationId: locationId == _unset ? this.locationId : locationId as String,
name: name == _unset ? this.name : name as String,
type: type == _unset ? this.type : type as String,
status: status == _unset ? this.status : status as String,
radius: radius == _unset ? this.radius : radius as double,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
id: id == _unset ? this.id : id as String,
locationObj:
locationObj == _unset ? this.locationObj : locationObj as Locations?,
unitObj: unitObj == _unset ? this.unitObj : unitObj as Units?,
);
}
}

View File

@ -0,0 +1,215 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class UnitStatistics implements SupadartClass<UnitStatistics> {
final String id;
final int crimeTotal;
final int crimeCleared;
final double? percentage;
final int? pending;
final int month;
final int year;
final DateTime? createdAt;
final DateTime? updatedAt;
final String codeUnit;
final Units? unit;
const UnitStatistics({
required this.id,
required this.crimeTotal,
required this.crimeCleared,
this.percentage,
this.pending,
required this.month,
required this.year,
this.createdAt,
this.updatedAt,
required this.codeUnit,
this.unit,
});
static String get table_name => 'unit_statistics';
static String get c_id => 'id';
static String get c_crimeTotal => 'crime_total';
static String get c_crimeCleared => 'crime_cleared';
static String get c_percentage => 'percentage';
static String get c_pending => 'pending';
static String get c_month => 'month';
static String get c_year => 'year';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_codeUnit => 'code_unit';
static List<UnitStatistics> converter(List<Map<String, dynamic>> data) {
return data.map(UnitStatistics.fromJson).toList();
}
static UnitStatistics converterSingle(Map<String, dynamic> data) {
return UnitStatistics.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
int? crimeTotal,
int? crimeCleared,
double? percentage,
int? pending,
int? month,
int? year,
DateTime? createdAt,
DateTime? updatedAt,
String? codeUnit,
}) {
return {
if (id != null) 'id': id,
if (crimeTotal != null) 'crime_total': crimeTotal,
if (crimeCleared != null) 'crime_cleared': crimeCleared,
if (percentage != null) 'percentage': percentage.toString(),
if (pending != null) 'pending': pending,
if (month != null) 'month': month,
if (year != null) 'year': year,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (codeUnit != null) 'code_unit': codeUnit,
};
}
static Map<String, dynamic> insert({
String? id,
required int crimeTotal,
required int crimeCleared,
double? percentage,
int? pending,
required int month,
required int year,
DateTime? createdAt,
DateTime? updatedAt,
required String codeUnit,
}) {
return _generateMap(
id: id,
crimeTotal: crimeTotal,
crimeCleared: crimeCleared,
percentage: percentage,
pending: pending,
month: month,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
codeUnit: codeUnit,
);
}
static Map<String, dynamic> update({
String? id,
int? crimeTotal,
int? crimeCleared,
double? percentage,
int? pending,
int? month,
int? year,
DateTime? createdAt,
DateTime? updatedAt,
String? codeUnit,
}) {
return _generateMap(
id: id,
crimeTotal: crimeTotal,
crimeCleared: crimeCleared,
percentage: percentage,
pending: pending,
month: month,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
codeUnit: codeUnit,
);
}
factory UnitStatistics.fromJson(Map<String, dynamic> jsonn) {
return UnitStatistics(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
crimeTotal:
jsonn['crime_total'] != null
? int.parse(jsonn['crime_total'].toString())
: 0,
crimeCleared:
jsonn['crime_cleared'] != null
? int.parse(jsonn['crime_cleared'].toString())
: 0,
percentage:
jsonn['percentage'] != null
? double.parse(jsonn['percentage'].toString())
: null,
pending:
jsonn['pending'] != null
? int.parse(jsonn['pending'].toString())
: null,
month: jsonn['month'] != null ? int.parse(jsonn['month'].toString()) : 0,
year: jsonn['year'] != null ? int.parse(jsonn['year'].toString()) : 0,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
codeUnit: jsonn['code_unit'] != null ? jsonn['code_unit'].toString() : '',
unit:
jsonn['units'] != null
? Units.fromJson(jsonn['units'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
crimeTotal: crimeTotal,
crimeCleared: crimeCleared,
percentage: percentage,
pending: pending,
month: month,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
codeUnit: codeUnit,
// 'units': unit?.toJson(),
);
}
static const _unset = Object();
UnitStatistics copyWith({
Object? id = _unset,
Object? crimeTotal = _unset,
Object? crimeCleared = _unset,
Object? percentage = _unset,
Object? pending = _unset,
Object? month = _unset,
Object? year = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? codeUnit = _unset,
Object? unit = _unset,
}) {
return UnitStatistics(
id: id == _unset ? this.id : id as String,
crimeTotal: crimeTotal == _unset ? this.crimeTotal : crimeTotal as int,
crimeCleared:
crimeCleared == _unset ? this.crimeCleared : crimeCleared as int,
percentage:
percentage == _unset ? this.percentage : percentage as double?,
pending: pending == _unset ? this.pending : pending as int?,
month: month == _unset ? this.month : month as int,
year: year == _unset ? this.year : year as int,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
codeUnit: codeUnit == _unset ? this.codeUnit : codeUnit as String,
unit: unit == _unset ? this.unit : unit as Units?,
);
}
}

View File

@ -0,0 +1,280 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
enum UNIT_TYPE { other, polda, polres, polsek }
class Units implements SupadartClass<Units> {
final String codeUnit;
final String? districtId;
final String name;
final String? description;
final UNIT_TYPE type;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? address;
final double? landArea;
final double latitude;
final double longitude;
final String location;
final String cityId;
final String? phone;
final Cities? city;
final Districts? district;
const Units({
required this.codeUnit,
this.districtId,
required this.name,
this.description,
required this.type,
this.createdAt,
this.updatedAt,
this.address,
this.landArea,
required this.latitude,
required this.longitude,
required this.location,
required this.cityId,
this.phone,
this.city,
this.district,
});
static String get table_name => 'units';
static String get c_codeUnit => 'code_unit';
static String get c_districtId => 'district_id';
static String get c_name => 'name';
static String get c_description => 'description';
static String get c_type => 'type';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_address => 'address';
static String get c_landArea => 'land_area';
static String get c_latitude => 'latitude';
static String get c_longitude => 'longitude';
static String get c_location => 'location';
static String get c_cityId => 'city_id';
static String get c_phone => 'phone';
static List<Units> converter(List<Map<String, dynamic>> data) {
return data.map(Units.fromJson).toList();
}
static Units converterSingle(Map<String, dynamic> data) {
return Units.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? codeUnit,
String? districtId,
String? name,
String? description,
UNIT_TYPE? type,
DateTime? createdAt,
DateTime? updatedAt,
String? address,
double? landArea,
double? latitude,
double? longitude,
String? location,
String? cityId,
String? phone,
}) {
return {
if (codeUnit != null) 'code_unit': codeUnit,
if (districtId != null) 'district_id': districtId,
if (name != null) 'name': name,
if (description != null) 'description': description,
if (type != null) 'type': type.toString().split('.').last,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (address != null) 'address': address,
if (landArea != null) 'land_area': landArea.toString(),
if (latitude != null) 'latitude': latitude.toString(),
if (longitude != null) 'longitude': longitude.toString(),
if (location != null) 'location': location,
if (cityId != null) 'city_id': cityId,
if (phone != null) 'phone': phone,
};
}
static Map<String, dynamic> insert({
String? codeUnit,
String? districtId,
required String name,
String? description,
required UNIT_TYPE type,
DateTime? createdAt,
DateTime? updatedAt,
String? address,
double? landArea,
required double latitude,
required double longitude,
required String location,
required String cityId,
String? phone,
}) {
return _generateMap(
codeUnit: codeUnit,
districtId: districtId,
name: name,
description: description,
type: type,
createdAt: createdAt,
updatedAt: updatedAt,
address: address,
landArea: landArea,
latitude: latitude,
longitude: longitude,
location: location,
cityId: cityId,
phone: phone,
);
}
static Map<String, dynamic> update({
String? codeUnit,
String? districtId,
String? name,
String? description,
UNIT_TYPE? type,
DateTime? createdAt,
DateTime? updatedAt,
String? address,
double? landArea,
double? latitude,
double? longitude,
String? location,
String? cityId,
String? phone,
}) {
return _generateMap(
codeUnit: codeUnit,
districtId: districtId,
name: name,
description: description,
type: type,
createdAt: createdAt,
updatedAt: updatedAt,
address: address,
landArea: landArea,
latitude: latitude,
longitude: longitude,
location: location,
cityId: cityId,
phone: phone,
);
}
factory Units.fromJson(Map<String, dynamic> jsonn) {
return Units(
codeUnit: jsonn['code_unit'] != null ? jsonn['code_unit'].toString() : '',
districtId:
jsonn['district_id'] != null ? jsonn['district_id'].toString() : null,
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
type:
jsonn['type'] != null
? UNIT_TYPE.values.byName(jsonn['type'].toString())
: UNIT_TYPE.values.first,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
address: jsonn['address'] != null ? jsonn['address'].toString() : null,
landArea:
jsonn['land_area'] != null
? double.parse(jsonn['land_area'].toString())
: null,
latitude:
jsonn['latitude'] != null
? double.parse(jsonn['latitude'].toString())
: 0.0,
longitude:
jsonn['longitude'] != null
? double.parse(jsonn['longitude'].toString())
: 0.0,
location: jsonn['location'] != null ? jsonn['location'].toString() : '',
cityId: jsonn['city_id'] != null ? jsonn['city_id'].toString() : '',
phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
city:
jsonn['cities'] != null
? Cities.fromJson(jsonn['cities'] as Map<String, dynamic>)
: null,
district:
jsonn['districts'] != null
? Districts.fromJson(jsonn['districts'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
codeUnit: codeUnit,
districtId: districtId,
name: name,
description: description,
type: type,
createdAt: createdAt,
updatedAt: updatedAt,
address: address,
landArea: landArea,
latitude: latitude,
longitude: longitude,
location: location,
cityId: cityId,
phone: phone,
// 'cities': city?.toJson(),
// 'districts': district?.toJson(),
);
}
static const _unset = Object();
Units copyWith({
Object? codeUnit = _unset,
Object? districtId = _unset,
Object? name = _unset,
Object? description = _unset,
Object? type = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? address = _unset,
Object? landArea = _unset,
Object? latitude = _unset,
Object? longitude = _unset,
Object? location = _unset,
Object? cityId = _unset,
Object? phone = _unset,
Object? city = _unset,
Object? district = _unset,
}) {
return Units(
codeUnit: codeUnit == _unset ? this.codeUnit : codeUnit as String,
districtId:
districtId == _unset ? this.districtId : districtId as String?,
name: name == _unset ? this.name : name as String,
description:
description == _unset ? this.description : description as String?,
type: type == _unset ? this.type : type as UNIT_TYPE,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
address: address == _unset ? this.address : address as String?,
landArea: landArea == _unset ? this.landArea : landArea as double?,
latitude: latitude == _unset ? this.latitude : latitude as double,
longitude: longitude == _unset ? this.longitude : longitude as double,
location: location == _unset ? this.location : location as String,
cityId: cityId == _unset ? this.cityId : cityId as String,
phone: phone == _unset ? this.phone : phone as String?,
city: city == _unset ? this.city : city as Cities?,
district: district == _unset ? this.district : district as Districts?,
);
}
}

View File

@ -0,0 +1,209 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
enum STATUS_CONTACT_MESSAGES { PENDING, IN_PROGRESS, RESOLVED, CLOSED }
class ContactMessages implements SupadartClass<ContactMessages> {
final String id;
final String? name;
final String? email;
final String? phone;
final String? messageType;
final String? messageTypeLabel;
final String? message;
final STATUS_CONTACT_MESSAGES status;
final DateTime createdAt;
final DateTime updatedAt;
const ContactMessages({
required this.id,
this.name,
this.email,
this.phone,
this.messageType,
this.messageTypeLabel,
this.message,
required this.status,
required this.createdAt,
required this.updatedAt,
});
static String get table_name => 'contact_messages';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_email => 'email';
static String get c_phone => 'phone';
static String get c_messageType => 'message_type';
static String get c_messageTypeLabel => 'message_type_label';
static String get c_message => 'message';
static String get c_status => 'status';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<ContactMessages> converter(List<Map<String, dynamic>> data) {
return data.map(ContactMessages.fromJson).toList();
}
static ContactMessages converterSingle(Map<String, dynamic> data) {
return ContactMessages.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
String? email,
String? phone,
String? messageType,
String? messageTypeLabel,
String? message,
STATUS_CONTACT_MESSAGES? status,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (email != null) 'email': email,
if (phone != null) 'phone': phone,
if (messageType != null) 'message_type': messageType,
if (messageTypeLabel != null) 'message_type_label': messageTypeLabel,
if (message != null) 'message': message,
if (status != null) 'status': status.toString().split('.').last,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
String? name,
String? email,
String? phone,
String? messageType,
String? messageTypeLabel,
String? message,
STATUS_CONTACT_MESSAGES? status,
DateTime? createdAt,
required DateTime updatedAt,
}) {
return _generateMap(
id: id,
name: name,
email: email,
phone: phone,
messageType: messageType,
messageTypeLabel: messageTypeLabel,
message: message,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
String? email,
String? phone,
String? messageType,
String? messageTypeLabel,
String? message,
STATUS_CONTACT_MESSAGES? status,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
email: email,
phone: phone,
messageType: messageType,
messageTypeLabel: messageTypeLabel,
message: message,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory ContactMessages.fromJson(Map<String, dynamic> jsonn) {
return ContactMessages(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : null,
email: jsonn['email'] != null ? jsonn['email'].toString() : null,
phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
messageType:
jsonn['message_type'] != null
? jsonn['message_type'].toString()
: null,
messageTypeLabel:
jsonn['message_type_label'] != null
? jsonn['message_type_label'].toString()
: null,
message: jsonn['message'] != null ? jsonn['message'].toString() : null,
status:
jsonn['status'] != null
? STATUS_CONTACT_MESSAGES.values.byName(
jsonn['status'].toString(),
)
: STATUS_CONTACT_MESSAGES.values.first,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
email: email,
phone: phone,
messageType: messageType,
messageTypeLabel: messageTypeLabel,
message: message,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static const _unset = Object();
ContactMessages copyWith({
Object? id = _unset,
Object? name = _unset,
Object? email = _unset,
Object? phone = _unset,
Object? messageType = _unset,
Object? messageTypeLabel = _unset,
Object? message = _unset,
Object? status = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
}) {
return ContactMessages(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String?,
email: email == _unset ? this.email : email as String?,
phone: phone == _unset ? this.phone : phone as String?,
messageType:
messageType == _unset ? this.messageType : messageType as String?,
messageTypeLabel:
messageTypeLabel == _unset
? this.messageTypeLabel
: messageTypeLabel as String?,
message: message == _unset ? this.message : message as String?,
status:
status == _unset ? this.status : status as STATUS_CONTACT_MESSAGES,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
);
}
}

View File

@ -0,0 +1,183 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class Logs implements SupadartClass<Logs> {
final String id;
final String action;
final String entity;
final String? entityId;
final Map<String, dynamic>? changes;
final String? userId;
final String? ipAddress;
final String? userAgent;
final DateTime createdAt;
const Logs({
required this.id,
required this.action,
required this.entity,
this.entityId,
this.changes,
this.userId,
this.ipAddress,
this.userAgent,
required this.createdAt,
});
static String get table_name => 'logs';
static String get c_id => 'id';
static String get c_action => 'action';
static String get c_entity => 'entity';
static String get c_entityId => 'entity_id';
static String get c_changes => 'changes';
static String get c_userId => 'user_id';
static String get c_ipAddress => 'ip_address';
static String get c_userAgent => 'user_agent';
static String get c_createdAt => 'created_at';
static List<Logs> converter(List<Map<String, dynamic>> data) {
return data.map(Logs.fromJson).toList();
}
static Logs converterSingle(Map<String, dynamic> data) {
return Logs.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? action,
String? entity,
String? entityId,
Map<String, dynamic>? changes,
String? userId,
String? ipAddress,
String? userAgent,
DateTime? createdAt,
}) {
return {
if (id != null) 'id': id,
if (action != null) 'action': action,
if (entity != null) 'entity': entity,
if (entityId != null) 'entity_id': entityId,
if (changes != null) 'changes': changes,
if (userId != null) 'user_id': userId,
if (ipAddress != null) 'ip_address': ipAddress,
if (userAgent != null) 'user_agent': userAgent,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String action,
required String entity,
String? entityId,
Map<String, dynamic>? changes,
String? userId,
String? ipAddress,
String? userAgent,
DateTime? createdAt,
}) {
return _generateMap(
id: id,
action: action,
entity: entity,
entityId: entityId,
changes: changes,
userId: userId,
ipAddress: ipAddress,
userAgent: userAgent,
createdAt: createdAt,
);
}
static Map<String, dynamic> update({
String? id,
String? action,
String? entity,
String? entityId,
Map<String, dynamic>? changes,
String? userId,
String? ipAddress,
String? userAgent,
DateTime? createdAt,
}) {
return _generateMap(
id: id,
action: action,
entity: entity,
entityId: entityId,
changes: changes,
userId: userId,
ipAddress: ipAddress,
userAgent: userAgent,
createdAt: createdAt,
);
}
factory Logs.fromJson(Map<String, dynamic> jsonn) {
return Logs(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
action: jsonn['action'] != null ? jsonn['action'].toString() : '',
entity: jsonn['entity'] != null ? jsonn['entity'].toString() : '',
entityId:
jsonn['entity_id'] != null ? jsonn['entity_id'].toString() : null,
changes:
jsonn['changes'] != null
? jsonn['changes'] as Map<String, dynamic>
: null,
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : null,
ipAddress:
jsonn['ip_address'] != null ? jsonn['ip_address'].toString() : null,
userAgent:
jsonn['user_agent'] != null ? jsonn['user_agent'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
action: action,
entity: entity,
entityId: entityId,
changes: changes,
userId: userId,
ipAddress: ipAddress,
userAgent: userAgent,
createdAt: createdAt,
);
}
static const _unset = Object();
Logs copyWith({
Object? id = _unset,
Object? action = _unset,
Object? entity = _unset,
Object? entityId = _unset,
Object? changes = _unset,
Object? userId = _unset,
Object? ipAddress = _unset,
Object? userAgent = _unset,
Object? createdAt = _unset,
}) {
return Logs(
id: id == _unset ? this.id : id as String,
action: action == _unset ? this.action : action as String,
entity: entity == _unset ? this.entity : entity as String,
entityId: entityId == _unset ? this.entityId : entityId as String?,
changes:
changes == _unset ? this.changes : changes as Map<String, dynamic>?,
userId: userId == _unset ? this.userId : userId as String?,
ipAddress: ipAddress == _unset ? this.ipAddress : ipAddress as String?,
userAgent: userAgent == _unset ? this.userAgent : userAgent as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
);
}
}

View File

@ -0,0 +1,186 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class PrismaMigrations implements SupadartClass<PrismaMigrations> {
final String id;
final String checksum;
final DateTime? finishedAt;
final String migrationName;
final String? logs;
final DateTime? rolledBackAt;
final DateTime startedAt;
final int appliedStepsCount;
const PrismaMigrations({
required this.id,
required this.checksum,
this.finishedAt,
required this.migrationName,
this.logs,
this.rolledBackAt,
required this.startedAt,
required this.appliedStepsCount,
});
static String get table_name => '_prisma_migrations';
static String get c_id => 'id';
static String get c_checksum => 'checksum';
static String get c_finishedAt => 'finished_at';
static String get c_migrationName => 'migration_name';
static String get c_logs => 'logs';
static String get c_rolledBackAt => 'rolled_back_at';
static String get c_startedAt => 'started_at';
static String get c_appliedStepsCount => 'applied_steps_count';
static List<PrismaMigrations> converter(List<Map<String, dynamic>> data) {
return data.map(PrismaMigrations.fromJson).toList();
}
static PrismaMigrations converterSingle(Map<String, dynamic> data) {
return PrismaMigrations.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? checksum,
DateTime? finishedAt,
String? migrationName,
String? logs,
DateTime? rolledBackAt,
DateTime? startedAt,
int? appliedStepsCount,
}) {
return {
if (id != null) 'id': id,
if (checksum != null) 'checksum': checksum,
if (finishedAt != null)
'finished_at': finishedAt.toUtc().toIso8601String(),
if (migrationName != null) 'migration_name': migrationName,
if (logs != null) 'logs': logs,
if (rolledBackAt != null)
'rolled_back_at': rolledBackAt.toUtc().toIso8601String(),
if (startedAt != null) 'started_at': startedAt.toUtc().toIso8601String(),
if (appliedStepsCount != null) 'applied_steps_count': appliedStepsCount,
};
}
static Map<String, dynamic> insert({
String? id,
required String checksum,
DateTime? finishedAt,
required String migrationName,
String? logs,
DateTime? rolledBackAt,
DateTime? startedAt,
int? appliedStepsCount,
}) {
return _generateMap(
id: id,
checksum: checksum,
finishedAt: finishedAt,
migrationName: migrationName,
logs: logs,
rolledBackAt: rolledBackAt,
startedAt: startedAt,
appliedStepsCount: appliedStepsCount,
);
}
static Map<String, dynamic> update({
String? id,
String? checksum,
DateTime? finishedAt,
String? migrationName,
String? logs,
DateTime? rolledBackAt,
DateTime? startedAt,
int? appliedStepsCount,
}) {
return _generateMap(
id: id,
checksum: checksum,
finishedAt: finishedAt,
migrationName: migrationName,
logs: logs,
rolledBackAt: rolledBackAt,
startedAt: startedAt,
appliedStepsCount: appliedStepsCount,
);
}
factory PrismaMigrations.fromJson(Map<String, dynamic> jsonn) {
return PrismaMigrations(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
checksum: jsonn['checksum'] != null ? jsonn['checksum'].toString() : '',
finishedAt:
jsonn['finished_at'] != null
? DateTime.parse(jsonn['finished_at'].toString())
: null,
migrationName:
jsonn['migration_name'] != null
? jsonn['migration_name'].toString()
: '',
logs: jsonn['logs'] != null ? jsonn['logs'].toString() : null,
rolledBackAt:
jsonn['rolled_back_at'] != null
? DateTime.parse(jsonn['rolled_back_at'].toString())
: null,
startedAt:
jsonn['started_at'] != null
? DateTime.parse(jsonn['started_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
appliedStepsCount:
jsonn['applied_steps_count'] != null
? int.parse(jsonn['applied_steps_count'].toString())
: 0,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
checksum: checksum,
finishedAt: finishedAt,
migrationName: migrationName,
logs: logs,
rolledBackAt: rolledBackAt,
startedAt: startedAt,
appliedStepsCount: appliedStepsCount,
);
}
static const _unset = Object();
PrismaMigrations copyWith({
Object? id = _unset,
Object? checksum = _unset,
Object? finishedAt = _unset,
Object? migrationName = _unset,
Object? logs = _unset,
Object? rolledBackAt = _unset,
Object? startedAt = _unset,
Object? appliedStepsCount = _unset,
}) {
return PrismaMigrations(
id: id == _unset ? this.id : id as String,
checksum: checksum == _unset ? this.checksum : checksum as String,
finishedAt:
finishedAt == _unset ? this.finishedAt : finishedAt as DateTime?,
migrationName:
migrationName == _unset
? this.migrationName
: migrationName as String,
logs: logs == _unset ? this.logs : logs as String?,
rolledBackAt:
rolledBackAt == _unset
? this.rolledBackAt
: rolledBackAt as DateTime?,
startedAt: startedAt == _unset ? this.startedAt : startedAt as DateTime,
appliedStepsCount:
appliedStepsCount == _unset
? this.appliedStepsCount
: appliedStepsCount as int,
);
}
}

View File

@ -1,6 +1,12 @@
export 'cities_model.dart';
export 'demographics_model.dart';
export 'districts_model.dart';
export 'geographics_model.dart';
export 'location_logs_model.dart';
export 'locations_model.dart';
export 'models/cities_model.dart';
export 'models/demographics_model.dart';
export 'models/districts_model.dart';
export 'models/geographics_model.dart';
export 'models/location_logs_model.dart';
export 'models/locations_model.dart';
export 'supadart-models/cities_model_supadart.dart';
export 'supadart-models/demographics_model_supadart.dart';
export 'supadart-models/districts_model_supadart.dart';
export 'supadart-models/geographics_model_supadart.dart';
export 'supadart-models/location_logs_model_supadart.dart';
export 'supadart-models/locations_model_supadart.dart';

View File

@ -1,5 +1,5 @@
import 'package:sigap/src/features/daily-ops/models/units_model.dart';
import 'package:sigap/src/features/map/models/districts_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/units_model.dart';
import 'package:sigap/src/features/map/models/models/districts_model.dart';
class CityModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/map/models/districts_model.dart';
import 'package:sigap/src/features/map/models/models/districts_model.dart';
class DemographicModel {
final String id;

View File

@ -1,9 +1,9 @@
import 'package:sigap/src/features/daily-ops/models/units_model.dart';
import 'package:sigap/src/features/map/models/cities_model.dart';
import 'package:sigap/src/features/map/models/demographics_model.dart';
import 'package:sigap/src/features/map/models/geographics_model.dart';
import 'package:sigap/src/features/map/models/locations_model.dart';
import 'package:sigap/src/features/panic-button/models/crimes_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/units_model.dart';
import 'package:sigap/src/features/map/models/models/cities_model.dart';
import 'package:sigap/src/features/map/models/models/demographics_model.dart';
import 'package:sigap/src/features/map/models/models/geographics_model.dart';
import 'package:sigap/src/features/map/models/models/locations_model.dart';
import 'package:sigap/src/features/panic-button/models/models/crimes_model.dart';
class DistrictModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/map/models/districts_model.dart';
import 'package:sigap/src/features/map/models/models/districts_model.dart';
class GeographicModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/personalization/models/users_model.dart';
import 'package:sigap/src/features/personalization/models/models/users_model.dart';
class LocationLogModel {
final String id;

View File

@ -1,7 +1,7 @@
import 'package:sigap/src/features/daily-ops/models/patrol_units_model.dart';
import 'package:sigap/src/features/panic-button/models/crime_incidents_model.dart';
import 'package:sigap/src/features/panic-button/models/events_model.dart';
import 'package:sigap/src/features/panic-button/models/incident_logs_model.dart';
import 'package:sigap/src/features/daily-ops/models/models/patrol_units_model.dart';
import 'package:sigap/src/features/panic-button/models/models/crime_incidents_model.dart';
import 'package:sigap/src/features/panic-button/models/models/events_model.dart';
import 'package:sigap/src/features/panic-button/models/models/incident_logs_model.dart';
class LocationModel {
final String id;

View File

@ -0,0 +1,113 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class Cities implements SupadartClass<Cities> {
final String id;
final String name;
final DateTime? createdAt;
final DateTime? updatedAt;
const Cities({
required this.id,
required this.name,
this.createdAt,
this.updatedAt,
});
static String get table_name => 'cities';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Cities> converter(List<Map<String, dynamic>> data) {
return data.map(Cities.fromJson).toList();
}
static Cities converterSingle(Map<String, dynamic> data) {
return Cities.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Cities.fromJson(Map<String, dynamic> jsonn) {
return Cities(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static const _unset = Object();
Cities copyWith({
Object? id = _unset,
Object? name = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
}) {
return Cities(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
);
}
}

View File

@ -0,0 +1,193 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Demographics implements SupadartClass<Demographics> {
final String id;
final String districtId;
final int population;
final int numberOfUnemployed;
final double populationDensity;
final int year;
final DateTime? createdAt;
final DateTime? updatedAt;
final Districts? district;
const Demographics({
required this.id,
required this.districtId,
required this.population,
required this.numberOfUnemployed,
required this.populationDensity,
required this.year,
this.createdAt,
this.updatedAt,
this.district,
});
static String get table_name => 'demographics';
static String get c_id => 'id';
static String get c_districtId => 'district_id';
static String get c_population => 'population';
static String get c_numberOfUnemployed => 'number_of_unemployed';
static String get c_populationDensity => 'population_density';
static String get c_year => 'year';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Demographics> converter(List<Map<String, dynamic>> data) {
return data.map(Demographics.fromJson).toList();
}
static Demographics converterSingle(Map<String, dynamic> data) {
return Demographics.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? districtId,
int? population,
int? numberOfUnemployed,
double? populationDensity,
int? year,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (districtId != null) 'district_id': districtId,
if (population != null) 'population': population,
if (numberOfUnemployed != null)
'number_of_unemployed': numberOfUnemployed,
if (populationDensity != null)
'population_density': populationDensity.toString(),
if (year != null) 'year': year,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String districtId,
required int population,
required int numberOfUnemployed,
required double populationDensity,
required int year,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
districtId: districtId,
population: population,
numberOfUnemployed: numberOfUnemployed,
populationDensity: populationDensity,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? districtId,
int? population,
int? numberOfUnemployed,
double? populationDensity,
int? year,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
districtId: districtId,
population: population,
numberOfUnemployed: numberOfUnemployed,
populationDensity: populationDensity,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Demographics.fromJson(Map<String, dynamic> jsonn) {
return Demographics(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
districtId:
jsonn['district_id'] != null ? jsonn['district_id'].toString() : '',
population:
jsonn['population'] != null
? int.parse(jsonn['population'].toString())
: 0,
numberOfUnemployed:
jsonn['number_of_unemployed'] != null
? int.parse(jsonn['number_of_unemployed'].toString())
: 0,
populationDensity:
jsonn['population_density'] != null
? double.parse(jsonn['population_density'].toString())
: 0.0,
year: jsonn['year'] != null ? int.parse(jsonn['year'].toString()) : 0,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
district:
jsonn['districts'] != null
? Districts.fromJson(jsonn['districts'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
districtId: districtId,
population: population,
numberOfUnemployed: numberOfUnemployed,
populationDensity: populationDensity,
year: year,
createdAt: createdAt,
updatedAt: updatedAt,
// 'districts': district?.toJson(),
);
}
static const _unset = Object();
Demographics copyWith({
Object? id = _unset,
Object? districtId = _unset,
Object? population = _unset,
Object? numberOfUnemployed = _unset,
Object? populationDensity = _unset,
Object? year = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? district = _unset,
}) {
return Demographics(
id: id == _unset ? this.id : id as String,
districtId: districtId == _unset ? this.districtId : districtId as String,
population: population == _unset ? this.population : population as int,
numberOfUnemployed:
numberOfUnemployed == _unset
? this.numberOfUnemployed
: numberOfUnemployed as int,
populationDensity:
populationDensity == _unset
? this.populationDensity
: populationDensity as double,
year: year == _unset ? this.year : year as int,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
district: district == _unset ? this.district : district as Districts?,
);
}
}

View File

@ -0,0 +1,136 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Districts implements SupadartClass<Districts> {
final String id;
final String cityId;
final String name;
final DateTime? createdAt;
final DateTime? updatedAt;
final Cities? city;
const Districts({
required this.id,
required this.cityId,
required this.name,
this.createdAt,
this.updatedAt,
this.city,
});
static String get table_name => 'districts';
static String get c_id => 'id';
static String get c_cityId => 'city_id';
static String get c_name => 'name';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Districts> converter(List<Map<String, dynamic>> data) {
return data.map(Districts.fromJson).toList();
}
static Districts converterSingle(Map<String, dynamic> data) {
return Districts.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? cityId,
String? name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (cityId != null) 'city_id': cityId,
if (name != null) 'name': name,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String cityId,
required String name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
cityId: cityId,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? cityId,
String? name,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
cityId: cityId,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Districts.fromJson(Map<String, dynamic> jsonn) {
return Districts(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
cityId: jsonn['city_id'] != null ? jsonn['city_id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
city:
jsonn['cities'] != null
? Cities.fromJson(jsonn['cities'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
cityId: cityId,
name: name,
createdAt: createdAt,
updatedAt: updatedAt,
// 'cities': city?.toJson(),
);
}
static const _unset = Object();
Districts copyWith({
Object? id = _unset,
Object? cityId = _unset,
Object? name = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? city = _unset,
}) {
return Districts(
id: id == _unset ? this.id : id as String,
cityId: cityId == _unset ? this.cityId : cityId as String,
name: name == _unset ? this.name : name as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
city: city == _unset ? this.city : city as Cities?,
);
}
}

View File

@ -0,0 +1,264 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Geographics implements SupadartClass<Geographics> {
final String id;
final String districtId;
final String? address;
final double longitude;
final double latitude;
final double? landArea;
final String? polygon;
final String? geometry;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? description;
final String? type;
final String location;
final int? year;
final Districts? district;
const Geographics({
required this.id,
required this.districtId,
this.address,
required this.longitude,
required this.latitude,
this.landArea,
this.polygon,
this.geometry,
this.createdAt,
this.updatedAt,
this.description,
this.type,
required this.location,
this.year,
this.district,
});
static String get table_name => 'geographics';
static String get c_id => 'id';
static String get c_districtId => 'district_id';
static String get c_address => 'address';
static String get c_longitude => 'longitude';
static String get c_latitude => 'latitude';
static String get c_landArea => 'land_area';
static String get c_polygon => 'polygon';
static String get c_geometry => 'geometry';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_description => 'description';
static String get c_type => 'type';
static String get c_location => 'location';
static String get c_year => 'year';
static List<Geographics> converter(List<Map<String, dynamic>> data) {
return data.map(Geographics.fromJson).toList();
}
static Geographics converterSingle(Map<String, dynamic> data) {
return Geographics.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? districtId,
String? address,
double? longitude,
double? latitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
String? description,
String? type,
String? location,
int? year,
}) {
return {
if (id != null) 'id': id,
if (districtId != null) 'district_id': districtId,
if (address != null) 'address': address,
if (longitude != null) 'longitude': longitude.toString(),
if (latitude != null) 'latitude': latitude.toString(),
if (landArea != null) 'land_area': landArea.toString(),
if (polygon != null) 'polygon': polygon,
if (geometry != null) 'geometry': geometry,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (description != null) 'description': description,
if (type != null) 'type': type,
if (location != null) 'location': location,
if (year != null) 'year': year,
};
}
static Map<String, dynamic> insert({
String? id,
required String districtId,
String? address,
required double longitude,
required double latitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
String? description,
String? type,
required String location,
int? year,
}) {
return _generateMap(
id: id,
districtId: districtId,
address: address,
longitude: longitude,
latitude: latitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
description: description,
type: type,
location: location,
year: year,
);
}
static Map<String, dynamic> update({
String? id,
String? districtId,
String? address,
double? longitude,
double? latitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
String? description,
String? type,
String? location,
int? year,
}) {
return _generateMap(
id: id,
districtId: districtId,
address: address,
longitude: longitude,
latitude: latitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
description: description,
type: type,
location: location,
year: year,
);
}
factory Geographics.fromJson(Map<String, dynamic> jsonn) {
return Geographics(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
districtId:
jsonn['district_id'] != null ? jsonn['district_id'].toString() : '',
address: jsonn['address'] != null ? jsonn['address'].toString() : null,
longitude:
jsonn['longitude'] != null
? double.parse(jsonn['longitude'].toString())
: 0.0,
latitude:
jsonn['latitude'] != null
? double.parse(jsonn['latitude'].toString())
: 0.0,
landArea:
jsonn['land_area'] != null
? double.parse(jsonn['land_area'].toString())
: null,
polygon: jsonn['polygon'] != null ? jsonn['polygon'].toString() : null,
geometry: jsonn['geometry'] != null ? jsonn['geometry'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
type: jsonn['type'] != null ? jsonn['type'].toString() : null,
location: jsonn['location'] != null ? jsonn['location'].toString() : '',
year: jsonn['year'] != null ? int.parse(jsonn['year'].toString()) : null,
district:
jsonn['districts'] != null
? Districts.fromJson(jsonn['districts'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
districtId: districtId,
address: address,
longitude: longitude,
latitude: latitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
description: description,
type: type,
location: location,
year: year,
);
}
static const _unset = Object();
Geographics copyWith({
Object? id = _unset,
Object? districtId = _unset,
Object? address = _unset,
Object? longitude = _unset,
Object? latitude = _unset,
Object? landArea = _unset,
Object? polygon = _unset,
Object? geometry = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? description = _unset,
Object? type = _unset,
Object? location = _unset,
Object? year = _unset,
Object? district = _unset,
}) {
return Geographics(
id: id == _unset ? this.id : id as String,
districtId: districtId == _unset ? this.districtId : districtId as String,
address: address == _unset ? this.address : address as String?,
longitude: longitude == _unset ? this.longitude : longitude as double,
latitude: latitude == _unset ? this.latitude : latitude as double,
landArea: landArea == _unset ? this.landArea : landArea as double?,
polygon: polygon == _unset ? this.polygon : polygon as String?,
geometry: geometry == _unset ? this.geometry : geometry as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
description:
description == _unset ? this.description : description as String?,
type: type == _unset ? this.type : type as String?,
location: location == _unset ? this.location : location as String,
year: year == _unset ? this.year : year as int?,
district: district == _unset ? this.district : district as Districts?,
);
}
}

View File

@ -0,0 +1,199 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class LocationLogs implements SupadartClass<LocationLogs> {
final String id;
final String userId;
final double latitude;
final double longitude;
final String location;
final DateTime timestamp;
final String? description;
final DateTime createdAt;
final DateTime updatedAt;
final Users? user;
const LocationLogs({
required this.id,
required this.userId,
required this.latitude,
required this.longitude,
required this.location,
required this.timestamp,
this.description,
required this.createdAt,
required this.updatedAt,
this.user,
});
static String get table_name => 'location_logs';
static String get c_id => 'id';
static String get c_userId => 'user_id';
static String get c_latitude => 'latitude';
static String get c_longitude => 'longitude';
static String get c_location => 'location';
static String get c_timestamp => 'timestamp';
static String get c_description => 'description';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<LocationLogs> converter(List<Map<String, dynamic>> data) {
return data.map(LocationLogs.fromJson).toList();
}
static LocationLogs converterSingle(Map<String, dynamic> data) {
return LocationLogs.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? userId,
double? latitude,
double? longitude,
String? location,
DateTime? timestamp,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (userId != null) 'user_id': userId,
if (latitude != null) 'latitude': latitude.toString(),
if (longitude != null) 'longitude': longitude.toString(),
if (location != null) 'location': location,
if (timestamp != null) 'timestamp': timestamp.toUtc().toIso8601String(),
if (description != null) 'description': description,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String userId,
required double latitude,
required double longitude,
required String location,
required DateTime timestamp,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
userId: userId,
latitude: latitude,
longitude: longitude,
location: location,
timestamp: timestamp,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? userId,
double? latitude,
double? longitude,
String? location,
DateTime? timestamp,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
userId: userId,
latitude: latitude,
longitude: longitude,
location: location,
timestamp: timestamp,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory LocationLogs.fromJson(Map<String, dynamic> jsonn) {
return LocationLogs(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
latitude:
jsonn['latitude'] != null
? double.parse(jsonn['latitude'].toString())
: 0.0,
longitude:
jsonn['longitude'] != null
? double.parse(jsonn['longitude'].toString())
: 0.0,
location: jsonn['location'] != null ? jsonn['location'].toString() : '',
timestamp:
jsonn['timestamp'] != null
? DateTime.parse(jsonn['timestamp'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
user:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
userId: userId,
latitude: latitude,
longitude: longitude,
location: location,
timestamp: timestamp,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
// 'users': user?.toJson(),
);
}
static const _unset = Object();
LocationLogs copyWith({
Object? id = _unset,
Object? userId = _unset,
Object? latitude = _unset,
Object? longitude = _unset,
Object? location = _unset,
Object? timestamp = _unset,
Object? description = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? user = _unset,
}) {
return LocationLogs(
id: id == _unset ? this.id : id as String,
userId: userId == _unset ? this.userId : userId as String,
latitude: latitude == _unset ? this.latitude : latitude as double,
longitude: longitude == _unset ? this.longitude : longitude as double,
location: location == _unset ? this.location : location as String,
timestamp: timestamp == _unset ? this.timestamp : timestamp as DateTime,
description:
description == _unset ? this.description : description as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
user: user == _unset ? this.user : user as Users?,
);
}
}

View File

@ -0,0 +1,278 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Locations implements SupadartClass<Locations> {
final String id;
final String districtId;
final String eventId;
final String? address;
final String? type;
final double latitude;
final double longitude;
final double? landArea;
final String? polygon;
final String? geometry;
final DateTime? createdAt;
final DateTime? updatedAt;
final String location;
final double? distanceToUnit;
final Districts? district;
final Events? event;
const Locations({
required this.id,
required this.districtId,
required this.eventId,
this.address,
this.type,
required this.latitude,
required this.longitude,
this.landArea,
this.polygon,
this.geometry,
this.createdAt,
this.updatedAt,
required this.location,
this.distanceToUnit,
this.district,
this.event,
});
static String get table_name => 'locations';
static String get c_id => 'id';
static String get c_districtId => 'district_id';
static String get c_eventId => 'event_id';
static String get c_address => 'address';
static String get c_type => 'type';
static String get c_latitude => 'latitude';
static String get c_longitude => 'longitude';
static String get c_landArea => 'land_area';
static String get c_polygon => 'polygon';
static String get c_geometry => 'geometry';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_location => 'location';
static String get c_distanceToUnit => 'distance_to_unit';
static List<Locations> converter(List<Map<String, dynamic>> data) {
return data.map(Locations.fromJson).toList();
}
static Locations converterSingle(Map<String, dynamic> data) {
return Locations.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? districtId,
String? eventId,
String? address,
String? type,
double? latitude,
double? longitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
String? location,
double? distanceToUnit,
}) {
return {
if (id != null) 'id': id,
if (districtId != null) 'district_id': districtId,
if (eventId != null) 'event_id': eventId,
if (address != null) 'address': address,
if (type != null) 'type': type,
if (latitude != null) 'latitude': latitude.toString(),
if (longitude != null) 'longitude': longitude.toString(),
if (landArea != null) 'land_area': landArea.toString(),
if (polygon != null) 'polygon': polygon,
if (geometry != null) 'geometry': geometry,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (location != null) 'location': location,
if (distanceToUnit != null) 'distance_to_unit': distanceToUnit.toString(),
};
}
static Map<String, dynamic> insert({
String? id,
required String districtId,
required String eventId,
String? address,
String? type,
required double latitude,
required double longitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
required String location,
double? distanceToUnit,
}) {
return _generateMap(
id: id,
districtId: districtId,
eventId: eventId,
address: address,
type: type,
latitude: latitude,
longitude: longitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
location: location,
distanceToUnit: distanceToUnit,
);
}
static Map<String, dynamic> update({
String? id,
String? districtId,
String? eventId,
String? address,
String? type,
double? latitude,
double? longitude,
double? landArea,
String? polygon,
String? geometry,
DateTime? createdAt,
DateTime? updatedAt,
String? location,
double? distanceToUnit,
}) {
return _generateMap(
id: id,
districtId: districtId,
eventId: eventId,
address: address,
type: type,
latitude: latitude,
longitude: longitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
location: location,
distanceToUnit: distanceToUnit,
);
}
factory Locations.fromJson(Map<String, dynamic> jsonn) {
return Locations(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
districtId:
jsonn['district_id'] != null ? jsonn['district_id'].toString() : '',
eventId: jsonn['event_id'] != null ? jsonn['event_id'].toString() : '',
address: jsonn['address'] != null ? jsonn['address'].toString() : null,
type: jsonn['type'] != null ? jsonn['type'].toString() : null,
latitude:
jsonn['latitude'] != null
? double.parse(jsonn['latitude'].toString())
: 0.0,
longitude:
jsonn['longitude'] != null
? double.parse(jsonn['longitude'].toString())
: 0.0,
landArea:
jsonn['land_area'] != null
? double.parse(jsonn['land_area'].toString())
: null,
polygon: jsonn['polygon'] != null ? jsonn['polygon'].toString() : null,
geometry: jsonn['geometry'] != null ? jsonn['geometry'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
location: jsonn['location'] != null ? jsonn['location'].toString() : '',
distanceToUnit:
jsonn['distance_to_unit'] != null
? double.parse(jsonn['distance_to_unit'].toString())
: null,
district:
jsonn['districts'] != null
? Districts.fromJson(jsonn['districts'] as Map<String, dynamic>)
: null,
event:
jsonn['events'] != null
? Events.fromJson(jsonn['events'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
districtId: districtId,
eventId: eventId,
address: address,
type: type,
latitude: latitude,
longitude: longitude,
landArea: landArea,
polygon: polygon,
geometry: geometry,
createdAt: createdAt,
updatedAt: updatedAt,
location: location,
distanceToUnit: distanceToUnit,
// 'districts': district?.toJson(),
// 'events': event?.toJson(),
);
}
static const _unset = Object();
Locations copyWith({
Object? id = _unset,
Object? districtId = _unset,
Object? eventId = _unset,
Object? address = _unset,
Object? type = _unset,
Object? latitude = _unset,
Object? longitude = _unset,
Object? landArea = _unset,
Object? polygon = _unset,
Object? geometry = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? location = _unset,
Object? distanceToUnit = _unset,
Object? district = _unset,
Object? event = _unset,
}) {
return Locations(
id: id == _unset ? this.id : id as String,
districtId: districtId == _unset ? this.districtId : districtId as String,
eventId: eventId == _unset ? this.eventId : eventId as String,
address: address == _unset ? this.address : address as String?,
type: type == _unset ? this.type : type as String?,
latitude: latitude == _unset ? this.latitude : latitude as double,
longitude: longitude == _unset ? this.longitude : longitude as double,
landArea: landArea == _unset ? this.landArea : landArea as double?,
polygon: polygon == _unset ? this.polygon : polygon as String?,
geometry: geometry == _unset ? this.geometry : geometry as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
location: location == _unset ? this.location : location as String,
distanceToUnit:
distanceToUnit == _unset
? this.distanceToUnit
: distanceToUnit as double?,
district: district == _unset ? this.district : district as Districts?,
event: event == _unset ? this.event : event as Events?,
);
}
}

View File

@ -1,6 +1,6 @@
import 'package:get/get.dart';
import 'package:sigap/src/cores/repositories/personalization/roles_repository.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
import 'package:sigap/src/utils/constants/app_routes.dart';
import 'package:sigap/src/utils/popups/loaders.dart';

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
import 'package:sigap/src/utils/constants/colors.dart';
class RoleCard extends StatelessWidget {

View File

@ -1,6 +1,14 @@
export 'crime_incidents_model.dart';
export 'crimes_model.dart';
export 'events_model.dart';
export 'evidences_model.dart';
export 'incident_logs_model.dart';
export 'sessions_model.dart';
export 'models/crime_incidents_model.dart';
export 'models/crimes_model.dart';
export 'models/events_model.dart';
export 'models/evidences_model.dart';
export 'models/incident_logs_model.dart';
export 'models/sessions_model.dart';
export 'supadart-models/crime_categories_model_supadart.dart';
export 'supadart-models/crime_incidents_model_supadart.dart';
export 'supadart-models/crimes_model_supadart.dart';
export 'supadart-models/evidence_model_supadart.dart';
export 'supadart-models/incident_logs_model_supadart.dart';
export 'supadart-models/panic_button_logs_model_supadart.dart';
export 'supadart-models/sessions_model_supadart.dart';

View File

@ -1,5 +1,5 @@
import 'package:sigap/src/features/map/models/districts_model.dart';
import 'package:sigap/src/features/panic-button/models/crime_incidents_model.dart';
import 'package:sigap/src/features/map/models/models/districts_model.dart';
import 'package:sigap/src/features/panic-button/models/models/crime_incidents_model.dart';
enum CrimeRates { low, medium, high, critical }

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/map/models/locations_model.dart';
import 'package:sigap/src/features/map/models/models/locations_model.dart';
class EventModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/panic-button/models/incident_logs_model.dart';
import 'package:sigap/src/features/panic-button/models/models/incident_logs_model.dart';
class EvidenceModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/panic-button/models/evidences_model.dart';
import 'package:sigap/src/features/panic-button/models/models/evidences_model.dart';
class IncidentLogModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/panic-button/models/events_model.dart';
import 'package:sigap/src/features/panic-button/models/models/events_model.dart';
enum SessionStatus { active, inactive }

View File

@ -0,0 +1,141 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class CrimeCategories implements SupadartClass<CrimeCategories> {
final String id;
final String name;
final String description;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? type;
const CrimeCategories({
required this.id,
required this.name,
required this.description,
this.createdAt,
this.updatedAt,
this.type,
});
static String get table_name => 'crime_categories';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_description => 'description';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_type => 'type';
static List<CrimeCategories> converter(List<Map<String, dynamic>> data) {
return data.map(CrimeCategories.fromJson).toList();
}
static CrimeCategories converterSingle(Map<String, dynamic> data) {
return CrimeCategories.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
String? type,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (description != null) 'description': description,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (type != null) 'type': type,
};
}
static Map<String, dynamic> insert({
String? id,
required String name,
required String description,
DateTime? createdAt,
DateTime? updatedAt,
String? type,
}) {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
type: type,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
String? type,
}) {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
type: type,
);
}
factory CrimeCategories.fromJson(Map<String, dynamic> jsonn) {
return CrimeCategories(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
type: jsonn['type'] != null ? jsonn['type'].toString() : null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
type: type,
);
}
static const _unset = Object();
CrimeCategories copyWith({
Object? id = _unset,
Object? name = _unset,
Object? description = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? type = _unset,
}) {
return CrimeCategories(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String,
description:
description == _unset ? this.description : description as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
type: type == _unset ? this.type : type as String?,
);
}
}

View File

@ -0,0 +1,243 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
enum CRIME_STATUS { closed, open, resolved, underInvestigation, unresolved }
class CrimeIncidents implements SupadartClass<CrimeIncidents> {
final String id;
final String crimeId;
final String crimeCategoryId;
final String locationId;
final String description;
final int victimCount;
final CRIME_STATUS? status;
final DateTime? createdAt;
final DateTime? updatedAt;
final DateTime timestamp;
final CrimeCategories? crimeCategory;
final Crimes? crime;
final Locations? location;
const CrimeIncidents({
required this.id,
required this.crimeId,
required this.crimeCategoryId,
required this.locationId,
required this.description,
required this.victimCount,
this.status,
this.createdAt,
this.updatedAt,
required this.timestamp,
this.crimeCategory,
this.crime,
this.location,
});
static String get table_name => 'crime_incidents';
static String get c_id => 'id';
static String get c_crimeId => 'crime_id';
static String get c_crimeCategoryId => 'crime_category_id';
static String get c_locationId => 'location_id';
static String get c_description => 'description';
static String get c_victimCount => 'victim_count';
static String get c_status => 'status';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_timestamp => 'timestamp';
static List<CrimeIncidents> converter(List<Map<String, dynamic>> data) {
return data.map(CrimeIncidents.fromJson).toList();
}
static CrimeIncidents converterSingle(Map<String, dynamic> data) {
return CrimeIncidents.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? crimeId,
String? crimeCategoryId,
String? locationId,
String? description,
int? victimCount,
CRIME_STATUS? status,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? timestamp,
}) {
return {
if (id != null) 'id': id,
if (crimeId != null) 'crime_id': crimeId,
if (crimeCategoryId != null) 'crime_category_id': crimeCategoryId,
if (locationId != null) 'location_id': locationId,
if (description != null) 'description': description,
if (victimCount != null) 'victim_count': victimCount,
if (status != null) 'status': status.toString().split('.').last,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (timestamp != null) 'timestamp': timestamp.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String crimeId,
required String crimeCategoryId,
required String locationId,
required String description,
required int victimCount,
CRIME_STATUS? status,
DateTime? createdAt,
DateTime? updatedAt,
required DateTime timestamp,
}) {
return _generateMap(
id: id,
crimeId: crimeId,
crimeCategoryId: crimeCategoryId,
locationId: locationId,
description: description,
victimCount: victimCount,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
timestamp: timestamp,
);
}
static Map<String, dynamic> update({
String? id,
String? crimeId,
String? crimeCategoryId,
String? locationId,
String? description,
int? victimCount,
CRIME_STATUS? status,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? timestamp,
}) {
return _generateMap(
id: id,
crimeId: crimeId,
crimeCategoryId: crimeCategoryId,
locationId: locationId,
description: description,
victimCount: victimCount,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
timestamp: timestamp,
);
}
factory CrimeIncidents.fromJson(Map<String, dynamic> jsonn) {
return CrimeIncidents(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
crimeId: jsonn['crime_id'] != null ? jsonn['crime_id'].toString() : '',
crimeCategoryId:
jsonn['crime_category_id'] != null
? jsonn['crime_category_id'].toString()
: '',
locationId:
jsonn['location_id'] != null ? jsonn['location_id'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : '',
victimCount:
jsonn['victim_count'] != null
? int.parse(jsonn['victim_count'].toString())
: 0,
status:
jsonn['status'] != null
? CRIME_STATUS.values.byName(jsonn['status'].toString())
: CRIME_STATUS.values.first,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
timestamp:
jsonn['timestamp'] != null
? DateTime.parse(jsonn['timestamp'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
crimeCategory:
jsonn['crime_categories'] != null
? CrimeCategories.fromJson(
jsonn['crime_categories'] as Map<String, dynamic>,
)
: null,
crime:
jsonn['crimes'] != null
? Crimes.fromJson(jsonn['crimes'] as Map<String, dynamic>)
: null,
location:
jsonn['locations'] != null
? Locations.fromJson(jsonn['locations'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
crimeId: crimeId,
crimeCategoryId: crimeCategoryId,
locationId: locationId,
description: description,
victimCount: victimCount,
status: status,
createdAt: createdAt,
updatedAt: updatedAt,
timestamp: timestamp,
);
}
static const _unset = Object();
CrimeIncidents copyWith({
Object? id = _unset,
Object? crimeId = _unset,
Object? crimeCategoryId = _unset,
Object? locationId = _unset,
Object? description = _unset,
Object? victimCount = _unset,
Object? status = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? timestamp = _unset,
Object? crimeCategory = _unset,
Object? crime = _unset,
Object? location = _unset,
}) {
return CrimeIncidents(
id: id == _unset ? this.id : id as String,
crimeId: crimeId == _unset ? this.crimeId : crimeId as String,
crimeCategoryId:
crimeCategoryId == _unset
? this.crimeCategoryId
: crimeCategoryId as String,
locationId: locationId == _unset ? this.locationId : locationId as String,
description:
description == _unset ? this.description : description as String,
victimCount:
victimCount == _unset ? this.victimCount : victimCount as int,
status: status == _unset ? this.status : status as CRIME_STATUS?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
timestamp: timestamp == _unset ? this.timestamp : timestamp as DateTime,
crimeCategory:
crimeCategory == _unset
? this.crimeCategory
: crimeCategory as CrimeCategories?,
crime: crime == _unset ? this.crime : crime as Crimes?,
location: location == _unset ? this.location : location as Locations?,
);
}
}

View File

@ -0,0 +1,263 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
enum CRIME_RATES { critical, high, low, medium }
class Crimes implements SupadartClass<Crimes> {
final String id;
final String districtId;
final DateTime? createdAt;
final CRIME_RATES level;
final String? method;
final int? month;
final int numberOfCrime;
final double score;
final DateTime? updatedAt;
final int? year;
final String? sourceType;
final int crimeCleared;
final double avgCrime;
final Districts? district;
const Crimes({
required this.id,
required this.districtId,
this.createdAt,
required this.level,
this.method,
this.month,
required this.numberOfCrime,
required this.score,
this.updatedAt,
this.year,
this.sourceType,
required this.crimeCleared,
required this.avgCrime,
this.district,
});
static String get table_name => 'crimes';
static String get c_id => 'id';
static String get c_districtId => 'district_id';
static String get c_createdAt => 'created_at';
static String get c_level => 'level';
static String get c_method => 'method';
static String get c_month => 'month';
static String get c_numberOfCrime => 'number_of_crime';
static String get c_score => 'score';
static String get c_updatedAt => 'updated_at';
static String get c_year => 'year';
static String get c_sourceType => 'source_type';
static String get c_crimeCleared => 'crime_cleared';
static String get c_avgCrime => 'avg_crime';
static List<Crimes> converter(List<Map<String, dynamic>> data) {
return data.map(Crimes.fromJson).toList();
}
static Crimes converterSingle(Map<String, dynamic> data) {
return Crimes.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? districtId,
DateTime? createdAt,
CRIME_RATES? level,
String? method,
int? month,
int? numberOfCrime,
double? score,
DateTime? updatedAt,
int? year,
String? sourceType,
int? crimeCleared,
double? avgCrime,
}) {
return {
if (id != null) 'id': id,
if (districtId != null) 'district_id': districtId,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (level != null) 'level': level.toString().split('.').last,
if (method != null) 'method': method,
if (month != null) 'month': month,
if (numberOfCrime != null) 'number_of_crime': numberOfCrime,
if (score != null) 'score': score.toString(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (year != null) 'year': year,
if (sourceType != null) 'source_type': sourceType,
if (crimeCleared != null) 'crime_cleared': crimeCleared,
if (avgCrime != null) 'avg_crime': avgCrime.toString(),
};
}
static Map<String, dynamic> insert({
String? id,
required String districtId,
DateTime? createdAt,
CRIME_RATES? level,
String? method,
int? month,
int? numberOfCrime,
double? score,
DateTime? updatedAt,
int? year,
String? sourceType,
int? crimeCleared,
double? avgCrime,
}) {
return _generateMap(
id: id,
districtId: districtId,
createdAt: createdAt,
level: level,
method: method,
month: month,
numberOfCrime: numberOfCrime,
score: score,
updatedAt: updatedAt,
year: year,
sourceType: sourceType,
crimeCleared: crimeCleared,
avgCrime: avgCrime,
);
}
static Map<String, dynamic> update({
String? id,
String? districtId,
DateTime? createdAt,
CRIME_RATES? level,
String? method,
int? month,
int? numberOfCrime,
double? score,
DateTime? updatedAt,
int? year,
String? sourceType,
int? crimeCleared,
double? avgCrime,
}) {
return _generateMap(
id: id,
districtId: districtId,
createdAt: createdAt,
level: level,
method: method,
month: month,
numberOfCrime: numberOfCrime,
score: score,
updatedAt: updatedAt,
year: year,
sourceType: sourceType,
crimeCleared: crimeCleared,
avgCrime: avgCrime,
);
}
factory Crimes.fromJson(Map<String, dynamic> jsonn) {
return Crimes(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
districtId:
jsonn['district_id'] != null ? jsonn['district_id'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
level:
jsonn['level'] != null
? CRIME_RATES.values.byName(jsonn['level'].toString())
: CRIME_RATES.values.first,
method: jsonn['method'] != null ? jsonn['method'].toString() : null,
month:
jsonn['month'] != null ? int.parse(jsonn['month'].toString()) : null,
numberOfCrime:
jsonn['number_of_crime'] != null
? int.parse(jsonn['number_of_crime'].toString())
: 0,
score:
jsonn['score'] != null
? double.parse(jsonn['score'].toString())
: 0.0,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
year: jsonn['year'] != null ? int.parse(jsonn['year'].toString()) : null,
sourceType:
jsonn['source_type'] != null ? jsonn['source_type'].toString() : null,
crimeCleared:
jsonn['crime_cleared'] != null
? int.parse(jsonn['crime_cleared'].toString())
: 0,
avgCrime:
jsonn['avg_crime'] != null
? double.parse(jsonn['avg_crime'].toString())
: 0.0,
district:
jsonn['districts'] != null
? Districts.fromJson(jsonn['districts'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
districtId: districtId,
createdAt: createdAt,
level: level,
method: method,
month: month,
numberOfCrime: numberOfCrime,
score: score,
updatedAt: updatedAt,
year: year,
sourceType: sourceType,
crimeCleared: crimeCleared,
avgCrime: avgCrime,
// 'districts': district?.toJson(),
);
}
static const _unset = Object();
Crimes copyWith({
Object? id = _unset,
Object? districtId = _unset,
Object? createdAt = _unset,
Object? level = _unset,
Object? method = _unset,
Object? month = _unset,
Object? numberOfCrime = _unset,
Object? score = _unset,
Object? updatedAt = _unset,
Object? year = _unset,
Object? sourceType = _unset,
Object? crimeCleared = _unset,
Object? avgCrime = _unset,
Object? district = _unset,
}) {
return Crimes(
id: id == _unset ? this.id : id as String,
districtId: districtId == _unset ? this.districtId : districtId as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
level: level == _unset ? this.level : level as CRIME_RATES,
method: method == _unset ? this.method : method as String?,
month: month == _unset ? this.month : month as int?,
numberOfCrime:
numberOfCrime == _unset ? this.numberOfCrime : numberOfCrime as int,
score: score == _unset ? this.score : score as double,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
year: year == _unset ? this.year : year as int?,
sourceType:
sourceType == _unset ? this.sourceType : sourceType as String?,
crimeCleared:
crimeCleared == _unset ? this.crimeCleared : crimeCleared as int,
avgCrime: avgCrime == _unset ? this.avgCrime : avgCrime as double,
district: district == _unset ? this.district : district as Districts?,
);
}
}

View File

@ -0,0 +1,148 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Events implements SupadartClass<Events> {
final String id;
final String name;
final String? description;
final String code;
final DateTime createdAt;
final String userId;
final Users? user;
const Events({
required this.id,
required this.name,
this.description,
required this.code,
required this.createdAt,
required this.userId,
this.user,
});
static String get table_name => 'events';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_description => 'description';
static String get c_code => 'code';
static String get c_createdAt => 'created_at';
static String get c_userId => 'user_id';
static List<Events> converter(List<Map<String, dynamic>> data) {
return data.map(Events.fromJson).toList();
}
static Events converterSingle(Map<String, dynamic> data) {
return Events.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
String? description,
String? code,
DateTime? createdAt,
String? userId,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (description != null) 'description': description,
if (code != null) 'code': code,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (userId != null) 'user_id': userId,
};
}
static Map<String, dynamic> insert({
String? id,
required String name,
String? description,
required String code,
DateTime? createdAt,
required String userId,
}) {
return _generateMap(
id: id,
name: name,
description: description,
code: code,
createdAt: createdAt,
userId: userId,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
String? description,
String? code,
DateTime? createdAt,
String? userId,
}) {
return _generateMap(
id: id,
name: name,
description: description,
code: code,
createdAt: createdAt,
userId: userId,
);
}
factory Events.fromJson(Map<String, dynamic> jsonn) {
return Events(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
code: jsonn['code'] != null ? jsonn['code'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
user:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
description: description,
code: code,
createdAt: createdAt,
userId: userId,
// 'users': user?.toJson(),
);
}
static const _unset = Object();
Events copyWith({
Object? id = _unset,
Object? name = _unset,
Object? description = _unset,
Object? code = _unset,
Object? createdAt = _unset,
Object? userId = _unset,
Object? user = _unset,
}) {
return Events(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String,
description:
description == _unset ? this.description : description as String?,
code: code == _unset ? this.code : code as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
userId: userId == _unset ? this.userId : userId as String,
user: user == _unset ? this.user : user as Users?,
);
}
}

View File

@ -0,0 +1,185 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Evidence implements SupadartClass<Evidence> {
final String incidentId;
final String type;
final String url;
final DateTime? uploadedAt;
final String? caption;
final String? description;
final Map<String, dynamic>? metadata;
final String id;
final IncidentLogs? incident;
const Evidence({
required this.incidentId,
required this.type,
required this.url,
this.uploadedAt,
this.caption,
this.description,
this.metadata,
required this.id,
this.incident,
});
static String get table_name => 'evidence';
static String get c_incidentId => 'incident_id';
static String get c_type => 'type';
static String get c_url => 'url';
static String get c_uploadedAt => 'uploaded_at';
static String get c_caption => 'caption';
static String get c_description => 'description';
static String get c_metadata => 'metadata';
static String get c_id => 'id';
static List<Evidence> converter(List<Map<String, dynamic>> data) {
return data.map(Evidence.fromJson).toList();
}
static Evidence converterSingle(Map<String, dynamic> data) {
return Evidence.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? incidentId,
String? type,
String? url,
DateTime? uploadedAt,
String? caption,
String? description,
Map<String, dynamic>? metadata,
String? id,
}) {
return {
if (incidentId != null) 'incident_id': incidentId,
if (type != null) 'type': type,
if (url != null) 'url': url,
if (uploadedAt != null)
'uploaded_at': uploadedAt.toUtc().toIso8601String(),
if (caption != null) 'caption': caption,
if (description != null) 'description': description,
if (metadata != null) 'metadata': metadata,
if (id != null) 'id': id,
};
}
static Map<String, dynamic> insert({
required String incidentId,
required String type,
required String url,
DateTime? uploadedAt,
String? caption,
String? description,
Map<String, dynamic>? metadata,
String? id,
}) {
return _generateMap(
incidentId: incidentId,
type: type,
url: url,
uploadedAt: uploadedAt,
caption: caption,
description: description,
metadata: metadata,
id: id,
);
}
static Map<String, dynamic> update({
String? incidentId,
String? type,
String? url,
DateTime? uploadedAt,
String? caption,
String? description,
Map<String, dynamic>? metadata,
String? id,
}) {
return _generateMap(
incidentId: incidentId,
type: type,
url: url,
uploadedAt: uploadedAt,
caption: caption,
description: description,
metadata: metadata,
id: id,
);
}
factory Evidence.fromJson(Map<String, dynamic> jsonn) {
return Evidence(
incidentId:
jsonn['incident_id'] != null ? jsonn['incident_id'].toString() : '',
type: jsonn['type'] != null ? jsonn['type'].toString() : '',
url: jsonn['url'] != null ? jsonn['url'].toString() : '',
uploadedAt:
jsonn['uploaded_at'] != null
? DateTime.parse(jsonn['uploaded_at'].toString())
: null,
caption: jsonn['caption'] != null ? jsonn['caption'].toString() : null,
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
metadata:
jsonn['metadata'] != null
? jsonn['metadata'] as Map<String, dynamic>
: null,
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
incident:
jsonn['incident_logs'] != null
? IncidentLogs.fromJson(
jsonn['incident_logs'] as Map<String, dynamic>,
)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
incidentId: incidentId,
type: type,
url: url,
uploadedAt: uploadedAt,
caption: caption,
description: description,
metadata: metadata,
id: id,
// 'incident_logs': incident?.toJson(),
);
}
static const _unset = Object();
Evidence copyWith({
Object? incidentId = _unset,
Object? type = _unset,
Object? url = _unset,
Object? uploadedAt = _unset,
Object? caption = _unset,
Object? description = _unset,
Object? metadata = _unset,
Object? id = _unset,
Object? incident = _unset,
}) {
return Evidence(
incidentId: incidentId == _unset ? this.incidentId : incidentId as String,
type: type == _unset ? this.type : type as String,
url: url == _unset ? this.url : url as String,
uploadedAt:
uploadedAt == _unset ? this.uploadedAt : uploadedAt as DateTime?,
caption: caption == _unset ? this.caption : caption as String?,
description:
description == _unset ? this.description : description as String?,
metadata:
metadata == _unset
? this.metadata
: metadata as Map<String, dynamic>?,
id: id == _unset ? this.id : id as String,
incident: incident == _unset ? this.incident : incident as IncidentLogs?,
);
}
}

View File

@ -0,0 +1,230 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class IncidentLogs implements SupadartClass<IncidentLogs> {
final String id;
final String userId;
final String locationId;
final String categoryId;
final String? description;
final String? source;
final DateTime time;
final bool? verified;
final DateTime? createdAt;
final DateTime? updatedAt;
final CrimeCategories? category;
final Locations? locationObj;
final Users? user;
const IncidentLogs({
required this.id,
required this.userId,
required this.locationId,
required this.categoryId,
this.description,
this.source,
required this.time,
this.verified,
this.createdAt,
this.updatedAt,
this.category,
this.locationObj,
this.user,
});
static String get table_name => 'incident_logs';
static String get c_id => 'id';
static String get c_userId => 'user_id';
static String get c_locationId => 'location_id';
static String get c_categoryId => 'category_id';
static String get c_description => 'description';
static String get c_source => 'source';
static String get c_time => 'time';
static String get c_verified => 'verified';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<IncidentLogs> converter(List<Map<String, dynamic>> data) {
return data.map(IncidentLogs.fromJson).toList();
}
static IncidentLogs converterSingle(Map<String, dynamic> data) {
return IncidentLogs.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? userId,
String? locationId,
String? categoryId,
String? description,
String? source,
DateTime? time,
bool? verified,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (userId != null) 'user_id': userId,
if (locationId != null) 'location_id': locationId,
if (categoryId != null) 'category_id': categoryId,
if (description != null) 'description': description,
if (source != null) 'source': source,
if (time != null) 'time': time.toUtc().toIso8601String(),
if (verified != null) 'verified': verified,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String userId,
required String locationId,
required String categoryId,
String? description,
String? source,
required DateTime time,
bool? verified,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
userId: userId,
locationId: locationId,
categoryId: categoryId,
description: description,
source: source,
time: time,
verified: verified,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? userId,
String? locationId,
String? categoryId,
String? description,
String? source,
DateTime? time,
bool? verified,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
userId: userId,
locationId: locationId,
categoryId: categoryId,
description: description,
source: source,
time: time,
verified: verified,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory IncidentLogs.fromJson(Map<String, dynamic> jsonn) {
return IncidentLogs(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
locationId:
jsonn['location_id'] != null ? jsonn['location_id'].toString() : '',
categoryId:
jsonn['category_id'] != null ? jsonn['category_id'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
source: jsonn['source'] != null ? jsonn['source'].toString() : null,
time:
jsonn['time'] != null
? DateTime.parse(jsonn['time'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
verified: jsonn['verified'] != null ? jsonn['verified'] as bool : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: null,
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: null,
category:
jsonn['crime_categories'] != null
? CrimeCategories.fromJson(
jsonn['crime_categories'] as Map<String, dynamic>,
)
: null,
locationObj:
jsonn['locations'] != null
? Locations.fromJson(jsonn['locations'] as Map<String, dynamic>)
: null,
user:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
userId: userId,
locationId: locationId,
categoryId: categoryId,
description: description,
source: source,
time: time,
verified: verified,
createdAt: createdAt,
updatedAt: updatedAt,
// 'crime_categories': category?.toJson(),
// 'locations': locationObj?.toJson(),
// 'users': user?.toJson(),
);
}
static const _unset = Object();
IncidentLogs copyWith({
Object? id = _unset,
Object? userId = _unset,
Object? locationId = _unset,
Object? categoryId = _unset,
Object? description = _unset,
Object? source = _unset,
Object? time = _unset,
Object? verified = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? category = _unset,
Object? locationObj = _unset,
Object? user = _unset,
}) {
return IncidentLogs(
id: id == _unset ? this.id : id as String,
userId: userId == _unset ? this.userId : userId as String,
locationId: locationId == _unset ? this.locationId : locationId as String,
categoryId: categoryId == _unset ? this.categoryId : categoryId as String,
description:
description == _unset ? this.description : description as String?,
source: source == _unset ? this.source : source as String?,
time: time == _unset ? this.time : time as DateTime,
verified: verified == _unset ? this.verified : verified as bool?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
category:
category == _unset ? this.category : category as CrimeCategories?,
locationObj:
locationObj == _unset ? this.locationObj : locationObj as Locations?,
user: user == _unset ? this.user : user as Users?,
);
}
}

View File

@ -0,0 +1,155 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class PanicButtonLogs implements SupadartClass<PanicButtonLogs> {
final String id;
final String userId;
final String? officerId;
final String incidentId;
final DateTime timestamp;
final IncidentLogs? incident;
final Officers? officer;
final Users? userObj;
const PanicButtonLogs({
required this.id,
required this.userId,
this.officerId,
required this.incidentId,
required this.timestamp,
this.incident,
this.officer,
this.userObj,
});
static String get table_name => 'panic_button_logs';
static String get c_id => 'id';
static String get c_userId => 'user_id';
static String get c_officerId => 'officer_id';
static String get c_incidentId => 'incident_id';
static String get c_timestamp => 'timestamp';
static List<PanicButtonLogs> converter(List<Map<String, dynamic>> data) {
return data.map(PanicButtonLogs.fromJson).toList();
}
static PanicButtonLogs converterSingle(Map<String, dynamic> data) {
return PanicButtonLogs.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? userId,
String? officerId,
String? incidentId,
DateTime? timestamp,
}) {
return {
if (id != null) 'id': id,
if (userId != null) 'user_id': userId,
if (officerId != null) 'officer_id': officerId,
if (incidentId != null) 'incident_id': incidentId,
if (timestamp != null) 'timestamp': timestamp.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String userId,
String? officerId,
required String incidentId,
required DateTime timestamp,
}) {
return _generateMap(
id: id,
userId: userId,
officerId: officerId,
incidentId: incidentId,
timestamp: timestamp,
);
}
static Map<String, dynamic> update({
String? id,
String? userId,
String? officerId,
String? incidentId,
DateTime? timestamp,
}) {
return _generateMap(
id: id,
userId: userId,
officerId: officerId,
incidentId: incidentId,
timestamp: timestamp,
);
}
factory PanicButtonLogs.fromJson(Map<String, dynamic> jsonn) {
return PanicButtonLogs(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
officerId:
jsonn['officer_id'] != null ? jsonn['officer_id'].toString() : null,
incidentId:
jsonn['incident_id'] != null ? jsonn['incident_id'].toString() : '',
timestamp:
jsonn['timestamp'] != null
? DateTime.parse(jsonn['timestamp'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
incident:
jsonn['incident_logs'] != null
? IncidentLogs.fromJson(
jsonn['incident_logs'] as Map<String, dynamic>,
)
: null,
officer:
jsonn['officers'] != null
? Officers.fromJson(jsonn['officers'] as Map<String, dynamic>)
: null,
userObj:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
userId: userId,
officerId: officerId,
incidentId: incidentId,
timestamp: timestamp,
// 'incident_logs': incident?.toJson(),
// 'officers': officer?.toJson(),
// 'users': userObj?.toJson(),
);
}
static const _unset = Object();
PanicButtonLogs copyWith({
Object? id = _unset,
Object? userId = _unset,
Object? officerId = _unset,
Object? incidentId = _unset,
Object? timestamp = _unset,
Object? incident = _unset,
Object? officer = _unset,
Object? userObj = _unset,
}) {
return PanicButtonLogs(
id: id == _unset ? this.id : id as String,
userId: userId == _unset ? this.userId : userId as String,
officerId: officerId == _unset ? this.officerId : officerId as String?,
incidentId: incidentId == _unset ? this.incidentId : incidentId as String,
timestamp: timestamp == _unset ? this.timestamp : timestamp as DateTime,
incident: incident == _unset ? this.incident : incident as IncidentLogs?,
officer: officer == _unset ? this.officer : officer as Officers?,
userObj: userObj == _unset ? this.userObj : userObj as Users?,
);
}
}

View File

@ -0,0 +1,147 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
enum SESSION_STATUS { active, completed }
class Sessions implements SupadartClass<Sessions> {
final String id;
final String userId;
final String eventId;
final SESSION_STATUS status;
final DateTime createdAt;
final Events? eventObj;
final Users? userObj;
const Sessions({
required this.id,
required this.userId,
required this.eventId,
required this.status,
required this.createdAt,
this.eventObj,
this.userObj,
});
static String get table_name => 'sessions';
static String get c_id => 'id';
static String get c_userId => 'user_id';
static String get c_eventId => 'event_id';
static String get c_status => 'status';
static String get c_createdAt => 'created_at';
static List<Sessions> converter(List<Map<String, dynamic>> data) {
return data.map(Sessions.fromJson).toList();
}
static Sessions converterSingle(Map<String, dynamic> data) {
return Sessions.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? userId,
String? eventId,
SESSION_STATUS? status,
DateTime? createdAt,
}) {
return {
if (id != null) 'id': id,
if (userId != null) 'user_id': userId,
if (eventId != null) 'event_id': eventId,
if (status != null) 'status': status.toString().split('.').last,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String userId,
required String eventId,
SESSION_STATUS? status,
DateTime? createdAt,
}) {
return _generateMap(
id: id,
userId: userId,
eventId: eventId,
status: status,
createdAt: createdAt,
);
}
static Map<String, dynamic> update({
String? id,
String? userId,
String? eventId,
SESSION_STATUS? status,
DateTime? createdAt,
}) {
return _generateMap(
id: id,
userId: userId,
eventId: eventId,
status: status,
createdAt: createdAt,
);
}
factory Sessions.fromJson(Map<String, dynamic> jsonn) {
return Sessions(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
eventId: jsonn['event_id'] != null ? jsonn['event_id'].toString() : '',
status:
jsonn['status'] != null
? SESSION_STATUS.values.byName(jsonn['status'].toString())
: SESSION_STATUS.values.first,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
eventObj:
jsonn['events'] != null
? Events.fromJson(jsonn['events'] as Map<String, dynamic>)
: null,
userObj:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
userId: userId,
eventId: eventId,
status: status,
createdAt: createdAt,
// 'events': eventObj?.toJson(),
// 'users': userObj?.toJson(),
);
}
static const _unset = Object();
Sessions copyWith({
Object? id = _unset,
Object? userId = _unset,
Object? eventId = _unset,
Object? status = _unset,
Object? createdAt = _unset,
Object? eventObj = _unset,
Object? userObj = _unset,
}) {
return Sessions(
id: id == _unset ? this.id : id as String,
userId: userId == _unset ? this.userId : userId as String,
eventId: eventId == _unset ? this.eventId : eventId as String,
status: status == _unset ? this.status : status as SESSION_STATUS,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
eventObj: eventObj == _unset ? this.eventObj : eventObj as Events?,
userObj: userObj == _unset ? this.userObj : userObj as Users?,
);
}
}

View File

@ -1,5 +1,10 @@
export 'permissions_model.dart';
export 'profile_model.dart';
export 'resources_model.dart';
export 'roles_model.dart';
export 'users_model.dart';
export 'models/permissions_model.dart';
export 'models/profile_model.dart';
export 'models/resources_model.dart';
export 'models/roles_model.dart';
export 'models/users_model.dart';
export 'supadart-models/permissions_model_supadart.dart';
export 'supadart-models/profiles_model_supadart.dart';
export 'supadart-models/resources_model_supadart.dart';
export 'supadart-models/roles_model_supadart.dart';
export 'supadart-models/users_model_supadart.dart';

View File

@ -1,5 +1,5 @@
import 'package:sigap/src/features/personalization/models/resources_model.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/resources_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
class PermissionModel {
final String id;

View File

@ -1,4 +1,4 @@
import 'package:sigap/src/features/personalization/models/permissions_model.dart';
import 'package:sigap/src/features/personalization/models/models/permissions_model.dart';
class ResourceModel {
final String id;

View File

@ -1,5 +1,5 @@
import 'package:sigap/src/features/personalization/models/profile_model.dart';
import 'package:sigap/src/features/personalization/models/roles_model.dart';
import 'package:sigap/src/features/personalization/models/models/profile_model.dart';
import 'package:sigap/src/features/personalization/models/models/roles_model.dart';
class UserModel {
final String id;

View File

@ -0,0 +1,159 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Permissions implements SupadartClass<Permissions> {
final String id;
final String action;
final String resourceId;
final String roleId;
final DateTime createdAt;
final DateTime updatedAt;
final Resources? resource;
final Roles? roleObj;
const Permissions({
required this.id,
required this.action,
required this.resourceId,
required this.roleId,
required this.createdAt,
required this.updatedAt,
this.resource,
this.roleObj,
});
static String get table_name => 'permissions';
static String get c_id => 'id';
static String get c_action => 'action';
static String get c_resourceId => 'resource_id';
static String get c_roleId => 'role_id';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Permissions> converter(List<Map<String, dynamic>> data) {
return data.map(Permissions.fromJson).toList();
}
static Permissions converterSingle(Map<String, dynamic> data) {
return Permissions.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? action,
String? resourceId,
String? roleId,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (action != null) 'action': action,
if (resourceId != null) 'resource_id': resourceId,
if (roleId != null) 'role_id': roleId,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String action,
required String resourceId,
required String roleId,
DateTime? createdAt,
required DateTime updatedAt,
}) {
return _generateMap(
id: id,
action: action,
resourceId: resourceId,
roleId: roleId,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? action,
String? resourceId,
String? roleId,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
action: action,
resourceId: resourceId,
roleId: roleId,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Permissions.fromJson(Map<String, dynamic> jsonn) {
return Permissions(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
action: jsonn['action'] != null ? jsonn['action'].toString() : '',
resourceId:
jsonn['resource_id'] != null ? jsonn['resource_id'].toString() : '',
roleId: jsonn['role_id'] != null ? jsonn['role_id'].toString() : '',
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
resource:
jsonn['resources'] != null
? Resources.fromJson(jsonn['resources'] as Map<String, dynamic>)
: null,
roleObj:
jsonn['roles'] != null
? Roles.fromJson(jsonn['roles'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
action: action,
resourceId: resourceId,
roleId: roleId,
createdAt: createdAt,
updatedAt: updatedAt,
// 'resources': resource?.toJson(),
// 'roles': roleObj?.toJson(),
);
}
static const _unset = Object();
Permissions copyWith({
Object? id = _unset,
Object? action = _unset,
Object? resourceId = _unset,
Object? roleId = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? resource = _unset,
Object? roleObj = _unset,
}) {
return Permissions(
id: id == _unset ? this.id : id as String,
action: action == _unset ? this.action : action as String,
resourceId: resourceId == _unset ? this.resourceId : resourceId as String,
roleId: roleId == _unset ? this.roleId : roleId as String,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
resource: resource == _unset ? this.resource : resource as Resources?,
roleObj: roleObj == _unset ? this.roleObj : roleObj as Roles?,
);
}
}

View File

@ -0,0 +1,204 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Profiles implements SupadartClass<Profiles> {
final String id;
final String userId;
final String? avatar;
final String? username;
final String? firstName;
final String? lastName;
final String? bio;
final Map<String, dynamic>? address;
final DateTime? birthDate;
final String nik;
final Users? user;
const Profiles({
required this.id,
required this.userId,
this.avatar,
this.username,
this.firstName,
this.lastName,
this.bio,
this.address,
this.birthDate,
required this.nik,
this.user,
});
static String get table_name => 'profiles';
static String get c_id => 'id';
static String get c_userId => 'user_id';
static String get c_avatar => 'avatar';
static String get c_username => 'username';
static String get c_firstName => 'first_name';
static String get c_lastName => 'last_name';
static String get c_bio => 'bio';
static String get c_address => 'address';
static String get c_birthDate => 'birth_date';
static String get c_nik => 'nik';
static List<Profiles> converter(List<Map<String, dynamic>> data) {
return data.map(Profiles.fromJson).toList();
}
static Profiles converterSingle(Map<String, dynamic> data) {
return Profiles.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? userId,
String? avatar,
String? username,
String? firstName,
String? lastName,
String? bio,
Map<String, dynamic>? address,
DateTime? birthDate,
String? nik,
}) {
return {
if (id != null) 'id': id,
if (userId != null) 'user_id': userId,
if (avatar != null) 'avatar': avatar,
if (username != null) 'username': username,
if (firstName != null) 'first_name': firstName,
if (lastName != null) 'last_name': lastName,
if (bio != null) 'bio': bio,
if (address != null) 'address': address,
if (birthDate != null) 'birth_date': birthDate.toIso8601String(),
if (nik != null) 'nik': nik,
};
}
static Map<String, dynamic> insert({
String? id,
required String userId,
String? avatar,
String? username,
String? firstName,
String? lastName,
String? bio,
Map<String, dynamic>? address,
DateTime? birthDate,
String? nik,
}) {
return _generateMap(
id: id,
userId: userId,
avatar: avatar,
username: username,
firstName: firstName,
lastName: lastName,
bio: bio,
address: address,
birthDate: birthDate,
nik: nik,
);
}
static Map<String, dynamic> update({
String? id,
String? userId,
String? avatar,
String? username,
String? firstName,
String? lastName,
String? bio,
Map<String, dynamic>? address,
DateTime? birthDate,
String? nik,
}) {
return _generateMap(
id: id,
userId: userId,
avatar: avatar,
username: username,
firstName: firstName,
lastName: lastName,
bio: bio,
address: address,
birthDate: birthDate,
nik: nik,
);
}
factory Profiles.fromJson(Map<String, dynamic> jsonn) {
return Profiles(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
avatar: jsonn['avatar'] != null ? jsonn['avatar'].toString() : null,
username: jsonn['username'] != null ? jsonn['username'].toString() : null,
firstName:
jsonn['first_name'] != null ? jsonn['first_name'].toString() : null,
lastName:
jsonn['last_name'] != null ? jsonn['last_name'].toString() : null,
bio: jsonn['bio'] != null ? jsonn['bio'].toString() : null,
address:
jsonn['address'] != null
? jsonn['address'] as Map<String, dynamic>
: null,
birthDate:
jsonn['birth_date'] != null
? DateTime.parse(jsonn['birth_date'].toString())
: null,
nik: jsonn['nik'] != null ? jsonn['nik'].toString() : '',
user:
jsonn['users'] != null
? Users.fromJson(jsonn['users'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
userId: userId,
avatar: avatar,
username: username,
firstName: firstName,
lastName: lastName,
bio: bio,
address: address,
birthDate: birthDate,
nik: nik,
// 'users': user?.toJson(),
);
}
static const _unset = Object();
Profiles copyWith({
Object? id = _unset,
Object? userId = _unset,
Object? avatar = _unset,
Object? username = _unset,
Object? firstName = _unset,
Object? lastName = _unset,
Object? bio = _unset,
Object? address = _unset,
Object? birthDate = _unset,
Object? nik = _unset,
Object? user = _unset,
}) {
return Profiles(
id: id == _unset ? this.id : id as String,
userId: userId == _unset ? this.userId : userId as String,
avatar: avatar == _unset ? this.avatar : avatar as String?,
username: username == _unset ? this.username : username as String?,
firstName: firstName == _unset ? this.firstName : firstName as String?,
lastName: lastName == _unset ? this.lastName : lastName as String?,
bio: bio == _unset ? this.bio : bio as String?,
address:
address == _unset ? this.address : address as Map<String, dynamic>?,
birthDate: birthDate == _unset ? this.birthDate : birthDate as DateTime?,
nik: nik == _unset ? this.nik : nik as String,
user: user == _unset ? this.user : user as Users?,
);
}
}

View File

@ -0,0 +1,191 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class Resources implements SupadartClass<Resources> {
final String id;
final String name;
final String? type;
final String? description;
final String? instanceRole;
final String? relations;
final Map<String, dynamic>? attributes;
final DateTime createdAt;
final DateTime updatedAt;
const Resources({
required this.id,
required this.name,
this.type,
this.description,
this.instanceRole,
this.relations,
this.attributes,
required this.createdAt,
required this.updatedAt,
});
static String get table_name => 'resources';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_type => 'type';
static String get c_description => 'description';
static String get c_instanceRole => 'instance_role';
static String get c_relations => 'relations';
static String get c_attributes => 'attributes';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Resources> converter(List<Map<String, dynamic>> data) {
return data.map(Resources.fromJson).toList();
}
static Resources converterSingle(Map<String, dynamic> data) {
return Resources.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
String? type,
String? description,
String? instanceRole,
String? relations,
Map<String, dynamic>? attributes,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (type != null) 'type': type,
if (description != null) 'description': description,
if (instanceRole != null) 'instance_role': instanceRole,
if (relations != null) 'relations': relations,
if (attributes != null) 'attributes': attributes,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String name,
String? type,
String? description,
String? instanceRole,
String? relations,
Map<String, dynamic>? attributes,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
type: type,
description: description,
instanceRole: instanceRole,
relations: relations,
attributes: attributes,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
String? type,
String? description,
String? instanceRole,
String? relations,
Map<String, dynamic>? attributes,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
type: type,
description: description,
instanceRole: instanceRole,
relations: relations,
attributes: attributes,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Resources.fromJson(Map<String, dynamic> jsonn) {
return Resources(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
type: jsonn['type'] != null ? jsonn['type'].toString() : null,
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
instanceRole:
jsonn['instance_role'] != null
? jsonn['instance_role'].toString()
: null,
relations:
jsonn['relations'] != null ? jsonn['relations'].toString() : null,
attributes:
jsonn['attributes'] != null
? jsonn['attributes'] as Map<String, dynamic>
: null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
type: type,
description: description,
instanceRole: instanceRole,
relations: relations,
attributes: attributes,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static const _unset = Object();
Resources copyWith({
Object? id = _unset,
Object? name = _unset,
Object? type = _unset,
Object? description = _unset,
Object? instanceRole = _unset,
Object? relations = _unset,
Object? attributes = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
}) {
return Resources(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String,
type: type == _unset ? this.type : type as String?,
description:
description == _unset ? this.description : description as String?,
instanceRole:
instanceRole == _unset ? this.instanceRole : instanceRole as String?,
relations: relations == _unset ? this.relations : relations as String?,
attributes:
attributes == _unset
? this.attributes
: attributes as Map<String, dynamic>?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
);
}
}

View File

@ -0,0 +1,128 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_header.dart';
class Roles implements SupadartClass<Roles> {
final String id;
final String name;
final String? description;
final DateTime createdAt;
final DateTime updatedAt;
const Roles({
required this.id,
required this.name,
this.description,
required this.createdAt,
required this.updatedAt,
});
static String get table_name => 'roles';
static String get c_id => 'id';
static String get c_name => 'name';
static String get c_description => 'description';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static List<Roles> converter(List<Map<String, dynamic>> data) {
return data.map(Roles.fromJson).toList();
}
static Roles converterSingle(Map<String, dynamic> data) {
return Roles.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? name,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return {
if (id != null) 'id': id,
if (name != null) 'name': name,
if (description != null) 'description': description,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
};
}
static Map<String, dynamic> insert({
String? id,
required String name,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static Map<String, dynamic> update({
String? id,
String? name,
String? description,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory Roles.fromJson(Map<String, dynamic> jsonn) {
return Roles(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
name: jsonn['name'] != null ? jsonn['name'].toString() : '',
description:
jsonn['description'] != null ? jsonn['description'].toString() : null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
name: name,
description: description,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
static const _unset = Object();
Roles copyWith({
Object? id = _unset,
Object? name = _unset,
Object? description = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
}) {
return Roles(
id: id == _unset ? this.id : id as String,
name: name == _unset ? this.name : name as String,
description:
description == _unset ? this.description : description as String?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
);
}
}

View File

@ -0,0 +1,408 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';
class Users implements SupadartClass<Users> {
final String id;
final String rolesId;
final String email;
final String? phone;
final String? encryptedPassword;
final DateTime? invitedAt;
final DateTime? confirmedAt;
final DateTime? emailConfirmedAt;
final DateTime? recoverySentAt;
final DateTime? lastSignInAt;
final Map<String, dynamic>? appMetadata;
final Map<String, dynamic>? userMetadata;
final DateTime createdAt;
final DateTime updatedAt;
final DateTime? bannedUntil;
final bool isAnonymous;
final String? bannedReason;
final bool isBanned;
final int panicStrike;
final int spoofingAttempts;
final Roles? role;
final Profiles? profile;
const Users({
required this.id,
required this.rolesId,
required this.email,
this.phone,
this.encryptedPassword,
this.invitedAt,
this.confirmedAt,
this.emailConfirmedAt,
this.recoverySentAt,
this.lastSignInAt,
this.appMetadata,
this.userMetadata,
required this.createdAt,
required this.updatedAt,
this.bannedUntil,
required this.isAnonymous,
this.bannedReason,
required this.isBanned,
required this.panicStrike,
required this.spoofingAttempts,
this.role,
this.profile,
});
static String get table_name => 'users';
static String get c_id => 'id';
static String get c_rolesId => 'roles_id';
static String get c_email => 'email';
static String get c_phone => 'phone';
static String get c_encryptedPassword => 'encrypted_password';
static String get c_invitedAt => 'invited_at';
static String get c_confirmedAt => 'confirmed_at';
static String get c_emailConfirmedAt => 'email_confirmed_at';
static String get c_recoverySentAt => 'recovery_sent_at';
static String get c_lastSignInAt => 'last_sign_in_at';
static String get c_appMetadata => 'app_metadata';
static String get c_userMetadata => 'user_metadata';
static String get c_createdAt => 'created_at';
static String get c_updatedAt => 'updated_at';
static String get c_bannedUntil => 'banned_until';
static String get c_isAnonymous => 'is_anonymous';
static String get c_bannedReason => 'banned_reason';
static String get c_isBanned => 'is_banned';
static String get c_panicStrike => 'panic_strike';
static String get c_spoofingAttempts => 'spoofing_attempts';
static List<Users> converter(List<Map<String, dynamic>> data) {
return data.map(Users.fromJson).toList();
}
static Users converterSingle(Map<String, dynamic> data) {
return Users.fromJson(data);
}
static Map<String, dynamic> _generateMap({
String? id,
String? rolesId,
String? email,
String? phone,
String? encryptedPassword,
DateTime? invitedAt,
DateTime? confirmedAt,
DateTime? emailConfirmedAt,
DateTime? recoverySentAt,
DateTime? lastSignInAt,
Map<String, dynamic>? appMetadata,
Map<String, dynamic>? userMetadata,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? bannedUntil,
bool? isAnonymous,
String? bannedReason,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return {
if (id != null) 'id': id,
if (rolesId != null) 'roles_id': rolesId,
if (email != null) 'email': email,
if (phone != null) 'phone': phone,
if (encryptedPassword != null) 'encrypted_password': encryptedPassword,
if (invitedAt != null) 'invited_at': invitedAt.toUtc().toIso8601String(),
if (confirmedAt != null)
'confirmed_at': confirmedAt.toUtc().toIso8601String(),
if (emailConfirmedAt != null)
'email_confirmed_at': emailConfirmedAt.toUtc().toIso8601String(),
if (recoverySentAt != null)
'recovery_sent_at': recoverySentAt.toUtc().toIso8601String(),
if (lastSignInAt != null)
'last_sign_in_at': lastSignInAt.toUtc().toIso8601String(),
if (appMetadata != null) 'app_metadata': appMetadata,
if (userMetadata != null) 'user_metadata': userMetadata,
if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
if (bannedUntil != null)
'banned_until': bannedUntil.toUtc().toIso8601String(),
if (isAnonymous != null) 'is_anonymous': isAnonymous,
if (bannedReason != null) 'banned_reason': bannedReason,
if (isBanned != null) 'is_banned': isBanned,
if (panicStrike != null) 'panic_strike': panicStrike,
if (spoofingAttempts != null) 'spoofing_attempts': spoofingAttempts,
};
}
static Map<String, dynamic> insert({
String? id,
required String rolesId,
required String email,
String? phone,
String? encryptedPassword,
DateTime? invitedAt,
DateTime? confirmedAt,
DateTime? emailConfirmedAt,
DateTime? recoverySentAt,
DateTime? lastSignInAt,
Map<String, dynamic>? appMetadata,
Map<String, dynamic>? userMetadata,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? bannedUntil,
bool? isAnonymous,
String? bannedReason,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return _generateMap(
id: id,
rolesId: rolesId,
email: email,
phone: phone,
encryptedPassword: encryptedPassword,
invitedAt: invitedAt,
confirmedAt: confirmedAt,
emailConfirmedAt: emailConfirmedAt,
recoverySentAt: recoverySentAt,
lastSignInAt: lastSignInAt,
appMetadata: appMetadata,
userMetadata: userMetadata,
createdAt: createdAt,
updatedAt: updatedAt,
bannedUntil: bannedUntil,
isAnonymous: isAnonymous,
bannedReason: bannedReason,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
);
}
static Map<String, dynamic> update({
String? id,
String? rolesId,
String? email,
String? phone,
String? encryptedPassword,
DateTime? invitedAt,
DateTime? confirmedAt,
DateTime? emailConfirmedAt,
DateTime? recoverySentAt,
DateTime? lastSignInAt,
Map<String, dynamic>? appMetadata,
Map<String, dynamic>? userMetadata,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? bannedUntil,
bool? isAnonymous,
String? bannedReason,
bool? isBanned,
int? panicStrike,
int? spoofingAttempts,
}) {
return _generateMap(
id: id,
rolesId: rolesId,
email: email,
phone: phone,
encryptedPassword: encryptedPassword,
invitedAt: invitedAt,
confirmedAt: confirmedAt,
emailConfirmedAt: emailConfirmedAt,
recoverySentAt: recoverySentAt,
lastSignInAt: lastSignInAt,
appMetadata: appMetadata,
userMetadata: userMetadata,
createdAt: createdAt,
updatedAt: updatedAt,
bannedUntil: bannedUntil,
isAnonymous: isAnonymous,
bannedReason: bannedReason,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
);
}
factory Users.fromJson(Map<String, dynamic> jsonn) {
return Users(
id: jsonn['id'] != null ? jsonn['id'].toString() : '',
rolesId: jsonn['roles_id'] != null ? jsonn['roles_id'].toString() : '',
email: jsonn['email'] != null ? jsonn['email'].toString() : '',
phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
encryptedPassword:
jsonn['encrypted_password'] != null
? jsonn['encrypted_password'].toString()
: null,
invitedAt:
jsonn['invited_at'] != null
? DateTime.parse(jsonn['invited_at'].toString())
: null,
confirmedAt:
jsonn['confirmed_at'] != null
? DateTime.parse(jsonn['confirmed_at'].toString())
: null,
emailConfirmedAt:
jsonn['email_confirmed_at'] != null
? DateTime.parse(jsonn['email_confirmed_at'].toString())
: null,
recoverySentAt:
jsonn['recovery_sent_at'] != null
? DateTime.parse(jsonn['recovery_sent_at'].toString())
: null,
lastSignInAt:
jsonn['last_sign_in_at'] != null
? DateTime.parse(jsonn['last_sign_in_at'].toString())
: null,
appMetadata:
jsonn['app_metadata'] != null
? jsonn['app_metadata'] as Map<String, dynamic>
: null,
userMetadata:
jsonn['user_metadata'] != null
? jsonn['user_metadata'] as Map<String, dynamic>
: null,
createdAt:
jsonn['created_at'] != null
? DateTime.parse(jsonn['created_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
updatedAt:
jsonn['updated_at'] != null
? DateTime.parse(jsonn['updated_at'].toString())
: DateTime.fromMillisecondsSinceEpoch(0),
bannedUntil:
jsonn['banned_until'] != null
? DateTime.parse(jsonn['banned_until'].toString())
: null,
isAnonymous:
jsonn['is_anonymous'] != null ? jsonn['is_anonymous'] as bool : false,
bannedReason:
jsonn['banned_reason'] != null
? jsonn['banned_reason'].toString()
: null,
isBanned: jsonn['is_banned'] != null ? jsonn['is_banned'] as bool : false,
panicStrike:
jsonn['panic_strike'] != null
? int.parse(jsonn['panic_strike'].toString())
: 0,
spoofingAttempts:
jsonn['spoofing_attempts'] != null
? int.parse(jsonn['spoofing_attempts'].toString())
: 0,
role:
jsonn['roles'] != null
? Roles.fromJson(jsonn['roles'] as Map<String, dynamic>)
: null,
profile:
jsonn['profiles'] != null
? Profiles.fromJson(jsonn['profiles'] as Map<String, dynamic>)
: null,
);
}
Map<String, dynamic> toJson() {
return _generateMap(
id: id,
rolesId: rolesId,
email: email,
phone: phone,
encryptedPassword: encryptedPassword,
invitedAt: invitedAt,
confirmedAt: confirmedAt,
emailConfirmedAt: emailConfirmedAt,
recoverySentAt: recoverySentAt,
lastSignInAt: lastSignInAt,
appMetadata: appMetadata,
userMetadata: userMetadata,
createdAt: createdAt,
updatedAt: updatedAt,
bannedUntil: bannedUntil,
isAnonymous: isAnonymous,
bannedReason: bannedReason,
isBanned: isBanned,
panicStrike: panicStrike,
spoofingAttempts: spoofingAttempts,
// 'roles': role?.toJson(),
// 'profiles': profile?.toJson(),
);
}
static const _unset = Object();
Users copyWith({
Object? id = _unset,
Object? rolesId = _unset,
Object? email = _unset,
Object? phone = _unset,
Object? encryptedPassword = _unset,
Object? invitedAt = _unset,
Object? confirmedAt = _unset,
Object? emailConfirmedAt = _unset,
Object? recoverySentAt = _unset,
Object? lastSignInAt = _unset,
Object? appMetadata = _unset,
Object? userMetadata = _unset,
Object? createdAt = _unset,
Object? updatedAt = _unset,
Object? bannedUntil = _unset,
Object? isAnonymous = _unset,
Object? bannedReason = _unset,
Object? isBanned = _unset,
Object? panicStrike = _unset,
Object? spoofingAttempts = _unset,
Object? role = _unset,
Object? profile = _unset,
}) {
return Users(
id: id == _unset ? this.id : id as String,
rolesId: rolesId == _unset ? this.rolesId : rolesId as String,
email: email == _unset ? this.email : email as String,
phone: phone == _unset ? this.phone : phone as String?,
encryptedPassword:
encryptedPassword == _unset
? this.encryptedPassword
: encryptedPassword as String?,
invitedAt: invitedAt == _unset ? this.invitedAt : invitedAt as DateTime?,
confirmedAt:
confirmedAt == _unset ? this.confirmedAt : confirmedAt as DateTime?,
emailConfirmedAt:
emailConfirmedAt == _unset
? this.emailConfirmedAt
: emailConfirmedAt as DateTime?,
recoverySentAt:
recoverySentAt == _unset
? this.recoverySentAt
: recoverySentAt as DateTime?,
lastSignInAt:
lastSignInAt == _unset
? this.lastSignInAt
: lastSignInAt as DateTime?,
appMetadata:
appMetadata == _unset
? this.appMetadata
: appMetadata as Map<String, dynamic>?,
userMetadata:
userMetadata == _unset
? this.userMetadata
: userMetadata as Map<String, dynamic>?,
createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
bannedUntil:
bannedUntil == _unset ? this.bannedUntil : bannedUntil as DateTime?,
isAnonymous:
isAnonymous == _unset ? this.isAnonymous : isAnonymous as bool,
bannedReason:
bannedReason == _unset ? this.bannedReason : bannedReason as String?,
isBanned: isBanned == _unset ? this.isBanned : isBanned as bool,
panicStrike:
panicStrike == _unset ? this.panicStrike : panicStrike as int,
spoofingAttempts:
spoofingAttempts == _unset
? this.spoofingAttempts
: spoofingAttempts as int,
role: role == _unset ? this.role : role as Roles?,
profile: profile == _unset ? this.profile : profile as Profiles?,
);
}
}

View File

@ -0,0 +1,28 @@
library;
export '../src/features/map/models/supadart-models/cities_model_supadart.dart';
export '../src/features/explore/models/supadart-models/contact_messages_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/crime_categories_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/crime_incidents_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/crimes_model_supadart.dart';
export '../src/features/map/models/supadart-models/demographics_model_supadart.dart';
export '../src/features/map/models/supadart-models/districts_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/events_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/evidence_model_supadart.dart';
export '../src/features/map/models/supadart-models/geographics_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/incident_logs_model_supadart.dart';
export '../src/features/map/models/supadart-models/location_logs_model_supadart.dart';
export '../src/features/map/models/supadart-models/locations_model_supadart.dart';
export '../src/features/explore/models/supadart-models/logs_model_supadart.dart';
export '../src/features/daily-ops/models/supadart-models/officers_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/panic_button_logs_model_supadart.dart';
export '../src/features/daily-ops/models/supadart-models/patrol_units_model_supadart.dart';
export '../src/features/personalization/models/supadart-models/permissions_model_supadart.dart';
export '../src/features/explore/models/supadart-models/prisma_migrations_model_supadart.dart';
export '../src/features/personalization/models/supadart-models/profiles_model_supadart.dart';
export '../src/features/personalization/models/supadart-models/resources_model_supadart.dart';
export '../src/features/personalization/models/supadart-models/roles_model_supadart.dart';
export '../src/features/panic-button/models/supadart-models/sessions_model_supadart.dart';
export '../src/features/daily-ops/models/supadart-models/unit_statistics_model_supadart.dart';
export '../src/features/daily-ops/models/supadart-models/units_model_supadart.dart';
export '../src/features/personalization/models/supadart-models/users_model_supadart.dart';

View File

@ -0,0 +1,69 @@
// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison,prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the SupaDart configuration.
// SDK
import 'package:supabase_flutter/supabase_flutter.dart';
// No Intl package needed
// No Dart Convert needed
// Supadart Class
abstract class SupadartClass<T> {
static Map<String, dynamic> insert(Map<String, dynamic> data) {
throw UnimplementedError();
}
static Map<String, dynamic> update(Map<String, dynamic> data) {
throw UnimplementedError();
}
factory SupadartClass.fromJson(Map<String, dynamic> json) {
throw UnimplementedError();
}
static converter(List<Map<String, dynamic>> data) {
throw UnimplementedError();
}
static converterSingle(Map<String, dynamic> data) {
throw UnimplementedError();
}
}
// Supabase Client Extension
extension SupadartClient on SupabaseClient {
SupabaseQueryBuilder get incident_logs => from('incident_logs');
SupabaseQueryBuilder get demographics => from('demographics');
SupabaseQueryBuilder get contact_messages => from('contact_messages');
SupabaseQueryBuilder get resources => from('resources');
SupabaseQueryBuilder get profiles => from('profiles');
SupabaseQueryBuilder get _prisma_migrations => from('_prisma_migrations');
SupabaseQueryBuilder get locations => from('locations');
SupabaseQueryBuilder get crimes => from('crimes');
SupabaseQueryBuilder get geographics => from('geographics');
SupabaseQueryBuilder get unit_statistics => from('unit_statistics');
SupabaseQueryBuilder get districts => from('districts');
SupabaseQueryBuilder get location_logs => from('location_logs');
SupabaseQueryBuilder get crime_incidents => from('crime_incidents');
SupabaseQueryBuilder get permissions => from('permissions');
SupabaseQueryBuilder get panic_button_logs => from('panic_button_logs');
SupabaseQueryBuilder get crime_categories => from('crime_categories');
SupabaseQueryBuilder get patrol_units => from('patrol_units');
SupabaseQueryBuilder get units => from('units');
SupabaseQueryBuilder get cities => from('cities');
SupabaseQueryBuilder get logs => from('logs');
SupabaseQueryBuilder get officers => from('officers');
SupabaseQueryBuilder get events => from('events');
SupabaseQueryBuilder get evidence => from('evidence');
SupabaseQueryBuilder get users => from('users');
SupabaseQueryBuilder get sessions => from('sessions');
SupabaseQueryBuilder get roles => from('roles');
}
// Supabase Storage Client Extension
extension SupadartStorageClient on SupabaseStorageClient {}
// Enums
// Utils

View File

@ -32,7 +32,7 @@ dependencies:
sdk: flutter
# Utility Packages
intl:
intl: ^0.19.0
logger:
url_launcher:
flutter_native_splash:
@ -94,7 +94,7 @@ dependencies:
google_fonts:
# Localization
flutter_localizations
dev_dependencies:
flutter_test:

View File

@ -0,0 +1,37 @@
# Don't want to expose your supabase credentials? you have two options
# 1. Use a .env file to specify SUPABASE_URL and SUPABASE_ANON_KEY
# 2. Specify --url and --key in the CLI (ex. supadart -u <url> -k <key>)
SUPABASE_URL:
SUPABASE_ANON_KEY:
# Enums in your database? map them here (Case Sensitive)
# Please take a look at the documentation to see how to work with enums
enums:
# mood: [happy, sad, neutral, excited, angry]
crime_rates: ["critical", "high", "low", "medium"]
crime_status:
["closed", "open", "resolved", "under_investigation", "unresolved"]
session_status: ["active", "completed"]
status_contact_messages: ["closed", "new", "read", "replied"]
unit_type: ["other", "polda", "polres", "polsek"]
# Optional, where to place the generated classes files default: ./lib/models/
output: lib/models/
# Set to true, if you want to generate separated files for each classes
separated: true
# Set to true, if you are not using Flutter, just normal Dart project
dart: false
# Optional, used to map table names to class names(case-sensitive)
mappings:
_prisma_migrations: PrismaMigrations
# books: book
# categories: category
# children: child
# people: person
# Optional, used to exclude methods from generated classes, comment out to include them
exclude:
# - toJson
# - copyWith
- New

View File

@ -43,8 +43,8 @@ DECLARE
loc_lng FLOAT;
unit_lat FLOAT;
unit_lng FLOAT;
loc_point GEOGRAPHY;
unit_point GEOGRAPHY;
loc_point gis.GEOGRAPHY;
unit_point gis.GEOGRAPHY;
BEGIN
-- Ambil lat/lng dari location yang baru
SELECT gis.ST_Y(NEW.location::gis.geometry), gis.ST_X(NEW.location::gis.geometry)

View File

@ -0,0 +1,567 @@
-- CreateExtension
CREATE SCHEMA IF NOT EXISTS "extensions";
CREATE SCHEMA IF NOT EXISTS "gis";
CREATE SCHEMA IF NOT EXISTS "pgsodium";
CREATE SCHEMA IF NOT EXISTS "vault";
CREATE SCHEMA IF NOT EXISTS graphql;
CREATE EXTENSION IF NOT EXISTS pg_graphql WITH SCHEMA graphql;
CREATE EXTENSION IF NOT EXISTS pg_net WITH SCHEMA "extensions";
CREATE EXTENSION IF NOT EXISTS pgsodium WITH SCHEMA "pgsodium";
CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA "vault";
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA extensions;
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA extensions;
CREATE EXTENSION IF NOT EXISTS pgjwt WITH SCHEMA extensions;
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE EXTENSION IF NOT EXISTS "postgis" WITH SCHEMA "gis";
-- CreateExtension
CREATE EXTENSION IF NOT EXISTS "postgis" WITH SCHEMA "gis";
-- CreateExtension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions";
-- CreateEnum
CREATE TYPE "session_status" AS ENUM ('active', 'completed');
-- CreateEnum
CREATE TYPE "status_contact_messages" AS ENUM ('new', 'read', 'replied', 'closed');
-- CreateEnum
CREATE TYPE "crime_rates" AS ENUM ('low', 'medium', 'high', 'critical');
-- CreateEnum
CREATE TYPE "crime_status" AS ENUM ('open', 'closed', 'under_investigation', 'resolved', 'unresolved');
-- CreateEnum
CREATE TYPE "unit_type" AS ENUM ('polda', 'polsek', 'polres', 'other');
-- CreateTable
CREATE TABLE "profiles" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"user_id" UUID NOT NULL,
"avatar" VARCHAR(355),
"username" VARCHAR(255),
"first_name" VARCHAR(255),
"last_name" VARCHAR(255),
"bio" VARCHAR,
"address" JSON,
"birth_date" TIMESTAMP(3),
CONSTRAINT "profiles_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "users" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"roles_id" UUID NOT NULL,
"email" VARCHAR(255) NOT NULL,
"phone" VARCHAR(20),
"encrypted_password" VARCHAR(255),
"invited_at" TIMESTAMPTZ(6),
"confirmed_at" TIMESTAMPTZ(6),
"email_confirmed_at" TIMESTAMPTZ(6),
"recovery_sent_at" TIMESTAMPTZ(6),
"last_sign_in_at" TIMESTAMPTZ(6),
"app_metadata" JSONB,
"user_metadata" JSONB,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"banned_until" TIMESTAMPTZ(6),
"is_anonymous" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "roles" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" VARCHAR(255) NOT NULL,
"description" TEXT,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "roles_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "sessions" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"user_id" UUID NOT NULL,
"event_id" UUID NOT NULL,
"status" "session_status" NOT NULL DEFAULT 'active',
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "sessions_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "events" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" VARCHAR(255) NOT NULL,
"description" VARCHAR(255),
"code" TEXT NOT NULL,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" UUID NOT NULL,
CONSTRAINT "events_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "resources" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" VARCHAR(255) NOT NULL,
"type" TEXT,
"description" TEXT,
"instance_role" TEXT,
"relations" TEXT,
"attributes" JSONB,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "resources_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "permissions" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"action" TEXT NOT NULL,
"resource_id" UUID NOT NULL,
"role_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL,
CONSTRAINT "permissions_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "cities" (
"id" VARCHAR(20) NOT NULL,
"name" VARCHAR(100) NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "cities_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "crime_incidents" (
"id" VARCHAR(20) NOT NULL,
"crime_id" VARCHAR(20) NOT NULL,
"crime_category_id" VARCHAR(20) NOT NULL,
"location_id" UUID NOT NULL,
"description" TEXT NOT NULL,
"victim_count" INTEGER NOT NULL,
"status" "crime_status" DEFAULT 'open',
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"timestamp" TIMESTAMPTZ(6) NOT NULL,
CONSTRAINT "crime_incidents_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "crime_categories" (
"id" VARCHAR(20) NOT NULL,
"name" VARCHAR(255) NOT NULL,
"description" TEXT NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"type" VARCHAR(100),
CONSTRAINT "crime_categories_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "crimes" (
"id" VARCHAR(20) NOT NULL,
"district_id" VARCHAR(20) NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"level" "crime_rates" NOT NULL DEFAULT 'low',
"method" VARCHAR(100),
"month" INTEGER,
"number_of_crime" INTEGER NOT NULL DEFAULT 0,
"score" DOUBLE PRECISION NOT NULL DEFAULT 0,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"year" INTEGER,
CONSTRAINT "crimes_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "demographics" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"district_id" VARCHAR(20) NOT NULL,
"population" INTEGER NOT NULL,
"number_of_unemployed" INTEGER NOT NULL,
"population_density" DOUBLE PRECISION NOT NULL,
"year" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "demographics_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "districts" (
"id" VARCHAR(20) NOT NULL,
"city_id" VARCHAR(20) NOT NULL,
"name" VARCHAR(100) NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "districts_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "locations" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"district_id" VARCHAR(20) NOT NULL,
"event_id" UUID NOT NULL,
"address" VARCHAR(255),
"type" VARCHAR(100),
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,
"land_area" DOUBLE PRECISION,
"polygon" gis.geometry,
"geometry" gis.geometry,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"location" gis.geography NOT NULL,
CONSTRAINT "locations_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "incident_logs" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"user_id" UUID NOT NULL,
"location_id" UUID NOT NULL,
"category_id" VARCHAR(20) NOT NULL,
"description" TEXT,
"source" TEXT DEFAULT 'manual',
"time" TIMESTAMPTZ(6) NOT NULL,
"verified" BOOLEAN DEFAULT false,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "incident_logs_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "units" (
"code_unit" VARCHAR(20) NOT NULL,
"district_id" VARCHAR(20) NOT NULL,
"name" VARCHAR(100) NOT NULL,
"description" TEXT,
"type" "unit_type" NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"address" TEXT,
"land_area" DOUBLE PRECISION,
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,
"location" gis.geography NOT NULL
);
-- CreateTable
CREATE TABLE "unit_statistics" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"code_unit" VARCHAR(20) NOT NULL,
"crime_total" INTEGER NOT NULL,
"crime_cleared" INTEGER NOT NULL,
"percentage" DOUBLE PRECISION,
"pending" INTEGER,
"month" INTEGER NOT NULL,
"year" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "unit_statistics_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "geographics" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"district_id" VARCHAR(20) NOT NULL,
"address" TEXT,
"longitude" DOUBLE PRECISION NOT NULL,
"latitude" DOUBLE PRECISION NOT NULL,
"land_area" DOUBLE PRECISION,
"polygon" gis.geometry,
"geometry" gis.geometry,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"description" TEXT,
"type" VARCHAR(100),
"location" gis.geography NOT NULL,
"year" INTEGER,
CONSTRAINT "geographics_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "contact_messages" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" VARCHAR(255),
"email" VARCHAR(255),
"phone" VARCHAR(20),
"message_type" VARCHAR(50),
"message_type_label" VARCHAR(50),
"message" TEXT,
"status" "status_contact_messages" NOT NULL DEFAULT 'new',
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL,
CONSTRAINT "contact_messages_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "logs" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"action" VARCHAR(100) NOT NULL,
"entity" VARCHAR(100) NOT NULL,
"entity_id" VARCHAR(100),
"changes" JSONB,
"user_id" VARCHAR(100),
"ip_address" VARCHAR(100),
"user_agent" VARCHAR(255),
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "logs_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "profiles_user_id_key" ON "profiles"("user_id");
-- CreateIndex
CREATE UNIQUE INDEX "profiles_username_key" ON "profiles"("username");
-- CreateIndex
CREATE INDEX "profiles_user_id_idx" ON "profiles"("user_id");
-- CreateIndex
CREATE INDEX "profiles_username_idx" ON "profiles"("username");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "users_phone_key" ON "users"("phone");
-- CreateIndex
CREATE INDEX "users_is_anonymous_idx" ON "users"("is_anonymous");
-- CreateIndex
CREATE INDEX "users_created_at_idx" ON "users"("created_at");
-- CreateIndex
CREATE INDEX "users_updated_at_idx" ON "users"("updated_at");
-- CreateIndex
CREATE UNIQUE INDEX "roles_name_key" ON "roles"("name");
-- CreateIndex
CREATE INDEX "idx_sessions_user_id" ON "sessions"("user_id");
-- CreateIndex
CREATE INDEX "idx_sessions_event_id" ON "sessions"("event_id");
-- CreateIndex
CREATE INDEX "idx_sessions_status" ON "sessions"("status");
-- CreateIndex
CREATE UNIQUE INDEX "events_code_key" ON "events"("code");
-- CreateIndex
CREATE INDEX "idx_events_name" ON "events"("name");
-- CreateIndex
CREATE INDEX "idx_events_code" ON "events"("code");
-- CreateIndex
CREATE INDEX "idx_events_id" ON "events"("id");
-- CreateIndex
CREATE UNIQUE INDEX "resources_name_key" ON "resources"("name");
-- CreateIndex
CREATE INDEX "idx_cities_name" ON "cities"("name");
-- CreateIndex
CREATE INDEX "idx_crime_incidents_crime_category_id" ON "crime_incidents"("crime_category_id");
-- CreateIndex
CREATE INDEX "idx_crime_incidents_date" ON "crime_incidents"("timestamp");
-- CreateIndex
CREATE INDEX "idx_crime_incidents_location_id" ON "crime_incidents"("location_id");
-- CreateIndex
CREATE INDEX "idx_crime_incidents_crime_id" ON "crime_incidents"("crime_id");
-- CreateIndex
CREATE INDEX "idx_crime_incidents_status" ON "crime_incidents"("status");
-- CreateIndex
CREATE INDEX "idx_crime_categories_name" ON "crime_categories"("name");
-- CreateIndex
CREATE INDEX "idx_crimes_district_id_year_month" ON "crimes"("district_id", "year", "month");
-- CreateIndex
CREATE INDEX "idx_crimes_month_year" ON "crimes"("month", "year");
-- CreateIndex
CREATE INDEX "idx_crimes_month" ON "crimes"("month");
-- CreateIndex
CREATE INDEX "idx_crimes_year" ON "crimes"("year");
-- CreateIndex
CREATE INDEX "idx_crimes_district_id_month" ON "crimes"("district_id", "month");
-- CreateIndex
CREATE INDEX "idx_demographics_year" ON "demographics"("year");
-- CreateIndex
CREATE UNIQUE INDEX "demographics_district_id_year_key" ON "demographics"("district_id", "year");
-- CreateIndex
CREATE INDEX "idx_districts_city_id" ON "districts"("city_id");
-- CreateIndex
CREATE INDEX "idx_districts_name" ON "districts"("name");
-- CreateIndex
CREATE INDEX "idx_locations_district_id" ON "locations"("district_id");
-- CreateIndex
CREATE INDEX "idx_locations_type" ON "locations"("type");
-- CreateIndex
CREATE INDEX "idx_locations_geography" ON "locations" USING GIST ("location");
-- CreateIndex
CREATE INDEX "idx_incident_logs_category_id" ON "incident_logs"("category_id");
-- CreateIndex
CREATE INDEX "idx_incident_logs_time" ON "incident_logs"("time");
-- CreateIndex
CREATE UNIQUE INDEX "units_code_unit_key" ON "units"("code_unit");
-- CreateIndex
CREATE INDEX "idx_units_name" ON "units"("name");
-- CreateIndex
CREATE INDEX "idx_units_type" ON "units"("type");
-- CreateIndex
CREATE INDEX "idx_units_code_unit" ON "units"("code_unit");
-- CreateIndex
CREATE INDEX "idx_units_district_id" ON "units"("district_id");
-- CreateIndex
CREATE INDEX "idx_unit_location" ON "units" USING GIST ("location");
-- CreateIndex
CREATE INDEX "idx_unit_statistics_year_month" ON "unit_statistics"("year", "month");
-- CreateIndex
CREATE UNIQUE INDEX "unit_statistics_code_unit_month_year_key" ON "unit_statistics"("code_unit", "month", "year");
-- CreateIndex
CREATE INDEX "idx_geographics_district_id" ON "geographics"("district_id");
-- CreateIndex
CREATE INDEX "idx_geographics_type" ON "geographics"("type");
-- CreateIndex
CREATE INDEX "idx_geographics_district_id_year" ON "geographics"("district_id", "year");
-- CreateIndex
CREATE INDEX "idx_geographics_location" ON "geographics" USING GIST ("location");
-- CreateIndex
CREATE INDEX "logs_entity_idx" ON "logs"("entity");
-- CreateIndex
CREATE INDEX "logs_user_id_idx" ON "logs"("user_id");
-- AddForeignKey
ALTER TABLE "profiles" ADD CONSTRAINT "profiles_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_id_fkey" FOREIGN KEY ("roles_id") REFERENCES "roles"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "events"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "events" ADD CONSTRAINT "events_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "permissions" ADD CONSTRAINT "permissions_resource_id_fkey" FOREIGN KEY ("resource_id") REFERENCES "resources"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "permissions" ADD CONSTRAINT "permissions_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "roles"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "crime_incidents" ADD CONSTRAINT "crime_incidents_crime_category_id_fkey" FOREIGN KEY ("crime_category_id") REFERENCES "crime_categories"("id") ON DELETE RESTRICT ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "crime_incidents" ADD CONSTRAINT "crime_incidents_crime_id_fkey" FOREIGN KEY ("crime_id") REFERENCES "crimes"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "crime_incidents" ADD CONSTRAINT "crime_incidents_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "crimes" ADD CONSTRAINT "crimes_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "demographics" ADD CONSTRAINT "demographics_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "districts" ADD CONSTRAINT "districts_city_id_fkey" FOREIGN KEY ("city_id") REFERENCES "cities"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "locations" ADD CONSTRAINT "locations_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "locations" ADD CONSTRAINT "locations_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "events"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "incident_logs" ADD CONSTRAINT "fk_incident_category" FOREIGN KEY ("category_id") REFERENCES "crime_categories"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "incident_logs" ADD CONSTRAINT "incident_logs_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "incident_logs" ADD CONSTRAINT "incident_logs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "units" ADD CONSTRAINT "units_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "unit_statistics" ADD CONSTRAINT "unit_statistics_code_unit_fkey" FOREIGN KEY ("code_unit") REFERENCES "units"("code_unit") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "geographics" ADD CONSTRAINT "geographics_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,14 @@
-- AlterTable
ALTER TABLE "units" ADD COLUMN "phone" TEXT;
grant all privileges on all tables in schema public to postgres, anon, authenticated, service_role, prisma;
grant all privileges on all functions in schema public to postgres, anon, authenticated, service_role, prisma;
grant all privileges on all sequences in schema public to postgres, anon, authenticated, service_role, prisma;
alter default privileges in schema public grant all on tables to postgres, anon, authenticated, service_role, prisma;
alter default privileges in schema public grant all on functions to postgres, anon, authenticated, service_role, prisma;
alter default privileges in schema public grant all on sequences to postgres, anon, authenticated, service_role, prisma;
grant usage on schema "public" to anon;
grant usage on schema "public" to authenticated;
grant usage on schema "public" to prisma;

View File

@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `phone` on the `units` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "units" DROP COLUMN "phone";

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "units" ADD COLUMN "phone" TEXT;

View File

@ -0,0 +1,41 @@
/*
Warnings:
- You are about to drop the column `code_unit` on the `unit_statistics` table. All the data in the column will be lost.
- A unique constraint covering the columns `[unit_id,month,year]` on the table `unit_statistics` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[district_id]` on the table `units` will be added. If there are existing duplicate values, this will fail.
- Made the column `year` on table `crimes` required. This step will fail if there are existing NULL values in that column.
- Added the required column `unit_id` to the `unit_statistics` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "unit_statistics" DROP CONSTRAINT "unit_statistics_code_unit_fkey";
-- DropForeignKey
ALTER TABLE "units" DROP CONSTRAINT "units_district_id_fkey";
-- DropIndex
DROP INDEX "unit_statistics_code_unit_month_year_key";
-- AlterTable
ALTER TABLE "crimes" ALTER COLUMN "year" SET NOT NULL;
-- AlterTable
ALTER TABLE "unit_statistics" DROP COLUMN "code_unit",
ADD COLUMN "unit_id" UUID NOT NULL;
-- AlterTable
ALTER TABLE "units" ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "units_pkey" PRIMARY KEY ("id");
-- CreateIndex
CREATE UNIQUE INDEX "unit_statistics_unit_id_month_year_key" ON "unit_statistics"("unit_id", "month", "year");
-- CreateIndex
CREATE UNIQUE INDEX "units_district_id_key" ON "units"("district_id");
-- AddForeignKey
ALTER TABLE "units" ADD CONSTRAINT "units_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "districts"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "unit_statistics" ADD CONSTRAINT "unit_statistics_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "units"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,29 @@
/*
Warnings:
- You are about to drop the column `unit_id` on the `unit_statistics` table. All the data in the column will be lost.
- The primary key for the `units` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `units` table. All the data in the column will be lost.
- A unique constraint covering the columns `[code_unit,month,year]` on the table `unit_statistics` will be added. If there are existing duplicate values, this will fail.
- Added the required column `code_unit` to the `unit_statistics` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "unit_statistics" DROP CONSTRAINT "unit_statistics_unit_id_fkey";
-- DropIndex
DROP INDEX "unit_statistics_unit_id_month_year_key";
-- AlterTable
ALTER TABLE "unit_statistics" DROP COLUMN "unit_id",
ADD COLUMN "code_unit" VARCHAR(20) NOT NULL;
-- AlterTable
ALTER TABLE "units" DROP CONSTRAINT "units_pkey",
DROP COLUMN "id";
-- CreateIndex
CREATE UNIQUE INDEX "unit_statistics_code_unit_month_year_key" ON "unit_statistics"("code_unit", "month", "year");
-- AddForeignKey
ALTER TABLE "unit_statistics" ADD CONSTRAINT "unit_statistics_code_unit_fkey" FOREIGN KEY ("code_unit") REFERENCES "units"("code_unit") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "crimes" ALTER COLUMN "year" DROP NOT NULL;

View File

@ -0,0 +1,15 @@
/*
Warnings:
- Added the required column `city_id` to the `units` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "units_district_id_key";
-- AlterTable
ALTER TABLE "units" ADD COLUMN "city_id" VARCHAR(20) NOT NULL,
ADD CONSTRAINT "units_pkey" PRIMARY KEY ("code_unit");
-- AddForeignKey
ALTER TABLE "units" ADD CONSTRAINT "units_city_id_fkey" FOREIGN KEY ("city_id") REFERENCES "cities"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "crimes" ADD COLUMN "source_type" VARCHAR(100);
-- AlterTable
ALTER TABLE "locations" ADD COLUMN "distance" DOUBLE PRECISION;

View File

@ -0,0 +1,30 @@
/*
Warnings:
- You are about to drop the column `distance` on the `locations` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "locations" DROP COLUMN "distance",
ADD COLUMN "distance_from_unit" DOUBLE PRECISION;
-- CreateTable
CREATE TABLE "location_logs" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"user_id" UUID NOT NULL,
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,
"location" gis.geography(Point,4326) NOT NULL,
"timestamp" TIMESTAMPTZ(6) NOT NULL,
"description" VARCHAR(255),
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "location_logs_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "idx_location_logs_timestamp" ON "location_logs"("timestamp");
-- CreateIndex
CREATE INDEX "idx_location_logs_user_id" ON "location_logs"("user_id");

View File

@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the `location_logs` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
DROP TABLE "location_logs";

View File

@ -0,0 +1,73 @@
/*
Warnings:
- You are about to drop the column `distance_from_unit` on the `locations` table. All the data in the column will be lost.
- You are about to drop the column `code_unit` on the `unit_statistics` table. All the data in the column will be lost.
- The primary key for the `units` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `city_id` on the `units` table. All the data in the column will be lost.
- You are about to drop the column `phone` on the `units` table. All the data in the column will be lost.
- A unique constraint covering the columns `[unit_id,month,year]` on the table `unit_statistics` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[district_id]` on the table `units` will be added. If there are existing duplicate values, this will fail.
- Made the column `year` on table `crimes` required. This step will fail if there are existing NULL values in that column.
- Added the required column `unit_id` to the `unit_statistics` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "unit_statistics" DROP CONSTRAINT "unit_statistics_code_unit_fkey";
-- DropForeignKey
ALTER TABLE "units" DROP CONSTRAINT "units_city_id_fkey";
-- DropIndex
DROP INDEX "unit_statistics_code_unit_month_year_key";
-- AlterTable
ALTER TABLE "crimes" ALTER COLUMN "year" SET NOT NULL;
-- AlterTable
ALTER TABLE "locations" DROP COLUMN "distance_from_unit",
ADD COLUMN "distance_to_unit" DOUBLE PRECISION;
-- AlterTable
ALTER TABLE "unit_statistics" DROP COLUMN "code_unit",
ADD COLUMN "unit_id" UUID NOT NULL;
-- AlterTable
ALTER TABLE "units" DROP CONSTRAINT "units_pkey",
DROP COLUMN "city_id",
DROP COLUMN "phone",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "units_pkey" PRIMARY KEY ("id");
-- CreateTable
CREATE TABLE "location_logs" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"user_id" UUID NOT NULL,
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,
"location" gis.geography NOT NULL,
"timestamp" TIMESTAMPTZ(6) NOT NULL,
"description" VARCHAR(255),
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "location_logs_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "idx_location_logs_timestamp" ON "location_logs"("timestamp");
-- CreateIndex
CREATE INDEX "idx_location_logs_user_id" ON "location_logs"("user_id");
-- CreateIndex
CREATE UNIQUE INDEX "unit_statistics_unit_id_month_year_key" ON "unit_statistics"("unit_id", "month", "year");
-- CreateIndex
CREATE UNIQUE INDEX "units_district_id_key" ON "units"("district_id");
-- AddForeignKey
ALTER TABLE "unit_statistics" ADD CONSTRAINT "unit_statistics_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "units"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "location_logs" ADD CONSTRAINT "location_logs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "crimes" ALTER COLUMN "year" DROP NOT NULL;

View File

@ -0,0 +1,12 @@
-- CreateTable
CREATE TABLE "test" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" VARCHAR(100) NOT NULL,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "test_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "idx_test_name" ON "test"("name");

View File

@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the `test` table. If the table is not empty, all the data it contains will be lost.
*/
-- AlterTable
ALTER TABLE "crimes" ADD COLUMN "crime_cleared" INTEGER NOT NULL DEFAULT 0;
-- DropTable
DROP TABLE "test";

View File

@ -0,0 +1,12 @@
/*
Warnings:
- Added the required column `city_id` to the `units` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "units" ADD COLUMN "city_id" VARCHAR(20) NOT NULL,
ALTER COLUMN "district_id" DROP NOT NULL;
-- AddForeignKey
ALTER TABLE "units" ADD CONSTRAINT "units_city_id_fkey" FOREIGN KEY ("city_id") REFERENCES "cities"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "units" ADD COLUMN "phone" TEXT;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "crimes" ADD COLUMN "avg_crime" DOUBLE PRECISION NOT NULL DEFAULT 0;

View File

@ -0,0 +1,30 @@
/*
Warnings:
- You are about to drop the column `unit_id` on the `unit_statistics` table. All the data in the column will be lost.
- The primary key for the `units` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `units` table. All the data in the column will be lost.
- A unique constraint covering the columns `[code_unit,month,year]` on the table `unit_statistics` will be added. If there are existing duplicate values, this will fail.
- Added the required column `code_unit` to the `unit_statistics` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "unit_statistics" DROP CONSTRAINT "unit_statistics_unit_id_fkey";
-- DropIndex
DROP INDEX "unit_statistics_unit_id_month_year_key";
-- AlterTable
ALTER TABLE "unit_statistics" DROP COLUMN "unit_id",
ADD COLUMN "code_unit" VARCHAR(20) NOT NULL;
-- AlterTable
ALTER TABLE "units" DROP CONSTRAINT "units_pkey",
DROP COLUMN "id",
ADD CONSTRAINT "units_pkey" PRIMARY KEY ("code_unit");
-- CreateIndex
CREATE UNIQUE INDEX "unit_statistics_code_unit_month_year_key" ON "unit_statistics"("code_unit", "month", "year");
-- AddForeignKey
ALTER TABLE "unit_statistics" ADD CONSTRAINT "unit_statistics_code_unit_fkey" FOREIGN KEY ("code_unit") REFERENCES "units"("code_unit") ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -0,0 +1,85 @@
-- CreateTable
CREATE TABLE "patrol_units" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"unit_id" VARCHAR(20) NOT NULL,
"location_id" UUID NOT NULL,
"name" VARCHAR(100) NOT NULL,
"type" VARCHAR(50) NOT NULL,
"status" VARCHAR(50) NOT NULL,
"radius" DOUBLE PRECISION NOT NULL,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "patrol_units_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "officers" (
"id" TEXT NOT NULL,
"unit_id" VARCHAR(20) NOT NULL,
"role_id" UUID NOT NULL,
"nrp" VARCHAR(100) NOT NULL,
"name" VARCHAR(100) NOT NULL,
"rank" VARCHAR(100),
"position" VARCHAR(100),
"phone" VARCHAR(20),
"email" VARCHAR(255),
"avatar" TEXT,
"valid_until" TIMESTAMP(3),
"qr_code" TEXT,
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
"patrol_unitsId" UUID,
CONSTRAINT "officers_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "idx_patrol_units_unit_id" ON "patrol_units"("unit_id");
-- CreateIndex
CREATE INDEX "idx_patrol_units_location_id" ON "patrol_units"("location_id");
-- CreateIndex
CREATE INDEX "idx_patrol_units_name" ON "patrol_units"("name");
-- CreateIndex
CREATE INDEX "idx_patrol_units_type" ON "patrol_units"("type");
-- CreateIndex
CREATE INDEX "idx_patrol_units_status" ON "patrol_units"("status");
-- CreateIndex
CREATE UNIQUE INDEX "officers_nrp_key" ON "officers"("nrp");
-- CreateIndex
CREATE INDEX "idx_officers_unit_id" ON "officers"("unit_id");
-- CreateIndex
CREATE INDEX "idx_officers_nrp" ON "officers"("nrp");
-- CreateIndex
CREATE INDEX "idx_officers_name" ON "officers"("name");
-- CreateIndex
CREATE INDEX "idx_officers_rank" ON "officers"("rank");
-- CreateIndex
CREATE INDEX "idx_officers_position" ON "officers"("position");
-- CreateIndex
CREATE INDEX "idx_units_location_district" ON "units"("district_id", "location");
-- AddForeignKey
ALTER TABLE "patrol_units" ADD CONSTRAINT "patrol_units_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "patrol_units" ADD CONSTRAINT "patrol_units_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "units"("code_unit") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "officers" ADD CONSTRAINT "officers_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "units"("code_unit") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "officers" ADD CONSTRAINT "officers_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "roles"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE "officers" ADD CONSTRAINT "officers_patrol_unitsId_fkey" FOREIGN KEY ("patrol_unitsId") REFERENCES "patrol_units"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "evidence" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"incident_id" UUID NOT NULL,
"type" VARCHAR(50) NOT NULL,
"url" TEXT NOT NULL,
"uploaded_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "evidence_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "idx_evidence_incident_id" ON "evidence"("incident_id");
-- AddForeignKey
ALTER TABLE "evidence" ADD CONSTRAINT "evidence_incident_id_fkey" FOREIGN KEY ("incident_id") REFERENCES "incident_logs"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "evidence" ADD COLUMN "caption" VARCHAR(255),
ADD COLUMN "description" VARCHAR(255),
ADD COLUMN "metadata" JSONB;

View File

@ -0,0 +1,46 @@
/*
Warnings:
- The primary key for the `evidence` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `officers` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `patrol_unitsId` on the `officers` table. All the data in the column will be lost.
- The `id` column on the `officers` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `patrol_units` table will be changed. If it partially fails, the table could be left without primary key constraint.
- A unique constraint covering the columns `[id]` on the table `evidence` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[id]` on the table `patrol_units` will be added. If there are existing duplicate values, this will fail.
- Changed the type of `id` on the `evidence` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Added the required column `patrol_unit_id` to the `officers` table without a default value. This is not possible if the table is not empty.
- Changed the type of `id` on the `patrol_units` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- DropForeignKey
ALTER TABLE "officers" DROP CONSTRAINT "officers_patrol_unitsId_fkey";
-- AlterTable
ALTER TABLE "evidence" DROP CONSTRAINT "evidence_pkey",
DROP COLUMN "id",
ADD COLUMN "id" VARCHAR(20) NOT NULL,
ADD CONSTRAINT "evidence_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "officers" DROP CONSTRAINT "officers_pkey",
DROP COLUMN "patrol_unitsId",
ADD COLUMN "patrol_unit_id" VARCHAR(20) NOT NULL,
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "officers_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "patrol_units" DROP CONSTRAINT "patrol_units_pkey",
DROP COLUMN "id",
ADD COLUMN "id" VARCHAR(20) NOT NULL,
ADD CONSTRAINT "patrol_units_pkey" PRIMARY KEY ("id");
-- CreateIndex
CREATE UNIQUE INDEX "evidence_id_key" ON "evidence"("id");
-- CreateIndex
CREATE UNIQUE INDEX "patrol_units_id_key" ON "patrol_units"("id");
-- AddForeignKey
ALTER TABLE "officers" ADD CONSTRAINT "officers_patrol_unit_id_fkey" FOREIGN KEY ("patrol_unit_id") REFERENCES "patrol_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

Some files were not shown because too many files have changed in this diff Show More