aman-satu-flutter/lib/core/entity/Goods.dart

62 lines
1.7 KiB
Dart

const String GoodTableName = 'goods';
const String GoodColumnId = 'id';
const String GoodColumnCategoryId = 'category_id';
const String GoodColumnName = 'name';
const String GoodColumnEan = 'ean';
const String GoodColumnArticul = 'articul';
const String GoodColumnPrice = 'price';
const String GoodColumnOptPrice = 'opt_price';
const String GoodColumnBasePrice = 'base_price';
const String GoodColumnDivisible = 'divisible';
const String GoodColumnUpdatedAt = 'updated_at';
const String GoodColumnAppCompanyId = 'app_company_id';
class Good {
int? id;
int? categoryId;
String? name;
String? ean;
int? articul;
num? price;
num? optPrice;
num? basePrice;
int? divisible;
String? updatedAt;
int? appCompanyId;
Map<String, dynamic> toMap() {
var map = <String, dynamic>{
GoodColumnArticul: articul,
GoodColumnName: name,
GoodColumnPrice: price,
GoodColumnCategoryId: categoryId,
GoodColumnEan: ean,
GoodColumnAppCompanyId: appCompanyId,
GoodColumnOptPrice: optPrice,
GoodColumnBasePrice: basePrice,
GoodColumnDivisible: divisible,
GoodColumnUpdatedAt: updatedAt,
};
if (id != null) {
map[GoodColumnId] = id;
}
return map;
}
Good();
Good.fromMap(Map<String, dynamic> map) {
id = map[GoodColumnId];
articul = map[GoodColumnArticul];
name = map[GoodColumnName];
price = map[GoodColumnPrice]?.toDouble();
categoryId = map[GoodColumnCategoryId];
ean = map[GoodColumnEan];
appCompanyId = map[GoodColumnAppCompanyId];
optPrice = map[GoodColumnOptPrice];
basePrice = map[GoodColumnBasePrice];
divisible = map[GoodColumnDivisible];
updatedAt = map[GoodColumnUpdatedAt];
}
}