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

69 lines
1.9 KiB
Dart

import 'package:satu/core/utils/utils_parse.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 {
Good();
Good.fromMap(Map<String, dynamic> map) {
id = map[GoodColumnId] as int;
articul = map[GoodColumnArticul] as int;
name = (map[GoodColumnName] ?? '') as String ;
price = map[GoodColumnPrice] as num;
categoryId = map[GoodColumnCategoryId] as int;
ean = map[GoodColumnEan] as String;
appCompanyId = map[GoodColumnAppCompanyId] as int;
optPrice = map[GoodColumnOptPrice] as num;
basePrice = cast<num>(map[GoodColumnBasePrice]);
divisible = map[GoodColumnDivisible] as int;
updatedAt = map[GoodColumnUpdatedAt] as String;
}
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() {
final Map<String, dynamic> 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;
}
}