Initial commit - app-padrao-1.0
This commit is contained in:
43
lib/features/services/data/models/service_model.dart
Normal file
43
lib/features/services/data/models/service_model.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'service_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 6) // TypeId 0=User, 1=Haircut, 2=Product, 3=TransactionType/4=Transaction, 5=Settings
|
||||
class ServiceModel {
|
||||
@HiveField(0)
|
||||
final String id;
|
||||
|
||||
@HiveField(1)
|
||||
final String name; // Ex: Corte Máquina, Barba
|
||||
|
||||
@HiveField(2)
|
||||
final double price; // Preço padrão
|
||||
|
||||
@HiveField(3)
|
||||
final int durationMinutes; // Duração estimada (opcional, bom ter)
|
||||
|
||||
@HiveField(4)
|
||||
final String userId; // Para segregar por usuário
|
||||
|
||||
ServiceModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.price,
|
||||
this.durationMinutes = 30,
|
||||
required this.userId,
|
||||
});
|
||||
|
||||
ServiceModel copyWith({
|
||||
String? name,
|
||||
double? price,
|
||||
int? durationMinutes,
|
||||
}) {
|
||||
return ServiceModel(
|
||||
id: id,
|
||||
name: name ?? this.name,
|
||||
price: price ?? this.price,
|
||||
durationMinutes: durationMinutes ?? this.durationMinutes,
|
||||
userId: userId,
|
||||
);
|
||||
}
|
||||
}
|
||||
53
lib/features/services/data/models/service_model.g.dart
Normal file
53
lib/features/services/data/models/service_model.g.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'service_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ServiceModelAdapter extends TypeAdapter<ServiceModel> {
|
||||
@override
|
||||
final int typeId = 6;
|
||||
|
||||
@override
|
||||
ServiceModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ServiceModel(
|
||||
id: fields[0] as String,
|
||||
name: fields[1] as String,
|
||||
price: fields[2] as double,
|
||||
durationMinutes: fields[3] as int,
|
||||
userId: fields[4] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ServiceModel obj) {
|
||||
writer
|
||||
..writeByte(5)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.price)
|
||||
..writeByte(3)
|
||||
..write(obj.durationMinutes)
|
||||
..writeByte(4)
|
||||
..write(obj.userId);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ServiceModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user