backup. before shop update

This commit is contained in:
2021-08-31 13:28:33 -04:00
parent c378a6203c
commit 808ffa3211
292 changed files with 51551 additions and 695 deletions

77
lib/models/product.dart Normal file
View File

@@ -0,0 +1,77 @@
import 'dart:convert';
import 'Subproduct.dart';
import 'product_attribute.dart';
class Product {
int id;
int businessId;
int categoryId;
String name;
double price;
double regularPrice;
String description;
String detailDescription;
String imagePath;
double monthSales;
int rate;
double leftNum;
List<ProductAttribute> productAttributes;
bool nonInventory;
String extraData;
List<Subproduct> subproducts;
Product(int id, int businessId, String name, double price, String description,
String imagePath, List<ProductAttribute> productAttributes) {
this.id = id;
this.businessId = businessId;
this.name = name;
this.price = price;
this.description = description;
this.imagePath = imagePath;
this.productAttributes = productAttributes;
}
Product.fromJson(Map<String, dynamic> json)
: id = json['id'],
businessId = json['business_id'],
categoryId = json['category_id'],
name = json['name'],
price = double.parse(json['price'].toString()),
regularPrice = double.parse(json['regular_price'].toString()),
description = json['description'],
detailDescription = json['detail_description'],
imagePath = json['image_path'],
monthSales = json['month_sales'] != null ? double.parse(json['month_sales'].toString()) : 0.0,
rate = json['rate'],
leftNum = json['left_num'] != null ? double.parse(json['left_num'].toString()) : 0.0,
productAttributes = json['productattributes'] != null ? (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList() : [],
nonInventory = json['non_inventory'],
extraData = json['extra_data'],
subproducts = json['subproducts'] != null ? (json['subproducts'] as List).map((e) => Subproduct.fromJson(e)).toList() : [];
Map<String, dynamic> toJson() => {
'id': id,
'business_id': businessId,
'category_id': categoryId,
'name': name,
'price': price,
'regular_price': regularPrice,
'description': description,
'detail_description': detailDescription,
'image_path': imagePath,
'month_sales': monthSales,
'rate': rate,
'left_num': leftNum,
'productattributes': productAttributes,
'non_inventory': nonInventory,
'extra_data': extraData,
'subproducts': subproducts,
};
@override
String toString() {
return json.encode(this);
}
}