133 lines
3.3 KiB
Dart
Raw Normal View History

2025-08-03 23:53:06 +07:00
import 'dart:convert';
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
class TableResponseModel {
final bool? success;
final TableData? data;
final dynamic errors;
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
TableResponseModel({
this.success,
this.data,
this.errors,
});
factory TableResponseModel.fromJson(String str) =>
TableResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory TableResponseModel.fromMap(Map<String, dynamic> json) =>
TableResponseModel(
success: json["success"],
data: json["data"] == null ? null : TableData.fromMap(json["data"]),
errors: json["errors"],
);
Map<String, dynamic> toMap() => {
"success": success,
"data": data?.toMap(),
"errors": errors,
};
}
class TableData {
final List<TableModel>? tables;
final int? totalCount;
final int? page;
final int? limit;
final int? totalPages;
TableData({
this.tables,
this.totalCount,
this.page,
this.limit,
this.totalPages,
2025-07-30 22:38:44 +07:00
});
2025-08-03 23:53:06 +07:00
factory TableData.fromMap(Map<String, dynamic> json) => TableData(
tables: json["tables"] == null
? []
: List<TableModel>.from(
json["tables"].map((x) => TableModel.fromMap(x))),
totalCount: json["total_count"],
page: json["page"],
limit: json["limit"],
totalPages: json["total_pages"],
);
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
Map<String, dynamic> toMap() => {
"tables": tables == null
? []
: List<dynamic>.from(tables!.map((x) => x.toMap())),
"total_count": totalCount,
"page": page,
"limit": limit,
"total_pages": totalPages,
};
}
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
class TableModel {
final String? id;
final String? organizationId;
final String? outletId;
final String? tableName;
final String? status;
final int? paymentAmount;
final double? positionX;
final double? positionY;
final int? capacity;
final bool? isActive;
final DateTime? createdAt;
final DateTime? updatedAt;
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
TableModel({
this.id,
this.organizationId,
this.outletId,
this.tableName,
this.status,
this.paymentAmount,
this.positionX,
this.positionY,
this.capacity,
this.isActive,
this.createdAt,
this.updatedAt,
});
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
factory TableModel.fromMap(Map<String, dynamic> json) => TableModel(
id: json["id"],
organizationId: json["organization_id"],
outletId: json["outlet_id"],
tableName: json["table_name"],
status: json["status"],
paymentAmount: json["payment_amount"],
positionX: json["position_x"]?.toDouble(),
positionY: json["position_y"]?.toDouble(),
capacity: json["capacity"],
isActive: json["is_active"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
2025-07-30 22:38:44 +07:00
2025-08-03 23:53:06 +07:00
Map<String, dynamic> toMap() => {
"id": id,
"organization_id": organizationId,
"outlet_id": outletId,
"table_name": tableName,
"status": status,
"payment_amount": paymentAmount,
"position_x": positionX,
"position_y": positionY,
"capacity": capacity,
"is_active": isActive,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
2025-07-30 22:38:44 +07:00
}