update database
This commit is contained in:
69
lib/features/showrooms/data/models/showroom_model.dart
Normal file
69
lib/features/showrooms/data/models/showroom_model.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:convert';
|
||||
import 'package:hive_ce/hive.dart';
|
||||
import 'package:worker/core/constants/storage_constants.dart';
|
||||
|
||||
part 'showroom_model.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.showroomModel)
|
||||
class ShowroomModel extends HiveObject {
|
||||
ShowroomModel({required this.showroomId, required this.title, required this.description, this.coverImage, this.link360, required this.area, required this.style, required this.location, this.galleryImages, required this.viewCount, required this.isFeatured, required this.isActive, this.publishedAt, this.createdBy});
|
||||
|
||||
@HiveField(0) final String showroomId;
|
||||
@HiveField(1) final String title;
|
||||
@HiveField(2) final String description;
|
||||
@HiveField(3) final String? coverImage;
|
||||
@HiveField(4) final String? link360;
|
||||
@HiveField(5) final double area;
|
||||
@HiveField(6) final String style;
|
||||
@HiveField(7) final String location;
|
||||
@HiveField(8) final String? galleryImages;
|
||||
@HiveField(9) final int viewCount;
|
||||
@HiveField(10) final bool isFeatured;
|
||||
@HiveField(11) final bool isActive;
|
||||
@HiveField(12) final DateTime? publishedAt;
|
||||
@HiveField(13) final String? createdBy;
|
||||
|
||||
factory ShowroomModel.fromJson(Map<String, dynamic> json) => ShowroomModel(
|
||||
showroomId: json['showroom_id'] as String,
|
||||
title: json['title'] as String,
|
||||
description: json['description'] as String,
|
||||
coverImage: json['cover_image'] as String?,
|
||||
link360: json['link_360'] as String?,
|
||||
area: (json['area'] as num).toDouble(),
|
||||
style: json['style'] as String,
|
||||
location: json['location'] as String,
|
||||
galleryImages: json['gallery_images'] != null ? jsonEncode(json['gallery_images']) : null,
|
||||
viewCount: json['view_count'] as int? ?? 0,
|
||||
isFeatured: json['is_featured'] as bool? ?? false,
|
||||
isActive: json['is_active'] as bool? ?? true,
|
||||
publishedAt: json['published_at'] != null ? DateTime.parse(json['published_at']?.toString() ?? '') : null,
|
||||
createdBy: json['created_by'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'showroom_id': showroomId,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'cover_image': coverImage,
|
||||
'link_360': link360,
|
||||
'area': area,
|
||||
'style': style,
|
||||
'location': location,
|
||||
'gallery_images': galleryImages != null ? jsonDecode(galleryImages!) : null,
|
||||
'view_count': viewCount,
|
||||
'is_featured': isFeatured,
|
||||
'is_active': isActive,
|
||||
'published_at': publishedAt?.toIso8601String(),
|
||||
'created_by': createdBy,
|
||||
};
|
||||
|
||||
List<String>? get galleryImagesList {
|
||||
if (galleryImages == null) return null;
|
||||
try {
|
||||
final decoded = jsonDecode(galleryImages!) as List;
|
||||
return decoded.map((e) => e.toString()).toList();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
80
lib/features/showrooms/data/models/showroom_model.g.dart
Normal file
80
lib/features/showrooms/data/models/showroom_model.g.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'showroom_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ShowroomModelAdapter extends TypeAdapter<ShowroomModel> {
|
||||
@override
|
||||
final typeId = 21;
|
||||
|
||||
@override
|
||||
ShowroomModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ShowroomModel(
|
||||
showroomId: fields[0] as String,
|
||||
title: fields[1] as String,
|
||||
description: fields[2] as String,
|
||||
coverImage: fields[3] as String?,
|
||||
link360: fields[4] as String?,
|
||||
area: (fields[5] as num).toDouble(),
|
||||
style: fields[6] as String,
|
||||
location: fields[7] as String,
|
||||
galleryImages: fields[8] as String?,
|
||||
viewCount: (fields[9] as num).toInt(),
|
||||
isFeatured: fields[10] as bool,
|
||||
isActive: fields[11] as bool,
|
||||
publishedAt: fields[12] as DateTime?,
|
||||
createdBy: fields[13] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ShowroomModel obj) {
|
||||
writer
|
||||
..writeByte(14)
|
||||
..writeByte(0)
|
||||
..write(obj.showroomId)
|
||||
..writeByte(1)
|
||||
..write(obj.title)
|
||||
..writeByte(2)
|
||||
..write(obj.description)
|
||||
..writeByte(3)
|
||||
..write(obj.coverImage)
|
||||
..writeByte(4)
|
||||
..write(obj.link360)
|
||||
..writeByte(5)
|
||||
..write(obj.area)
|
||||
..writeByte(6)
|
||||
..write(obj.style)
|
||||
..writeByte(7)
|
||||
..write(obj.location)
|
||||
..writeByte(8)
|
||||
..write(obj.galleryImages)
|
||||
..writeByte(9)
|
||||
..write(obj.viewCount)
|
||||
..writeByte(10)
|
||||
..write(obj.isFeatured)
|
||||
..writeByte(11)
|
||||
..write(obj.isActive)
|
||||
..writeByte(12)
|
||||
..write(obj.publishedAt)
|
||||
..writeByte(13)
|
||||
..write(obj.createdBy);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ShowroomModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:hive_ce/hive.dart';
|
||||
import 'package:worker/core/constants/storage_constants.dart';
|
||||
|
||||
part 'showroom_product_model.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.showroomProductModel)
|
||||
class ShowroomProductModel extends HiveObject {
|
||||
ShowroomProductModel({required this.showroomId, required this.productId, required this.quantityUsed});
|
||||
|
||||
@HiveField(0) final String showroomId;
|
||||
@HiveField(1) final String productId;
|
||||
@HiveField(2) final double quantityUsed;
|
||||
|
||||
factory ShowroomProductModel.fromJson(Map<String, dynamic> json) => ShowroomProductModel(
|
||||
showroomId: json['showroom_id'] as String,
|
||||
productId: json['product_id'] as String,
|
||||
quantityUsed: (json['quantity_used'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'showroom_id': showroomId,
|
||||
'product_id': productId,
|
||||
'quantity_used': quantityUsed,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'showroom_product_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ShowroomProductModelAdapter extends TypeAdapter<ShowroomProductModel> {
|
||||
@override
|
||||
final typeId = 22;
|
||||
|
||||
@override
|
||||
ShowroomProductModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ShowroomProductModel(
|
||||
showroomId: fields[0] as String,
|
||||
productId: fields[1] as String,
|
||||
quantityUsed: (fields[2] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ShowroomProductModel obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(0)
|
||||
..write(obj.showroomId)
|
||||
..writeByte(1)
|
||||
..write(obj.productId)
|
||||
..writeByte(2)
|
||||
..write(obj.quantityUsed);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ShowroomProductModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user