基础数据基类–商品
一、商品种类
|
描述 |
|
类名 |
|
商品基类 |
包含必须属性 |
BaseGoodsBean |
|
商城里展示的商品 |
有多sku |
SpuGoodsBean |
|
用户想要购买的商品 |
|
SkuGoodsBean |
枚举的使用
在Flutter中
packages/app_models/lib/goods/base_goods_enum.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import 'package:flutter_data_helper/flutter_data_helper.dart';
enum GoodsSaleState { up, down, }
GoodsSaleState goodsSaleStateFromString(String value) { Iterable<GoodsSaleState> values = [ GoodsSaleState.up, GoodsSaleState.down, ]; return EnumStringUtil.enumFromString(values, value); }
String goodsSaleStateStringFromEnum(o) { return EnumStringUtil.enumToString(o); }
enum GoodsPhysicalType { physical, virtual, }
|
在iOS中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| protocol GoodsPriceProtocol { var marketPrice: Int? { get set } var salePrice: Int? { get set } }
protocol GoodsBrandProtocol { var brandName: String? { get set } var brandId: String? { get set } }
class BaseGoodsBean: GoodsPriceProtocol, GoodsBrandProtocol { var marketPrice: Int? var salePrice: Int? var brandName: String? var brandId: String? }
|
在Flutter中
packages/app_models/lib/goods/base_goods_bean.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| import 'base_goods_enum.dart';
abstract class GoodsPriceModel { int? marketPrice; int? salePrice; }
abstract class GoodsBrandModel { String? brandId; String? brandName; }
abstract class GoodsShopModel { String? shopId; String? shopName; }
class BaseGoodsBean implements GoodsPriceModel, GoodsBrandModel, GoodsShopModel { final String id; final String name; final String imageOrVideoUrl; final GoodsSaleState goodsSaleState; final GoodsPhysicalType physicalType;
@override int? marketPrice; @override int? salePrice;
@override String? brandId; @override String? brandName;
@override String? shopId; @override String? shopName;
BaseGoodsBean({ required this.id, required this.name, required this.imageOrVideoUrl, required this.goodsSaleState, required this.physicalType, this.marketPrice, this.salePrice, this.brandId, this.brandName, this.shopId, this.shopName, }); }
|
展示的商品
选中的商品
packages/app_models/lib/goods/selected_goods_bean.dart
End