Initial commit - app-padrao-1.0
This commit is contained in:
69
lib/features/haircuts/data/models/haircut_model.dart
Normal file
69
lib/features/haircuts/data/models/haircut_model.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'haircut_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class HaircutModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final String id;
|
||||
|
||||
@HiveField(1)
|
||||
final String userId;
|
||||
|
||||
@HiveField(2)
|
||||
final String clientName;
|
||||
|
||||
@HiveField(3)
|
||||
final String serviceType;
|
||||
|
||||
@HiveField(4)
|
||||
final double price;
|
||||
|
||||
@HiveField(5)
|
||||
final DateTime dateTime;
|
||||
|
||||
@HiveField(6)
|
||||
final String? notes;
|
||||
|
||||
@HiveField(7)
|
||||
final String? transactionId; // Link com a transação financeira
|
||||
|
||||
@HiveField(8, defaultValue: 'Dinheiro')
|
||||
final String paymentMethod;
|
||||
|
||||
HaircutModel({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.clientName,
|
||||
required this.serviceType,
|
||||
required this.price,
|
||||
required this.dateTime,
|
||||
this.notes,
|
||||
this.transactionId,
|
||||
this.paymentMethod = 'Dinheiro',
|
||||
});
|
||||
|
||||
HaircutModel copyWith({
|
||||
String? id,
|
||||
String? userId,
|
||||
String? clientName,
|
||||
String? serviceType,
|
||||
double? price,
|
||||
DateTime? dateTime,
|
||||
String? notes,
|
||||
String? transactionId,
|
||||
String? paymentMethod,
|
||||
}) {
|
||||
return HaircutModel(
|
||||
id: id ?? this.id,
|
||||
userId: userId ?? this.userId,
|
||||
clientName: clientName ?? this.clientName,
|
||||
serviceType: serviceType ?? this.serviceType,
|
||||
price: price ?? this.price,
|
||||
dateTime: dateTime ?? this.dateTime,
|
||||
notes: notes ?? this.notes,
|
||||
transactionId: transactionId ?? this.transactionId,
|
||||
paymentMethod: paymentMethod ?? this.paymentMethod,
|
||||
);
|
||||
}
|
||||
}
|
||||
65
lib/features/haircuts/data/models/haircut_model.g.dart
Normal file
65
lib/features/haircuts/data/models/haircut_model.g.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'haircut_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class HaircutModelAdapter extends TypeAdapter<HaircutModel> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
|
||||
@override
|
||||
HaircutModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return HaircutModel(
|
||||
id: fields[0] as String,
|
||||
userId: fields[1] as String,
|
||||
clientName: fields[2] as String,
|
||||
serviceType: fields[3] as String,
|
||||
price: fields[4] as double,
|
||||
dateTime: fields[5] as DateTime,
|
||||
notes: fields[6] as String?,
|
||||
transactionId: fields[7] as String?,
|
||||
paymentMethod: fields[8] == null ? 'Dinheiro' : fields[8] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, HaircutModel obj) {
|
||||
writer
|
||||
..writeByte(9)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.userId)
|
||||
..writeByte(2)
|
||||
..write(obj.clientName)
|
||||
..writeByte(3)
|
||||
..write(obj.serviceType)
|
||||
..writeByte(4)
|
||||
..write(obj.price)
|
||||
..writeByte(5)
|
||||
..write(obj.dateTime)
|
||||
..writeByte(6)
|
||||
..write(obj.notes)
|
||||
..writeByte(7)
|
||||
..write(obj.transactionId)
|
||||
..writeByte(8)
|
||||
..write(obj.paymentMethod);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is HaircutModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user